1 package edu.psu.geovista.app.spreadsheet.table;
2
3 /*
4 * The range to be sorted:
5 * - entire table
6 * - a column/serveral column
7 * - a row/serveral rows
8 * - a range
9 * User: jchen
10 * Date: Mar 23, 2003
11 * Time: 10:50:29 AM
12 * To change template for new class use
13 * Code Style | Class Templates options (Tools | IDE Options).
14 */
15
16 import java.util.HashSet;
17
18
19 public class SortRange {
20 public static final int ENTIRE_TABLE=0;
21 public static final int COLUMNS=1;
22 public static final int ROWS=2;
23 public static final int RANGE=3;
24
25 private int type=3; //range type
26 private HashSet rows;//the rows' index (in Model)that are in the edu.psu.geovista.app.spreadsheet.tools.Sort Range
27 private HashSet columns;//the columns' index that are in the edu.psu.geovista.app.spreadsheet.tools.Sort Range
28
29 public SortRange() {
30 rows=new HashSet();
31 columns=new HashSet();
32 }
33 //private boolean entireTable;//true if sortrange is entire table
34
35 /*** See if cell(x,y) in sortRange
36 * assume x, y is within the table
37 */
38 public boolean containCell(int x, int y){
39 if (this.getType() ==SortRange.ENTIRE_TABLE ){
40 return true;
41 }
42 else{
43 Integer row=new Integer(x);
44 Integer col=new Integer(y);
45 if (this.getRows().contains(row)&&
46 this.getColumns().contains(col)){
47 return true;
48 }
49 else{
50 return false;
51 }
52 }
53 }
54 /*** See if rowX in sortRange
55 * assume x is within the table
56 */
57 public boolean containRow(int x){
58 if (this.getType() ==SortRange.ENTIRE_TABLE ){
59 return true;
60 }
61 else{
62 Integer row=new Integer(x);
63 if (this.getRows().contains(row)){
64 return true;
65 }
66 else{
67 return false;
68 }
69 }
70 }
71 /*** See if cell(x,y) in sortRange
72 * assume y is within the table
73 */
74 public boolean containColumn(int y){
75 if (this.getType() ==SortRange.ENTIRE_TABLE ){
76 return true;
77 }
78 else{
79
80 Integer col=new Integer(y);
81 if ( this.getColumns().contains(col)){
82 return true;
83 }
84 else{
85 return false;
86 }
87 }
88 }
89
90
91
92 public int getType() {
93 return type;
94 }
95
96 public void setType(int type) {
97 this.type = type;
98 }
99
100 public HashSet getColumns() {
101 return columns;
102 }
103 /***
104 *
105 */
106 public void setColumn(int y) {
107 Integer col=new Integer(y);
108 this.columns.add(col);
109
110 }
111 /***
112 * true if the SortRange contains a column index
113 */
114 public boolean contains(int y){
115 Integer col=new Integer(y);
116 return this.columns.contains(col);
117 }
118
119 public HashSet getRows() {
120 return rows;
121 }
122
123 public void setRow(int x) {
124 Integer row=new Integer(x);
125 this.rows.add(row);
126 }
127 }
128
This page was automatically generated by Maven