}\r
\r
return alPos;\r
-\r
}\r
\r
+ public void hideSelectedColumns()\r
+ {\r
+ while (size() > 0)\r
+ {\r
+ int column = ( (Integer) getSelected().firstElement()).intValue();\r
+ hideColumns(column);\r
+ }\r
\r
+ }\r
\r
- public void hideColumns(int res)\r
+ public void hideColumns(int start, int end)\r
{\r
if(hiddenColumns==null)\r
hiddenColumns = new Vector();\r
\r
- // First find out range of columns to hide\r
- int min = res, max = res+1;\r
- while( contains(min) )\r
- { removeElement(min); min --; }\r
-\r
- while( contains(max) )\r
- { removeElement(max); max ++; }\r
-\r
- min++; max--;\r
-\r
boolean added = false;\r
- for(int i=0; i<hiddenColumns.size(); i++)\r
+ boolean overlap = false;\r
+\r
+ for (int i = 0; i < hiddenColumns.size(); i++)\r
{\r
- int [] region = (int[])hiddenColumns.elementAt(i);\r
- if( max < region[0])\r
+ int[] region = (int[]) hiddenColumns.elementAt(i);\r
+ if ( start<=region[1] && end>=region[0])\r
+ {\r
+ hiddenColumns.removeElementAt(i);\r
+ overlap = true;\r
+ break;\r
+ }\r
+ else if (end < region[0] && start < region[0])\r
{\r
- hiddenColumns.insertElementAt(new int[]{min, max}, i);\r
+ hiddenColumns.insertElementAt(new int[]\r
+ {start, end}, i);\r
added = true;\r
break;\r
}\r
}\r
\r
- if(!added)\r
- hiddenColumns.addElement(new int[]{min, max});\r
+ if(overlap)\r
+ {\r
+ hideColumns(start, end);\r
+ }\r
+ else if (!added)\r
+ hiddenColumns.addElement(new int[] {start, end});\r
+\r
+ }\r
+\r
+ /**\r
+ * This method will find a range of selected columns\r
+ * around the column specified\r
+ * @param res int\r
+ */\r
+ public void hideColumns(int col)\r
+ {\r
+ // First find out range of columns to hide\r
+ int min = col, max = col+1;\r
+ while( contains(min) )\r
+ { removeElement(min); min --; }\r
+\r
+ while( contains(max) )\r
+ { removeElement(max); max ++; }\r
+\r
+ min++; max--;\r
\r
+ hideColumns(min, max);\r
}\r
\r
public void revealAllHiddenColumns()\r
break;\r
}\r
}\r
+ if(hiddenColumns.size()==0)\r
+ hiddenColumns = null;\r
}\r
\r
public boolean isVisible(int column)\r