Пример #1
0
  private void processNewFile(DataBean bean) {
    try {
      locker.acquire();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    playback.addFile((String) bean.getGuiParameters().get(GuiParameters.FILENAME));
    String colourScheme = getPreferenceColourMapChoice();

    SWTGridEntry entry =
        new SWTGridEntry(
            (String) bean.getGuiParameters().get(GuiParameters.FILENAME),
            bean.getData().get(0),
            canvas,
            colourScheme,
            getPreferenceAutoContrastLo(),
            getPreferenceAutoContrastHi());
    Integer xPos = (Integer) bean.getGuiParameters().get(GuiParameters.IMAGEGRIDXPOS);
    Integer yPos = (Integer) bean.getGuiParameters().get(GuiParameters.IMAGEGRIDYPOS);
    if (xPos != null && yPos != null) imageGrid.addEntry(entry, xPos, yPos);
    else imageGrid.addEntry(entry);
    imageGrid.setThumbnailSize(getPreferenceImageSize());
    locker.release();
    if (liveActive) playback.moveToLast();
  }
Пример #2
0
 private void resetPlaying(boolean reset) {
   playback.stop();
   if (reset) playback.clearPlayback();
   btnPlay.setSelection(false);
   btnPlay.setImage(imgPlay);
   sldProgress.setSelection(0);
   curPosition = -1;
 }
Пример #3
0
 /** Play button action of ImageExplorer */
 public void play() {
   boolean isPaused = playback.isPaused();
   btnPlay.setImage(imgStill);
   playback.start();
   if (!isPaused) {
     playback.setSelection(getSelection());
     playback.setDelay(getPreferenceTimeDelay());
     playback.setStepping(getPreferencePlaybackRate());
     execSvc.execute(playback);
   }
 }
Пример #4
0
  @Override
  public void dispose() {
    isDisposed = true;
    GuiBean finalBean = saveStateToServer();

    if (imageGrid != null) {
      imageGrid.dispose();
    }
    if (execSvc != null) {
      execSvc.shutdown();
    }
    if (finalBean != null) {
      try {
        plotServer.updateGui(plotViewName, finalBean);
      } catch (Exception e) {
        logger.warn("Problem with updating plot server with GUI data");
        e.printStackTrace();
      }
    }

    playback.dispose();
  }
Пример #5
0
 @Override
 public void widgetSelected(SelectionEvent e) {
   if (e.getSource().equals(cmbDirectoryLocation)) {
     final String newDirectory =
         cmbDirectoryLocation.getItem(cmbDirectoryLocation.getSelectionIndex());
     if (newDirectory != null && newDirectory.length() > 0) {
       addToHistory();
       resetHistory();
       resetPlaying(true);
       spawnLoadJob(newDirectory);
       currentDir = newDirectory;
     }
   } else if (e.getSource().equals(btnHistoryBack)) {
     String newDir = history.get(historyPointer);
     btnHistoryForw.setEnabled(true);
     cmbDirectoryLocation.setText(newDir);
     resetPlaying(true);
     spawnLoadJob(newDir);
     historyPointer++;
     if (historyPointer >= history.size()) {
       btnHistoryBack.setEnabled(false);
       historyPointer = history.size() - 1;
     }
     if (firstBack) {
       addToHistory();
       firstBack = false;
       historyPointer++;
     }
   } else if (e.getSource().equals(btnHistoryForw)) {
     historyPointer--;
     String newDir = history.get(historyPointer);
     resetPlaying(true);
     spawnLoadJob(newDir);
     cmbDirectoryLocation.setText(newDir);
     btnHistoryBack.setEnabled(true);
     if (historyPointer <= 0) {
       btnHistoryForw.setEnabled(false);
       historyPointer = 1;
     }
   } else if (e.getSource().equals(btnPlay)) {
     if (btnPlay.getSelection()) {
       boolean isPaused = playback.isPaused();
       btnPlay.setImage(imgStill);
       playback.start();
       if (!isPaused) {
         playback.setSelection(getSelection());
         playback.setDelay(getPreferenceTimeDelay());
         playback.setStepping(getPreferencePlaybackRate());
         execSvc.execute(playback);
       }
     } else {
       playback.pause();
       btnPlay.setImage(imgPlay);
     }
   } else if (e.getSource().equals(btnStop)) {
     sldProgress.setSelection(0);
     curPosition = -1;
     btnPlay.setSelection(false);
     btnPlay.setImage(imgPlay);
     playback.stop();
   } else if (e.getSource().equals(btnRewind)) {
     sldProgress.setSelection(0);
     curPosition = -1;
     playback.rewind();
   } else if (e.getSource().equals(btnForward)) {
     sldProgress.setSelection(sldProgress.getMaximum());
     playback.forward();
   } else if (e.getSource().equals(sldProgress)) {
     int p = sldProgress.getSelection();
     if (p != curPosition) {
       playback.setPlayPos(p);
       curPosition = p;
     }
   } else if (e.getSource().equals(btnPlayLoop)) {
     playback.setAutoRewind(btnPlayLoop.getSelection());
   }
 }
Пример #6
0
  @SuppressWarnings("unchecked")
  @Override
  public void update(Object source, Object changeCode) {
    if (stopLoading) return;

    if (source == ImageExplorerView.FOLDER_UPDATE_MARKER) { // Folder Update
      if (changeCode instanceof List<?>) {
        playback.clearPlayback();
        btnPlay
            .getDisplay()
            .asyncExec(
                new Runnable() {
                  @Override
                  public void run() {
                    resetPlaying(false);
                    if (isLive) {
                      playback.setDelay(50);
                      playback.setStepping(1);
                      playback.start();
                      btnPlay.setSelection(true);
                      btnPlay.setImage(imgStill);
                      execSvc.execute(playback);
                      if (!monActive)
                        CommandExecutor.executeCommand(
                            getViewSite(),
                            "uk.ac.diamond.scisoft.analysis.rcp.MontorDirectoryAction");
                      cmbDirectoryLocation.setText(currentDir);
                      isLive = false;
                    }
                  }
                });
        filesToLoad = (List<String>) changeCode;
        processClientLocalUpdate();
      }
    } else {
      if (source instanceof RMIPlotServer && changeCode instanceof String) {
        String viewName = (String) changeCode;
        if (!viewName.startsWith("Image Explorer")) return;
        RMIPlotServer server = (RMIPlotServer) source;
        try {
          String[] names = server.getGuiNames();
          final DataBean bean = server.getData(names[0]);
          // when imagegrid size is set it means we need to reset the grid
          if (bean != null && bean.getGuiParameters().get(GuiParameters.IMAGEGRIDSIZE) != null) {
            Display.getDefault()
                .syncExec(
                    new Runnable() {
                      @Override
                      public void run() {
                        Integer[] gridDim =
                            (Integer[]) bean.getGuiParameters().get(GuiParameters.IMAGEGRIDSIZE);
                        if (imageGrid != null) imageGrid.dispose();
                        imageGrid =
                            new PlotServerSWTImageGrid(
                                gridDim[0], gridDim[1], canvas, plotViewName);
                        imageGrid.setThumbnailSize(getPreferenceImageSize());
                      }
                    });
          }
          if (bean != null) {
            if (bean.getData().isEmpty()) {
              // We try to load the data from the filename if data not in the databean
              String filename = (String) bean.getGuiParameters().get(GuiParameters.FILENAME);
              if (filename == null) return;
              List<DatasetWithAxisInformation> data = new ArrayList<>();
              DatasetWithAxisInformation dwai = new DatasetWithAxisInformation();
              IDataHolder holder = LoaderFactory.getData(filename);
              IDataset loadedData = holder.getDataset(0);
              dwai.setData(loadedData);
              data.add(dwai);
              bean.setData(data);
            }
            processUpdate(bean);
          } else {
            throw new Exception("Databean is null. This image grid use is not supported.");
          }
        } catch (Exception e) {
          logger.error("Error updating data from server: ", e);
        }
      }
    }
  }