private UnitValue[] getPos(ComponentWrapper cw, CC cc) { UnitValue[] callbackPos = null; if (callbackList != null) { for (int i = 0; i < callbackList.size() && callbackPos == null; i++) callbackPos = callbackList.get(i).getPosition(cw); // NOT a copy! } // If one is null, return the other (which many also be null) UnitValue[] ccPos = cc.getPos(); // A copy!! if (callbackPos == null || ccPos == null) return callbackPos != null ? callbackPos : ccPos; // Merge for (int i = 0; i < 4; i++) { UnitValue cbUv = callbackPos[i]; if (cbUv != null) ccPos[i] = cbUv; } return ccPos; }
private final CC corrPos(String uv, int ix) { UnitValue[] b = getPos(); if (b == null) b = new UnitValue[4]; b[ix] = ConstraintParser.parseUnitValue(uv, (ix % 2 == 0)); setPos(b); setBoundsInGrid(true); return this; }
/** Same functionality as {@link #x(String x)} and {@link #y(String y)} together. * <p> * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com. * @param x The x position as a UnitValue. E.g. "10" or "40mm" or "container.x+10". * @param y The y position as a UnitValue. E.g. "10" or "40mm" or "container.x+10". * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>. * @see #setPos(UnitValue[]) */ public final CC pos(String x, String y) { UnitValue[] b = getPos(); if (b == null) b = new UnitValue[4]; b[0] = ConstraintParser.parseUnitValue(x, true); b[1] = ConstraintParser.parseUnitValue(y, false); setPos(b); setBoundsInGrid(false); return this; }
UnitValue[] pos = cc.getPos(); if (pos != null) { if (cc.isBoundsInGrid()) {
char c2 = part.charAt(1); if (c2 == ' ' || (c2 == '2' && part.charAt(2) == ' ')) { if (cc.getPos() == null) { cc.setPos(new UnitValue[4]); } else if (cc.isBoundsInGrid() == false) { UnitValue[] pos = cc.getPos(); pos[edge] = parseUnitValue(part.substring(2).trim(), null, c == 'x'); cc.setPos(pos); ix = startsWithLenient(part, "pos", 3, true); if (ix > -1) { if (cc.getPos() != null && cc.isBoundsInGrid()) throw new IllegalArgumentException("Can not combine 'pos' with 'x/y/x2/y2' keywords.");