@Override public UIWidget next() { return (UIWidget) it.next().getComponent(); }
@Override public void onDraw(Canvas canvas) { int[] bounds = {0, 0, canvas.size().x, canvas.size().y}; layoutContainer(canvas, bounds); for (ComponentWrapper wrapper : wrappers.values()) { UIWidget component = (UIWidget) wrapper.getComponent(); Rect2i region = Rect2i.createFromMinAndSize(wrapper.getX(), wrapper.getY(), wrapper.getWidth(), wrapper.getHeight()); canvas.drawWidget(component, region); } if (debug) { grid.paintDebug(); } for (Rect2i region : debugRects) { canvas.drawLine(region.minX(), region.minY(), region.maxX(), region.minY(), Color.WHITE); canvas.drawLine(region.maxX(), region.minY(), region.maxX(), region.maxY(), Color.WHITE); canvas.drawLine(region.maxX(), region.maxY(), region.minX(), region.maxY(), Color.WHITE); canvas.drawLine(region.minX(), region.maxY(), region.minX(), region.minY(), Color.WHITE); } }
@Override public final boolean equals(Object o) { if (o instanceof ComponentWrapper == false) return false; return c.equals(((ComponentWrapper) o).getComponent()); }
@Override public final boolean equals(Object o) { if (o == null || o instanceof ComponentWrapper == false) return false; return getComponent().equals(((ComponentWrapper) o).getComponent()); }
/** Checks so all components in ccMap actually exist in the parent's collection. Removes * any references that don't. * @param parent The parent to compare ccMap against. Never null. */ private void cleanConstraintMaps(Container parent) { HashSet<Component> parentCompSet = new HashSet<Component>(Arrays.asList(parent.getComponents())); Iterator<Map.Entry<ComponentWrapper, CC>> it = ccMap.entrySet().iterator(); while(it.hasNext()) { Component c = (Component) it.next().getKey().getComponent(); if (parentCompSet.contains(c) == false) { it.remove(); scrConstrMap.remove(c); } } }
private static synchronized void saveGrid(ComponentWrapper parComp, LinkedHashMap<Integer, Cell> grid) { if (PARENT_GRIDPOS_MAP == null) // Lazy since only if designing in IDEs PARENT_GRIDPOS_MAP = new WeakHashMap<Object, ArrayList<WeakCell>>(4); ArrayList<WeakCell> weakCells = new ArrayList<WeakCell>(grid.size()); for (Map.Entry<Integer, Cell> e : grid.entrySet()) { Cell cell = e.getValue(); Integer xyInt = e.getKey(); if (xyInt != null) { int x = (xyInt << 16) >> 16; int y = xyInt >> 16; for (CompWrap cw : cell.compWraps) weakCells.add(new WeakCell(cw.comp.getComponent(), x, y, cell.spanx, cell.spany)); } } PARENT_GRIDPOS_MAP.put(parComp.getComponent(), weakCells); }
/** Checks so all components in ccMap actually exist in the parent's collection. Removes * any references that don't. * @param parent The parent to compare ccMap against. Never null. */ private void checkConstrMap(Composite parent) { Control[] children = parent.getChildren(); HashSet<Control> parentCompSet = new HashSet<Control>(Arrays.asList(children)); // Clear cached constraints Iterator<Map.Entry<ComponentWrapper, CC>> ccIt = ccMap.entrySet().iterator(); while(ccIt.hasNext()) { Control c = (Control) ccIt.next().getKey().getComponent(); if (c.isDisposed() || parentCompSet.contains(c) == false) { ccIt.remove(); scrConstrMap.remove(c); grid = null; // To clear any references to a removed widget } } // Recreate constraints if changed. for (Control child : children) { if (scrConstrMap.get(child) != child.getLayoutData()) setComponentConstraintsImpl(child, child.getLayoutData(), true); } }
boolean resetLastInvalidOnParent = false; // Added in 3.7.3 to resolve a timing regression introduced in 3.7.1 for (ComponentWrapper wrapper : ccMap.keySet()) { Object component = wrapper.getComponent(); if (component instanceof JTextArea || component instanceof JEditorPane) resetLastInvalidOnParent = true;