Search in sources :

Example 1 with ConfigureScalingCommand

use of org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand in project nebula.widgets.nattable by eclipse.

the class HierarchicalTreeLayerTest method scaleTo150.

private void scaleTo150() {
    IDpiConverter dpiConverter = new AbstractDpiConverter() {

        @Override
        protected void readDpiFromDisplay() {
            this.dpi = 144;
        }
    };
    this.treeLayer.doCommand(new ConfigureScalingCommand(dpiConverter, dpiConverter));
}
Also used : AbstractDpiConverter(org.eclipse.nebula.widgets.nattable.layer.AbstractDpiConverter) IDpiConverter(org.eclipse.nebula.widgets.nattable.layer.IDpiConverter) ConfigureScalingCommand(org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand)

Example 2 with ConfigureScalingCommand

use of org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand in project nebula.widgets.nattable by eclipse.

the class MultiRowResizeCommandTest method testMultiResizeWithDownscaleOnSelection.

@Test
public void testMultiResizeWithDownscaleOnSelection() {
    GridLayer gridLayer = new DummyGridLayerStack();
    IDpiConverter dpiConverter = new AbstractDpiConverter() {

        @Override
        protected void readDpiFromDisplay() {
            this.dpi = 120;
        }
    };
    gridLayer.doCommand(new ConfigureScalingCommand(dpiConverter, dpiConverter));
    setClientAreaProvider(gridLayer);
    // select columns
    gridLayer.doCommand(new SelectColumnCommand(gridLayer, 3, 1, false, false));
    gridLayer.doCommand(new SelectColumnCommand(gridLayer, 4, 1, false, true));
    gridLayer.doCommand(new SelectColumnCommand(gridLayer, 5, 1, false, true));
    // scaling enabled, therefore default height of 20 pixels is up scaled
    // to 25
    assertEquals(25, gridLayer.getRowHeightByPosition(2));
    assertEquals(25, gridLayer.getRowHeightByPosition(3));
    assertEquals(25, gridLayer.getRowHeightByPosition(4));
    assertEquals(25, gridLayer.getRowHeightByPosition(5));
    assertEquals(25, gridLayer.getRowHeightByPosition(6));
    // select rows
    gridLayer.doCommand(new SelectRowsCommand(gridLayer, 1, new int[] { 3, 4, 5 }, false, true, -1));
    // resize one of the selected columns
    RowResizeCommand columnResizeCommand = new RowResizeCommand(gridLayer, 3, 50, true);
    gridLayer.doCommand(columnResizeCommand);
    // command executed with down scaling enabled, therefore set height 50
    // is first down scaled on setting the value and then up scaled to 50
    // again on accessing the height
    assertEquals(25, gridLayer.getRowHeightByPosition(2));
    assertEquals(50, gridLayer.getRowHeightByPosition(3));
    assertEquals(50, gridLayer.getRowHeightByPosition(4));
    assertEquals(50, gridLayer.getRowHeightByPosition(5));
    assertEquals(25, gridLayer.getRowHeightByPosition(6));
}
Also used : AbstractDpiConverter(org.eclipse.nebula.widgets.nattable.layer.AbstractDpiConverter) DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) SelectColumnCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand) IDpiConverter(org.eclipse.nebula.widgets.nattable.layer.IDpiConverter) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) ConfigureScalingCommand(org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand) SelectRowsCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand) Test(org.junit.Test)

Example 3 with ConfigureScalingCommand

use of org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand in project nebula.widgets.nattable by eclipse.

the class RowResizeCommandTest method testResizeWithDownscale.

@Test
public void testResizeWithDownscale() {
    IDpiConverter dpiConverter = new AbstractDpiConverter() {

        @Override
        protected void readDpiFromDisplay() {
            this.dpi = 120;
        }
    };
    this.dataLayer.doCommand(new ConfigureScalingCommand(dpiConverter, dpiConverter));
    // scaling enabled, therefore default height of 20 pixels is up scaled
    // to 25
    assertEquals(25, this.dataLayer.getRowHeightByPosition(3));
    RowResizeCommand rowResizeCommand = new RowResizeCommand(this.dataLayer, 3, 50, true);
    this.dataLayer.doCommand(rowResizeCommand);
    // command executed with down scaling enabled, therefore set height 50
    // is first down scaled on setting the value and then up scaled to 50
    // again on accessing the height
    assertEquals(50, this.dataLayer.getRowHeightByPosition(3));
}
Also used : AbstractDpiConverter(org.eclipse.nebula.widgets.nattable.layer.AbstractDpiConverter) IDpiConverter(org.eclipse.nebula.widgets.nattable.layer.IDpiConverter) ConfigureScalingCommand(org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand) Test(org.junit.Test)

