use of org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand in project nebula.widgets.nattable by eclipse.
the class MultiColumnResizeCommandTest method testMultiResizeWithoutDownscaleOnSelection.
@Test
public void testMultiResizeWithoutDownscaleOnSelection() {
DummyGridLayerStack 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));
// 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));
// resize one of the selected columns
ColumnResizeCommand columnResizeCommand = new ColumnResizeCommand(gridLayer, 3, 150);
gridLayer.doCommand(columnResizeCommand);
// 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));
}
use of org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand in project nebula.widgets.nattable by eclipse.
the class MultiRowResizeCommandTest 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 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));
MultiRowResizeCommand resizeCommand = new MultiRowResizeCommand(gridLayer, new int[] { 3, 4, 5 }, 50);
gridLayer.doCommand(resizeCommand);
// command executed with down scaling disabled, therefore set height 50
// is up scaled to 63
assertEquals(25, gridLayer.getRowHeightByPosition(2));
assertEquals(63, gridLayer.getRowHeightByPosition(3));
assertEquals(63, gridLayer.getRowHeightByPosition(4));
assertEquals(63, gridLayer.getRowHeightByPosition(5));
assertEquals(25, gridLayer.getRowHeightByPosition(6));
}
use of org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand in project nebula.widgets.nattable by eclipse.
the class NatTable method internalSetLayer.
private void internalSetLayer(ILayer layer) {
if (layer != null) {
this.underlyingLayer = layer;
this.underlyingLayer.setClientAreaProvider(new IClientAreaProvider() {
@Override
public Rectangle getClientArea() {
final Rectangle clientArea = new Rectangle(0, 0, 0, 0);
if (!isDisposed()) {
getDisplay().syncExec(new Runnable() {
@Override
public void run() {
Rectangle natClientArea = NatTable.this.getClientArea();
clientArea.x = natClientArea.x;
clientArea.y = natClientArea.y;
clientArea.width = natClientArea.width;
clientArea.height = natClientArea.height;
}
});
}
return clientArea;
}
});
this.underlyingLayer.addLayerListener(this);
// register the DPI scaling
this.underlyingLayer.doCommand(new ConfigureScalingCommand(new AbstractDpiConverter() {
@Override
protected void readDpiFromDisplay() {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
dpi = Display.getDefault().getDPI().x;
}
});
}
}, new AbstractDpiConverter() {
@Override
protected void readDpiFromDisplay() {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
dpi = Display.getDefault().getDPI().y;
}
});
}
}));
}
}
use of org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand in project nebula.widgets.nattable by eclipse.
the class RowResizeCommandTest method testResizeWithoutDownscale.
@Test
public void testResizeWithoutDownscale() {
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);
this.dataLayer.doCommand(rowResizeCommand);
// command executed with down scaling disabled, therefore set height 50
// is up scaled to 63
assertEquals(63, this.dataLayer.getRowHeightByPosition(3));
}
use of org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand in project nebula.widgets.nattable by eclipse.
the class ColumnResizeCommandTest method testResizeWithoutDownscale.
@Test
public void testResizeWithoutDownscale() {
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);
this.dataLayer.doCommand(columnResizeCommand);
// command executed with down scaling disabled, therefore set width 150
// is up scaled to 188
assertEquals(188, this.dataLayer.getColumnWidthByPosition(3));
}
Aggregations