Пример #1
0
 public void setGraphLines(boolean checked) {
   if (histogramPlotter != null) {
     Plot1DGraphTable table = histogramPlotter.getColourTable();
     for (int i = 0; i < 4; i++) table.getLegendEntry(i).setVisible(checked);
   }
   histogramPlotter.updateAllAppearance();
   histogramPlotter.refresh(false);
 }
Пример #2
0
  @Override
  public void createPartControl(Composite parent) {

    this.parent = parent;
    container = new Composite(parent, SWT.NONE);
    container.setLayout(new GridLayout(1, false));

    final Composite top = new Composite(container, SWT.NONE);
    top.setLayout(new GridLayout(3, false));
    top.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    final Label scheme = new Label(top, SWT.NONE);
    scheme.setText("Colour Scheme");
    cmbColourMap = new CCombo(top, SWT.BORDER | SWT.READ_ONLY);
    cmbColourMap.setToolTipText("Change the color scheme.");
    cmbColourMap.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    btnExpertMode = new Button(top, SWT.CHECK);
    btnExpertMode.setText("Expert");
    btnExpertMode.setToolTipText("Enable expert mode for customising colour channels");
    btnExpertMode.addSelectionListener(this);

    advancedComp = new Composite(container, SWT.NONE);
    // controlGroup.setText("RGB Settings");   // Looks a bit busy with this label
    advancedComp.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    advancedComp.setLayout(new GridLayout(3, false));

    expertGroup = new Group(advancedComp, SWT.NONE);
    expertGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
    expertGroup.setLayout(new GridLayout(3, false));
    {
      Label lblRed = new Label(expertGroup, SWT.NONE);
      lblRed.setText("Red");
      cmbRedColour = new CCombo(expertGroup, SWT.BORDER | SWT.READ_ONLY);

      btnRedInverse = new Button(expertGroup, SWT.CHECK);
      btnRedInverse.setText("Inverse");
      btnRedInverse.addSelectionListener(this);

      Label lblGreen = new Label(expertGroup, SWT.NONE);
      lblGreen.setText("Green");
      cmbGreenColour = new CCombo(expertGroup, SWT.BORDER | SWT.READ_ONLY);
      btnGreenInverse = new Button(expertGroup, SWT.CHECK);
      btnGreenInverse.setText("Inverse");
      btnGreenInverse.addSelectionListener(this);

      Label lblBlue = new Label(expertGroup, SWT.NONE);
      lblBlue.setText("Blue");
      cmbBlueColour = new CCombo(expertGroup, SWT.BORDER | SWT.READ_ONLY);
      btnBlueInverse = new Button(expertGroup, SWT.CHECK);
      btnBlueInverse.setText("Inverse");
      btnBlueInverse.addSelectionListener(this);

      Label lblAlpha = new Label(expertGroup, SWT.NONE);
      lblAlpha.setText("Alpha");
      cmbAlpha = new CCombo(expertGroup, SWT.BORDER | SWT.READ_ONLY);
      btnAlphaInverse = new Button(expertGroup, SWT.CHECK);
      btnAlphaInverse.setText("Inverse");
      btnAlphaInverse.addSelectionListener(this);
    }
    expertGroup.setVisible(getPreferenceColourMapExpertMode());
    ((GridData) expertGroup.getLayoutData()).exclude = !getPreferenceColourMapExpertMode();

    threshPanel = new Group(advancedComp, SWT.NONE);
    threshPanel.setText("Mark's special threshhold"); // Looks a bit busy with this label
    threshPanel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    threshPanel.setLayout(new GridLayout(2, false));
    {
      Label lblMinValue = new Label(threshPanel, SWT.NONE);
      lblMinValue.setText("Min threshold");
      spnMinValue = new Spinner(threshPanel, SWT.BORDER);
      spnMinValue.setMinimum(0);
      spnMinValue.setMaximum(100);
      spnMinValue.addSelectionListener(this);
      Label lblMaxValue = new Label(threshPanel, SWT.NONE);
      lblMaxValue.setText("Max threshold");
      spnMaxValue = new Spinner(threshPanel, SWT.BORDER);
      spnMaxValue.setMinimum(0);
      spnMaxValue.setMaximum(100);
      spnMaxValue.addSelectionListener(this);
    }
    threshPanel.setVisible(false);
    ((GridData) threshPanel.getLayoutData()).exclude = true;

    rangePanel = new Group(container, SWT.NONE);
    rangePanel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    rangePanel.setLayout(new GridLayout(3, false));
    rangePanel.setText("Histogram range");
    {
      Label lblStartValue = new Label(rangePanel, SWT.NONE);
      lblStartValue.setText("Minimum");
      spnRangeStart = new FloatSpinner(rangePanel, SWT.BORDER);
      GridData gridData = new GridData(SWT.NONE, SWT.NONE, true, false);
      spnRangeStart.setLayoutData(gridData);
      spnRangeStart.addSelectionListener(this);
      sldMinValue = new Slider(rangePanel, SWT.BORDER);
      gridData = new GridData(SWT.FILL, SWT.NONE, true, false);
      gridData.minimumWidth = 90;
      sldMinValue.setLayoutData(gridData);
      sldMinValue.addSelectionListener(this);
      sldMinValue.setMinimum(0);
      sldMinValue.setMaximum(SLIDERSECTIONS);
      sldMinValue.setIncrement(1);
      Label lblStopValue = new Label(rangePanel, SWT.NONE);
      lblStopValue.setText("Maximum");
      gridData = new GridData(SWT.NONE, SWT.NONE, true, false);
      spnRangeStop = new FloatSpinner(rangePanel, SWT.BORDER);
      spnRangeStop.setLayoutData(gridData);
      spnRangeStop.addSelectionListener(this);
      spnRangeStart.setEnabled(false);
      spnRangeStop.setEnabled(false);
      sldMaxValue = new Slider(rangePanel, SWT.BORDER);
      gridData = new GridData(SWT.FILL, SWT.NONE, true, false);
      gridData.minimumWidth = 90;
      sldMaxValue.setLayoutData(gridData);
      sldMaxValue.addSelectionListener(this);
      sldMaxValue.setMinimum(0);
      sldMaxValue.setMaximum(SLIDERSECTIONS);
      sldMaxValue.setIncrement(1);

      spnRangeStart.setEnabled(false);
      spnRangeStop.setEnabled(false);
      sldMinValue.setEnabled(false);
      sldMaxValue.setEnabled(false);
    }
    {
      composite = new Composite(container, SWT.NONE);
      composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
      composite.setLayout(new FillLayout());

      histogramPlotter = new DataSetPlotter(PlottingMode.BARCHART, composite, false);
      histogramPlotter.setXAxisLabel("Intensity Value");
      histogramPlotter.setYAxisLabel("Count");
      histogramPlotter.setAxisModes(AxisMode.CUSTOM, AxisMode.LINEAR, AxisMode.LINEAR);
      histogramPlotter.setXTickLabelFormat(TickFormatting.plainMode);
      histogramPlotter.setXAxisValues(xAxis, 1);

      Plot1DGraphTable colourTable = histogramPlotter.getColourTable();
      Plot1DAppearance plotApp = new Plot1DAppearance(Color.RED, Plot1DStyles.SOLID, "");
      colourTable.addEntryOnLegend(plotApp);
      plotApp = new Plot1DAppearance(Color.GREEN, Plot1DStyles.SOLID, "");
      colourTable.addEntryOnLegend(plotApp);
      plotApp = new Plot1DAppearance(Color.BLUE, Plot1DStyles.SOLID, "");
      colourTable.addEntryOnLegend(plotApp);
      plotApp = new Plot1DAppearance(Color.ORANGE, Plot1DStyles.SOLID, "");
      colourTable.addEntryOnLegend(plotApp);
    }

    cmbColourMap.addSelectionListener(this);
    cmbRedColour.addSelectionListener(this);
    cmbGreenColour.addSelectionListener(this);
    cmbBlueColour.addSelectionListener(this);
    cmbAlpha.addSelectionListener(this);
    buildToolbar();
    GlobalColourMaps.InitializeColourMaps();
    fillupColourComboBoxes();
    fillupColourMapBox();
    buildGradientImage();
  }