Esempio n. 1
0
  @Override
  public void dispose() {
    // store current settings back into preferences
    IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
    String pName = getPartName();
    Integer setting = colourSettings.get(pName);
    if (setting != null)
      preferenceStore.setValue(
          pName + "." + PreferenceConstants.PLOT_VIEW_PLOT2D_COLOURMAP, setting);
    preferenceStore.setValue(
        pName + "." + PreferenceConstants.PLOT_VIEW_PLOT2D_SCALING, (useLog ? 1 : 0));
    deleteIObservers();
    if (histogramPlotter != null) histogramPlotter.cleanUp();
    data = null;
    if (histogramUI != null) {
      histogramUI.deactivate(false);
      histogramUI.dispose();
    }
    if (!cmbAlpha.isDisposed()) cmbAlpha.removeSelectionListener(this);
    if (!cmbRedColour.isDisposed()) cmbRedColour.removeSelectionListener(this);
    if (!cmbGreenColour.isDisposed()) cmbGreenColour.removeSelectionListener(this);
    if (!cmbBlueColour.isDisposed()) cmbBlueColour.removeSelectionListener(this);
    if (!btnGreenInverse.isDisposed()) btnGreenInverse.removeSelectionListener(this);
    if (!btnBlueInverse.isDisposed()) btnBlueInverse.removeSelectionListener(this);
    if (!btnAlphaInverse.isDisposed()) btnAlphaInverse.removeSelectionListener(this);
    if (!btnRedInverse.isDisposed()) btnRedInverse.removeSelectionListener(this);

    super.dispose();
  }
 /** @return thumbnail size */
 private int getPreferenceImageSize() {
   IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
   int size =
       preferenceStore.isDefault(PreferenceConstants.IMAGEEXPLORER_IMAGESIZE)
           ? preferenceStore.getDefaultInt(PreferenceConstants.IMAGEEXPLORER_IMAGESIZE)
           : preferenceStore.getInt(PreferenceConstants.IMAGEEXPLORER_IMAGESIZE);
   return size;
 }
 private double getPreferenceAutoContrastHi() {
   IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
   int v =
       preferenceStore.isDefault(PreferenceConstants.IMAGEEXPLORER_AUTOCONTRAST_HITHRESHOLD)
           ? preferenceStore.getDefaultInt(
               PreferenceConstants.IMAGEEXPLORER_AUTOCONTRAST_HITHRESHOLD)
           : preferenceStore.getInt(PreferenceConstants.IMAGEEXPLORER_AUTOCONTRAST_HITHRESHOLD);
   return v / 100.0;
 }
Esempio n. 4
0
 private double getPreferenceAutoContrastLo() {
   IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
   int v =
       preferenceStore.isDefault(PreferenceConstants.PLOT_VIEW_PLOT2D_AUTOCONTRAST_LOTHRESHOLD)
           ? preferenceStore.getDefaultInt(
               PreferenceConstants.PLOT_VIEW_PLOT2D_AUTOCONTRAST_LOTHRESHOLD)
           : preferenceStore.getInt(PreferenceConstants.PLOT_VIEW_PLOT2D_AUTOCONTRAST_LOTHRESHOLD);
   return v / 100.0;
 }
Esempio n. 5
0
 private boolean getPreferenceColourMapExpertMode() {
   IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
   // try to retrieve setting from last session
   if (preferenceStore.getBoolean(
       getPartName() + "." + PreferenceConstants.PLOT_VIEW_PLOT2D_CMAP_EXPERT)) return true;
   return preferenceStore.isDefault(PreferenceConstants.PLOT_VIEW_PLOT2D_CMAP_EXPERT)
       ? preferenceStore.getDefaultBoolean(PreferenceConstants.PLOT_VIEW_PLOT2D_CMAP_EXPERT)
       : preferenceStore.getBoolean(PreferenceConstants.PLOT_VIEW_PLOT2D_CMAP_EXPERT);
 }
