Пример #1
0
  @Override
  public void actionPerformed(ActionEvent e) {

    if (e.getSource() == spvp.getDeleteAllButton()) {
      Icy.getMainInterface().getSwimmingPool().removeAll();
    }
  }
Пример #2
0
  @Override
  protected void finalize() throws Throwable {
    // unregister plugin (weak reference so we can do it here)
    Icy.getMainInterface().unRegisterPlugin(this);

    super.finalize();
  }
Пример #3
0
  /** Handle {@link MainFrame#PROPERTY_DETACHEDMODE} property change here. */
  @Override
  public void propertyChange(PropertyChangeEvent evt) {
    final boolean isDetached = Icy.getMainInterface().isDetachedMode();
    final ImageJToolRibbonBand band = (ImageJToolRibbonBand) getBand(1);

    band.setDetachedBtnPressed(isDetached);
    band.updateEnable(isDetached);
  }
Пример #4
0
  /** Initialization stuff which cannot be done at construction time */
  public void init() {
    // refresh band state
    propertyChange(null);

    final MainFrame mainFrame = Icy.getMainInterface().getMainFrame();
    // we listen detach mode change
    if (mainFrame != null)
      mainFrame.addPropertyChangeListener(MainFrame.PROPERTY_DETACHEDMODE, this);
  }
Пример #5
0
  private void refreshGUI() {
    spvp.getScrollPanel().removeAll();

    for (SwimmingObject result : Icy.getMainInterface().getSwimmingPool().getObjects()) {
      JPanel panel = new SwimmingPoolObjectPanel(result);
      ComponentUtil.setFixedHeight(panel, 40);
      spvp.getScrollPanel().add(panel);
    }

    spvp.getScrollPanel().add(Box.createVerticalGlue());

    String text = "No object in swimming pool.";

    int numberOfSwimmingObject = Icy.getMainInterface().getSwimmingPool().getObjects().size();
    if (numberOfSwimmingObject > 0) {
      text = "" + numberOfSwimmingObject + " objects in swimming pool.";
    }

    spvp.getNumberOfSwimmingObjectLabel().setText(text);

    spvp.getScrollPane().invalidate();
    spvp.getScrollPane().repaint();
  }
Пример #6
0
  public SwimmingPoolViewer() {

    mainFrame.getContentPane().setLayout(new BorderLayout());
    mainFrame.getContentPane().add(spvp, BorderLayout.CENTER);
    mainFrame.setVisible(true);
    mainFrame.setPreferredSize(new Dimension(400, 400));
    mainFrame.addToDesktopPane();
    mainFrame.center();
    mainFrame.pack();

    Icy.getMainInterface().getSwimmingPool().addListener(this);
    spvp.getDeleteAllButton().addActionListener(this);

    refreshGUI();

    mainFrame.requestFocus();
  }
Пример #7
0
 @Override
 public void removeListener(Object source) {
   Icy.getMainInterface().removeListener(this);
 }
