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

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

Introduction

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

Prototype

public ConstantSize(double value, Unit unit) 

Source Link

Document

Constructs a ConstantSize for the given size and unit.

Usage

From source file:com.intellij.uiDesigner.radComponents.RadFormLayoutManager.java

License:Apache License

private static ConstantSize scaleSize(final FormSpec rowSpec, final RadContainer container, final int newPx) {
    if (rowSpec.getSize() instanceof ConstantSize) {
        ConstantSize oldSize = (ConstantSize) rowSpec.getSize();
        int oldPx = oldSize.getPixelSize(container.getDelegee());
        double newValue = Math.round(oldSize.getValue() * newPx / oldPx * 10) / 10;
        return new ConstantSize(newValue, oldSize.getUnit());
    }//from   w  w  w  .  j  a  va  2s .  c  o m
    return new ConstantSize(newPx, ConstantSize.PIXEL);
}

From source file:com.intellij.uiDesigner.radComponents.RadFormLayoutManagerTest.java

License:Apache License

public void testMoveColumnRight() {
    myManager.insertGridCells(myContainer, 0, false, false, true);
    final ConstantSize colSize = new ConstantSize(17, ConstantSize.MM);
    myLayout.setColumnSpec(1, new ColumnSpec(colSize));
    RadComponent c = newComponent(0, 0, 1, 1);
    myContainer.addComponent(c);//from  w ww. j  a  va2  s.  c  om
    myManager.processCellsMoved(myContainer, false, new int[] { 0 }, 3);
    assertEquals(colSize, myLayout.getColumnSpec(3).getSize());
    assertEquals(3, myLayout.getConstraints(c.getDelegee()).gridX);
}

From source file:com.intellij.uiDesigner.radComponents.RadFormLayoutManagerTest.java

License:Apache License

public void testMoveColumnLeft() {
    myManager.insertGridCells(myContainer, 0, false, false, true);
    final ConstantSize colSize = new ConstantSize(17, ConstantSize.MM);
    myLayout.setColumnSpec(3, new ColumnSpec(colSize));
    RadComponent c = newComponent(0, 2, 1, 1);
    myContainer.addComponent(c);// w w  w. jav a2  s .  c o  m
    myManager.processCellsMoved(myContainer, false, new int[] { 2 }, 0);
    assertEquals(colSize, myLayout.getColumnSpec(1).getSize());
    assertEquals(1, myLayout.getConstraints(c.getDelegee()).gridX);
}

From source file:com.intellij.uiDesigner.radComponents.RadFormLayoutManagerTest.java

License:Apache License

public void testMoveMultipleColumnsRight() {
    myManager.insertGridCells(myContainer, 0, false, false, true);
    myManager.insertGridCells(myContainer, 0, false, false, true);
    final ConstantSize colSize1 = new ConstantSize(17, ConstantSize.MM);
    final ConstantSize colSize2 = new ConstantSize(19, ConstantSize.MM);
    myLayout.setColumnSpec(1, new ColumnSpec(colSize1));
    myLayout.setColumnSpec(3, new ColumnSpec(colSize2));
    RadComponent c1 = newComponent(0, 0, 1, 1);
    myContainer.addComponent(c1);//www .j  av  a2  s  .  c  om
    RadComponent c2 = newComponent(0, 2, 1, 1);
    myContainer.addComponent(c2);
    myManager.processCellsMoved(myContainer, false, new int[] { 0, 2 }, 5);
    assertEquals(colSize1, myLayout.getColumnSpec(3).getSize());
    assertEquals(colSize2, myLayout.getColumnSpec(5).getSize());
    assertEquals(3, myLayout.getConstraints(c1.getDelegee()).gridX);
    assertEquals(5, myLayout.getConstraints(c2.getDelegee()).gridX);
}