示例#1
0
 public void pan(boolean enabled) {
   if (enabled) {
     _plot.setMouseActions(
         PlotMouseActionList.getDefaultPanActions().getActions(), SWT.CURSOR_HAND);
   } else {
     _plot.setMouseActions(new IPlotMouseAction[0], SWT.CURSOR_ARROW);
   }
 }
示例#2
0
 public void zoomWindow(boolean enabled) {
   if (enabled) {
     _plot.setMouseActions(
         PlotMouseActionList.getDefaultZoomWindowActions().getActions(), SWT.CURSOR_CROSS);
   } else {
     _plot.setMouseActions(new IPlotMouseAction[0], SWT.CURSOR_ARROW);
   }
 }
示例#3
0
 @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);
 }
示例#4
0
  @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);
  }
示例#5
0
 public WaveletViewer(final Composite parent, final String title) {
   super(parent, true, true, false, false);
   _model = new WaveletViewerModel(_plot.getActiveModelSpace());
   _plot.setTitle(title);
 }
示例#6
0
 @Override
 protected void checkAspectRatio() {
   _plot.getModelSpaceCanvas().checkAspectRatio();
 }
示例#7
0
 @Override
 protected void updateAll() {
   _plot.updateAll();
 }
示例#8
0
  @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();
                    }
                  }
                }
              }
            });
  }
示例#9
0
 public void setCursorStyle(int cursorStyle) {
   _plot.getModelSpaceCanvas().setCursorStyle(cursorStyle);
 }
示例#10
0
 public void setBackgroundViewColor(RGB color) {
   _plot.setBackgroundPlotColor(color);
 }
示例#11
0
 public RGB getBackgroundViewColor() {
   return _plot.getBackgroundPlotColor();
 }
示例#12
0
 public void home() {
   _plot.unzoom();
 }
示例#13
0
 public void zoomOut() {
   _plot.zoom(1 / _plot.getZoomFactor());
 }
示例#14
0
 public void zoomIn() {
   _plot.zoom(_plot.getZoomFactor());
 }
示例#15
0
 public void updateFromModel() {
   _plot.getModelSpaceCanvas().checkAspectRatio();
   _plot.getModelSpaceCanvas().update(UpdateLevel.RESIZE);
   this.redraw();
 }