@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 setRowConstraints(String constraint) { rowConstraints = constraint; setRc(ConstraintParser.parseColumnConstraints(ConstraintParser.prepare(constraint))); }
public void setLayoutConstraints(String constraint) { layoutConstraints = constraint; setLc(ConstraintParser.parseLayoutConstraint(ConstraintParser.prepare(constraint))); }
/** * use the string layout constraints */ public MigPane(String layoutConstraints, String colConstraints, String rowConstraints) { super(); setLayoutConstraints(ConstraintParser.parseLayoutConstraint(ConstraintParser.prepare(layoutConstraints))); setColumnConstraints(ConstraintParser.parseColumnConstraints(ConstraintParser.prepare(colConstraints))); setRowConstraints(ConstraintParser.parseRowConstraints(ConstraintParser.prepare(rowConstraints))); construct(); }
/** * use the string layout constraints */ public MigPane(String layoutConstraints, String colConstraints) { super(); setLayoutConstraints(ConstraintParser.parseLayoutConstraint(ConstraintParser.prepare(layoutConstraints))); setColumnConstraints(ConstraintParser.parseColumnConstraints(ConstraintParser.prepare(colConstraints))); construct(); }
/** rows called in FXML on MigPane itself */ public void setRows(String value) { this.fxmlRowConstraints = value; setRowConstraints( ConstraintParser.parseRowConstraints( ConstraintParser.prepare( value ) ) ); } public String getRows() { return fxmlRowConstraints; }
/** Parses all component constraints and stores the parsed values in the transient (cache) member variables. * @param constrMap The constraints as <code>String</code>s. Strings <b>must be lower case and trimmed</b> * @return The parsed constraints. Never <code>null</code>. */ public static Map<ComponentWrapper, CC> parseComponentConstraints(Map<ComponentWrapper, String> constrMap) { HashMap<ComponentWrapper, CC> flowConstrMap = new HashMap<ComponentWrapper, CC>(); for (Iterator<Map.Entry<ComponentWrapper, String>> it = constrMap.entrySet().iterator(); it.hasNext();) { Map.Entry<ComponentWrapper, String> entry = it.next(); flowConstrMap.put(entry.getKey(), parseComponentConstraint(entry.getValue())); } return flowConstrMap; }
return UnitValue.INF; int oper = getOper(s); boolean inline = oper == UnitValue.ADD || oper == UnitValue.SUB || oper == UnitValue.MUL || oper == UnitValue.DIV; 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); } else { char delim; delim = '/'; uvs = toTrimmedTokens(s, delim); if (uvs.length > 2) { // More than one +-*/. String last = uvs[uvs.length - 1]; throw new IllegalArgumentException("Malformed UnitValue: '" + s + "'"); UnitValue sub1 = parseUnitValue(uvs[0], null, isHor); UnitValue sub2 = parseUnitValue(uvs[1], null, isHor); } else { try { String[] numParts = getNumTextParts(s); float value = numParts[0].length() > 0 ? Float.parseFloat(numParts[0]) : 1; // e.g. "related" has no number part..
/** Sets the row layout constraints for the layout manager instance as a String. * <p> * See the class JavaDocs for information on how this string is formatted. * @param constr The row layout constraints as a String representation. <code>null</code> is converted to <code>""</code> for storage. * @throws RuntimeException if the constraint was not valid. */ public void setRowConstraints(Object constr) { if (constr == null || constr instanceof String) { constr = ConstraintParser.prepare((String) constr); rowSpecs = ConstraintParser.parseRowConstraints((String) constr); } else if (constr instanceof AC) { rowSpecs = (AC) constr; } else { throw new IllegalArgumentException("Illegal constraint type: " + constr.getClass().toString()); } rowConstraints = constr; grid = null; }
public MigPane add(Node node, String sCc) { CC cc = ConstraintParser.parseComponentConstraint(ConstraintParser.prepare(sCc)); add(node, cc); return this; }
public void setColConstraints(String constraint) { colConstraints = constraint; setCC(ConstraintParser.parseColumnConstraints(ConstraintParser.prepare(constraint))); }
/** layout called in FXML on MigPane itself */ public void setLayout(String value) { this.fxmLayoutConstraints = value; setLayoutConstraints( ConstraintParser.parseLayoutConstraint( ConstraintParser.prepare( value ) ) ); } public String getLayout() { return fxmLayoutConstraints; }
/** Sets the row layout constraints for the layout manager instance as a String. * <p> * See the class JavaDocs for information on how this string is formatted. * @param constr The row layout constraints as a String or {@link net.miginfocom.layout.AC} representation. <code>null</code> is converted to <code>""</code> for storage. * @throws RuntimeException if the constraint was not valid. */ public void setRowConstraints(Object constr) { if (constr == null || constr instanceof String) { constr = ConstraintParser.prepare((String) constr); rowSpecs = ConstraintParser.parseRowConstraints((String) constr); } else if (constr instanceof AC) { rowSpecs = (AC) constr; } else { throw new IllegalArgumentException("Illegal constraint type: " + constr.getClass().toString()); } rowConstraints = constr; dirty = true; }
public MigPane add(int index, Node node, String sCc) { CC cc = ConstraintParser.parseComponentConstraint(ConstraintParser.prepare(sCc)); add(index, node, cc); return this; }
/** cols called in FXML on MigPane itself */ public void setCols(String value) { this.fxmlColumConstraints = value; setColumnConstraints( ConstraintParser.parseColumnConstraints( ConstraintParser.prepare( value ) ) ); } public String getCols() { return fxmlColumConstraints; }
/** Sets the layout constraints for the layout manager instance as a String. * <p> * See the class JavaDocs for information on how this string is formatted. * @param constr The layout constraints as a String or {@link net.miginfocom.layout.LC} representation. <code>null</code> is converted to <code>""</code> for storage. * @throws RuntimeException if the constraint was not valid. */ public void setLayoutConstraints(Object constr) { if (constr == null || constr instanceof String) { constr = ConstraintParser.prepare((String) constr); lc = ConstraintParser.parseLayoutConstraint((String) constr); } else if (constr instanceof LC) { lc = (LC) constr; } else { throw new IllegalArgumentException("Illegal constraint type: " + constr.getClass().toString()); } layoutConstraints = constr; dirty = true; }
public static void setCc(Node node, String cc) { CC lCC = ConstraintParser.parseComponentConstraint( ConstraintParser.prepare( cc ) ); setCc(node, lCC); }
/** Sets the column layout constraints for the layout manager instance as a String. * <p> * See the class JavaDocs for information on how this string is formatted. * @param constr The column layout constraints as a String representation. <code>null</code> is converted to <code>""</code> for storage. * @throws RuntimeException if the constraint was not valid. */ public void setColumnConstraints(Object constr) { if (constr == null || constr instanceof String) { constr = ConstraintParser.prepare((String) constr); colSpecs = ConstraintParser.parseColumnConstraints((String) constr); } else if (constr instanceof AC) { colSpecs = (AC) constr; } else { throw new IllegalArgumentException("Illegal constraint type: " + constr.getClass().toString()); } colConstraints = constr; grid = null; }
/** Sets the layout constraints for the layout manager instance as a String. * <p> * See the class JavaDocs for information on how this string is formatted. * @param s The layout constraints as a String representation. <code>null</code> is converted to <code>""</code> for storage. * @throws RuntimeException if the constraint was not valid. */ public void setLayoutConstraints(Object s) { if (s == null || s instanceof String) { s = ConstraintParser.prepare((String) s); lc = ConstraintParser.parseLayoutConstraint((String) s); } else if (s instanceof LC) { lc = (LC) s; } else { throw new IllegalArgumentException("Illegal constraint type: " + s.getClass().toString()); } layoutConstraints = s; grid = null; }
/** Sets the component constraint for the component that already must be handled by this layout manager. * <p> * See the class JavaDocs for information on how this string is formatted. * @param constr The component constraints as a String or {@link net.miginfocom.layout.CC}. <code>null</code> is ok. * @param comp The component to set the constraints for. * @param noCheck Doesn't check if control already is managed. * @throws RuntimeException if the constraint was not valid. * @throws IllegalArgumentException If the component is not handling the component. */ private void setComponentConstraintsImpl(Control comp, Object constr, boolean noCheck) { if (noCheck == false && scrConstrMap.containsKey(comp) == false) throw new IllegalArgumentException("Component must already be added to parent!"); ComponentWrapper cw = new SwtComponentWrapper(comp); if (constr == null || constr instanceof String) { String cStr = ConstraintParser.prepare((String) constr); scrConstrMap.put(comp, constr); ccMap.put(cw, ConstraintParser.parseComponentConstraint(cStr)); } else if (constr instanceof CC) { scrConstrMap.put(comp, constr); ccMap.put(cw, (CC) constr); } else { throw new IllegalArgumentException("Constraint must be String or ComponentConstraint: " + constr.getClass().toString()); } grid = null; }