Beispiel #1
0
 void drawSpectrum(double h) {
   Color c;
   for (int x = 5; x < 7; x++) {
     for (int y = 0; y < 32; y++) {
       float hue = (float) (y / (2 * h) - .15);
       c = Color.getHSBColor(hue, 1f, 1f);
       setRoi(x * (int) (w / 2), y * (int) (h / 2), (int) w / 2, (int) h / 2);
       setColor(c);
       fill();
     }
   }
   setRoi(55, 32, 22, 16); // Solid red
   setColor(0xff0000);
   fill();
   setRoi(55, 120, 22, 16); // Solid green
   setColor(0x00ff00);
   fill();
   setRoi(55, 208, 22, 16); // Solid blue
   setColor(0x0000ff);
   fill();
   setRoi(55, 80, 22, 8); // Solid yellow
   setColor(0xffff00);
   fill();
   setRoi(55, 168, 22, 8); // Solid cyan
   setColor(0x00ffff);
   fill();
   setRoi(55, 248, 22, 8); // Solid magenta
   setColor(0xff00ff);
   fill();
 }
Beispiel #2
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);
  }
Beispiel #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();
  }
Beispiel #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);
 }
Beispiel #5
0
  void drawColors(int colorWidth, int colorHeight, int columns, int rows) {
    w = colorWidth;
    h = colorHeight;
    setColor(0xffffff);
    setRoi(0, 0, 110, 320);
    fill();
    drawRamp();
    resetBW();
    flipper();
    drawLine(0, 256, 110, 256);

    int x = 1;
    int y = 0;
    refreshBackground();
    refreshForeground();

    Color c;
    float hue, saturation = 1f, brightness = 1f;
    double w = colorWidth, h = colorHeight;
    for (x = 2; x < 10; x++) {
      for (y = 0; y < 32; y++) {
        hue = (float) (y / (2 * h) - .15);
        if (x < 6) {
          saturation = 1f;
          brightness = (float) (x * 4 / w);
        } else {
          saturation = 1f - ((float) ((5 - x) * -4 / w));
          brightness = 1f;
        }
        c = Color.getHSBColor(hue, saturation, brightness);
        setRoi(x * (int) (w / 2), y * (int) (h / 2), (int) w / 2, (int) h / 2);
        setColor(c);
        fill();
      }
    }
    drawSpectrum(h);
    resetRoi();
  }
    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;
    }