Exemplo n.º 1
0
  /**
   * Class constructor alloowing specification of the heading text.
   *
   * @param properties the Properties object containing the initial values of the extensions list
   *     and the path to be displayed. This object is updated tin response to root changes,
   *     extension changes, and file selections. If any property is missing, a suitable one is
   *     supplied by default.
   * @param heading the text to appear in the heading of the JPanel.
   * @param background the background color or null if the default is to be used.
   */
  public SourcePanel(ApplicationProperties properties, String heading, Color background) {
    super();
    this.properties = properties;
    if (background == null) this.background = Color.getHSBColor(0.58f, 0.17f, 0.95f);
    else this.background = background;

    // Make the file filter
    filter = new GeneralFileFilter();
    String extensions = properties.getProperty("extensions");
    if (extensions != null) filter.setExtensions(extensions);
    else {
      filter.addExtension(".dcm");
      properties.setProperty("extensions", filter.getExtensionString());
    }

    // Get the starting directory path from the properties.
    // If it is missing, start in the directory containing the program.
    String currentDirectoryPath = properties.getProperty("directory");
    if (currentDirectoryPath == null) currentDirectoryPath = System.getProperty("user.dir");

    // Create the UI components
    this.setLayout(new BorderLayout());
    directoryPane = new DirectoryPane(filter, currentDirectoryPath);
    directoryPane.addFileListener(this);
    headerPanel = new HeaderPanel(heading);
    footerPanel = new FooterPanel();
    this.add(headerPanel, BorderLayout.NORTH);
    this.add(directoryPane, BorderLayout.CENTER);
    this.add(footerPanel, BorderLayout.SOUTH);
  }
Exemplo n.º 2
0
 /* Wraps everything into a Cell Manager Class*/
 private CellManager toCellManager(ImagePlus imp, ArrayList<PolygonRoi> rois, ImagePlus av_imp) {
   CellManager cm = new CellManager(av_imp, imp, this.ovr);
   Iterator itr = rois.iterator();
   ArrayList<Double> av_sig = new ArrayList<>();
   PolygonRoi roi;
   while (itr.hasNext()) {
     roi = (PolygonRoi) itr.next();
     av_sig = Activity_Analysis.getAverageSignal(imp, roi);
     CalciumSignal ca_sig = new CalciumSignal(av_sig, this.dt_r);
     ovr.add(roi);
     ca_sig.DeltaF();
     cm.addCell(ca_sig, roi);
   }
   //            catch(Exception e){
   //                IJ.showMessage(e.getMessage());
   //            }
   //        }
   ovr.setLabelColor(Color.WHITE);
   //        ovr.setFillColor(Color.GREEN);
   ovr.setStrokeColor(Color.getHSBColor(100, 30, 87));
   av_imp.setOverlay(ovr);
   av_imp.show();
   IJ.run("In [+]", "");
   IJ.run("In [+]", "");
   return cm;
 }
Exemplo n.º 3
0
  void initComponents() {
    JPanel mainPanel = new JPanel(new BorderLayout());
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    Color bgColor = Color.getHSBColor(0.58f, 0.17f, 0.95f);
    buttonPanel.setBackground(bgColor);
    Border empty = BorderFactory.createEmptyBorder(5, 5, 5, 5);
    buttonPanel.setBorder(empty);

    textField = new JTextField(75);
    buttonPanel.add(textField);

    buttonPanel.add(Box.createHorizontalStrut(10));
    searchPHI = new JButton("Search PHI");
    searchPHI.addActionListener(this);
    buttonPanel.add(searchPHI);

    buttonPanel.add(Box.createHorizontalStrut(10));
    searchTrial = new JButton("Search Trial IDs");
    searchTrial.addActionListener(this);
    buttonPanel.add(searchTrial);

    buttonPanel.add(Box.createHorizontalStrut(20));
    buttonPanel.add(Box.createHorizontalGlue());
    saveAs = new JCheckBox("Save As...");
    saveAs.setBackground(bgColor);
    buttonPanel.add(saveAs);

    mainPanel.add(buttonPanel, BorderLayout.NORTH);

    JScrollPane scrollPane = new JScrollPane();
    textPane = new ColorPane();
    // textPane.setEditable(false);
    scrollPane.setViewportView(textPane);
    mainPanel.add(scrollPane, BorderLayout.CENTER);

    JPanel footerPanel = new JPanel();
    footerPanel.setLayout(new BoxLayout(footerPanel, BoxLayout.X_AXIS));
    footerPanel.setBackground(bgColor);
    message = new JLabel("Ready...");
    footerPanel.add(message);
    mainPanel.add(footerPanel, BorderLayout.SOUTH);

    setTitle(windowTitle);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent evt) {
            System.exit(0);
          }
        });
    getContentPane().add(mainPanel, BorderLayout.CENTER);
    pack();
    centerFrame();
  }
