예제 #1
0
 @SuppressWarnings("unchecked")
 private void retainStateFromServer() {
   try {
     GuiBean guiBean = plotServer.getGuiState(plotViewName);
     if (guiBean != null && guiBean.containsKey(GuiParameters.IMAGEGRIDSTORE)) {
       ArrayList<GridImageEntry> entries =
           (ArrayList<GridImageEntry>) guiBean.get(GuiParameters.IMAGEGRIDSTORE);
       Iterator<GridImageEntry> iter = entries.iterator();
       String colourScheme = getPreferenceColourMapChoice();
       while (iter.hasNext()) {
         GridImageEntry entry = iter.next();
         SWTGridEntry gridEntry =
             new SWTGridEntry(
                 entry.getFilename(),
                 null,
                 canvas,
                 colourScheme,
                 getPreferenceAutoContrastLo(),
                 getPreferenceAutoContrastHi());
         imageGrid.addEntry(gridEntry, entry.getGridColumnPos(), entry.getGridRowPos());
       }
     }
   } catch (Exception e) {
     logger.warn("Problem with getting GUI data from plot server");
   }
 }
예제 #2
0
 @Override
 public void update(Object theObserved, Object changeCode) {
   if (theObserved.equals(plotConsumer)) {
     if (changeCode instanceof DataBean) {
       plotWindow.processPlotUpdate((DataBean) changeCode);
       notifyDataObservers((DataBean) changeCode);
     } else if (changeCode instanceof GuiBean) {
       plotWindow.processGUIUpdate((GuiBean) changeCode);
     }
   } else {
     if (changeCode instanceof String && changeCode.equals(plotName)) {
       plotConsumer.addJob(new PlotJob(PlotJobType.Data));
     }
     if (changeCode instanceof GuiUpdate) {
       GuiUpdate gu = (GuiUpdate) changeCode;
       if (gu.getGuiName().contains(plotName)) {
         GuiBean bean = gu.getGuiData();
         UUID id = (UUID) bean.get(GuiParameters.PLOTID);
         if (id == null || plotId.compareTo(id) != 0) { // filter out own beans
           if (guiBean == null) guiBean = bean.copy(); // cache a local copy
           else guiBean.merge(bean); // or merge it
           PlotJob job = new PlotJob(PlotJobType.GUI);
           job.setGuiBean(bean);
           plotConsumer.addJob(job);
         }
       }
     }
   }
 }
예제 #3
0
 private GuiBean saveStateToServer() {
   plotServer.deleteIObserver(this);
   if (imageGrid == null) return null;
   ArrayList<GridImageEntry> entries = imageGrid.getListOfEntries();
   GuiBean bean = new GuiBean();
   bean.put(GuiParameters.PLOTMODE, GuiPlotMode.IMGEXPL);
   bean.put(GuiParameters.IMAGEGRIDSTORE, entries);
   return bean;
 }
예제 #4
0
  /**
   * Remove gui information from plot server
   *
   * @param key
   */
  @Override
  public void removeGUIInfo(GuiParameters key) {
    getGUIState();

    guiBean.put(GuiParameters.PLOTID, plotId); // put plotID in bean
    guiBean.remove(key);

    pushGUIState();
  }
예제 #5
0
  /**
   * Push gui information back to plot server
   *
   * @param key
   * @param value
   */
  @Override
  public void putGUIInfo(GuiParameters key, Serializable value) {
    getGUIState();

    guiBean.put(GuiParameters.PLOTID, plotId); // put plotID in bean
    guiBean.put(key, value);

    pushGUIState();
  }
예제 #6
0
 private void cleanUpOnServer() {
   FileOperationBean fopBean = new FileOperationBean(FileOperationBean.DELETEGRIDIMGTEMPDIR);
   GuiBean bean = new GuiBean();
   bean.put(GuiParameters.FILEOPERATION, fopBean);
   // plotServer.deleteIObserver(this);
   try {
     plotServer.updateGui(plotViewName, bean);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
예제 #7
0
  /**
   * Push gui information back to plot server
   *
   * @param key
   * @param value
   */
  public void pushGUIUpdate(GuiParameters key, Serializable value) {
    if (guiBean == null) {
      try {
        guiBean = plotServer.getGuiState(plotViewName);
      } catch (Exception e) {
        logger.warn("Problem with getting GUI data from plot server");
      }
      if (guiBean == null) guiBean = new GuiBean();
    }

    guiBean.put(GuiParameters.PLOTID, plotID); // put plotID in bean

    guiBean.put(key, value);

    try {
      logger.info("Pushing bean to server: {}", guiBean);
      plotServer.updateGui(plotViewName, guiBean);
    } catch (Exception e) {
      logger.warn("Problem with updating plot server with GUI data");
      e.printStackTrace();
    }
  }
예제 #8
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;
      }
    }
  }