Exemple #1
0
  protected Dataset createZoom(
      final IImageTrace image,
      IRegion region,
      IROI rbs,
      boolean tryUpdate,
      boolean isDrag,
      IProgressMonitor monitor) {

    if (!(region.getROI() instanceof RectangularROI)) return null;
    final RectangularROI bounds = (RectangularROI) (rbs == null ? region.getROI() : rbs);
    if (bounds == null) return null;
    if (!region.isVisible()) return null;

    if (monitor.isCanceled()) return null;

    final int yInc = bounds.getPoint()[1] < bounds.getEndPoint()[1] ? 1 : -1;
    final int xInc = bounds.getPoint()[0] < bounds.getEndPoint()[0] ? 1 : -1;

    Dataset im = DatasetUtils.convertToDataset(image.getData());
    Dataset slice = DatasetUtils.convertToDataset(ToolUtils.getClippedSlice(im, bounds));
    slice.setName(region.getName());
    // Calculate axes to have real values not size
    Dataset yLabels = null;
    Dataset xLabels = null;
    if (image.getAxes() != null && image.getAxes().size() > 0) {
      Dataset xl = DatasetUtils.convertToDataset(image.getAxes().get(0));
      if (xl != null) xLabels = ZoomTool.getLabelsFromLabels(xl, bounds, 0);
      Dataset yl = DatasetUtils.convertToDataset(image.getAxes().get(1));
      if (yl != null) yLabels = ZoomTool.getLabelsFromLabels(yl, bounds, 1);
    }

    if (yLabels == null)
      yLabels =
          DatasetFactory.createRange(
              IntegerDataset.class, bounds.getPoint()[1], bounds.getEndPoint()[1], yInc);
    if (xLabels == null)
      xLabels =
          DatasetFactory.createRange(
              IntegerDataset.class, bounds.getPoint()[0], bounds.getEndPoint()[0], xInc);

    final IImageTrace zoom_trace =
        (IImageTrace)
            profilePlottingSystem.updatePlot2D(
                slice, Arrays.asList(new IDataset[] {xLabels, yLabels}), monitor);
    registerTraces(region, Arrays.asList(new ITrace[] {zoom_trace}));
    Display.getDefault()
        .syncExec(
            new Runnable() {
              public void run() {
                zoom_trace.setPaletteData(image.getPaletteData());
              }
            });

    return slice;
  }
Exemple #2
0
  public void createControl(Composite parent, IActionBars actionbars) {

    this.content = new Composite(parent, SWT.NONE);
    content.setLayout(new GridLayout(1, false));
    GridUtils.removeMargins(content);
    content.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));

    // Make some sashes
    final SashForm horiz = new SashForm(content, SWT.VERTICAL);
    horiz.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    horiz.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    final SashForm top = new SashForm(horiz, SWT.HORIZONTAL);
    final SashForm bottom = new SashForm(horiz, SWT.HORIZONTAL);

    // Fill the sashes
    topSystem.createPlotPart(top, "Integration", null, PlotType.XY, getPart());
    Label label = new Label(top, SWT.NONE);
    label.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));

    super.createControl(bottom, actionbars);
    rightSystem.createPlotPart(bottom, "Integration", null, PlotType.XY, getPart());

    horiz.setWeights(new int[] {30, 70});
    top.setWeights(new int[] {70, 30});
    bottom.setWeights(new int[] {70, 30});

    topSystem.setShowLegend(false);
    rightSystem.setShowLegend(false);
    profilePlottingSystem.setShowIntensity(false);
  }
Exemple #3
0
 public void dispose() {
   super.dispose();
   topSystem.dispose();
   rightSystem.dispose();
 }