Exemplo n.º 4
0
 public FooterPanel() {
   super();
   this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
   this.setBackground(Color.getHSBColor(0.58f, 0.17f, 0.95f));
   subdirectories = new JCheckBox("Include subdirectories");
   subdirectories.setBackground(background);
   this.add(subdirectories);
   this.add(Box.createHorizontalGlue());
   extensionButton = new JButton(filter.getDescription());
   this.add(extensionButton);
   this.add(Box.createHorizontalStrut(17));
   extensionButton.addActionListener(this);
 }
 protected Color colorForValue(double value, double brightness) {
   return Color.getHSBColor((float) value, 1.0f, (float) brightness); // use array value as hue
 }
Exemplo n.º 6
0
    ImageProcessor setup(ImagePlus imp) {

      ImageProcessor ip;
      int type = imp.getType();
      if (type != ImagePlus.COLOR_RGB) return null;
      ip = imp.getProcessor();
      int id = imp.getID();
      int slice = imp.getCurrentSlice();

      if ((id != previousImageID) | (slice != previousSlice) | (flag)) {
        flag = false; // if true, flags a change from HSB to RGB or viceversa
        numSlices = imp.getStackSize();
        stack = imp.getStack();
        width = stack.getWidth();
        height = stack.getHeight();
        numPixels = width * height;

        hSource = new byte[numPixels];
        sSource = new byte[numPixels];
        bSource = new byte[numPixels];

        // restore = (int[])ip.getPixelsCopy(); //This runs into trouble sometimes, so do it the
        // long way:
        int[] temp = (int[]) ip.getPixels();
        restore = new int[numPixels];
        for (int i = 0; i < numPixels; i++) restore[i] = temp[i];

        fillMask = new int[numPixels];

        // Get hsb or rgb from image.
        ColorProcessor cp = (ColorProcessor) ip;
        IJ.showStatus("Gathering data");

        if (isRGB) cp.getRGB(hSource, sSource, bSource);
        else cp.getHSB(hSource, sSource, bSource);

        IJ.showStatus("done");

        // Create a spectrum ColorModel for the Hue histogram plot.
        Color c;
        byte[] reds = new byte[256];
        byte[] greens = new byte[256];
        byte[] blues = new byte[256];
        for (int i = 0; i < 256; i++) {
          c = Color.getHSBColor(i / 255f, 1f, 1f);

          reds[i] = (byte) c.getRed();
          greens[i] = (byte) c.getGreen();
          blues[i] = (byte) c.getBlue();
        }
        ColorModel cm = new IndexColorModel(8, 256, reds, greens, blues);

        // Make an image with just the hue from the RGB image and the spectrum LUT.
        // This is just for a hue histogram for the plot.  Do not show it.
        // ByteProcessor bpHue = new ByteProcessor(width,height,h,cm);
        ByteProcessor bpHue = new ByteProcessor(width, height, hSource, cm);
        ImagePlus impHue = new ImagePlus("Hue", bpHue);
        // impHue.show();

        ByteProcessor bpSat = new ByteProcessor(width, height, sSource, cm);
        ImagePlus impSat = new ImagePlus("Sat", bpSat);
        // impSat.show();

        ByteProcessor bpBri = new ByteProcessor(width, height, bSource, cm);
        ImagePlus impBri = new ImagePlus("Bri", bpBri);
        // impBri.show();

        plot.setHistogram(impHue, 0);
        splot.setHistogram(impSat, 1);
        bplot.setHistogram(impBri, 2);

        updateLabels();
        updatePlot();
        updateScrollBars();
        imp.updateAndDraw();
      }
      previousImageID = id;
      previousSlice = slice;
      return ip;
    }