boolean isGapAfterPush() { return gapAfter != null && gapAfter.getGapPush(); }
boolean isGapBeforePush() { return gapBefore != null && gapBefore.getGapPush(); }
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; }
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; }
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); }
/** 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; }
retValues[i] = wrapGapSize.getPixelSizes(refSize, container, null); fillInPushGaps[i] = wrapGapSize.getGapPush();