1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.spreadsheet;
16 public static final int MAXROWSPEC = Integer.MAX_VALUE;//1048576;//
17 public static final int MAXCOLUMNSPEC = Integer.MAX_VALUE;//16384;//
21 public int startColumn;
24 public Range(int startRow, int endRow, int startColumn, int endColumn) {
25 this.startRow = startRow;
27 this.startColumn = startColumn;
28 this.endColumn = endColumn;
30 if(startRow == -1) this.startRow = MAXROWSPEC;
31 if(endRow == -1) this.endRow = MAXROWSPEC;
32 if(startColumn == -1) this.startColumn = MAXCOLUMNSPEC;
33 if(endColumn == -1) this.endColumn = MAXCOLUMNSPEC;
36 public Range(Range copy) {
37 this.startRow = copy.startRow;
38 this.endRow = copy.endRow;
39 this.startColumn = copy.startColumn;
40 this.endColumn = copy.endColumn;
43 public static Range combine(Range from, Range to) {
44 return new Range(from.startRow, to.endRow, from.startColumn, to.endColumn);
47 public boolean isFull() {
48 return endRow == MAXROWSPEC && endColumn == MAXCOLUMNSPEC;
51 public boolean isFullRows() {
52 return endRow == MAXROWSPEC;
55 public boolean isFullColumns() {
56 return endColumn == MAXCOLUMNSPEC;
60 return (endRow-startRow + 1) * (endColumn - startColumn + 1);
64 return (endColumn - startColumn + 1);
68 return (endRow-startRow + 1);
71 public boolean contains(Range r) {
73 if(r.endRow > endRow) return false;
74 if(r.startRow < startRow) return false;
77 if(r.startColumn < startColumn) return false;
78 if(r.endColumn > endColumn) return false;
84 public String toString() {
85 return "Range[(" + startRow + "," + startColumn + ")-(" + endRow + "," + endColumn + ")]";