static BoundSize derive(BoundSize bs, UnitValue min, UnitValue pref, UnitValue max) { if (bs == null || bs.isUnset()) return new BoundSize(min, pref, max, null); return new BoundSize( min != null ? min : bs.getMin(), pref != null ? pref : bs.getPreferred(), max != null ? max : bs.getMax(), bs.getGapPush(), null); }
private int constrain(ContainerWrapper parent, int winSize, int prefSize, BoundSize constrain) { if (constrain == null) return winSize; int retSize = winSize; UnitValue wUV = constrain.getPreferred(); if (wUV != null) retSize = wUV.getPixels(prefSize, parent, parent); retSize = constrain.constrain(retSize, prefSize, parent); return constrain.getGapPush() ? Math.max(winSize, retSize) : retSize; }
private static void appendBoundSize(BoundSize size, StringBuffer sb, boolean isHor, boolean asAPI) if (size.isUnset() == false) { if (size.getPreferred() == null) { if (size.getMin() == null) { if (asAPI) { sb.append(isHor ? ".maxWidth(\"" : ".maxHeight(\"").append(getUV(size.getMax())).append("\")"); } else { sb.append(isHor ? ",wmax " : ",hmax ").append(getUV(size.getMax())); } else if (size.getMax() == null) { if (asAPI) { sb.append(isHor ? ".minWidth(\"" : ".minHeight(\"").append(getUV(size.getMin())).append("\")"); } else { sb.append(isHor ? ",wmin " : ",hmin ").append(getUV(size.getMin())); sb.append(isHor ? ".width(\"" : ".height(\"").append(getUV(size.getMin())).append("::").append(getUV(size.getMax())).append("\")"); } else { sb.append(isHor ? ",width " : ",height ").append(getUV(size.getMin())).append("::").append(getUV(size.getMax()));
boolean isMin = part.charAt(3) == 'n'; DimConstraint dc = isHor ? cc.getHorizontal() : cc.getVertical(); dc.setSize(new BoundSize( isMin ? uv : dc.getSize().getMin(), dc.getSize().getPreferred(), isMin ? (dc.getSize().getMax()) : uv, uvStr ));
/** Returns the gaps as pixel values. * @param parent The parent. Used to get the pixel values. * @param comp The component that the gap is for. If not for a component it is <code>null</code>. * @param adjGap The gap that the adjacent component, if any, has towards <code>comp</code>. * @param adjacentComp The adjacent component if any. May be <code>null</code>. * @param refSize The reference size used to get the pixel sizes. * @param adjacentSide What side the <code>adjacentComp</code> is on. 0 = top, 1 = left, 2 = bottom, 3 = right. * @param tag The tag string that the component might be tagged with in the component constraints. May be <code>null</code>. * @param isLTR If it is left-to-right. * @return The [min,preferred,max] sizes for the specified gap. Uses {@link net.miginfocom.layout.LayoutUtil#NOT_SET} * for gap sizes that are <code>null</code>. Returns <code>null</code> if there was no gap specified. A new and free to use array. */ int[] getComponentGaps(ContainerWrapper parent, ComponentWrapper comp, BoundSize adjGap, ComponentWrapper adjacentComp, String tag, int refSize, int adjacentSide, boolean isLTR) { BoundSize gap = adjacentSide < 2 ? gapBefore : gapAfter; boolean hasGap = gap != null && gap.getGapPush(); if ((gap == null || gap.isUnset()) && (adjGap == null || adjGap.isUnset()) && comp != null) gap = PlatformDefaults.getDefaultComponentGap(comp, adjacentComp, adjacentSide + 1, tag, isLTR); if (gap == null) return hasGap ? new int[] {0, 0, LayoutUtil.NOT_SET} : null; int[] ret = new int[3]; for (int i = LayoutUtil.MIN; i <= LayoutUtil.MAX; i++) { UnitValue uv = gap.getSize(i); ret[i] = uv != null ? uv.getPixels(refSize, parent, null) : LayoutUtil.NOT_SET; } return ret; }
if (defGap == null) defGap = isHor ? PlatformDefaults.getGridGapX() : PlatformDefaults.getGridGapY(); int[] defGapArr = defGap.getPixelSizes(refSize, container, null); } else { if (wrapGapSize.isUnset()) { retValues[i] = new int[] {defGapArr[0], defGapArr[1], defGapArr[2]}; } else { retValues[i] = wrapGapSize.getPixelSizes(refSize, container, null); fillInPushGaps[i] = wrapGapSize.getGapPush();
boolean isGapAfterPush() { return gapAfter != null && gapAfter.getGapPush(); }
boolean hasGapAfter() { return gapAfter != null && gapAfter.isUnset() == false; }
/** Returns the gaps as pixel values. * @param parent The parent. Used to get the pixel values. * @param defGap The default gap to use if there is no gap set on this object (i.e. it is null). * @param refSize The reference size used to get the pixel sizes. * @param before IF it is the gap before rather than the gap after to return. * @return The [min,preferred,max] sizes for the specified gap. Uses {@link net.miginfocom.layout.LayoutUtil#NOT_SET} * for gap sizes that are <code>null</code>. Returns <code>null</code> if there was no gap specified. A new and free to use array. */ int[] getRowGaps(ContainerWrapper parent, BoundSize defGap, int refSize, boolean before) { BoundSize gap = before ? gapBefore : gapAfter; if (gap == null || gap.isUnset()) gap = defGap; if (gap == null || gap.isUnset()) return null; int[] ret = new int[3]; for (int i = LayoutUtil.MIN; i <= LayoutUtil.MAX; i++) { UnitValue uv = gap.getSize(i); ret[i] = uv != null ? uv.getPixels(refSize, parent, null) : LayoutUtil.NOT_SET; } return ret; }
private void resetLinkValues(boolean parentSize, boolean compLinks) { Object lay = container.getLayout(); if (compLinks) LinkHandler.clearTemporaryBounds(lay); boolean defIns = !hasDocks(); int parW = parentSize ? lc.getWidth().constrain(container.getWidth(), getParentSize(container, true), container) : 0; int parH = parentSize ? lc.getHeight().constrain(container.getHeight(), getParentSize(container, false), container) : 0; int insX = LayoutUtil.getInsets(lc, 0, defIns).getPixels(0, container, null); int insY = LayoutUtil.getInsets(lc, 1, defIns).getPixels(0, container, null); int visW = parW - insX - LayoutUtil.getInsets(lc, 2, defIns).getPixels(0, container, null); int visH = parH - insY - LayoutUtil.getInsets(lc, 3, defIns).getPixels(0, container, null); LinkHandler.setBounds(lay, "visual", insX, insY, visW, visH, true, false); LinkHandler.setBounds(lay, "container", 0, 0, parW, parH, true, false); }
/** Sets gap between two cells in the grid. Note that this is not a gap between component IN a cell, that has to be set * on the component constraints. The value will be the min and preferred size of the gap. * @param x The value that will be transformed to pixels. If <code>null</code> the current value will not change. * @param y The value that will be transformed to pixels. If <code>null</code> the current value will not change. */ public static void setGridCellGap(UnitValue x, UnitValue y) { if (x != null) DEF_HGAP = new BoundSize(x, x, null, null); if (y != null) DEF_VGAP = new BoundSize(y, y, null, null); MOD_COUNT++; }
boolean isGapBeforePush() { return gapBefore != null && gapBefore.getGapPush(); }
boolean hasGapBefore() { return gapBefore != null && gapBefore.isUnset() == false; }
/** Sets gap value for components that are "unrelated". * @param x The value that will be transformed to pixels. If <code>null</code> the current value will not change. * @param y The value that will be transformed to pixels. If <code>null</code> the current value will not change. */ public static void setUnrelatedGap(UnitValue x, UnitValue y) { setUnitValue(new String[] {"u", "unrel", "unrelated"}, x, y); UNRELATED_X = new BoundSize(x, x, null, "unrel:unrel"); UNRELATED_Y = new BoundSize(y, y, null, "unrel:unrel"); }
private double constrain(ContainerWrapper parent, double winSize, double prefSize, BoundSize constrain) { if (constrain == null) return winSize; double retSize = winSize; UnitValue wUV = constrain.getPreferred(); if (wUV != null) retSize = wUV.getPixels((float) prefSize, parent, parent); retSize = constrain.constrain((int) Math.ceil(retSize), (float) prefSize, parent); return constrain.getGapPush() ? Math.max(winSize, retSize) : retSize; }
if (size.isUnset() == false) { if (asAPI) { sb.append(".size(\"").append(getBS(size)).append("\")");
/** Sets gap value for components that are "related". * @param x The value that will be transformed to pixels. If <code>null</code> the current value will not change. * @param y The value that will be transformed to pixels. If <code>null</code> the current value will not change. */ public static void setRelatedGap(UnitValue x, UnitValue y) { setUnitValue(new String[] {"r", "rel", "related"}, x, y); RELATED_X = new BoundSize(x, x, null, "rel:rel"); RELATED_Y = new BoundSize(y, y, null, "rel:rel"); }
s = s.substring(0, l - (s.endsWith(":push") ? 5 : 4)); if (s.length() == 0) return new BoundSize(null, null, null, true, cs); s0 = s0.substring(0, s0.length() - 1); UnitValue uv = parseUnitValue(s0, null, isHor); return new BoundSize(((isGap || hasEM) ? uv : null), uv, (hasEM ? uv : null), push, cs); return new BoundSize(parseUnitValue(s0, null, isHor), parseUnitValue(sizes[1], null, isHor), null, push, cs); } else if (sizes.length == 3) { return new BoundSize(parseUnitValue(s0, null, isHor), parseUnitValue(sizes[1], null, isHor), parseUnitValue(sizes[2], null, isHor), push, cs); } else { throw new IllegalArgumentException("Min:Preferred:Max size section must contain 0, 1 or 2 colons. '" + cs + "'");