Java Code Examples for org.jfree.util.UnitType#ABSOLUTE
The following examples show how to use
org.jfree.util.UnitType#ABSOLUTE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RectangleInsetsTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Serialize an instance, restore it, and check for identity. */ public void testSerialization() { final RectangleInsets i1 = new RectangleInsets( UnitType.ABSOLUTE, 1.0, 2.0, 3.0, 4.0 ); RectangleInsets i2 = null; try { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); final ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(i1); out.close(); final ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); i2 = (RectangleInsets) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertTrue(i1.equals(i2)); }
Example 2
Source File: RectangleInsetsTest.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Test the equals() method. */ public void testEquals() { RectangleInsets i1 = new RectangleInsets( UnitType.ABSOLUTE, 1.0, 2.0, 3.0, 4.0 ); RectangleInsets i2 = new RectangleInsets( UnitType.ABSOLUTE, 1.0, 2.0, 3.0, 4.0 ); assertTrue(i1.equals(i2)); assertTrue(i2.equals(i1)); i1 = new RectangleInsets(UnitType.RELATIVE, 1.0, 2.0, 3.0, 4.0); assertFalse(i1.equals(i2)); i2 = new RectangleInsets(UnitType.RELATIVE, 1.0, 2.0, 3.0, 4.0); assertTrue(i1.equals(i2)); i1 = new RectangleInsets(UnitType.RELATIVE, 0.0, 2.0, 3.0, 4.0); assertFalse(i1.equals(i2)); i2 = new RectangleInsets(UnitType.RELATIVE, 0.0, 2.0, 3.0, 4.0); assertTrue(i1.equals(i2)); i1 = new RectangleInsets(UnitType.RELATIVE, 0.0, 0.0, 3.0, 4.0); assertFalse(i1.equals(i2)); i2 = new RectangleInsets(UnitType.RELATIVE, 0.0, 0.0, 3.0, 4.0); assertTrue(i1.equals(i2)); i1 = new RectangleInsets(UnitType.RELATIVE, 0.0, 0.0, 0.0, 4.0); assertFalse(i1.equals(i2)); i2 = new RectangleInsets(UnitType.RELATIVE, 0.0, 0.0, 0.0, 4.0); assertTrue(i1.equals(i2)); i1 = new RectangleInsets(UnitType.RELATIVE, 0.0, 0.0, 0.0, 0.0); assertFalse(i1.equals(i2)); i2 = new RectangleInsets(UnitType.RELATIVE, 0.0, 0.0, 0.0, 0.0); assertTrue(i1.equals(i2)); }
Example 3
Source File: UnitTypeFieldHandler.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Object convertUponSet(Object value) { if (value == null) { return null; } return UnitType.RELATIVE.toString().equals(value) ? UnitType.RELATIVE : UnitType.ABSOLUTE.toString().equals(value) ? UnitType.ABSOLUTE : null; }
Example 4
Source File: RectangleInsetsTest.java From ccu-historian with GNU General Public License v3.0 | 4 votes |
/** * Some checks for the createAdjustedRectangle() method. */ public void testCreateAdjustedRectangleAbsolute() { RectangleInsets i1 = new RectangleInsets( UnitType.ABSOLUTE, 1.0, 2.0, 3.0, 4.0 ); Rectangle2D base = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0); // no adjustment Rectangle2D adjusted = i1.createAdjustedRectangle( base, LengthAdjustmentType.NO_CHANGE, LengthAdjustmentType.NO_CHANGE ); assertEquals(new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0), adjusted); // expand height adjusted = i1.createAdjustedRectangle( base, LengthAdjustmentType.NO_CHANGE, LengthAdjustmentType.EXPAND ); assertEquals(new Rectangle2D.Double(10.0, 19.0, 30.0, 44.0), adjusted); // contract height adjusted = i1.createAdjustedRectangle( base, LengthAdjustmentType.NO_CHANGE, LengthAdjustmentType.CONTRACT ); assertEquals(new Rectangle2D.Double(10.0, 21.0, 30.0, 36.0), adjusted); // expand width adjusted = i1.createAdjustedRectangle( base, LengthAdjustmentType.EXPAND, LengthAdjustmentType.NO_CHANGE ); assertEquals(new Rectangle2D.Double(8.0, 20.0, 36.0, 40.0), adjusted); // contract width adjusted = i1.createAdjustedRectangle( base, LengthAdjustmentType.CONTRACT, LengthAdjustmentType.NO_CHANGE ); assertEquals(new Rectangle2D.Double(12.0, 20.0, 24.0, 40.0), adjusted); // expand both adjusted = i1.createAdjustedRectangle( base, LengthAdjustmentType.EXPAND, LengthAdjustmentType.EXPAND ); assertEquals(new Rectangle2D.Double(8.0, 19.0, 36.0, 44.0), adjusted); // expand width contract height adjusted = i1.createAdjustedRectangle( base, LengthAdjustmentType.EXPAND, LengthAdjustmentType.CONTRACT ); assertEquals(new Rectangle2D.Double(8.0, 21.0, 36.0, 36.0), adjusted); // contract both adjusted = i1.createAdjustedRectangle( base, LengthAdjustmentType.CONTRACT, LengthAdjustmentType.CONTRACT ); assertEquals(new Rectangle2D.Double(12.0, 21.0, 24.0, 36.0), adjusted); // contract width expand height adjusted = i1.createAdjustedRectangle( base, LengthAdjustmentType.CONTRACT, LengthAdjustmentType.EXPAND ); assertEquals(new Rectangle2D.Double(12.0, 19.0, 24.0, 44.0), adjusted); }
Example 5
Source File: RectangleInsets.java From ccu-historian with GNU General Public License v3.0 | 2 votes |
/** * Creates a new instance with the specified insets (as 'absolute' units). * * @param top the top insets. * @param left the left insets. * @param bottom the bottom insets. * @param right the right insets. */ public RectangleInsets(final double top, final double left, final double bottom, final double right) { this(UnitType.ABSOLUTE, top, left, bottom, right); }