@Override protected void checkAspectRatio() { _plot.getModelSpaceCanvas().checkAspectRatio(); }
public void setCursorStyle(int cursorStyle) { _plot.getModelSpaceCanvas().setCursorStyle(cursorStyle); }
@Override protected void initializeViewerSpecificFeatures() { IModelSpaceCanvas canvas = _plot.getModelSpaceCanvas(); canvas.removeCursorListener(_plot); canvas.addCursorListener(this); canvas .getComposite() .addKeyListener( new KeyAdapter() { @Override public void keyPressed(final KeyEvent e) { IModelSpace activeModelSpace = _plot.getActiveModelSpace(); if (e.keyCode == SWT.ARROW_UP) { if (activeModelSpace.getAxisY().getScale() == AxisScale.LOG) { MessageDialog.openError( getShell(), "Shift Error", "Shifting of a logarithmic axis not currently supported."); return; } ModelSpaceBounds bounds = activeModelSpace.getViewableBounds(); double yStart = bounds.getStartY(); double yEnd = bounds.getEndY(); double dist = yEnd - yStart; double shift = dist / 4; double sign = -1; AxisDirection direction = activeModelSpace.getAxisY().getDirection(); if (direction.equals(AxisDirection.BOTTOM_TO_TOP)) { sign = 1; } yStart += shift * sign; yEnd += shift * sign; activeModelSpace.setViewableBounds( bounds.getStartX(), bounds.getEndX(), yStart, yEnd); } else if (e.keyCode == SWT.ARROW_DOWN) { if (activeModelSpace.getAxisY().getScale() == AxisScale.LOG) { MessageDialog.openError( getShell(), "Shift Error", "Shifting of a logarithmic axis not currently supported."); return; } ModelSpaceBounds bounds = activeModelSpace.getViewableBounds(); double yStart = bounds.getStartY(); double yEnd = bounds.getEndY(); double dist = yEnd - yStart; double shift = dist / 4; double sign = 1; AxisDirection direction = activeModelSpace.getAxisY().getDirection(); if (direction.equals(AxisDirection.BOTTOM_TO_TOP)) { sign = -1; } yStart += shift * sign; yEnd += shift * sign; activeModelSpace.setViewableBounds( bounds.getStartX(), bounds.getEndX(), yStart, yEnd); } else if (e.keyCode == SWT.ARROW_LEFT) { if (activeModelSpace.getAxisX().getScale() == AxisScale.LOG) { MessageDialog.openError( getShell(), "Shift Error", "Shifting of a logarithmic axis not currently supported."); return; } ModelSpaceBounds bounds = activeModelSpace.getViewableBounds(); double xStart = bounds.getStartX(); double xEnd = bounds.getEndX(); double dist = xEnd - xStart; double shift = dist / 4; double sign = 1; AxisDirection direction = activeModelSpace.getAxisX().getDirection(); if (direction.equals(AxisDirection.LEFT_TO_RIGHT)) { sign = -1; } xStart += shift * sign; xEnd += shift * sign; activeModelSpace.setViewableBounds( xStart, xEnd, bounds.getStartY(), bounds.getEndY()); } else if (e.keyCode == SWT.ARROW_RIGHT) { if (activeModelSpace.getAxisX().getScale() == AxisScale.LOG) { MessageDialog.openError( getShell(), "Shift Error", "Shifting of a logarithmic axis not currently supported."); return; } ModelSpaceBounds bounds = activeModelSpace.getViewableBounds(); double xStart = bounds.getStartX(); double xEnd = bounds.getEndX(); double dist = xEnd - xStart; double shift = dist / 4; double sign = -1; AxisDirection direction = activeModelSpace.getAxisX().getDirection(); if (direction.equals(AxisDirection.LEFT_TO_RIGHT)) { sign = 1; } xStart += shift * sign; xEnd += shift * sign; activeModelSpace.setViewableBounds( xStart, xEnd, bounds.getStartY(), bounds.getEndY()); } else if (e.character == ' ') { TreeSelection selection = (TreeSelection) _layerViewer.getSelection(); Iterator iterator = selection.iterator(); while (iterator.hasNext()) { Object object = iterator.next(); if (object instanceof IViewLayer) { IViewLayer layer = (IViewLayer) object; boolean visible = !layer.isVisible(); layer.setVisible(visible); _layerViewer.setChecked(layer, visible); _plot.updateAll(); } } } } }); }
public void updateFromModel() { _plot.getModelSpaceCanvas().checkAspectRatio(); _plot.getModelSpaceCanvas().update(UpdateLevel.RESIZE); this.redraw(); }