List of usage examples for com.jgoodies.forms.layout ConstantSize POINT
Unit POINT
To view the source code for com.jgoodies.forms.layout ConstantSize POINT.
Click Source Link
From source file:org.eclipse.wb.internal.swing.FormLayout.model.FormSizeConstantInfo.java
License:Open Source License
/** * @return the value in pixels for value in given {@link Unit}. *///www. jav a 2 s . c o m public static int convertToPixels(double value, Unit unit) { UnitConverter converter = DefaultUnitConverter.getInstance(); // int pixels = 0; if (unit == ConstantSize.PIXEL) { pixels = (int) value; } else if (unit == ConstantSize.POINT) { pixels = converter.pointAsPixel((int) value, m_toolkitComponent); } else if (unit == ConstantSize.DLUX) { pixels = converter.dialogUnitXAsPixel((int) value, m_toolkitComponent); } else if (unit == ConstantSize.DLUY) { pixels = converter.dialogUnitYAsPixel((int) value, m_toolkitComponent); } else if (unit == ConstantSize.MILLIMETER) { pixels = converter.millimeterAsPixel(value, m_toolkitComponent); } else if (unit == ConstantSize.CENTIMETER) { pixels = converter.centimeterAsPixel(value, m_toolkitComponent); } else if (unit == ConstantSize.INCH) { pixels = converter.inchAsPixel(value, m_toolkitComponent); } // return pixels; }
From source file:org.eclipse.wb.internal.swing.FormLayout.model.FormSizeConstantInfo.java
License:Open Source License
/** * @return the value in given {@link Unit} for value in pixels. *///from w w w .j a v a2 s . c om public static double convertFromPixels(int pixels, Unit unit) throws Exception { if (unit == ConstantSize.PIXEL) { return pixels; } else if (unit == ConstantSize.POINT) { return convertFromPixelsInt(pixels, "pointAsPixel"); } else if (unit == ConstantSize.DLUX) { return convertFromPixelsInt(pixels, "dialogUnitXAsPixel"); } else if (unit == ConstantSize.DLUY) { return convertFromPixelsInt(pixels, "dialogUnitYAsPixel"); } else if (unit == ConstantSize.MILLIMETER) { return convertFromPixelsDouble(pixels, "millimeterAsPixel"); } else if (unit == ConstantSize.CENTIMETER) { return convertFromPixelsDouble(pixels, "centimeterAsPixel"); } else { Assert.isTrue(unit == ConstantSize.INCH); return convertFromPixelsDouble(pixels, "inchAsPixel"); } }
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}. *///w w w. ja v a2 s . c o m 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 . ja va2 s. 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)} *///from ww w . j a v a 2 s. c o 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); } }