Пример #8
0
  /** The width of the inner component of the inspector should not exceed 300. */
  public InspectorPanel() {
    super("Inspector", "inspector", new Point(600, 140), new Dimension(280, 600));

    // tab panel
    mainPane = new ExtTabbedPanel();
    mainPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);

    // main panels
    sequencePanel = new SequencePanel();
    // final JPanel pluginsPanel = new PluginsPanel();
    roisPanel = new RoisPanel(true, true);
    layersPanel = new LayersPanel(true, true);
    historyPanel = new UndoManagerPanel();
    outputConsolePanel = new OutputConsolePanel();
    chatPanel = new ChatPanel();

    // add main tab panels
    mainPane.addTab(
        "Sequence",
        null,
        new JScrollPane(
            sequencePanel,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER),
        "Sequence informations");
    // mainPane.add("Active Plugin", pluginsPanel);
    mainPane.addTab("Layer", null, layersPanel, "Show all layers details");
    mainPane.addTab("ROI", null, roisPanel, "Manage / edit your ROI");
    // mainPane.addTab("History", null, historyPanel, "Actions history");
    mainPane.addTab("Output", null, outputConsolePanel, "Console output");
    mainPane.addTab("Chat", null, chatPanel, "Chat room");

    // minimum required size for sequence infos panel
    final Dimension minDim = new Dimension(280, 480);
    getFrame().setMinimumSizeInternal(minDim);
    getFrame().setMinimumSizeExternal(minDim);
    setMinimumSize(minDim);
    setLayout(new BorderLayout());

    add(mainPane, BorderLayout.CENTER);
    add(new MemoryMonitorPanel(), BorderLayout.SOUTH);

    validate();
    setVisible(true);

    // get default color of tab background
    final Color defaultBgColor = mainPane.getBackgroundAt(0);

    mainPane.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            final int index = getIndexOfTab(outputConsolePanel);

            // set back default tab color
            if ((index != -1) && (mainPane.getSelectedIndex() == index))
              mainPane.setBackgroundAt(index, defaultBgColor);
          }
        });

    outputConsolePanel.addOutputConsoleChangeListener(
        new OutputConsoleChangeListener() {
          @Override
          public void outputConsoleChanged(OutputConsolePanel source, boolean isError) {
            final int index = getIndexOfTab(outputConsolePanel);

            if ((index != -1) && (mainPane.getSelectedIndex() != index)) {
              final boolean fIsError = isError;

              ThreadUtil.invokeLater(
                  new Runnable() {
                    @Override
                    public void run() {
                      // change output console tab color when new data
                      if (fIsError) mainPane.setBackgroundAt(index, Color.red);
                      else if (!mainPane.getBackgroundAt(index).equals(Color.red))
                        mainPane.setBackgroundAt(index, Color.blue);
                    }
                  });
            }
          }
        });

    // add focused sequence & viewer listener
    Icy.getMainInterface().addFocusedViewerListener(this);
    Icy.getMainInterface().addFocusedSequenceListener(this);
  }
