예제 #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 processNewGrid(DataBean bean) {
    final Integer[] gridDims = (Integer[]) bean.getGuiParameters().get(GuiParameters.IMAGEGRIDSIZE);

    if (gridDims != null && gridDims.length > 0) {
      try {
        locker.acquire();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }

      canvas
          .getDisplay()
          .asyncExec(
              new Runnable() {
                @Override
                public void run() {
                  imageGrid.dispose();
                  if (gridDims.length == 1)
                    imageGrid =
                        new PlotServerSWTImageGrid(gridDims[0], gridDims[0], canvas, plotViewName);
                  else
                    imageGrid =
                        new PlotServerSWTImageGrid(gridDims[1], gridDims[0], canvas, plotViewName);
                  imageGrid.setThumbnailSize(getPreferenceImageSize());
                  locker.release();
                  canvas.redraw();
                }
              });
    }
    cleanUpOnServer();
  }
예제 #3
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);
        }
      }
    }
  }
예제 #4
0
  private void processUpdate(DataBean bean) {
    if (bean == null) return;
    if (bean.getGuiParameters() == null) return;
    UUID id = (UUID) bean.getGuiParameters().get(GuiParameters.PLOTID);
    if (id == null || plotID.compareTo(id) != 0) { // filter out own beans
      if (guiBean == null) guiBean = bean.getGuiParameters().copy(); // cache a local copy
      else guiBean.merge(bean.getGuiParameters()); // or merge it

      if (bean.getGuiParameters().containsKey(GuiParameters.FILEOPERATION)) return;

      if (bean.getGuiParameters().containsKey(GuiParameters.PLOTMODE)) {
        GuiPlotMode plotMode = (GuiPlotMode) bean.getGuiParameters().get(GuiParameters.PLOTMODE);
        if (plotMode.equals(GuiPlotMode.IMGEXPL)) {
          if (bean.getGuiParameters().containsKey(GuiParameters.FILENAME)) {
            if (filesToLoad == null) filesToLoad = new ArrayList<String>();
            filesToLoad.add((String) bean.getGuiParameters().get(GuiParameters.FILENAME));
            processNewFile(bean);
          } else if (bean.getGuiParameters().containsKey(GuiParameters.IMAGEGRIDSIZE)) {
            if (filesToLoad == null) filesToLoad = new ArrayList<String>();
            else filesToLoad.clear();
            btnPlay
                .getDisplay()
                .asyncExec(
                    new Runnable() {
                      @Override
                      public void run() {
                        resetPlaying(true);
                      }
                    });
            processNewGrid(bean);
          }
        }
      } else if (bean.getGuiParameters().containsKey(GuiParameters.IMAGEGRIDLIVEVIEW)) {
        String directory = (String) bean.getGuiParameters().get(GuiParameters.IMAGEGRIDLIVEVIEW);
        spawnLoadJob(directory);
        currentDir = directory;
        isLive = true;
        liveActive = true;
      }
    }
  }