/** * Creates and returns a <code>Border</code> using sizes as specified by * the given string. This string is a comma-separated encoding of * 4 <code>ConstantSize</code>s. * * @param encodedSizes top, left, bottom, right gap encoded as String * @return an <code>EmptyBorder</code> with the specified gaps * * @see #createEmptyBorder(ConstantSize, ConstantSize, ConstantSize, ConstantSize) */ public static Border createEmptyBorder(String encodedSizes) { String[] token = encodedSizes.split("\\s*,\\s*"); int tokenCount = token.length; if (token.length != 4) { throw new IllegalArgumentException( "The border requires 4 sizes, but \"" + encodedSizes + "\" has " + tokenCount + "."); } ConstantSize top = Sizes.constant(token[0], false); ConstantSize left = Sizes.constant(token[1], true); ConstantSize bottom = Sizes.constant(token[2], false); ConstantSize right = Sizes.constant(token[3], true); return createEmptyBorder(top, left, bottom, right); }
/** * Converts the size if necessary and returns the value in pixels. * * @param component the associated component * @return the size in pixels */ public int getPixelSize(Component component) { if (unit == PIXEL) return intValue(); else if (unit == POINT) return Sizes.pointAsPixel(intValue(), component); else if (unit == INCH) return Sizes.inchAsPixel(value, component); else if (unit == MILLIMETER) return Sizes.millimeterAsPixel(value, component); else if (unit == CENTIMETER) return Sizes.centimeterAsPixel(value, component); else if (unit == DIALOG_UNITS_X) return Sizes.dialogUnitXAsPixel(intValue(), component); else if (unit == DIALOG_UNITS_Y) return Sizes.dialogUnitYAsPixel(intValue(), component); else throw new IllegalStateException("Invalid unit " + unit); }
/** * Converts Inches and returns pixels using the specified resolution. * * @param in the Inches * @param component the component that provides the graphics object * @return the given Inches as pixels */ public static int inchAsPixel(double in, Component component) { return in == 0d ? 0 : getUnitConverter().inchAsPixel(in, component); }
FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, new RowSpec(RowSpec.CENTER, Sizes.bounded(Sizes.MINIMUM, Sizes.constant("15px", false), Sizes.constant("50px", false)), 0), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
new ColumnSpec(Sizes.dluX(0)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(10)) }, new RowSpec[] { new RowSpec(Sizes.dluY(10)), FormFactory.LINE_GAP_ROWSPEC, new RowSpec(RowSpec.TOP, Sizes.DEFAULT, FormSpec.NO_GROW), FormFactory.LINE_GAP_ROWSPEC, new RowSpec(RowSpec.TOP, Sizes.dluY(10), FormSpec.NO_GROW), FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, new RowSpec(Sizes.dluY(10)) }));
int ascent = metrics.getMaxAscent(); int hGapDlu = centerSeparators ? 3 : 1; int hGap = Sizes.dialogUnitXAsPixel(hGapDlu, label); int vOffset = centerSeparators ? 1 + (labelHeight - separatorHeight) / 2
FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(120)) }, new RowSpec[] {
new RowSpec( RowSpec.FILL, Sizes.DEFAULT, FormSpec.NO_GROW ), FormFactory.LINE_GAP_ROWSPEC, new RowSpec( RowSpec.FILL, Sizes.dluY( 60 ), FormSpec.DEFAULT_GROW ) } ) );
contentPane.setLayout(new FormLayout( new ColumnSpec[] { new ColumnSpec(Sizes.dluX(10)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(10)) }, new RowSpec[] { new RowSpec(Sizes.dluY(10)), FormFactory.LINE_GAP_ROWSPEC, new RowSpec(RowSpec.BOTTOM, Sizes.DEFAULT, FormSpec.NO_GROW), new RowSpec("fill:max(default;60dlu):grow"), FormFactory.LINE_GAP_ROWSPEC, new RowSpec(Sizes.dluY(10)) })); new ColumnSpec(Sizes.dluX(10)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(10)) }, new RowSpec[] { new RowSpec(Sizes.dluY(10)), FormFactory.LINE_GAP_ROWSPEC,
int ascent = metrics.getMaxAscent(); int hGapDlu = 3; int hGap = Sizes.dialogUnitXAsPixel(hGapDlu, label); int vOffset = 1 + (labelHeight - separatorHeight) / 2;
FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(50)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec("max(min;100dlu):grow"),
/** * Converts the size if necessary and returns the value in pixels. * * @param component * the associated component * @return the size in pixels */ public int getPixelSize(Component component) { if (unit == PIXEL) return intValue(); else if (unit == POINT) return Sizes.pointAsPixel(intValue(), component); else if (unit == INCH) return Sizes.inchAsPixel(value, component); else if (unit == MILLIMETER) return Sizes.millimeterAsPixel(value, component); else if (unit == CENTIMETER) return Sizes.centimeterAsPixel(value, component); else if (unit == DIALOG_UNITS_X) return Sizes.dialogUnitXAsPixel(intValue(), component); else if (unit == DIALOG_UNITS_Y) return Sizes.dialogUnitYAsPixel(intValue(), component); else throw new IllegalStateException("Invalid unit " + unit); }
/** * Converts DTP Points and returns pixels using the resolution of the * given component's graphics object. * * @param pt DTP Points * @param component the component that provides the graphics object * @return the given Points as pixels */ public static int pointAsPixel(int pt, Component component) { return pt == 0 ? 0 : getUnitConverter().pointAsPixel(pt, component); }
/** * Creates and returns a {@code Border} using sizes as specified by * the given string. This string is a comma-separated encoding of * 4 {@code ConstantSize}s. * * @param encodedSizes top, left, bottom, right gap encoded as String * @return an {@code EmptyBorder} with the specified gaps * * @see #createEmptyBorder(ConstantSize, ConstantSize, ConstantSize, ConstantSize) */ public static Border createEmptyBorder(String encodedSizes) { String[] token = encodedSizes.split("\\s*,\\s*"); int tokenCount = token.length; checkArgument(token.length == 4, "The border requires 4 sizes, but \"%s\" has %d.", encodedSizes, Integer.valueOf(tokenCount)); ConstantSize top = Sizes.constant(token[0], false); ConstantSize left = Sizes.constant(token[1], true); ConstantSize bottom = Sizes.constant(token[2], false); ConstantSize right = Sizes.constant(token[3], true); return createEmptyBorder(top, left, bottom, right); }
new ColumnSpec(Sizes.dluX(10)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.RIGHT, Sizes.DEFAULT, FormSpec.NO_GROW), new ColumnSpec("max(min;40dlu)"), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(10)) }, new RowSpec[] { new RowSpec(Sizes.dluY(10)), FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, new ColumnSpec(Sizes.dluX(10)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.RIGHT, Sizes.DEFAULT, FormSpec.NO_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(20)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec("max(default;45dlu)"), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(20)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(30)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(10)) }, new RowSpec[] { new RowSpec(Sizes.dluY(10)),
int ascent = metrics.getMaxAscent(); int hGapDlu = centerSeparators ? 3 : 1; int hGap = Sizes.dialogUnitXAsPixel(hGapDlu, label); int vOffset = centerSeparators ? 1 + (labelHeight - separatorHeight) / 2 : ascent - separatorHeight / 2;
new ColumnSpec(ColumnSpec.DEFAULT, Sizes.dluX(10), FormSpec.NO_GROW), new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.DEFAULT, Sizes.dluX(10), FormSpec.NO_GROW), new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
/** * Converts the size if necessary and returns the value in pixels. * * @param component the associated component * @return the size in pixels */ public int getPixelSize(Component component) { if (unit == PIXEL) { return intValue(); } else if (unit == POINT) { return Sizes.pointAsPixel(intValue(), component); } else if (unit == INCH) { return Sizes.inchAsPixel(value, component); } else if (unit == MILLIMETER) { return Sizes.millimeterAsPixel(value, component); } else if (unit == CENTIMETER) { return Sizes.centimeterAsPixel(value, component); } else if (unit == DIALOG_UNITS_X) { return Sizes.dialogUnitXAsPixel(intValue(), component); } else if (unit == DIALOG_UNITS_Y) { return Sizes.dialogUnitYAsPixel(intValue(), component); } else { throw new IllegalStateException("Invalid unit " + unit); } }
/** * Converts vertical dialog units and returns pixels. * Honors the resolution, dialog font size, platform, and l&f. * * @param dluY the vertical dialog units * @param component the component that provides the graphics object * @return the given vertical dialog units as pixels */ public static int dialogUnitYAsPixel(int dluY, Component component) { return dluY == 0 ? 0 : getUnitConverter().dialogUnitYAsPixel(dluY, component); }
/** * Creates and returns a <code>Border</code> using sizes as specified by * the given string. This string is a comma-separated encoding of 4 * <code>ConstantSize</code>s. * * @param encodedSizes * top, left, bottom, right gap encoded as String * @return an <code>EmptyBorder</code> with the specified gaps * * @see #createEmptyBorder(ConstantSize, ConstantSize, ConstantSize, * ConstantSize) */ public static Border createEmptyBorder(String encodedSizes) { StringTokenizer tokenizer = new StringTokenizer(encodedSizes, ", "); int tokenCount = tokenizer.countTokens(); if (tokenCount != 4) { throw new IllegalArgumentException("The border requires 4 sizes, but '" + encodedSizes + "' has " + tokenCount + "."); } ConstantSize top = Sizes.constant(tokenizer.nextToken(), false); ConstantSize left = Sizes.constant(tokenizer.nextToken(), true); ConstantSize bottom = Sizes.constant(tokenizer.nextToken(), false); ConstantSize right = Sizes.constant(tokenizer.nextToken(), true); return createEmptyBorder(top, left, bottom, right); }