Example usage for com.jgoodies.forms.layout ConstantSize DIALOG_UNITS_Y

List of usage examples for com.jgoodies.forms.layout ConstantSize DIALOG_UNITS_Y

Introduction

In this page you can find the example usage for com.jgoodies.forms.layout ConstantSize DIALOG_UNITS_Y.

Prototype

Unit DIALOG_UNITS_Y

To view the source code for com.jgoodies.forms.layout ConstantSize DIALOG_UNITS_Y.

Click Source Link

Usage

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  w ww .j  a  v a2 s  .  co 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.RowSelectionEditPolicy.java

License:Open Source License

@Override
protected String getTextFeedbackText(ChangeBoundsRequest request, boolean inverse) {
    final FormLayoutInfo layout = getLayout();
    int pixels = getHostFigure().getSize().height;
    int pixelsDelta = request.getSizeDelta().height;
    try {// www  . j  a  v  a2 s .  c om
        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_Y;
                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.RowSelectionEditPolicy_heightPattern,
                    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_Y;
                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.RowSelectionEditPolicy_minimumHeightPattern,
                    lowerSize.getSource(true, true));
        }
    } catch (Throwable e) {
        return GefMessages.RowSelectionEditPolicy_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}.
 *//* www.  j a  v  a 2s  .  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  ww .ja  v a  2s.co  m*/
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)}
 *///from ww w.j av a2s .  co m
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);
    }
}