List of usage examples for com.jgoodies.forms.layout ConstantSize DIALOG_UNITS_X
Unit DIALOG_UNITS_X
To view the source code for com.jgoodies.forms.layout ConstantSize DIALOG_UNITS_X.
Click Source Link
From source file:com.intellij.uiDesigner.radComponents.FormLayoutColumnProperties.java
License:Apache License
private static void showConstantSize(final ConstantSize size, final JComboBox unitsCombo, final JSpinner spinner) { double value = size.getValue(); ConstantSize.Unit unit = size.getUnit(); if (unit.equals(ConstantSize.DIALOG_UNITS_X) || unit.equals(ConstantSize.DIALOG_UNITS_Y)) { unitsCombo.setSelectedItem("dlu"); } else {/*from ww w . j a v a 2s. c o m*/ unitsCombo.setSelectedItem(unit.abbreviation()); } spinner.setModel(new SpinnerNumberModel(0.0, 0.0, Double.MAX_VALUE, 1.0)); spinner.setValue(value); }
From source file:org.eclipse.wb.internal.swing.FormLayout.gef.header.selection.ColumnSelectionEditPolicy.java
License:Open Source License
@Override protected String getTextFeedbackText(ChangeBoundsRequest request, boolean inverse) { final FormLayoutInfo layout = getLayout(); int pixels = getHostFigure().getSize().width; int pixelsDelta = request.getSizeDelta().width; try {/*from w ww . j ava 2 s.c o m*/ FormSizeInfo sizeCopy = getDimension().copy().getSize(); if (sizeCopy.getComponentSize() == null ^ inverse) { // set current size if "null" if (sizeCopy.getConstantSize() == null) { FormSizeConstantInfo constantSize = new FormSizeConstantInfo(pixels, ConstantSize.PIXEL); Unit newUnit = sizeCopy.getLowerSize() != null ? sizeCopy.getLowerSize().getUnit() : ConstantSize.DIALOG_UNITS_X; constantSize.setUnit(newUnit); sizeCopy.setConstantSize(constantSize); } // update size final FormSizeConstantInfo constantSize; { constantSize = sizeCopy.getConstantSize(); constantSize.setAsPixels(pixels + pixelsDelta); } // prepare command m_resizeCommand = new EditCommand(layout) { @Override protected void executeEdit() throws Exception { getDimension().getSize().setConstantSize(constantSize); layout.writeDimensions(); } }; // return text return MessageFormat.format(GefMessages.ColumnSelectionEditPolicy_widthPattern, constantSize.getSource(true, true)); } else { // set current size if "null" if (sizeCopy.getLowerSize() == null) { FormSizeConstantInfo lowerSize = new FormSizeConstantInfo(pixels, ConstantSize.PIXEL); Unit newUnit = sizeCopy.getConstantSize() != null ? sizeCopy.getConstantSize().getUnit() : ConstantSize.DIALOG_UNITS_X; lowerSize.setUnit(newUnit); sizeCopy.setLowerSize(lowerSize); } // update size final FormSizeConstantInfo lowerSize; { lowerSize = sizeCopy.getLowerSize(); lowerSize.setAsPixels(pixels + pixelsDelta); } // prepare command m_resizeCommand = new EditCommand(layout) { @Override protected void executeEdit() throws Exception { FormSizeInfo size = getDimension().getSize(); // set component size if (size.getComponentSize() == null) { size.setComponentSize(Sizes.DEFAULT); } // set lower size size.setLowerSize(lowerSize); layout.writeDimensions(); } }; // return text return MessageFormat.format(GefMessages.ColumnSelectionEditPolicy_minimumWidthPattern, lowerSize.getSource(true, true)); } } catch (Throwable e) { return GefMessages.ColumnSelectionEditPolicy_exception; } }
From source file:org.eclipse.wb.internal.swing.FormLayout.model.ui.ConstantSizeComposite.java
License:Open Source License
/** * Configures value {@link Spinner} according current {@link Unit}. *//*from w w w .j a va 2 s . c om*/ private void configureSpinnerForUnit() { Unit unit = m_currentSize.getUnit(); if (unit == ConstantSize.PIXEL || unit == ConstantSize.POINT || unit == ConstantSize.DIALOG_UNITS_X || unit == ConstantSize.DIALOG_UNITS_Y) { m_valueSpinner.setDigits(0); m_divider = 1.0; } else { m_valueSpinner.setDigits(1); m_divider = 10.0; } }
From source file:org.eclipse.wb.tests.designer.swing.model.layout.FormLayout.FormSizeInfoTest.java
License:Open Source License
/** * Test for {@link FormSizeConstantInfo#convertFromPixels(int, Unit)} *///from w w w .java 2s . c om public void test_FormSizeConstantInfo_convertFromPixels() throws Exception { { double expected = 50.0; check_convertFromPixels(50, ConstantSize.PIXEL, expected); } { double expected = Expectations.get(39.0, new DblValue[] { new DblValue("kosta-home", 31.0), new DblValue("scheglov-win", 39.0) }); check_convertFromPixels(50, ConstantSize.POINT, expected); } { double expected = Expectations.get(34.0, new DblValue[] { new DblValue("kosta-home", 26.0), new DblValue("scheglov-win", 34.0) }); check_convertFromPixels(50, ConstantSize.DIALOG_UNITS_X, expected); } { double expected = Expectations.get(34.0, new DblValue[] { new DblValue("kosta-home", 32.0), new DblValue("scheglov-win", 34.0) }); check_convertFromPixels(50, ConstantSize.DIALOG_UNITS_Y, expected); } { double expected = Expectations.get(13.4, new DblValue[] { new DblValue("kosta-home", 10.7), new DblValue("scheglov-win", 13.4) }); check_convertFromPixels(50, ConstantSize.MILLIMETER, expected); } { double expected = Expectations.get(1.3, new DblValue[] { new DblValue("kosta-home", 1.1), new DblValue("scheglov-win", 1.3) }); check_convertFromPixels(50, ConstantSize.CENTIMETER, expected); } { double expected = Expectations.get(0.5, new DblValue[] { new DblValue("kosta-home", 0.4), new DblValue("scheglov-win", 0.5) }); check_convertFromPixels(50, ConstantSize.INCH, expected); } }
From source file:org.eclipse.wb.tests.designer.swing.model.layout.FormLayout.FormSizeInfoTest.java
License:Open Source License
/** * Test for {@link FormSizeConstantInfo#convertToPixels(double, Unit)} *//*w ww . j a va 2 s. com*/ public void test_FormSizeConstantInfo_convertToPixels() throws Exception { { int expected = 10; check_convertToPixels(10.0, ConstantSize.PIXEL, expected); } { int expected = Expectations.get(13, new IntValue[] { new IntValue("kosta-home", 16), new IntValue("scheglov-win", 13) }); check_convertToPixels(10.0, ConstantSize.POINT, expected); } { int expected = Expectations.get(15, new IntValue[] { new IntValue("kosta-home", 20), new IntValue("scheglov-win", 15) }); check_convertToPixels(10.0, ConstantSize.DIALOG_UNITS_X, expected); } { int expected = Expectations.get(15, new IntValue[] { new IntValue("kosta-home", 16), new IntValue("scheglov-win", 15) }); check_convertToPixels(10.0, ConstantSize.DIALOG_UNITS_Y, expected); } { int expected = Expectations.get(38, new IntValue[] { new IntValue("kosta-home", 47), new IntValue("scheglov-win", 38) }); check_convertToPixels(10.0, ConstantSize.MILLIMETER, expected); } { int expected = Expectations.get(378, new IntValue[] { new IntValue("kosta-home", 472), new IntValue("scheglov-win", 378) }); check_convertToPixels(10.0, ConstantSize.CENTIMETER, expected); } { int expected = Expectations.get(960, new IntValue[] { new IntValue("kosta-home", 1200), new IntValue("scheglov-win", 960) }); check_convertToPixels(10.0, ConstantSize.INCH, expected); } }