Example 4 with ConfigureScalingCommand

use of org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand in project nebula.widgets.nattable by eclipse.

the class ColumnResizeCommandTest method testResizeWithDownscale.

@Test
public void testResizeWithDownscale() {
    IDpiConverter dpiConverter = new AbstractDpiConverter() {

        @Override
        protected void readDpiFromDisplay() {
            this.dpi = 120;
        }
    };
    this.dataLayer.doCommand(new ConfigureScalingCommand(dpiConverter, dpiConverter));
    // scaling enabled, therefore default width of 100 pixels is up scaled
    // to 125
    assertEquals(125, this.dataLayer.getColumnWidthByPosition(3));
    ColumnResizeCommand columnResizeCommand = new ColumnResizeCommand(this.dataLayer, 3, 150, true);
    this.dataLayer.doCommand(columnResizeCommand);
    // command executed with down scaling enabled, therefore set width 150
    // is first down scaled on setting the value and then up scaled to 150
    // again on accessing the width
    assertEquals(150, this.dataLayer.getColumnWidthByPosition(3));
}
Also used : AbstractDpiConverter(org.eclipse.nebula.widgets.nattable.layer.AbstractDpiConverter) IDpiConverter(org.eclipse.nebula.widgets.nattable.layer.IDpiConverter) ConfigureScalingCommand(org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand) Test(org.junit.Test)

Example 5 with ConfigureScalingCommand

use of org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand in project nebula.widgets.nattable by eclipse.

the class MultiColumnResizeCommandTest method testMultiResizeWithoutDownscale.

@Test
public void testMultiResizeWithoutDownscale() {
    GridLayer gridLayer = new DummyGridLayerStack();
    IDpiConverter dpiConverter = new AbstractDpiConverter() {

        @Override
        protected void readDpiFromDisplay() {
            this.dpi = 120;
        }
    };
    gridLayer.doCommand(new ConfigureScalingCommand(dpiConverter, dpiConverter));
    setClientAreaProvider(gridLayer);
    // scaling enabled, therefore default width of 100 pixels is up scaled
    // to 125
    assertEquals(125, gridLayer.getColumnWidthByPosition(2));
    assertEquals(125, gridLayer.getColumnWidthByPosition(3));
    assertEquals(125, gridLayer.getColumnWidthByPosition(4));
    assertEquals(125, gridLayer.getColumnWidthByPosition(5));
    assertEquals(125, gridLayer.getColumnWidthByPosition(6));
    MultiColumnResizeCommand resizeCommand = new MultiColumnResizeCommand(gridLayer, new int[] { 3, 4, 5 }, 150);
    gridLayer.doCommand(resizeCommand);
    // command executed with down scaling disabled, therefore set width 150
    // is up scaled to 188
    assertEquals(125, gridLayer.getColumnWidthByPosition(2));
    assertEquals(188, gridLayer.getColumnWidthByPosition(3));
    assertEquals(188, gridLayer.getColumnWidthByPosition(4));
    assertEquals(188, gridLayer.getColumnWidthByPosition(5));
    assertEquals(125, gridLayer.getColumnWidthByPosition(6));
}
Also used : AbstractDpiConverter(org.eclipse.nebula.widgets.nattable.layer.AbstractDpiConverter) DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) IDpiConverter(org.eclipse.nebula.widgets.nattable.layer.IDpiConverter) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) ConfigureScalingCommand(org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand) Test(org.junit.Test)

Aggregations

ConfigureScalingCommand (org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand)15 AbstractDpiConverter (org.eclipse.nebula.widgets.nattable.layer.AbstractDpiConverter)14 IDpiConverter (org.eclipse.nebula.widgets.nattable.layer.IDpiConverter)13 Test (org.junit.Test)12 DummyGridLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack)8 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)6 SelectColumnCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand)3 SelectRowsCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2 ClientAreaResizeCommand (org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand)1 ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)1 ColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand)1 MultiColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand)1 SelectCellCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand)1 SelectRegionCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectRegionCommand)1 IClientAreaProvider (org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider)1