@Override public int getPreferredWidth(int hHint) { return grid.getWidth()[1]; }
@Override public int getMaximumHeight(int wHint) { return grid.getHeight()[2]; }
@Override public UIWidget next() { return (UIWidget) it.next().getComponent(); }
public void layoutContainer(Canvas canvas, int[] bounds) { for (ComponentWrapper wrapper : children) { if (wrapper instanceof MigLayout) { MigLayout layout = (MigLayout) wrapper; layout.layoutContainer(canvas, bounds); } else if (wrapper instanceof MigComponent) { MigComponent migComponent = (MigComponent) wrapper; migComponent.calculatePreferredSize(canvas, canvas.size()); } } checkCache(); if (grid.layout(bounds, lc.getAlignX(), lc.getAlignY(), debug, true)) { grid = null; checkCache(); grid.layout(bounds, lc.getAlignX(), lc.getAlignY(), debug, false); } }
@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); } }
public void setRowConstraints(String constraint) { rowConstraints = constraint; setRc(ConstraintParser.parseColumnConstraints(ConstraintParser.prepare(constraint))); }
@Override public void addWidget(UIWidget element, CCHint hint) { final ComponentWrapper cw = getWrapper(element); final String cStr = ConstraintParser.prepare(hint != null ? hint.cc : ""); CC constraint = AccessController.doPrivileged((PrivilegedAction<CC>) () -> ConstraintParser.parseComponentConstraint(cStr)); ccMap.put(cw, constraint); wrappers.put(element, cw); children.add(cw); dirty = true; }
public void setLayoutConstraints(String constraint) { layoutConstraints = constraint; setLc(ConstraintParser.parseLayoutConstraint(ConstraintParser.prepare(constraint))); }
/** The maximum size for the component. The value will override any value that is set on the component itself. * <p> * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com. * @param size The size expressed as a <code>UnitValue</code>. E.g. "100px" or "200mm". * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>. */ public final CC maxWidth(String size) { hor.setSize(LayoutUtil.derive(hor.getSize(), null, null, ConstraintParser.parseUnitValue(size, true))); return this; }
/** The minimum height for the container. The value will override any value that is set on the container itself. * <p> * For a more thorough explanation of what this constraint does see the white paper or Cheat Sheet at www.migcontainers.com. * @param height The height expressed as a <code>UnitValue</code>. E.g. "100px" or "200mm". * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>. */ public final LC minHeight(String height) { setHeight(LayoutUtil.derive(getHeight(), ConstraintParser.parseUnitValue(height, false), null, null)); return this; }
private void checkCache() { if (dirty) { grid = null; } if (grid == null) { grid = new Grid(this, lc, rc, cc, ccMap, new ArrayList<>()); } debugRects.clear(); dirty = false; }
public void setColConstraints(String constraint) { colConstraints = constraint; setCC(ConstraintParser.parseColumnConstraints(ConstraintParser.prepare(constraint))); }
@Override public int getMaximumWidth(int hHint) { return grid.getWidth()[2]; }
@Override public int getMinimumHeight(int wHint) { return grid.getHeight()[0]; }
/** The minimum size for the component. The value will override any value that is set on the component itself. * <p> * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com. * @param size The size expressed as a <code>UnitValue</code>. E.g. "100px" or "200mm". * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>. */ public final CC minHeight(String size) { ver.setSize(LayoutUtil.derive(ver.getSize(), ConstraintParser.parseUnitValue(size, false), null, null)); return this; }
/** The maximum height for the container. The value will override any value that is set on the container itself. * <p> * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcontainers.com. * @param height The height expressed as a <code>UnitValue</code>. E.g. "100px" or "200mm". * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>. */ public final LC maxHeight(String height) { setHeight(LayoutUtil.derive(getHeight(), null, null, ConstraintParser.parseUnitValue(height, false))); return this; }
@Override public int getMinimumWidth(int hHint) { return grid.getWidth()[0]; }
@Override public int getPreferredHeight(int wHint) { return grid.getHeight()[1]; }
/** The minimum size for the component. The value will override any value that is set on the component itself. * <p> * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com. * @param size The size expressed as a <code>UnitValue</code>. E.g. "100px" or "200mm". * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>. */ public final CC minWidth(String size) { hor.setSize(LayoutUtil.derive(hor.getSize(), ConstraintParser.parseUnitValue(size, true), null, null)); return this; }