1 14 package org.compiere.apps; 15 16 import java.util.*; 17 import java.awt.*; 18 19 import org.compiere.util.Log; 20 21 27 class ALayoutCollection extends HashMap 28 { 29 32 public ALayoutCollection() 33 { 34 super(); 35 } 37 45 public Object put (Object constraint, Object component) 46 { 47 if (!(component instanceof Component)) 48 throw new IllegalArgumentException ("ALayoutCollection can only add Component values"); 49 50 if (constraint != null 51 && !containsKey(constraint) 52 && constraint instanceof ALayoutConstraint) 53 { 54 return super.put (constraint, component); 56 } 57 58 if (super.size() == 0) 60 { 61 return super.put(new ALayoutConstraint(0,0), component); 63 } 64 65 int row = getMaxRow(); 67 if (row == -1) 68 row = 0; 69 int col = getMaxCol(row) + 1; 70 ALayoutConstraint next = new ALayoutConstraint(row, col); 71 return super.put(next, component); 73 } 75 79 public int getMaxRow () 80 { 81 int maxRow = -1; 82 Iterator i = keySet().iterator(); 84 while (i.hasNext()) 85 { 86 ALayoutConstraint c = (ALayoutConstraint)i.next(); 87 maxRow = Math.max(maxRow, c.getRow()); 88 } 89 return maxRow; 90 } 92 96 public int getMaxCol () 97 { 98 int maxCol = -1; 99 Iterator i = keySet().iterator(); 101 while (i.hasNext()) 102 { 103 ALayoutConstraint c = (ALayoutConstraint)i.next(); 104 maxCol = Math.max(maxCol, c.getCol()); 105 } 106 return maxCol; 107 } 109 114 public int getMaxCol (int row) 115 { 116 int maxCol = -1; 117 Iterator i = keySet().iterator(); 119 while (i.hasNext()) 120 { 121 ALayoutConstraint c = (ALayoutConstraint)i.next(); 122 if (c.getRow() == row) 123 maxCol = Math.max(maxCol, c.getCol()); 124 } 125 return maxCol; 126 } 128 } | Popular Tags |