Пример #9
0
  /**
   * Save the specified sequence in the specified file.<br>
   * When the sequence contains severals image the multipleFile flag is used to indicate if images
   * are saved as separate files (file then specify a directory) or not.<br>
   * <code>zMin</code> - <code>zMax</code> and <code>tMin</code> - <code>tMax</code> define the Z
   * and T images range to save.<br>
   *
   * @param formatWriter writer used to save sequence (define the image format).<br>
   *     If set to <code>null</code> then writer is determined from the file extension.<br>
   *     If destination file does not have a valid extension (for folder for instance) then you have
   *     to specify a valid Writer to write the image file (see {@link #getWriter(ImageFileFormat)})
   * @param sequence sequence to save
   * @param file file where we want to save sequence.<br>
   *     Depending the <code>formatWriter</code> the file extension may be modified.<br>
   *     That is preferred as saving an image with a wrong extension may result in error on future
   *     read (wrong reader detection).
   * @param zMin start Z position to save
   * @param zMax end Z position to save
   * @param tMin start T position to save
   * @param tMax end T position to save
   * @param fps frame rate for AVI sequence save
   * @param multipleFile flag to indicate if images are saved in separate file
   * @param showProgress show progress bar
   * @param addToRecent add the saved sequence to recent opened sequence list
   */
  public static void save(
      IFormatWriter formatWriter,
      Sequence sequence,
      File file,
      int zMin,
      int zMax,
      int tMin,
      int tMax,
      int fps,
      boolean multipleFile,
      boolean showProgress,
      boolean addToRecent) {
    final String filePath = FileUtil.cleanPath(FileUtil.getGenericPath(file.getAbsolutePath()));
    final int sizeT = (tMax - tMin) + 1;
    final int sizeZ = (zMax - zMin) + 1;
    final int numImages = sizeT * sizeZ;
    final FileFrame saveFrame;
    final ApplicationMenu mainMenu;

    if (addToRecent) mainMenu = Icy.getMainInterface().getApplicationMenu();
    else mainMenu = null;
    if (showProgress && !Icy.getMainInterface().isHeadLess())
      saveFrame = new FileFrame("Saving", filePath);
    else saveFrame = null;
    try {
      if (saveFrame != null) {
        saveFrame.setLength(numImages);
        saveFrame.setPosition(0);
      }

      // need multiple files ?
      if ((numImages > 1) && multipleFile) {
        final IFormatWriter writer;

        // so we won't create it for each image
        if (formatWriter == null) writer = getWriter(file, ImageFileFormat.TIFF);
        else writer = formatWriter;

        if (writer == null)
          throw new UnknownFormatException(
              "Can't find a valid image writer for the specified file: " + file);

        // save as severals images
        final DecimalFormat decimalFormat = new DecimalFormat("0000");
        final String fileName = FileUtil.getFileName(filePath, false);
        String fileExt = FileUtil.getFileExtension(filePath, true);

        String fileBaseDirectory = FileUtil.getDirectory(filePath);
        if (fileBaseDirectory.endsWith("/"))
          fileBaseDirectory = fileBaseDirectory.substring(0, fileBaseDirectory.length() - 1);

        // no extension (directory) ?
        if (StringUtil.isEmpty(fileExt)) {
          // filename is part of directory
          fileBaseDirectory += FileUtil.separator + fileName;
          // use the default file extension for the specified writer
          fileExt = "." + getImageFileFormat(writer, ImageFileFormat.TIFF).getExtensions()[0];
        }

        final String filePathWithoutExt = fileBaseDirectory + FileUtil.separator + fileName;

        // create output directory
        FileUtil.createDir(fileBaseDirectory);

        // default name used --> use filename
        if (sequence.isDefaultName()) sequence.setName(fileName);
        sequence.setFilename(fileBaseDirectory);

        for (int t = tMin; t <= tMax; t++) {
          for (int z = zMin; z <= zMax; z++) {
            String filename = filePathWithoutExt;

            if ((tMax - tMin) > 0) filename += "_t" + decimalFormat.format(t);
            if ((zMax - zMin) > 0) filename += "_z" + decimalFormat.format(z);
            filename += fileExt;

            // save as single image file
            save(writer, sequence, filename, z, z, t, t, fps, saveFrame);
          }
        }

        // add as one item to recent file list
        if (mainMenu != null) mainMenu.addRecentFile(fileBaseDirectory);
      } else {
        final String fileExt = FileUtil.getFileExtension(filePath, false);
        final ImageFileFormat iff;

        if (formatWriter != null) iff = getImageFileFormat(formatWriter, ImageFileFormat.TIFF);
        else iff = ImageFileFormat.getWriteFormat(fileExt, ImageFileFormat.TIFF);

        // force to set correct file extension
        final String fixedFilePath;

        if (iff.matches(fileExt)) fixedFilePath = filePath;
        else fixedFilePath = filePath + "." + iff.getExtensions()[0];

        // default name used --> use filename
        if (sequence.isDefaultName()) sequence.setName(FileUtil.getFileName(fixedFilePath, false));
        sequence.setFilename(fixedFilePath);

        // save into a single file
        save(formatWriter, sequence, fixedFilePath, zMin, zMax, tMin, tMax, fps, saveFrame);

        // add as one item to recent file list
        if (mainMenu != null) mainMenu.addRecentFile(fixedFilePath);
      }

      // Sequence persistence enabled --> save XML
      if (GeneralPreferences.getSequencePersistence()) sequence.saveXMLData();
    } catch (Exception e) {
      IcyExceptionHandler.showErrorMessage(e, true);
      if (showProgress && !Icy.getMainInterface().isHeadLess())
        new FailedAnnounceFrame("Failed to save image(s) (see output console for details)", 15);
      return;
    } finally {
      if (saveFrame != null) saveFrame.close();
    }
  }
Пример #10
0
 public IcyBufferedImage getFocusedImage() {
   return Icy.getMainInterface().getFocusedImage();
 }
Пример #11
0
 public Sequence getFocusedSequence() {
   return Icy.getMainInterface().getFocusedSequence();
 }
Пример #12
0
 public Viewer getFocusedViewer() {
   return Icy.getMainInterface().getFocusedViewer();
 }
Пример #13
0
 public ArrayList<Sequence> getSequences() {
   return Icy.getMainInterface().getSequences();
 }
Пример #14
0
 public void addSequence(final Sequence sequence) {
   Icy.getMainInterface().addSequence(sequence);
 }