public void pan(boolean enabled) { if (enabled) { _plot.setMouseActions( PlotMouseActionList.getDefaultPanActions().getActions(), SWT.CURSOR_HAND); } else { _plot.setMouseActions(new IPlotMouseAction[0], SWT.CURSOR_ARROW); } }
public void zoomWindow(boolean enabled) { if (enabled) { _plot.setMouseActions( PlotMouseActionList.getDefaultZoomWindowActions().getActions(), SWT.CURSOR_CROSS); } else { _plot.setMouseActions(new IPlotMouseAction[0], SWT.CURSOR_ARROW); } }
@Override protected ReadoutInfo getViewReadoutInfo(double x, double y) { IModelSpace modelSpace = _plot.getActiveModelSpace(); String xLabel = modelSpace.getAxisX().getLabel().getText(); String yLabel = modelSpace.getAxisY().getLabel().getText(); String[] keys = {xLabel, yLabel}; String[] values = {"" + x, "" + y}; return new ReadoutInfo("Mouse Location", keys, values); }
@Override protected void initializeCanvas(final Composite canvasComposite) { // Create the plot structure. _plot = new Plot(canvasComposite, initializeModelSpace(), PlotScrolling.NONE); // Initialize the canvas layout model (label margins, etc). CanvasLayoutModel layoutModel = _plot.getCanvasLayoutModel(); layoutModel.setTopLabelHeight(0); layoutModel.setTopAxisHeight(0); layoutModel.setRightLabelWidth(0); layoutModel.setRightAxisWidth(0); _plot.updateCanvasLayout(layoutModel); NumberFormat cursorFormatter = NumberFormat.getNumberInstance(); cursorFormatter.setGroupingUsed(false); _plot.setCursorFormatterX(cursorFormatter); _plot.setCursorFormatterY(cursorFormatter); _plot.setHorizontalAxisGridLineDensity(10); _plot.setVerticalAxisGridLineDensity(10); _plot.setHorizontalAxisAnnotationDensity(10); _plot.setVerticalAxisAnnotationDensity(10); }
public WaveletViewer(final Composite parent, final String title) { super(parent, true, true, false, false); _model = new WaveletViewerModel(_plot.getActiveModelSpace()); _plot.setTitle(title); }
@Override protected void checkAspectRatio() { _plot.getModelSpaceCanvas().checkAspectRatio(); }
@Override protected void updateAll() { _plot.updateAll(); }
@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 setCursorStyle(int cursorStyle) { _plot.getModelSpaceCanvas().setCursorStyle(cursorStyle); }
public void setBackgroundViewColor(RGB color) { _plot.setBackgroundPlotColor(color); }
public RGB getBackgroundViewColor() { return _plot.getBackgroundPlotColor(); }
public void home() { _plot.unzoom(); }
public void zoomOut() { _plot.zoom(1 / _plot.getZoomFactor()); }
public void zoomIn() { _plot.zoom(_plot.getZoomFactor()); }
public void updateFromModel() { _plot.getModelSpaceCanvas().checkAspectRatio(); _plot.getModelSpaceCanvas().update(UpdateLevel.RESIZE); this.redraw(); }