Esempio n. 6
0
 private int getPreferenceColourMapChoice() {
   IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
   // try to retrieve setting from last session
   int i =
       preferenceStore.getInt(
           getPartName() + "." + PreferenceConstants.PLOT_VIEW_PLOT2D_COLOURMAP);
   if (i != 0) return i;
   return preferenceStore.isDefault(PreferenceConstants.PLOT_VIEW_PLOT2D_COLOURMAP)
       ? preferenceStore.getDefaultInt(PreferenceConstants.PLOT_VIEW_PLOT2D_COLOURMAP)
       : preferenceStore.getInt(PreferenceConstants.PLOT_VIEW_PLOT2D_COLOURMAP);
 }
  @Override
  public void init(IViewSite site, IMemento memento) throws PartInitException {
    init(site);
    String storedExtensions = "";
    if (memento != null) { // Open dir path
      this.dirPath = memento.getString("DIR");
      storedExtensions = memento.getString("FILTERS");
      if (storedExtensions == null) storedExtensions = "";
    }
    // Filter Extensions
    imgExtensions = new Action[ImageExplorerDirectoryChooseAction.LISTOFSUFFIX.length];
    MenuManager filterMenu = new MenuManager("File Filters");
    for (int i = 0; i < ImageExplorerDirectoryChooseAction.LISTOFSUFFIX.length; i++) {
      final int number = i;
      imgExtensions[i] =
          new Action("", IAction.AS_CHECK_BOX) {
            @Override
            public void run() {
              if (this.isChecked()) {
                filter.remove(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[number]);
              } else {
                filter.add(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[number]);
              }
              // reload the directory
              updateDirectory.setUser(true);
              updateDirectory.setPriority(Job.DECORATE);
              updateDirectory.schedule(1000);
            }
          };
      imgExtensions[i].setText(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[i]);
      imgExtensions[i].setDescription(
          "Filter " + ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[i] + " on/off");
      if (storedExtensions.contains(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[i])) {
        imgExtensions[i].setChecked(false);
        filter.add(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[i]);
      } else imgExtensions[i].setChecked(true);
      filterMenu.add(imgExtensions[i]);
    }

    site.getActionBars().getMenuManager().add(filterMenu);

    // color submenus actions
    final IPaletteService pservice = PlatformUI.getWorkbench().getService(IPaletteService.class);
    final Collection<String> names = pservice.getColorSchemes();
    String schemeName = getPreferenceColourMapChoice();

    colorMenu = new MenuAction("Color");
    colorMenu.setId(getClass().getName() + colorMenu.getText());
    colorMenu.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/color_wheel.png"));

    final Map<String, IAction> paletteActions = new HashMap<String, IAction>(11);
    CheckableActionGroup group = new CheckableActionGroup();
    for (final String paletteName : names) {
      final Action action =
          new Action(paletteName, IAction.AS_CHECK_BOX) {
            @Override
            public void run() {
              try {
                setPreferenceColourMapChoice(paletteName);

                IPlottingSystem<Composite> system =
                    PlottingFactory.getPlottingSystem(getPreferencePlaybackView());
                if (system != null) {
                  final Collection<ITrace> traces = system.getTraces();
                  if (traces != null)
                    for (ITrace trace : traces) {
                      if (trace instanceof IPaletteTrace) {
                        IPaletteTrace paletteTrace = (IPaletteTrace) trace;
                        paletteTrace.setPalette(paletteName);
                      }
                    }
                }

              } catch (Exception ne) {
                logger.error("Cannot create palette data!", ne);
              }
            }
          };
      action.setId(paletteName);
      group.add(action);
      colorMenu.add(action);
      action.setChecked(paletteName.equals(schemeName));
      paletteActions.put(paletteName, action);
    }
    colorMenu.setToolTipText("Histogram");
    site.getActionBars().getMenuManager().add(colorMenu);

    // ImageExplorer preferences
    final Action openPreferences =
        new Action("Image Explorer Preferences...") {
          @Override
          public void run() {
            PreferenceDialog pref =
                PreferencesUtil.createPreferenceDialogOn(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    ImageExplorerPreferencePage.ID,
                    null,
                    null);
            if (pref != null) pref.open();
          }
        };
    site.getActionBars().getMenuManager().add(openPreferences);
  }
  @Override
  public void createPartControl(Composite parent) {
    plotViewName = getViewSite().getRegisteredName();
    plotServer.addIObserver(this);
    setPartName(plotViewName);
    this.parent = parent;
    parent.setLayout(new GridLayout(1, true));

    locationRow = new Composite(parent, SWT.NONE);
    locationRow.setLayout(new GridLayout(4, false));
    {
      btnHistoryBack = new Button(locationRow, SWT.LEFT);
      btnHistoryBack.setEnabled(false);
      btnHistoryBack.setToolTipText("Go back in history");
      btnHistoryBack.setImage(
          AnalysisRCPActivator.getImageDescriptor("icons/arrow_left.png").createImage());
      btnHistoryBack.addSelectionListener(this);
      btnHistoryForw = new Button(locationRow, SWT.LEFT);
      btnHistoryForw.setEnabled(false);
      btnHistoryForw.setToolTipText("Go forward in history");
      btnHistoryForw.addSelectionListener(this);
      btnHistoryForw.setImage(
          AnalysisRCPActivator.getImageDescriptor("icons/arrow_right.png").createImage());
      lblLocation = new Label(locationRow, SWT.LEFT);
      lblLocation.setText("Location:");

      cmbDirectoryLocation = new Combo(locationRow, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
      cmbDirectoryLocation.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
      cmbDirectoryLocation.addSelectionListener(this);
    }
    locationRow.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false, false));

    canvas = new Canvas(parent, SWT.DOUBLE_BUFFERED | SWT.V_SCROLL | SWT.H_SCROLL);
    canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    compHUD = new Group(parent, SWT.NONE);
    compHUD.setLayout(new GridLayout(6, false));
    compHUD.setText("Image Playback");
    {
      btnRewind = new Button(compHUD, SWT.PUSH);
      btnRewind.setImage(
          AnalysisRCPActivator.getImageDescriptor("icons/control_start.png").createImage());
      btnRewind.addSelectionListener(this);
      btnRewind.setToolTipText("Rewind");
      btnPlay = new Button(compHUD, SWT.TOGGLE);
      imgPlay = AnalysisRCPActivator.getImageDescriptor("icons/control_play.png").createImage();
      imgStill = AnalysisRCPActivator.getImageDescriptor("icons/control_pause.png").createImage();
      btnPlay.setImage(imgPlay);
      btnPlay.addSelectionListener(this);
      btnPlay.setToolTipText("Play/Pause");
      btnStop = new Button(compHUD, SWT.PUSH);
      btnStop.setImage(
          AnalysisRCPActivator.getImageDescriptor("icons/control_stop.png").createImage());
      btnStop.addSelectionListener(this);
      btnStop.setToolTipText("Stop playback");
      btnForward = new Button(compHUD, SWT.PUSH);
      btnForward.setImage(
          AnalysisRCPActivator.getImageDescriptor("icons/control_end.png").createImage());
      btnForward.addSelectionListener(this);
      btnForward.setToolTipText("Forward");
      btnPlayLoop = new Button(compHUD, SWT.TOGGLE);
      btnPlayLoop.setImage(
          AnalysisRCPActivator.getImageDescriptor("icons/control_repeat.png").createImage());
      btnPlayLoop.setToolTipText("Playback loop (On/off)");
      btnPlayLoop.addSelectionListener(this);
      sldProgress = new Scale(compHUD, SWT.HORIZONTAL);
      sldProgress.setPageIncrement(1);
      sldProgress.addSelectionListener(this);
      sldProgress.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    }
    compHUD.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));

    imageGrid = new PlotServerSWTImageGrid(canvas, plotViewName);
    imageGrid.setThumbnailSize(getPreferenceImageSize());
    retainStateFromServer();

    if (dirPath != null && dirPath.length() > 0) {
      dirPath.trim();
      updateDirectory.setUser(true);
      updateDirectory.setPriority(Job.DECORATE);
      updateDirectory.schedule(1000);
      cmbDirectoryLocation.setText(dirPath);
      currentDir = dirPath;
    }
    playback =
        new ImagePlayBack(
            parent,
            getPreferencePlaybackView(),
            getViewSite().getPage(),
            sldProgress,
            getPreferenceTimeDelay(),
            getPreferencePlaybackRate());

    isDisposed = false;

    // listen to preference changes to update the Live plot play back view and colour map
    AnalysisRCPActivator.getDefault()
        .getPreferenceStore()
        .addPropertyChangeListener(
            new IPropertyChangeListener() {
              @Override
              public void propertyChange(PropertyChangeEvent event) {
                if (event.getProperty().equals(PreferenceConstants.IMAGEEXPLORER_PLAYBACKVIEW)) {
                  playback.setPlotView(getPreferencePlaybackView());
                }
                if (event.getProperty().equals(PreferenceConstants.IMAGEEXPLORER_COLOURMAP)
                    || event.getProperty().equals(PreferenceConstants.IMAGEEXPLORER_IMAGESIZE)) {
                  List<GridImageEntry> images = imageGrid.getListOfEntries();
                  imageGrid.setThumbnailSize(getPreferenceImageSize());
                  String colourScheme = getPreferenceColourMapChoice();
                  for (GridImageEntry entry : images) {
                    IDataset data = entry.getData();
                    SWTGridEntry gridEntry =
                        new SWTGridEntry(
                            entry.getFilename(),
                            data,
                            canvas,
                            colourScheme,
                            getPreferenceAutoContrastLo(),
                            getPreferenceAutoContrastHi());
                    imageGrid.addEntry(gridEntry, entry.getGridColumnPos(), entry.getGridRowPos());
                  }
                  // Check the colour menu accordingly
                  IAction currentColour = colorMenu.findAction(colourScheme);
                  if (currentColour != null) currentColour.setChecked(true);
                }
              }
            });
  }
 /** @return plot name that playback uses */
 public String getPreferencePlaybackView() {
   IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
   return preferenceStore.isDefault(PreferenceConstants.IMAGEEXPLORER_PLAYBACKVIEW)
       ? preferenceStore.getDefaultString(PreferenceConstants.IMAGEEXPLORER_PLAYBACKVIEW)
       : preferenceStore.getString(PreferenceConstants.IMAGEEXPLORER_PLAYBACKVIEW);
 }
 private int getPreferencePlaybackRate() {
   IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
   return preferenceStore.isDefault(PreferenceConstants.IMAGEEXPLORER_PLAYBACKRATE)
       ? preferenceStore.getDefaultInt(PreferenceConstants.IMAGEEXPLORER_PLAYBACKRATE)
       : preferenceStore.getInt(PreferenceConstants.IMAGEEXPLORER_PLAYBACKRATE);
 }
 private int getPreferenceTimeDelay() {
   IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
   return preferenceStore.isDefault(PreferenceConstants.IMAGEEXPLORER_TIMEDELAYBETWEENIMAGES)
       ? preferenceStore.getDefaultInt(PreferenceConstants.IMAGEEXPLORER_TIMEDELAYBETWEENIMAGES)
       : preferenceStore.getInt(PreferenceConstants.IMAGEEXPLORER_TIMEDELAYBETWEENIMAGES);
 }
 private String getPreferenceColourMapChoice() {
   IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
   return preferenceStore.isDefault(PreferenceConstants.IMAGEEXPLORER_COLOURMAP)
       ? preferenceStore.getDefaultString(PreferenceConstants.IMAGEEXPLORER_COLOURMAP)
       : preferenceStore.getString(PreferenceConstants.IMAGEEXPLORER_COLOURMAP);
 }
 private void setPreferenceColourMapChoice(String colorMapChoice) {
   IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
   preferenceStore.setValue(PreferenceConstants.IMAGEEXPLORER_COLOURMAP, colorMapChoice);
 }
 @Override
 public void init(IWorkbench workbench) {
   setPreferenceStore(AnalysisRCPActivator.getDefault().getPreferenceStore());
 }