1 27 package org.htmlparser.parserapplications.filterbuilder.layouts; 28 29 import java.awt.*; 30 import java.io.*; 31 32 37 public class NullLayoutManager 38 implements 39 LayoutManager2, 40 Serializable 41 { 42 45 public NullLayoutManager () 46 { 47 } 48 49 55 public Dimension minimumLayoutSize (Container target) 56 { 57 return (preferredLayoutSize (target)); 58 } 59 60 66 public Dimension preferredLayoutSize (Container target) 67 { 68 int count; 69 Container parent; 70 Component component; 71 Point point; 72 Dimension dimension; 73 Insets insets; 74 Dimension ret; 75 76 synchronized (target.getTreeLock ()) 77 { 78 count = target.getComponentCount (); 79 if (0 == count) 80 { 81 ret = target.getSize (); 83 parent = target.getParent (); 84 if (null != parent) 85 { 86 insets = parent.getInsets (); 87 ret = parent.getSize (); 88 ret.setSize ( 89 ret.width - insets.left - insets.right, 90 ret.height - insets.top - insets.bottom); 91 } 92 } 93 else 94 { 95 ret = new Dimension (0, 0); 96 for (int i = 0 ; i < count ; i++) 97 { 98 component = target.getComponent (i); 99 if (component.isVisible ()) 100 { 101 point = component.getLocation (); 102 dimension = component.getPreferredSize(); 103 ret.width = Math.max (ret.width, point.x + dimension.width); 104 ret.height = Math.max (ret.height, point.y + dimension.height); 105 } 106 } 107 insets = target.getInsets (); 108 ret.width += insets.left + insets.right; 109 ret.height += insets.top + insets.bottom; 110 } 111 } 112 113 return (ret); 114 } 115 116 123 public Dimension maximumLayoutSize (Container target) 124 { 125 return (preferredLayoutSize (target)); 126 } 127 128 132 138 public void addLayoutComponent (String name, Component comp) 139 { 140 } 141 142 146 public void removeLayoutComponent (Component comp) 147 { 148 } 149 150 154 public void layoutContainer (Container target) 155 { 156 int count; 157 Component component; 158 Dimension dimension; 159 160 synchronized (target.getTreeLock ()) 161 { 162 count = target.getComponentCount (); 163 for (int i = 0 ; i < count ; i++) 164 { 165 component = target.getComponent (i); 166 if (component.isVisible ()) 167 { 168 dimension = component.getPreferredSize(); 169 component.setSize (dimension.width, dimension.height); 170 } 171 } 172 } 173 } 174 175 179 185 public void addLayoutComponent (Component comp, Object constraints) 186 { 187 } 188 189 197 public float getLayoutAlignmentX (Container target) 198 { 199 return (0.0f); 200 } 201 202 210 public float getLayoutAlignmentY (Container target) 211 { 212 return (0.0f); 213 } 214 215 220 public void invalidateLayout (Container target) 221 { 222 } 223 } 224 | Popular Tags |