/** Parses insets which consists of 1-4 <code>UnitValue</code>s. * @param s The string to parse. E.g. "10 10 10 10" or "20". If less than 4 groups the last will be used for the missing. * @param acceptPanel If "panel" and "dialog" should be accepted. They are used to access platform defaults. * @return An array of length 4 with the parsed insets. * @throws IllegalArgumentException if the parsing could not be done. */ public static UnitValue[] parseInsets(String s, boolean acceptPanel) { if (s.length() == 0 || s.equals("dialog") || s.equals("panel")) { if (acceptPanel == false) throw new IllegalArgumentException("Insets now allowed: " + s + "\n"); boolean isPanel = s.startsWith("p"); UnitValue[] ins = new UnitValue[4]; for (int j = 0; j < 4; j++) ins[j] = isPanel ? PlatformDefaults.getPanelInsets(j) : PlatformDefaults.getDialogInsets(j); return ins; } else { String[] insS = toTrimmedTokens(s, ' '); UnitValue[] ins = new UnitValue[4]; for (int j = 0; j < 4; j++) { UnitValue insSz = parseUnitValue(insS[j < insS.length ? j : insS.length - 1], UnitValue.ZERO, j % 2 == 1); ins[j] = insSz != null ? insSz : PlatformDefaults.getPanelInsets(j); } return ins; } }
if (inline == false) { // If the format is of type "opr(xxx,yyy)" (compared to in-line "10%+15px") String sub = s.substring(4, s.length() - 1).trim(); uvs = toTrimmedTokens(sub, ','); if (uvs.length == 1) return parseUnitValue(sub, null, isHor); delim = '/'; uvs = toTrimmedTokens(s, delim); if (uvs.length > 2) { // More than one +-*/. String last = uvs[uvs.length - 1];
String[] sizes = toTrimmedTokens(s, ':'); String s0 = sizes[0];
if (ix > -1) { boolean x = s.charAt(3) == 'x'; String[] gaps = toTrimmedTokens(s.substring(ix).trim(), ' '); ret[x ? 1 : 0] = parseBoundSize(gaps[0], true, x); if (gaps.length > 1) String[] gaps = toTrimmedTokens(s.substring(ix).trim(), ' ');
return lc; String[] parts = toTrimmedTokens(s, ','); String[] gaps = toTrimmedTokens(part.substring(4).trim(), ' '); lc.setGridGapX(parseBoundSize(gaps[0], true, true)); lc.setGridGapY(gaps.length > 1 ? parseBoundSize(gaps[1], true, false) : lc.getGridGapX()); String[] gaps = toTrimmedTokens(part.substring(ix).trim(), ' '); lc.setAlignX(parseUnitValueOrAlign(gaps[0], true, null)); if (gaps.length > 1) { String[] packs = toTrimmedTokens(part.substring(10).trim(), ' '); lc.setPackWidthAlign(packs[0].length() > 0 ? Float.parseFloat(packs[0]) : 0.5f); if (packs.length > 1) String[] packs = toTrimmedTokens(ps.length() > 0 ? ps : "pref pref", ' '); lc.setPackWidth(parseBoundSize(packs[0], false, true)); if (packs.length > 1)
dimConstraint.setGapAfter(gapAfter); String[] parts = toTrimmedTokens(s, ','); for (int i = 0; i < parts.length; i++) { String part = parts[i];
String[] parts = toTrimmedTokens(s, ','); String[] spans = toTrimmedTokens(part.substring(ix).trim(), ' '); cc.setSpanX(spans[0].length() > 0 ? Integer.parseInt(spans[0]) : LayoutUtil.INF); cc.setSpanY(spans.length > 1 ? Integer.parseInt(spans[1]) : 1); String[] shrinks = toTrimmedTokens(part.substring(ix).trim(), ' '); cc.getHorizontal().setShrink(parseFloat(shrinks[0], ResizeConstraint.WEIGHT_100)); if (shrinks.length > 1) (sp.startsWith("x") ? cc.getHorizontal() : cc.getVertical()).setShrinkPriority(Integer.parseInt(sp.substring(2))); } else { String[] shrinks = toTrimmedTokens(sp, ' '); cc.getHorizontal().setShrinkPriority(Integer.parseInt(shrinks[0])); if (shrinks.length > 1) String[] grows = toTrimmedTokens(part.substring(ix).trim(), ' '); cc.getHorizontal().setGrow(parseFloat(grows[0], ResizeConstraint.WEIGHT_100)); cc.getVertical().setGrow(parseFloat(grows.length > 1 ? grows[1] : "", ResizeConstraint.WEIGHT_100)); (c0 == 'x' ? cc.getHorizontal() : cc.getVertical()).setGrowPriority(Integer.parseInt(gp.substring(2))); } else { String[] grows = toTrimmedTokens(gp, ' '); cc.getHorizontal().setGrowPriority(Integer.parseInt(grows[0])); if (grows.length > 1) String[] gaps = toTrimmedTokens(part.substring(ix).trim(), ' '); cc.getHorizontal().setAlign(parseUnitValueOrAlign(gaps[0], true, null)); if (gaps.length > 1)