示例#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);
  }
示例#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;
 }
  private void drawColorBar(Graphics g) {
    int minimum, maximum, height;

    minimum = 100;
    maximum = 500;
    height = 1;
    int finalI = 0;

    for (int i = 0; i < (maximum - minimum); i++) {
      float f = 0.75f * i / (float) (maximum - minimum);
      g.setColor(Color.getHSBColor(0.75f - f, 1.0f, 1.0f));
      g.fillRect(getWidth() - 40, height * i + 50, 20, height);
      finalI = i;
    }

    g.setColor(Color.BLACK);
    g.drawString(
        String.valueOf(this.opticalReturnPowerController.getMaxValue()),
        getWidth() - 60,
        48); // Max Value
    g.drawString(
        String.valueOf(this.opticalReturnPowerController.getMinValue()),
        getWidth() - 60,
        finalI + 63); // Min Value
  }
示例#4
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();
 }
 public static String getRandomHexColor() {
   float hue = random.nextFloat();
   // sat between 0.1 and 0.3
   float saturation = (random.nextInt(2000) + 1000) / 10000f;
   float luminance = 0.9f;
   Color color = Color.getHSBColor(hue, saturation, luminance);
   return '#' + Integer.toHexString((color.getRGB() & 0xffffff) | 0x1000000).substring(1);
 }
示例#6
0
 public static BMColor[] generateColors(int n) {
   BMColor[] cols = new BMColor[n];
   for (int i = 0; i < n; i++) {
     Color c = Color.getHSBColor((float) i / (float) n, 0.85f, 1.0f);
     BMColor bmc = new BMColor("key" + i, "label" + i, c.getRed(), c.getGreen(), c.getBlue());
     cols[i] = bmc;
   }
   return cols;
 }
示例#7
0
 public void refreshColor() {
   Random random;
   long randomValue = (long) (System.nanoTime() * Math.pow(id + 1, 2) + 31);
   random = new Random(randomValue);
   color =
       Color.getHSBColor(
           random.nextFloat() * 1.3f, random.nextFloat() * 2.5f, random.nextFloat() * 4.4f);
   while ((color.getBlue() < 5 && color.getGreen() < 5 && color.getRed() < 5)
       || (color.getBlue() + 5 < Color.MAGENTA.getBlue()
           && color.getBlue() - 5 > Color.MAGENTA.getBlue()
           && color.getGreen() + 5 < Color.MAGENTA.getGreen()
           && color.getGreen() - 5 > Color.MAGENTA.getGreen()
           && color.getRed() + 5 < Color.MAGENTA.getRed()
           && color.getRed() - 5 > Color.MAGENTA.getRed())) {
     color =
         Color.getHSBColor(
             random.nextFloat() * 1.3f, random.nextFloat() * 2.5f, random.nextFloat() * 4.4f);
   }
 }
示例#8
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();
  }
示例#9
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);
 }
  private Container createContentPane() {
    startFrontEndPane = new JPanel(new BorderLayout());
    JPanel centeringPanel = new JPanel(new FlowLayout());
    JLabel startLabel = new JLabel();
    startLabel.setIcon(new ImageIcon(ClothesItem.class.getResource("clothesshop.jpg")));
    centeringPanel.add(startLabel);
    startFrontEndPane.add(centeringPanel, BorderLayout.CENTER);

    frontEndPane = (JPanel) getContentPane();
    frontEndPane.setLayout(new BorderLayout());
    frontEndPane.addMouseListener(new MouseForPopup(this));
    frontEndPane.setBackground(Color.getHSBColor(44, 56, 100));

    // top panel currently empty before "Select outfit" is pressed
    topPanel = new JPanel(new GridLayout(1, 5));

    frontEndPane.add(topPanel, BorderLayout.NORTH);

    JPanel centre = new JPanel(new GridLayout(1, 2));
    JPanel c1 = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 30));
    JPanel c2 = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 30));

    // Total Price label with prompt string until the items are shown

    totalPrice = new JLabel("Press Button Below To Start");
    c1.add(totalPrice);
    centre.add(c1);

    // Selected Price label empty until items selected
    selectedPrice = new JLabel();
    c2.add(selectedPrice);
    centre.add(c2);

    frontEndPane.add(centre, BorderLayout.CENTER);

    // adding buttons
    buttonHolder = new JPanel(new GridLayout(1, 2));

    selectOutfit = new JButton("Select Outfit");
    selectOutfit.addActionListener(this);
    buttonHolder.add(selectOutfit);

    replaceOutfit = new JButton("Replace"); // added after the selectOutfit is pressed once
    replaceOutfit.addActionListener(this);

    startFrontEndPane.add(selectOutfit, BorderLayout.SOUTH);
    frontEndPane.add(buttonHolder, BorderLayout.SOUTH);

    return startFrontEndPane;
  }
示例#11
0
 private Color convertMethylationRateToColor(float mr) {
   Color color;
   /*
   if (mr >= .25) {
       return Color.getHSBColor((mr - .25f) * (1f / 0.75f), 1, 1);
   } else {
       // use a light grey between 0 and 0.25 brightness to indicate moderate methylation at the site.
       return new Color(1f - mr, 1f - mr, 1f - mr);
   }
     */
   float v =
       1.5f
           + (mr
               / 2); // add one to have a floor. getHSBColor removes the floor to yield a fraction
                     // betweeen 0 and 1.
   return Color.getHSBColor(v, .75f, 1);
 }
示例#12
0
  /** Constuct the GUI * */
  public LifeView() {
    modelSize = 128;
    generationMax = 100;

    theModel = new LifeModel(modelSize);

    setLayout(new BorderLayout());
    JPanel displayPanel = new JPanel();
    generationDisplay = new JLabel(" ");
    sizeDisplay = new JLabel("" + modelSize);
    displayPanel.add(new JLabel("generation: "));
    displayPanel.add(generationDisplay);
    displayPanel.add(new JLabel(" size: "));
    displayPanel.add(sizeDisplay);
    setGenerationCount(0);

    canvas =
        new JPanel() {

          public void paint(Graphics g) {
            Image buffer = createImage(canvas.getSize().width, canvas.getSize().height);
            Graphics gbuffer = buffer.getGraphics();
            paintCanvas(gbuffer);
            g.drawImage(buffer, 0, 0, this);
          }

          public void update(Graphics g) {
            paint(g);
          }
        };

    canvas.setBackground(Color.black);

    add(displayPanel, BorderLayout.NORTH);
    add(canvas, BorderLayout.CENTER);

    colorMap = new Color[10];
    for (int i = 0; i < 10; ++i) {
      float hue = ((float) i) / (float) 10.0;
      colorMap[i] = Color.getHSBColor(hue, (float) 0.9, (float) 0.75);
    }
    start();
  }
示例#13
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();
  }
示例#14
0
 /**
  * Computes color from index in color table
  *
  * @param i index in color table
  * @return Color
  */
 public static Color index2color(int i) {
   if (i > 63 || i < 0) return Color.black;
   if (i >= 56)
     switch (i) {
       case 56:
         return Color.black;
       case 57:
         return Color.red;
       case 58:
         return Color.green;
       case 59:
         return Color.blue;
       case 60:
         return Color.yellow;
       case 61:
         return Color.magenta;
       case 62:
         return Color.cyan;
       case 63:
         return Color.white;
     }
   if (i >= 48) {
     int j = (int) ((i - 47) * 85 / 3.);
     return new Color(j, j, j);
   } else {
     float h, s, b;
     h = (i & 7) / 8.F;
     if (i >= 32) {
       b = 1;
       s = (2 - ((i & 8) >> 3)) / 4.F;
     } else {
       s = 1;
       b = (((i & 24) >> 3) + 1) / 4.F;
     }
     return Color.getHSBColor(h, s, b);
   }
 }
 protected Color colorForValue(double value, double brightness) {
   return Color.getHSBColor((float) value, 1.0f, (float) brightness); // use array value as hue
 }
示例#16
0
  public void d(
      Graphics2D rd,
      int i,
      int j,
      int k,
      int l,
      int i1,
      int j1,
      int k1,
      int l1,
      boolean flag,
      int i2) {
    if (master != 0) {
      if (av > 1500) {
        n = 8;
      } else {
        n = 16;
      }
    }
    int ai[] = new int[n];
    int ai1[] = new int[n];
    int ai2[] = new int[n];
    if (embos == 0) {
      for (int j2 = 0; j2 < n; j2++) {
        ai[j2] = ox[j2] + i;
        ai2[j2] = oy[j2] + j;
        ai1[j2] = oz[j2] + k;
      }

      if ((gr == -11 || gr == -13) && m.lastmaf == 1) {
        for (int k2 = 0; k2 < n; k2++) {
          ai[k2] = -ox[k2] + i;
          ai2[k2] = oy[k2] + j;
          ai1[k2] = -oz[k2] + k;
        }
      }
    } else {
      if (embos <= 11 && (double) m.random() > 0.5D && !glass) {
        for (int l2 = 0; l2 < n; l2++) {
          ai[l2] = (int) ((float) (ox[l2] + i) + (15F - m.random() * 30F));
          ai2[l2] = (int) ((float) (oy[l2] + j) + (15F - m.random() * 30F));
          ai1[l2] = (int) ((float) (oz[l2] + k) + (15F - m.random() * 30F));
        }

        rot(ai, ai2, i, j, i1, n);
        rot(ai2, ai1, j, k, j1, n);
        rot(ai, ai1, i, k, l, n);
        rot(ai, ai1, m.cx, m.cz, m.xz, n);
        rot(ai2, ai1, m.cy, m.cz, m.zy, n);
        int ai3[] = new int[n];
        int ai5[] = new int[n];
        for (int i4 = 0; i4 < n; i4++) {
          ai3[i4] = xs(ai[i4], ai1[i4]);
          ai5[i4] = ys(ai2[i4], ai1[i4]);
        }

        rd.setColor(new Color(230, 230, 230));
        rd.fillPolygon(ai3, ai5, n);
      }
      float f = 1.0F;
      if (embos <= 4) // / explode outward a little + white flame
      {
        f = 1.0F + m.random() / 5F;
      }
      if (embos > 4
          && embos <= 7) // / explode outward a little + white flame a bit bigger than previous
      {
        f = 1.0F + m.random() / 4F;
      }
      if (embos > 7
          && embos
              <= 9) /////// /// explode outward a little + white flame a bit bigger than previous +
      // polys start to darken
      {
        f = 1.0F + m.random() / 3F;
        if ((double) hsb[2] > 0.69999999999999996D) {
          hsb[2] = 0.7F;
        }
      }
      if (embos > 9
          && embos
              <= 10) /////// /// explode outward a little + white flame a bit bigger than previous +
      // maor darkening
      {
        f = 1.0F + m.random() / 2.0F;
        if ((double) hsb[2] > 0.59999999999999998D) {
          hsb[2] = 0.6F;
        }
      }
      if (embos > 10
          && embos
              <= 12) /////// /// explode outward a little + white flame a bit bigger than previous +
      // more darkkkk liek coffee beans
      {
        f = 1.0F + m.random() / 1.0F;
        if ((double) hsb[2] > 0.5D) {
          hsb[2] = 0.5F;
        }
      }
      if (embos == 12) // /////polys explode outward
      {
        chip = 1;
        ctmag = 2.0F;
        bfase = -7;
      }
      if (embos == 13) // ///// dark polys
      {
        hsb[1] = 0.2F;
        hsb[2] = 0.4F;
      }
      if (embos == 16) // // flames
      {
        pa = (int) (m.random() * (float) n);
        for (pb = (int) (m.random() * (float) n); pa == pb; pb = (int) (m.random() * (float) n)) {}
      }
      if (embos >= 16) // ///flames as well
      {
        byte byte0 = 1;
        byte byte1 = 1;
        int j4;
        for (j4 = Math.abs(j1); j4 > 270; j4 -= 360) {}
        j4 = Math.abs(j4);
        if (j4 > 90) {
          byte0 = -1;
        }
        int i5;
        for (i5 = Math.abs(i1); i5 > 270; i5 -= 360) {}
        i5 = Math.abs(i5);
        if (i5 > 90) {
          byte1 = -1;
        }
        int ai12[] = new int[3];
        int ai13[] = new int[3];
        ai[0] = ox[pa] + i;
        ai2[0] = oy[pa] + j;
        ai1[0] = oz[pa] + k;
        ai[1] = ox[pb] + i;
        ai2[1] = oy[pb] + j;
        for (ai1[1] = oz[pb] + k; Math.abs(ai[0] - ai[1]) > 100; ) {
          if (ai[1] > ai[0]) {
            ai[1] -= 30;
          } else {
            ai[1] += 30;
          }
        }

        while (Math.abs(ai1[0] - ai1[1]) > 100) {
          if (ai1[1] > ai1[0]) {
            ai1[1] -= 30;
          } else {
            ai1[1] += 30;
          }
        }
        int i7 = (int) ((double) (Math.abs(ai[0] - ai[1]) / 3) * (0.5D - (double) m.random()));
        int l7 = (int) ((double) (Math.abs(ai1[0] - ai1[1]) / 3) * (0.5D - (double) m.random()));
        ai[2] = (ai[0] + ai[1]) / 2 + i7;
        ai1[2] = (ai1[0] + ai1[1]) / 2 + l7;
        int i8 =
            (int)
                (((double) (Math.abs(ai[0] - ai[1]) + Math.abs(ai1[0] - ai1[1])) / 1.5D)
                    * ((double) (m.random() / 2.0F) + 0.5D));
        ai2[2] = (ai2[0] + ai2[1]) / 2 - byte0 * byte1 * i8;
        rot(ai, ai2, i, j, i1, 3);
        rot(ai2, ai1, j, k, j1, 3);
        rot(ai, ai1, i, k, l, 3);
        rot(ai, ai1, m.cx, m.cz, m.xz, 3);
        rot(ai2, ai1, m.cy, m.cz, m.zy, 3);
        int k8 = 0;
        do {
          ai12[k8] = xs(ai[k8], ai1[k8]);
          ai13[k8] = ys(ai2[k8], ai1[k8]);
        } while (++k8 < 3);
        // Flame color. Outer Flame Red Value
        k8 = (int) (255F + 255F * ((float) m.snap[0] / 400F));
        if (k8 > 255) {
          k8 = 255;
        }
        if (k8 < 0) {
          k8 = 0;
        }
        // Flame color. Outer Flame Green Value
        int i9 = (int) (169F + 169F * ((float) m.snap[1] / 300F));
        if (i9 > 255) {
          i9 = 255;
        }
        if (i9 < 0) {
          i9 = 0;
        }
        // Flame color. Outer Flame Blue Value
        int k9 = (int) (89F + 89F * ((float) m.snap[2] / 200F));
        if (k9 > 255) {
          k9 = 255;
        }
        if (k9 < 0) {
          k9 = 0;
        }
        rd.setColor(new Color(k8, i9, k9));
        rd.fillPolygon(ai12, ai13, 3);
        ai[0] = ox[pa] + i;
        ai2[0] = oy[pa] + j;
        ai1[0] = oz[pa] + k;
        ai[1] = ox[pb] + i;
        ai2[1] = oy[pb] + j;
        for (ai1[1] = oz[pb] + k; Math.abs(ai[0] - ai[1]) > 100; ) {
          if (ai[1] > ai[0]) {
            ai[1] -= 30;
          } else {
            ai[1] += 30;
          }
        }

        while (Math.abs(ai1[0] - ai1[1]) > 100) {
          if (ai1[1] > ai1[0]) {
            ai1[1] -= 30;
          } else {
            ai1[1] += 30;
          }
        }
        ai[2] = (ai[0] + ai[1]) / 2 + i7;
        ai1[2] = (ai1[0] + ai1[1]) / 2 + l7;
        i8 = (int) ((double) i8 * 0.80000000000000004D);
        ai2[2] = (ai2[0] + ai2[1]) / 2 - byte0 * byte1 * i8;
        rot(ai, ai2, i, j, i1, 3);
        rot(ai2, ai1, j, k, j1, 3);
        rot(ai, ai1, i, k, l, 3);
        rot(ai, ai1, m.cx, m.cz, m.xz, 3);
        rot(ai2, ai1, m.cy, m.cz, m.zy, 3);
        int i10 = 0;
        do {
          ai12[i10] = xs(ai[i10], ai1[i10]);
          ai13[i10] = ys(ai2[i10], ai1[i10]);
        } while (++i10 < 3);
        // Flame color. Inner Flame Red Value
        k8 = (int) (255F + 255F * ((float) m.snap[0] / 400F));
        if (k8 > 255) {
          k8 = 255;
        }
        if (k8 < 0) {
          k8 = 0;
        }
        // Flame color. Inner Flame Green Value
        i9 = (int) (207F + 207F * ((float) m.snap[1] / 300F));
        if (i9 > 255) {
          i9 = 255;
        }
        if (i9 < 0) {
          i9 = 0;
        }
        // Flame color. Inner Flame Blue Value
        k9 = (int) (136F + 136F * ((float) m.snap[2] / 200F));
        if (k9 > 255) {
          k9 = 255;
        }
        if (k9 < 0) {
          k9 = 0;
        }
        rd.setColor(new Color(k8, i9, k9));
        rd.fillPolygon(ai12, ai13, 3);
      }
      for (int k3 = 0; k3 < n; k3++) {
        if (typ == 1) {
          ai[k3] = (int) ((float) ox[k3] * f + (float) i);
        } else {
          ai[k3] = ox[k3] + i;
        }
        if (typ == 2) {
          ai2[k3] = (int) ((float) oy[k3] * f + (float) j);
        } else {
          ai2[k3] = oy[k3] + j;
        }
        if (typ == 3) {
          ai1[k3] = (int) ((float) oz[k3] * f + (float) k);
        } else {
          ai1[k3] = oz[k3] + k;
        }
      }

      if (embos != 70) {
        embos++;
      } else {
        embos = 16;
      }
    }
    if (wz != 0) {
      rot(ai2, ai1, wy + j, wz + k, l1, n);
    }
    if (wx != 0) {
      rot(ai, ai1, wx + i, wz + k, k1, n);
    }
    if (chip == 1 && ((double) m.random() > 0.59999999999999998D || bfase == 0)) {
      chip = 0;
      if (bfase == 0 && nocol) {
        bfase = 1;
      }
    }
    if (chip != 0) {
      if (chip == 1) {
        cxz = l;
        cxy = i1;
        czy = j1;
        int i3 = (int) (m.random() * (float) n);
        cox[0] = ox[i3];
        coz[0] = oz[i3];
        coy[0] = oy[i3];
        if (ctmag > 3F) {
          ctmag = 3F;
        }
        if (ctmag < -3F) {
          ctmag = -3F;
        }
        cox[1] = (int) ((float) cox[0] + ctmag * (10F - m.random() * 20F));
        cox[2] = (int) ((float) cox[0] + ctmag * (10F - m.random() * 20F));
        coy[1] = (int) ((float) coy[0] + ctmag * (10F - m.random() * 20F));
        coy[2] = (int) ((float) coy[0] + ctmag * (10F - m.random() * 20F));
        coz[1] = (int) ((float) coz[0] + ctmag * (10F - m.random() * 20F));
        coz[2] = (int) ((float) coz[0] + ctmag * (10F - m.random() * 20F));
        dx = 0;
        dy = 0;
        dz = 0;
        if (bfase != -7) {
          vx = (int) (ctmag * (30F - m.random() * 60F));
          vz = (int) (ctmag * (30F - m.random() * 60F));
          vy = (int) (ctmag * (30F - m.random() * 60F));
        } else {
          vx = (int) (ctmag * (10F - m.random() * 20F));
          vz = (int) (ctmag * (10F - m.random() * 20F));
          vy = (int) (ctmag * (10F - m.random() * 20F));
        }
        chip = 2;
      }
      int ai4[] = new int[3];
      int ai6[] = new int[3];
      int ai8[] = new int[3];
      int k4 = 0;
      do {
        ai4[k4] = cox[k4] + i;
        ai8[k4] = coy[k4] + j;
        ai6[k4] = coz[k4] + k;
      } while (++k4 < 3);
      rot(ai4, ai8, i, j, cxy, 3);
      rot(ai8, ai6, j, k, czy, 3);
      rot(ai4, ai6, i, k, cxz, 3);
      k4 = 0;
      do {
        ai4[k4] += dx;
        ai8[k4] += dy;
        ai6[k4] += dz;
      } while (++k4 < 3);
      dx += vx;
      dz += vz;
      dy += vy;
      vy += 7;
      if (ai8[0] > m.ground) {
        chip = 19;
      }
      rot(ai4, ai6, m.cx, m.cz, m.xz, 3);
      rot(ai8, ai6, m.cy, m.cz, m.zy, 3);
      int ai10[] = new int[3];
      int ai11[] = new int[3];
      int l5 = 0;
      do {
        ai10[l5] = xs(ai4[l5], ai6[l5]);
        ai11[l5] = ys(ai8[l5], ai6[l5]);
        if (ai11[l5] < 45 && m.flex != 0) {
          m.flex = 0;
        }
      } while (++l5 < 3);
      l5 = (int) (m.random() * 3F);
      if (bfase != -7) {
        if (l5 == 0) {
          rd.setColor((new Color(c[0], c[1], c[2])).darker());
        }
        if (l5 == 1) {
          rd.setColor(new Color(c[0], c[1], c[2]));
        }
        if (l5 == 2) {
          rd.setColor((new Color(c[0], c[1], c[2])).brighter());
        }
      } else {
        rd.setColor(Color.getHSBColor(hsb[0], hsb[1], hsb[2]));
      }
      rd.fillPolygon(ai10, ai11, 3);
      chip++;
      if (chip == 20) {
        chip = 0;
      }
    }
    rot(ai, ai2, i, j, i1, n);
    rot(ai2, ai1, j, k, j1, n);
    rot(ai, ai1, i, k, l, n);
    if (i1 != 0 || j1 != 0 || l != 0) {
      projf = 1.0F;
      int j3 = 0;
      do {
        int l3 = 0;
        do {
          if (l3 != j3) {
            projf *=
                (float)
                    (Math.sqrt(
                            (ai[j3] - ai[l3]) * (ai[j3] - ai[l3])
                                + (ai1[j3] - ai1[l3]) * (ai1[j3] - ai1[l3]))
                        / 100D);
          }
        } while (++l3 < 3);
      } while (++j3 < 3);
      projf = projf / 3F;
    }
    rot(ai, ai1, m.cx, m.cz, m.xz, n);
    boolean flag1 = false;
    int ai7[] = new int[n];
    int ai9[] = new int[n];
    int l4 = 500;
    for (int j5 = 0; j5 < n; j5++) {
      ai7[j5] = xs(ai[j5], ai1[j5]);
      ai9[j5] = ys(ai2[j5], ai1[j5]);
    }

    int k5 = 0;
    int i6 = 1;
    for (int j6 = 0; j6 < n; j6++) {
      for (int j7 = 0; j7 < n; j7++) {
        if (j6 != j7 && Math.abs(ai7[j6] - ai7[j7]) - Math.abs(ai9[j6] - ai9[j7]) < l4) {
          i6 = j6;
          k5 = j7;
          l4 = Math.abs(ai7[j6] - ai7[j7]) - Math.abs(ai9[j6] - ai9[j7]);
        }
      }
    }

    if (ai9[k5] < ai9[i6]) {
      int k6 = k5;
      k5 = i6;
      i6 = k6;
    }
    if (spy(ai[k5], ai1[k5]) > spy(ai[i6], ai1[i6])) {
      flag1 = true;
      int l6 = 0;
      for (int k7 = 0; k7 < n; k7++) {
        if (ai1[k7] < 50 && ai2[k7] > m.cy) {
          flag1 = false;
        } else if (ai2[k7] == ai2[0]) {
          l6++;
        }
      }

      if (l6 == n && ai2[0] > m.cy) {
        flag1 = false;
      }
    }
    rot(ai2, ai1, m.cy, m.cz, m.zy, n);
    boolean flag2 = true;
    int ai14[] = new int[n];
    int ai15[] = new int[n];
    int j8 = 0;
    int l8 = 0;
    int j9 = 0;
    int l9 = 0;
    int j10 = 0;
    for (int k10 = 0; k10 < n; k10++) {
      ai14[k10] = xs(ai[k10], ai1[k10]);
      ai15[k10] = ys(ai2[k10], ai1[k10]);
      if (ai15[k10] < 0 || ai1[k10] < 10) {
        j8++;
      }
      if (ai15[k10] > m.h || ai1[k10] < 10) {
        l8++;
      }
      if (ai14[k10] < 0 || ai1[k10] < 10) {
        j9++;
      }
      if (ai14[k10] > m.w || ai1[k10] < 10) {
        l9++;
      }
      if (ai15[k10] < 45 && m.flex != 0) {
        m.flex = 0;
      }
      if (ai1[k10] < 10) {
        j10++;
      }
    }

    if (i2 != -1) {
      int l10 = 0;
      int j11 = 0;
      for (int k11 = 0; k11 < n; k11++) {
        for (int l12 = k11; l12 < n; l12++) {
          if (k11 != l12) {
            if (Math.abs(ai14[k11] - ai14[l12]) > l10) {
              l10 = Math.abs(ai14[k11] - ai14[l12]);
            }
            if (Math.abs(ai15[k11] - ai15[l12]) > j11) {
              j11 = Math.abs(ai15[k11] - ai15[l12]);
            }
          }
        }
      }

      if (l10 == 0 || j11 == 0) {
        flag2 = false;
      } else if (l10 < 3 && j11 < 3 && i2 / l10 > 15 && i2 / j11 > 15) {
        flag2 = false;
      }
    }
    if (j9 == n || j8 == n || l8 == n || l9 == n) {
      flag2 = false;
    }
    if (m.trk && (j9 != 0 || j8 != 0 || l8 != 0 || l9 != 0)) {
      flag2 = false;
    }
    if (j10 != 0) {
      flag = true;
    }
    if (flag2) {
      int i11 = 1;
      byte byte2 = 1;
      byte byte3 = 1;
      if (Math.abs(ai15[0] - ai15[1]) > Math.abs(ai15[2] - ai15[1])) {
        byte2 = 0;
        byte3 = 2;
      } else {
        byte2 = 2;
        byte3 = 0;
        i11 *= -1;
      }
      if (ai15[1] > ai15[byte2]) {
        i11 *= -1;
      }
      if (ai14[1] > ai14[byte3]) {
        i11 *= -1;
      }
      int i13 = gr;
      if (i13 < 0 && i13 >= -17) {
        i13 = 0;
      }
      if (gr == -11) {
        i13 = -90;
      }
      if (gr == -14 || gr == -15) {
        i13 = -50;
      }
      if (gr == -16) {
        i13 = 35;
      }
      if (fs != 0) {
        i11 *= fs;
        if (i11 == -1) {
          i13 += 40;
          if (!road) {
            i11 = -111;
          }
        }
      }
      if (m.lightson && light == 2) {
        i13 -= 40;
      }
      int j14 = 0;
      int k15 = 0;
      int k16 = 0;
      int l16 = 0;
      int i17 = 0;
      int j17 = 0;
      for (int k17 = 0; k17 < n; k17++) {
        int i18 = 0;
        int k18 = 0;
        int i19 = 0;
        int j19 = 0;
        int k19 = 0;
        int l19 = 0;
        for (int i20 = 0; i20 < n; i20++) {
          if (ai2[k17] >= ai2[i20]) {
            i18++;
          }
          if (ai2[k17] <= ai2[i20]) {
            k18++;
          }
          if (ai[k17] >= ai[i20]) {
            i19++;
          }
          if (ai[k17] <= ai[i20]) {
            j19++;
          }
          if (ai1[k17] >= ai1[i20]) {
            k19++;
          }
          if (ai1[k17] <= ai1[i20]) {
            l19++;
          }
        }

        if (i18 == n) {
          j14 = ai2[k17];
        }
        if (k18 == n) {
          k15 = ai2[k17];
        }
        if (i19 == n) {
          k16 = ai[k17];
        }
        if (j19 == n) {
          l16 = ai[k17];
        }
        if (k19 == n) {
          i17 = ai1[k17];
        }
        if (l19 == n) {
          j17 = ai1[k17];
        }
      }

      int l17 = (j14 + k15) / 2;
      int j18 = (k16 + l16) / 2;
      int l18 = (i17 + j17) / 2;
      av =
          (int)
              Math.sqrt(
                  (m.cy - l17) * (m.cy - l17)
                      + (m.cx - j18) * (m.cx - j18)
                      + l18 * l18
                      + i13 * i13 * i13);
      if (!m.trk && (av > m.fade[disline] || av == 0)) {
        flag2 = false;
      }
      if (i11 == -111 && av > 4500) {
        flag2 = false;
      }
      if (i11 == -111 && av > 1500) {
        flag = true;
      }
      if (av > 3000 && m.adv <= 900) {
        flag = true;
      }
      if (gr == -12 && av < 11200) {
        m.lastmaf = i11;
      }
      if (gr == -13 && (!m.lastcheck || i2 != -1)) {
        flag2 = false;
      }
      if (gr == -16 && av > 1500) {
        flag2 = false;
      }
      if (flx != 0 && (double) m.random() > 0.29999999999999999D) {
        flag2 = false;
      }
    }
    if (flag2) {
      float f1 = (float) ((double) (projf / deltaf) + 0.29999999999999999D);
      if (flag) {
        boolean flag3 = false;
        if (f1 > 1.0F) {
          if ((double) f1 >= 1.27D) {
            flag3 = true;
          }
          f1 = 1.0F;
        }
        if (flag3) {
          f1 = (float) ((double) f1 * 0.89000000000000001D);
        } else {
          f1 = (float) ((double) f1 * 0.85999999999999999D);
        }
        if ((double) f1 < 0.37D) {
          f1 = 0.37F;
        }
        if (gr == -9) {
          f1 = 0.7F;
        }
        if (gr == -4) {
          f1 = 0.74F;
        }
        if (gr != -7 && flag1) {
          f1 = 0.32F;
        }
        if (gr == -8 || gr == -14 || gr == -15) {
          f1 = 1.0F;
        }
        if (gr == -11) {
          f1 = 0.67F;
          if (i2 == -1) {
            if (m.cpflik || m.nochekflk && !m.lastcheck) {
              f1 = 1.0F;
            } else {
              f1 = 0.76F;
            }
          }
        }
        if (gr == -13 && i2 == -1) {
          if (m.cpflik) {
            f1 = 0.0F;
          } else {
            f1 = 0.76F;
          }
        }
        if (gr == -6) {
          f1 = 0.62F;
        }
        if (gr == -5) {
          f1 = 0.55F;
        }
      } else {
        if (f1 > 1.0F) {
          f1 = 1.0F;
        }
        if ((double) f1 < 0.59999999999999998D || flag1) {
          f1 = 0.6F;
        }
      }
      Color color;
      if (!m.trk) {
        color = Color.getHSBColor(hsb[0], hsb[1], hsb[2] * f1);
      } else {
        float af[] = new float[3];
        Color.RGBtoHSB(oc[0], oc[1], oc[2], af);
        color = Color.getHSBColor(0.0F, 0.0F, af[2] * f1);
      }
      int l11 = color.getRed();
      int j13 = color.getGreen();
      int k14 = color.getBlue();
      if (m.lightson && light != 0) {
        l11 = oc[0];
        if (l11 > 255) {
          l11 = 255;
        }
        if (l11 < 0) {
          l11 = 0;
        }
        j13 = oc[1];
        if (j13 > 255) {
          j13 = 255;
        }
        if (j13 < 0) {
          j13 = 0;
        }
        k14 = oc[2];
        if (k14 > 255) {
          k14 = 255;
        }
        if (k14 < 0) {
          k14 = 0;
        }
      }
      if (!m.trk) {
        int l15 = 0;
        do {
          if (av > m.fade[l15]) {
            l11 = (l11 * m.fogd + m.cfade[0]) / (m.fogd + 1);
            j13 = (j13 * m.fogd + m.cfade[1]) / (m.fogd + 1);
            k14 = (k14 * m.fogd + m.cfade[2]) / (m.fogd + 1);
          }
        } while (++l15 < 8);
      }
      rd.setColor(new Color(l11, j13, k14));
      rd.fillPolygon(ai14, ai15, n);
      if (m.trk && gr == -10) {
        flag = false;
      }
      if (!flag) {
        if (flx == 0) {
          l11 = 0;
          j13 = 0;
          k14 = 0;
          if (m.lightson && light != 0) {
            l11 = oc[0] / 2;
            if (l11 > 255) {
              l11 = 255;
            }
            if (l11 < 0) {
              l11 = 0;
            }
            j13 = oc[1] / 2;
            if (j13 > 255) {
              j13 = 255;
            }
            if (j13 < 0) {
              j13 = 0;
            }
            k14 = oc[2] / 2;
            if (k14 > 255) {
              k14 = 255;
            }
            if (k14 < 0) {
              k14 = 0;
            }
          }
          rd.setColor(new Color(l11, j13, k14));
          rd.drawPolygon(ai14, ai15, n);
        } else {
          if (flx == 2) {
            rd.setColor(new Color(0, 0, 0));
            rd.drawPolygon(ai14, ai15, n);
          }
          if (flx == 1) {
            l11 = 0;
            j13 = (int) (223F + 223F * ((float) m.snap[1] / 100F));
            if (j13 > 255) {
              j13 = 255;
            }
            if (j13 < 0) {
              j13 = 0;
            }
            k14 = (int) (255F + 255F * ((float) m.snap[2] / 100F));
            if (k14 > 255) {
              k14 = 255;
            }
            if (k14 < 0) {
              k14 = 0;
            }
            rd.setColor(new Color(l11, j13, k14));
            rd.drawPolygon(ai14, ai15, n);
            flx = 2;
          }
          if (flx == 3) {
            l11 = 0;
            j13 = (int) (255F + 255F * ((float) m.snap[1] / 100F));
            if (j13 > 255) {
              j13 = 255;
            }
            if (j13 < 0) {
              j13 = 0;
            }
            k14 = (int) (223F + 223F * ((float) m.snap[2] / 100F));
            if (k14 > 255) {
              k14 = 255;
            }
            if (k14 < 0) {
              k14 = 0;
            }
            rd.setColor(new Color(l11, j13, k14));
            rd.drawPolygon(ai14, ai15, n);
            flx = 2;
          }
        }
      } else if (road && av <= 3000 && !m.trk && m.fade[0] > 4000) {
        if ((l11 -= 10) < 0) {
          l11 = 0;
        }
        if ((j13 -= 10) < 0) {
          j13 = 0;
        }
        if ((k14 -= 10) < 0) {
          k14 = 0;
        }
        rd.setColor(new Color(l11, j13, k14));
        rd.drawPolygon(ai14, ai15, n);
      }
      if (gr == -10) {
        if (!m.trk) {
          int i12 = c[0];
          int k13 = c[1];
          int l14 = c[2];
          if (i2 == -1) {
            if (m.nochekflk && !m.lastcheck) {
              i12 = (int) ((double) i12 * 1.25D);
              if (i12 > 255) {
                i12 = 255;
              }
              k13 = (int) ((double) k13 * 1.25D);
              if (k13 > 255) {
                k13 = 255;
              }
              l14 = (int) ((double) l14 * 1.25D);
              if (l14 > 255) {
                l14 = 255;
              }
            } else if (m.cpflik) {
              i12 = (int) ((double) i12 * 1.5D);
              if (i12 > 255) {
                i12 = 255;
              }
              k13 = (int) ((double) k13 * 1.5D);
              if (k13 > 255) {
                k13 = 255;
              }
              l14 = (int) ((double) l14 * 1.5D);
              if (l14 > 255) {
                l14 = 255;
              }
            }
          }
          int i16 = 0;
          do {
            if (av > m.fade[i16]) {
              i12 = (i12 * m.fogd + m.cfade[0]) / (m.fogd + 1);
              k13 = (k13 * m.fogd + m.cfade[1]) / (m.fogd + 1);
              l14 = (l14 * m.fogd + m.cfade[2]) / (m.fogd + 1);
            }
          } while (++i16 < 8);
          rd.setColor(new Color(i12, k13, l14));
          rd.drawPolygon(ai14, ai15, n);
        } else if (m.cpflik && m.hit == 5000) {
          int l13 = (int) (Math.random() * 115D);
          int j12 = l13 * 2 - 54;
          if (j12 < 0) {
            j12 = 0;
          }
          if (j12 > 255) {
            j12 = 255;
          }
          int i15 = 202 + l13 * 2;
          if (i15 < 0) {
            i15 = 0;
          }
          if (i15 > 255) {
            i15 = 255;
          }
          if ((l13 += 101) < 0) {
            l13 = 0;
          }
          if (l13 > 255) {
            l13 = 255;
          }
          rd.setColor(new Color(j12, l13, i15));
          rd.drawPolygon(ai14, ai15, n);
        }
      }
      if (gr == -18 && !m.trk) {
        int k12 = c[0];
        int i14 = c[1];
        int j15 = c[2];
        if (m.cpflik && m.elecr >= 0.0F) {
          k12 = (int) (25.5F * m.elecr);
          if (k12 > 255) {
            k12 = 255;
          }
          i14 = (int) (128F + 12.8F * m.elecr);
          if (i14 > 255) {
            i14 = 255;
          }
          j15 = 255;
        }
        int j16 = 0;
        do {
          if (av > m.fade[j16]) {
            k12 = (k12 * m.fogd + m.cfade[0]) / (m.fogd + 1);
            i14 = (i14 * m.fogd + m.cfade[1]) / (m.fogd + 1);
            j15 = (j15 * m.fogd + m.cfade[2]) / (m.fogd + 1);
          }
        } while (++j16 < 8);
        rd.setColor(new Color(k12, i14, j15));
        rd.drawPolygon(ai14, ai15, n);
      }
    }
  }
 public void drawPoint(Graphics g, double value, int x, int y) {
   g.setColor(Color.getHSBColor(0.75f - colorForValue(value), 1.0f, 1.0f));
   g.fillRect(x, y, this.thickness, 1);
 }
示例#18
0
 public static Color phasalColor(float s, float b, int i, int n) {
   float h = (float) phase() + i / (float) n;
   return Color.getHSBColor(h, s, b);
 }
/**
 * A theme for InfoNode look and feel. The theme infers some default colors from others, so
 * modifying a color might affect other, unmodified colors.
 *
 * @author $Author: jesper $
 * @version $Revision: 1.16 $
 */
public class InfoNodeLookAndFeelTheme {
  private static final float PRIMARY_HUE = Colors.ROYAL_BLUE_HUE;
  private static final float PRIMARY_SATURATION = 0.6f;
  private static final float PRIMARY_BRIGHTNESS = 0.67f;

  public static final Color DEFAULT_CONTROL_COLOR =
      Color.getHSBColor(Colors.SAND_HUE, 0.058f, 0.89f);
  public static final Color DEFAULT_PRIMARY_CONTROL_COLOR =
      Color.getHSBColor(PRIMARY_HUE, PRIMARY_SATURATION, 1f);
  public static final Color DEFAULT_BACKGROUND_COLOR = new Color(250, 250, 247);
  public static final Color DEFAULT_TEXT_COLOR = Color.BLACK;
  public static final Color DEFAULT_SELECTED_BACKGROUND_COLOR =
      Color.getHSBColor(PRIMARY_HUE, PRIMARY_SATURATION + 0.1f, PRIMARY_BRIGHTNESS);
  public static final Color DEFAULT_SELECTED_TEXT_COLOR = Color.WHITE;
  public static final Color DEFAULT_TOOLTIP_BACKGROUND_COLOR = new Color(255, 255, 180);
  public static final Color DEFAULT_TOOLTIP_FOREGROUND_COLOR = Color.BLACK;
  public static final Color DEFAULT_DESKTOP_COLOR =
      Color.getHSBColor(PRIMARY_HUE - 0.02f, PRIMARY_SATURATION, PRIMARY_BRIGHTNESS);

  public static final int DEFAULT_FONT_SIZE = 11;

  private static final String[] FONT_NAMES = {
      /*"Tahoma", */
    "Dialog"
  };

  private FontUIResource font = new FontUIResource("Dialog", 0, 11);
  private FontUIResource boldFont;

  private ColorValue controlColor = new ColorValue();
  private ColorValue primaryControlColor = new ColorValue();
  private ColorValue backgroundColor = new ColorValue();
  private ColorValue textColor = new ColorValue();
  private ColorValue selectedTextBackgroundColor = new ColorValue();

  private ColorValue focusColor = new ColorValue();
  private ColorValue selectedTextColor = new ColorValue();
  private ColorValue tooltipBackgroundColor = new ColorValue(DEFAULT_TOOLTIP_BACKGROUND_COLOR);
  private ColorValue tooltipForegroundColor = new ColorValue(DEFAULT_TOOLTIP_FOREGROUND_COLOR);
  private ColorValue desktopColor = new ColorValue(DEFAULT_DESKTOP_COLOR);

  private ColorValue treeIconBackgroundColor = new ColorValue();

  private ColorValue selectedMenuBackgroundColor = new ColorValue();
  private ColorValue selectedMenuForegroundColor = new ColorValue();

  private ColorValue inactiveTextColor = new ColorValue();

  private ColorUIResource controlHighlightColor;
  private ColorUIResource controlLightShadowColor;
  private ColorUIResource controlShadowColor;
  private ColorUIResource controlDarkShadowColor;

  private ColorUIResource primaryControlHighlightColor;
  private ColorUIResource primaryControlShadowColor;
  private ColorUIResource primaryControlDarkShadowColor;

  private ColorValue scrollBarBackgroundColor = new ColorValue();
  private ColorUIResource scrollBarBackgroundShadowColor;

  private ColorValue activeInternalFrameTitleBackgroundColor = new ColorValue();
  private ColorValue activeInternalFrameTitleGradientColor = new ColorValue();
  private ColorValue activeInternalFrameTitleForegroundColor = new ColorValue();
  private ColorValue inactiveInternalFrameTitleBackgroundColor = new ColorValue();
  private ColorValue inactiveInternalFrameTitleGradientColor = new ColorValue();
  private ColorValue inactiveInternalFrameTitleForegroundColor = new ColorValue();
  private IconUIResource internalFrameIcon =
      new IconUIResource(new BorderIcon(new WindowIcon(Color.BLACK, 12), 2));
  private IconUIResource internalFrameIconifyIcon = new IconUIResource(new MinimizeIcon());
  private IconUIResource internalFrameMinimizeIcon = new IconUIResource(new RestoreIcon());
  private IconUIResource internalFrameMaximizeIcon = new IconUIResource(new MaximizeIcon());
  private IconUIResource internalFrameCloseIcon = new IconUIResource(new CloseIcon());
  private BorderUIResource internalFrameBorder =
      new BorderUIResource(new LineBorder(Color.BLACK, 2));

  private FontValue internalFrameTitleFont = new FontValue();
  private FontValue optionPaneButtonFont = new FontValue();

  private IconUIResource treeOpenIcon = new IconUIResource(EmptyIcon.INSTANCE);
  private IconUIResource treeClosedIcon = new IconUIResource(EmptyIcon.INSTANCE);
  private IconUIResource treeLeafIcon = new IconUIResource(EmptyIcon.INSTANCE);

  private BorderValue menuBarBorder = new BorderValue();
  private BorderValue popupMenuBorder = new BorderValue();

  private BorderValue tableHeaderCellBorder = new BorderValue();

  private BorderValue textFieldBorder = new BorderValue();

  private BorderValue listItemBorder = new BorderValue(new EmptyBorder(1, 4, 1, 4));
  private BorderValue listFocusedItemBorder = new BorderValue();

  private int splitPaneDividerSize = 7;
  private int scrollBarWidth = 17;
  private InsetsUIResource buttonMargin = new InsetsUIResource(1, 6, 1, 6);

  private double shadingFactor = 1.6;

  private String name;

  /** Creates a default InfoNode look and feel theme. */
  public InfoNodeLookAndFeelTheme() {
    this(
        "Default Theme",
        DEFAULT_CONTROL_COLOR,
        DEFAULT_PRIMARY_CONTROL_COLOR,
        DEFAULT_BACKGROUND_COLOR,
        DEFAULT_TEXT_COLOR,
        DEFAULT_SELECTED_BACKGROUND_COLOR,
        DEFAULT_SELECTED_TEXT_COLOR);
  }

  /**
   * Creates a theme with custom colors.
   *
   * @param name the name of this theme
   * @param controlColor the background color for buttons, labels etc.
   * @param primaryControlColor the color of scrollbar "knobs", text and menu selection background
   * @param backgroundColor the background color for viewports, tree's, tables etc.
   * @param textColor the text color
   */
  public InfoNodeLookAndFeelTheme(
      String name,
      Color controlColor,
      Color primaryControlColor,
      Color backgroundColor,
      Color textColor) {
    this(
        name,
        controlColor,
        primaryControlColor,
        backgroundColor,
        textColor,
        primaryControlColor,
        ColorUtil.getOpposite(primaryControlColor));
  }

  /**
   * Creates a theme with custom colors.
   *
   * @param name the name of this theme
   * @param controlColor the background color for buttons, labels etc.
   * @param primaryControlColor the color of scrollbar "knobs"
   * @param backgroundColor the background color for viewports, tree's, tables etc.
   * @param textColor the text color
   * @param selectedBackgroundColor the background color for selected text, selected menu items
   * @param selectedTextColor the text color for selected text, selected menu items
   */
  public InfoNodeLookAndFeelTheme(
      String name,
      Color controlColor,
      Color primaryControlColor,
      Color backgroundColor,
      Color textColor,
      Color selectedBackgroundColor,
      Color selectedTextColor) {
    this(
        name,
        controlColor,
        primaryControlColor,
        backgroundColor,
        textColor,
        selectedBackgroundColor,
        selectedTextColor,
        1.3);
  }

  /**
   * Creates a theme with custom colors.
   *
   * @param name the name of this theme
   * @param controlColor the background color for buttons, labels etc.
   * @param primaryControlColor the color of scrollbar "knobs"
   * @param backgroundColor the background color for viewports, tree's, tables etc.
   * @param textColor the text color
   * @param selectedBackgroundColor the background color for selected text, selected menu items
   * @param selectedTextColor the text color for selected text, selected menu items
   * @param shadingFactor the shading factor is used when calculating brighter and darker control
   *     colors. A higher factor gives brighter and darker colors.
   */
  public InfoNodeLookAndFeelTheme(
      String name,
      Color controlColor,
      Color primaryControlColor,
      Color backgroundColor,
      Color textColor,
      Color selectedBackgroundColor,
      Color selectedTextColor,
      double shadingFactor) {
    this.name = name;
    String[] fontNames =
        GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();

    for (int i = 0; i < FONT_NAMES.length; i++) {
      if (ArrayUtil.containsEqual(fontNames, FONT_NAMES[i])) {
        font = new FontUIResource(new Font(FONT_NAMES[i], Font.PLAIN, DEFAULT_FONT_SIZE));
        break;
      }
    }

    updateFonts();

    this.controlColor.setColor(controlColor);
    this.primaryControlColor.setColor(primaryControlColor);
    this.backgroundColor.setColor(backgroundColor);
    this.selectedTextBackgroundColor.setColor(selectedBackgroundColor);
    this.selectedTextColor.setColor(selectedTextColor);
    this.textColor.setColor(textColor);
    this.shadingFactor = shadingFactor;
    updateColors();
  }

  private void updateFonts() {
    boldFont = new FontUIResource(font.deriveFont(Font.BOLD));
    internalFrameTitleFont.setDefaultFont(boldFont);
    optionPaneButtonFont.setDefaultFont(boldFont);
  }

  private void updateColors() {
    focusColor.setDefaultColor(
        ColorUtil.blend(controlColor.getColor(), textColor.getColor(), 0.5f));

    inactiveTextColor.setDefaultColor(focusColor);

    double invShadeAmount = 1.0 / (1 + shadingFactor * 1.2);
    double invShadeAmount2 = 1.0 / (1 + shadingFactor / 2);
    double invShadeAmount3 = 1.0 / (1 + shadingFactor / 7);

    controlHighlightColor =
        new ColorUIResource(ColorUtil.mult(controlColor.getColor(), 1 + shadingFactor));
    controlLightShadowColor =
        new ColorUIResource(ColorUtil.mult(controlColor.getColor(), invShadeAmount3));
    controlShadowColor =
        new ColorUIResource(ColorUtil.mult(controlColor.getColor(), invShadeAmount2));
    controlDarkShadowColor =
        new ColorUIResource(ColorUtil.mult(controlColor.getColor(), invShadeAmount));

    primaryControlHighlightColor = controlHighlightColor;
    primaryControlShadowColor =
        new ColorUIResource(ColorUtil.mult(primaryControlColor.getColor(), invShadeAmount2));
    primaryControlDarkShadowColor =
        new ColorUIResource(ColorUtil.mult(primaryControlColor.getColor(), invShadeAmount));

    scrollBarBackgroundColor.setDefaultColor(controlLightShadowColor);
    scrollBarBackgroundShadowColor =
        new ColorUIResource(ColorUtil.mult(scrollBarBackgroundColor.getColor(), invShadeAmount));

    selectedMenuBackgroundColor.setDefaultColor(selectedTextBackgroundColor);
    selectedMenuForegroundColor.setDefaultColor(selectedTextColor);

    treeIconBackgroundColor.setDefaultColor(
        ColorUtil.blend(backgroundColor.getColor(), primaryControlColor.getColor(), 0.15f));

    activeInternalFrameTitleBackgroundColor.setDefaultColor(
        ColorUtil.blend(
            primaryControlColor.getColor(), ColorUtil.getOpposite(getTextColor()), 0.5f));
    activeInternalFrameTitleForegroundColor.setDefaultColor(getTextColor());
    activeInternalFrameTitleGradientColor.setDefaultColor(
        ColorUtil.mult(activeInternalFrameTitleBackgroundColor.getColor(), 1.2));
    inactiveInternalFrameTitleBackgroundColor.setDefaultColor(controlLightShadowColor);
    inactiveInternalFrameTitleForegroundColor.setDefaultColor(getTextColor());
    inactiveInternalFrameTitleGradientColor.setDefaultColor(
        ColorUtil.mult(inactiveInternalFrameTitleBackgroundColor.getColor(), 1.2));

    menuBarBorder.setDefaultBorder(
        new BorderUIResource(
            new EtchedLineBorder(
                false, false, true, false, controlHighlightColor, controlDarkShadowColor)));
    popupMenuBorder.setDefaultBorder(
        new BorderUIResource(new PopupMenuBorder(controlHighlightColor, controlDarkShadowColor)));
    textFieldBorder.setDefaultBorder(
        new BorderUIResource(
            new CompoundBorder(
                new LineBorder(controlDarkShadowColor), new EmptyBorder(1, 2, 1, 2))));

    tableHeaderCellBorder.setDefaultBorder(
        new BorderUIResource(
            new CompoundBorder(
                new CompoundBorder(
                    new EdgeBorder(controlDarkShadowColor, false, true, false, true),
                    new HighlightBorder(false, controlHighlightColor)),
                new EmptyBorder(1, 4, 1, 4))));

    listFocusedItemBorder.setDefaultBorder(
        new CompoundBorder(new LineBorder(focusColor.getColor()), new EmptyBorder(0, 3, 0, 3)));
  }

  /**
   * Returns the theme name.
   *
   * @return the theme name
   */
  public String getName() {
    return name;
  }

  /**
   * Returns the shading factor. The shading factor is used when calculating brighter and darker
   * control colors. A higher factor gives brighter and darker colors.
   *
   * @return the shading factor
   */
  public double getShadingFactor() {
    return shadingFactor;
  }

  /**
   * Sets the shading factor. The shading factor is used when calculating brighter and darker
   * control colors. A higher factor gives brighter and darker colors.
   *
   * @param shadingFactor the shading factor
   */
  public void setShadingFactor(double shadingFactor) {
    this.shadingFactor = shadingFactor;
    updateColors();
  }

  /**
   * Returns the base font. This font is used as default font for all text.
   *
   * @return returns the base font
   */
  public FontUIResource getFont() {
    return font;
  }

  /**
   * Sets the base font. This font is used as default font for all text.
   *
   * @param font the base font
   */
  public void setFont(FontUIResource font) {
    this.font = font;
    updateFonts();
  }

  /**
   * Gets the background color used for {@link javax.swing.JComponent}.
   *
   * @return the background color used for {@link javax.swing.JComponent}
   */
  public ColorUIResource getControlColor() {
    return controlColor.getColor();
  }

  /**
   * Gets the color of scrollbar "knobs" etc.
   *
   * @return the color of scrollbar "knobs" etc,
   */
  public ColorUIResource getPrimaryControlColor() {
    return primaryControlColor.getColor();
  }

  /**
   * Gets the background color for {@link javax.swing.JViewport}, {@link javax.swing.JTree}, {@link
   * javax.swing.JTable} etc.
   *
   * @return the background color for {@link javax.swing.JViewport}, {@link javax.swing.JTree},
   *     {@link javax.swing.JTable} etc.
   */
  public ColorUIResource getBackgroundColor() {
    return backgroundColor.getColor();
  }

  /**
   * Gets the text color.
   *
   * @return the text color
   */
  public ColorUIResource getTextColor() {
    return textColor.getColor();
  }

  /**
   * Gets the selected text background color.
   *
   * @return the selected text background color
   */
  public ColorUIResource getSelectedTextBackgroundColor() {
    return selectedTextBackgroundColor.getColor();
  }

  /**
   * Gets the control focus marker color.
   *
   * @return the control focus marker color
   */
  public ColorUIResource getFocusColor() {
    return focusColor.getColor();
  }

  /**
   * Gets the selected text color.
   *
   * @return the selected text color
   */
  public ColorUIResource getSelectedTextColor() {
    return selectedTextColor.getColor();
  }

  /**
   * Gets the background color for {@link javax.swing.JToolTip}.
   *
   * @return the background color for {@link javax.swing.JToolTip}
   */
  public ColorUIResource getTooltipBackgroundColor() {
    return tooltipBackgroundColor.getColor();
  }

  /**
   * Gets the desktop color used in {@link javax.swing.JDesktopPane} etc.
   *
   * @return the desktop color used in {@link javax.swing.JDesktopPane} etc.
   */
  public ColorUIResource getDesktopColor() {
    return desktopColor.getColor();
  }

  /**
   * Gets the background color used for collapse and expand icons in a {@link javax.swing.JTree}.
   *
   * @return the background color used for collapse and expand icons in a {@link javax.swing.JTree}
   */
  public ColorUIResource getTreeIconBackgroundColor() {
    return treeIconBackgroundColor.getColor();
  }

  /**
   * Gets the background color used for selected {@link javax.swing.JMenuItem}'s.
   *
   * @return the background color used for selected {@link javax.swing.JMenuItem}'s
   */
  public ColorUIResource getSelectedMenuBackgroundColor() {
    return selectedMenuBackgroundColor.getColor();
  }

  /**
   * Gets the foreground color used for selected {@link javax.swing.JMenuItem}'s.
   *
   * @return the foreground color used for selected {@link javax.swing.JMenuItem}'s
   */
  public ColorUIResource getSelectedMenuForegroundColor() {
    return selectedMenuForegroundColor.getColor();
  }

  /**
   * Gets the color used for inactive text.
   *
   * @return the color used for inactive text
   */
  public ColorUIResource getInactiveTextColor() {
    return inactiveTextColor.getColor();
  }

  /**
   * Gets the control highlight color. By default this is a color a little brighter than the control
   * color.
   *
   * @return the control highlight color
   */
  public ColorUIResource getControlHighlightColor() {
    return controlHighlightColor;
  }

  /**
   * Gets the control light shadow color. By default this is a color a little darker than the
   * control color.
   *
   * @return the control light shadow color
   */
  public ColorUIResource getControlLightShadowColor() {
    return controlLightShadowColor;
  }

  /**
   * Gets the control shadow color. By default this is a color a little darker than the control
   * light shadow color.
   *
   * @return the control shadow color
   */
  public ColorUIResource getControlShadowColor() {
    return controlShadowColor;
  }

  /**
   * Gets the control dark shadow color. By default this is a color a little darker than the control
   * shadow color.
   *
   * @return the control dark shadow color
   */
  public ColorUIResource getControlDarkShadowColor() {
    return controlDarkShadowColor;
  }

  /**
   * Gets the primary control highlight color. By default this color is the same as the control
   * highlight color..
   *
   * @return the primary control highlight color
   */
  public ColorUIResource getPrimaryControlHighlightColor() {
    return primaryControlHighlightColor;
  }

  /**
   * Gets the primary control shadow color. By default this is a color a little darker than the
   * primary control color.
   *
   * @return the primary control shadow color
   */
  public ColorUIResource getPrimaryControlShadowColor() {
    return primaryControlShadowColor;
  }

  /**
   * Gets the primary control dark shadow color. By default this is a color a little darker than the
   * primary control shadow color.
   *
   * @return the primary control dark shadow color
   */
  public ColorUIResource getPrimaryControlDarkShadowColor() {
    return primaryControlDarkShadowColor;
  }

  /**
   * Gets the background color for {@link javax.swing.JScrollBar}'s.
   *
   * @return the background color for {@link javax.swing.JScrollBar}'s
   */
  public ColorUIResource getScrollBarBackgroundColor() {
    return scrollBarBackgroundColor.getColor();
  }

  /**
   * Gets the background shadow color for {@link javax.swing.JScrollBar}'s. By default this is a
   * color a little darker than the scroll bar background color.
   *
   * @return the background color for {@link javax.swing.JScrollBar}'s.
   */
  public ColorUIResource getScrollBarBackgroundShadowColor() {
    return scrollBarBackgroundShadowColor;
  }

  /**
   * Gets the background color for active {@link javax.swing.JInternalFrame}'s.
   *
   * @return the background color for active {@link javax.swing.JInternalFrame}'s
   */
  public ColorUIResource getActiveInternalFrameTitleBackgroundColor() {
    return activeInternalFrameTitleBackgroundColor.getColor();
  }

  /**
   * Gets the foreground color for active {@link javax.swing.JInternalFrame}'s.
   *
   * @return the foreground color for active {@link javax.swing.JInternalFrame}'s
   */
  public ColorUIResource getActiveInternalFrameTitleForegroundColor() {
    return activeInternalFrameTitleForegroundColor.getColor();
  }

  /**
   * Gets the gradient color for active {@link javax.swing.JInternalFrame}'s.
   *
   * @return the gradient color for active {@link javax.swing.JInternalFrame}'s
   */
  public ColorUIResource getActiveInternalFrameTitleGradientColor() {
    return activeInternalFrameTitleGradientColor.getColor();
  }

  /**
   * Gets the background color for inactive {@link javax.swing.JInternalFrame}'s.
   *
   * @return the background color for inactive {@link javax.swing.JInternalFrame}'s
   */
  public ColorUIResource getInactiveInternalFrameTitleBackgroundColor() {
    return inactiveInternalFrameTitleBackgroundColor.getColor();
  }

  /**
   * Gets the foreground color for inactive {@link javax.swing.JInternalFrame}'s.
   *
   * @return the foreground color for inactive {@link javax.swing.JInternalFrame}'s
   */
  public ColorUIResource getInactiveInternalFrameTitleForegroundColor() {
    return inactiveInternalFrameTitleForegroundColor.getColor();
  }

  /**
   * Gets the gradient color for inactive {@link javax.swing.JInternalFrame}'s.
   *
   * @return the gradient color for inactive {@link javax.swing.JInternalFrame}'s
   */
  public ColorUIResource getInactiveInternalFrameTitleGradientColor() {
    return inactiveInternalFrameTitleGradientColor.getColor();
  }

  /**
   * Gets the border around cells in {@link javax.swing.table.JTableHeader}'s.
   *
   * @return the border around cells in {@link javax.swing.table.JTableHeader}'s
   */
  public BorderUIResource getTableHeaderCellBorder() {
    return tableHeaderCellBorder.getBorder();
  }

  /**
   * Gets the icon to the left in the title bar of {@link javax.swing.JInternalFrame}'s.
   *
   * @return the icon to the left in the title bar of {@link javax.swing.JInternalFrame}'s
   */
  public IconUIResource getInternalFrameIcon() {
    return internalFrameIcon;
  }

  /**
   * Sets the icon to the left in the title bar of {@link javax.swing.JInternalFrame}'s.
   *
   * @param internalFrameIcon the icon
   */
  public void setInternalFrameIcon(IconUIResource internalFrameIcon) {
    this.internalFrameIcon = internalFrameIcon;
  }

  /**
   * Gets the icon used in the minimize button in the title bar of {@link
   * javax.swing.JInternalFrame}'s.
   *
   * @return the icon used in the minimize button in the title bar of {@link
   *     javax.swing.JInternalFrame}'s
   */
  public IconUIResource getInternalFrameMinimizeIcon() {
    return internalFrameMinimizeIcon;
  }

  /**
   * Sets the icon used in the minimize button in the title bar of {@link
   * javax.swing.JInternalFrame}'s.
   *
   * @param internalFrameMinimizeIcon the icon
   */
  public void setInternalFrameMinimizeIcon(IconUIResource internalFrameMinimizeIcon) {
    this.internalFrameMinimizeIcon = internalFrameMinimizeIcon;
  }

  /**
   * Gets the icon used in the maximize button in the title bar of {@link
   * javax.swing.JInternalFrame}'s.
   *
   * @return the icon used in the minimize button in the title bar of {@link
   *     javax.swing.JInternalFrame}'s
   */
  public IconUIResource getInternalFrameMaximizeIcon() {
    return internalFrameMaximizeIcon;
  }

  /**
   * Sets the icon used in the maximize button in the title bar of {@link
   * javax.swing.JInternalFrame}'s.
   *
   * @param internalFrameMaximizeIcon the icon
   */
  public void setInternalFrameMaximizeIcon(IconUIResource internalFrameMaximizeIcon) {
    this.internalFrameMaximizeIcon = internalFrameMaximizeIcon;
  }

  /**
   * Gets the icon used in the close button in the title bar of {@link
   * javax.swing.JInternalFrame}'s.
   *
   * @return the icon used in the close button in the title bar of {@link
   *     javax.swing.JInternalFrame}'s
   */
  public IconUIResource getInternalFrameCloseIcon() {
    return internalFrameCloseIcon;
  }

  /**
   * Sets the icon used in the close button in the title bar of {@link
   * javax.swing.JInternalFrame}'s.
   *
   * @param internalFrameCloseIcon the icon
   */
  public void setInternalFrameCloseIcon(IconUIResource internalFrameCloseIcon) {
    this.internalFrameCloseIcon = internalFrameCloseIcon;
  }

  /**
   * Gets the border used around {@link javax.swing.JInternalFrame}'s.
   *
   * @return the border used around {@link javax.swing.JInternalFrame}'s
   */
  public BorderUIResource getInternalFrameBorder() {
    return internalFrameBorder;
  }

  /**
   * Sets the border used around {@link javax.swing.JInternalFrame}'s.
   *
   * @param internalFrameBorder the border used around {@link javax.swing.JInternalFrame}'s
   */
  public void setInternalFrameBorder(BorderUIResource internalFrameBorder) {
    this.internalFrameBorder = internalFrameBorder;
  }

  /**
   * Gets the font used in the title of {@link javax.swing.JInternalFrame}'s. Defaults to the text
   * font with bold style.
   *
   * @return the font used in the title of {@link javax.swing.JInternalFrame}'s
   */
  public FontUIResource getInternalFrameTitleFont() {
    return internalFrameTitleFont.getFont();
  }

  /**
   * Sets the font used in the title of {@link javax.swing.JInternalFrame}'s. Defaults to the text
   * font with bold style.
   *
   * @param internalFrameTitleFont the font
   */
  public void setInternalFrameTitleFont(FontUIResource internalFrameTitleFont) {
    this.internalFrameTitleFont.setFont(internalFrameTitleFont);
  }

  /**
   * Sets the background color for {@link javax.swing.JComponent}'s.
   *
   * @param color the control color
   */
  public void setControlColor(Color color) {
    this.controlColor.setColor(color);
    updateColors();
  }

  /**
   * Sets the primary control background color used in scroll bar knobs etc.
   *
   * @param c the primary control background color
   */
  public void setPrimaryControlColor(Color c) {
    primaryControlColor.setColor(c);
    updateColors();
  }

  /**
   * Sets the background color used in {@link javax.swing.JViewport}, {@link javax.swing.JTree},
   * {@link javax.swing.JTable} etc.
   *
   * @param c the background color used in {@link javax.swing.JViewport}, {@link javax.swing.JTree},
   *     {@link javax.swing.JTable} etc.
   */
  public void setBackgroundColor(Color c) {
    backgroundColor.setColor(c);
    updateColors();
  }

  /**
   * Sets the text color.
   *
   * @param c the text color
   */
  public void setTextColor(Color c) {
    textColor.setColor(c);
    updateColors();
  }

  /**
   * Gets the font used in {@link javax.swing.JOptionPane} buttons. Defaults to the text font with
   * bold style.
   *
   * @return the font used in {@link javax.swing.JOptionPane} buttons
   */
  public FontUIResource getOptionPaneButtonFont() {
    return optionPaneButtonFont.getFont();
  }

  /**
   * Sets the font used in {@link javax.swing.JOptionPane} buttons. Defaults to the text font with
   * bold style.
   *
   * @param optionPaneButtonFont the font used in {@link javax.swing.JOptionPane} buttons
   */
  public void setOptionPaneButtonFont(FontUIResource optionPaneButtonFont) {
    this.optionPaneButtonFont.setFont(optionPaneButtonFont);
  }

  /**
   * Gets the size of the {@link javax.swing.JSplitPane} divider.
   *
   * @return the size of the {@link javax.swing.JSplitPane} divider
   */
  public int getSplitPaneDividerSize() {
    return splitPaneDividerSize;
  }

  /**
   * Sets the size of the {@link javax.swing.JSplitPane} divider.
   *
   * @param splitPaneDividerSize the size of the {@link javax.swing.JSplitPane} divider
   */
  public void setSplitPaneDividerSize(int splitPaneDividerSize) {
    this.splitPaneDividerSize = splitPaneDividerSize;
  }

  /**
   * Gets the border used around {@link javax.swing.JTextField} (including spinners etc.).
   *
   * @return the border used around {@link javax.swing.JTextField}
   */
  public BorderUIResource getTextFieldBorder() {
    return textFieldBorder.getBorder();
  }

  /**
   * Sets the border used around {@link javax.swing.JTextField} (including spinners etc.).
   *
   * @param textFieldBorder the border used around {@link javax.swing.JTextField}
   */
  public void setTextFieldBorder(BorderUIResource textFieldBorder) {
    this.textFieldBorder.setBorder(textFieldBorder);
  }

  /**
   * Gets the icon used with open nodes in a {@link javax.swing.JTree}.
   *
   * @return the icon used with open nodes in a {@link javax.swing.JTree}
   */
  public IconUIResource getTreeOpenIcon() {
    return treeOpenIcon;
  }

  /**
   * Sets the icon used with open nodes in a {@link javax.swing.JTree}.
   *
   * @param treeOpenIcon the icon used with open nodes in a {@link javax.swing.JTree}
   */
  public void setTreeOpenIcon(IconUIResource treeOpenIcon) {
    this.treeOpenIcon = treeOpenIcon;
  }

  /**
   * Gets the icon used with closed nodes in a {@link javax.swing.JTree}.
   *
   * @return the icon used with closed nodes in a {@link javax.swing.JTree}
   */
  public IconUIResource getTreeClosedIcon() {
    return treeClosedIcon;
  }

  /**
   * Sets the icon used with closed nodes in a {@link javax.swing.JTree}.
   *
   * @param treeClosedIcon the icon used with closed nodes in a {@link javax.swing.JTree}
   */
  public void setTreeClosedIcon(IconUIResource treeClosedIcon) {
    this.treeClosedIcon = treeClosedIcon;
  }

  /**
   * Gets the icon used with leaf nodes in a {@link javax.swing.JTree}.
   *
   * @return the icon used with leaf nodes in a {@link javax.swing.JTree}
   */
  public IconUIResource getTreeLeafIcon() {
    return treeLeafIcon;
  }

  /**
   * Sets the icon used with leaf nodes in a {@link javax.swing.JTree}.
   *
   * @param treeLeafIcon the icon used with leaf nodes in a {@link javax.swing.JTree}
   */
  public void setTreeLeafIcon(IconUIResource treeLeafIcon) {
    this.treeLeafIcon = treeLeafIcon;
  }

  /**
   * Gets the border used around {@link javax.swing.JMenuBar}'s.
   *
   * @return the border used around {@link javax.swing.JMenuBar}'s
   */
  public BorderUIResource getMenuBarBorder() {
    return menuBarBorder.getBorder();
  }

  /**
   * Sets the border used around {@link javax.swing.JMenuBar}'s.
   *
   * @param menuBarBorder the border used around {@link javax.swing.JMenuBar}'s
   */
  public void setMenuBarBorder(BorderUIResource menuBarBorder) {
    this.menuBarBorder.setBorder(menuBarBorder);
  }

  /**
   * Sets the selected text background color.
   *
   * @param selectedTextBackgroundColor the selected text background color
   */
  public void setSelectedTextBackgroundColor(Color selectedTextBackgroundColor) {
    this.selectedTextBackgroundColor.setColor(selectedTextBackgroundColor);
    updateColors();
  }

  /**
   * Sets the focus marker color.
   *
   * @param focusColor the focus marker color
   */
  public void setFocusColor(Color focusColor) {
    this.focusColor.setColor(focusColor);
  }

  /**
   * Sets the selected text color.
   *
   * @param selectedTextColor the selected text color
   */
  public void setSelectedTextColor(Color selectedTextColor) {
    this.selectedTextColor.setColor(selectedTextColor);
  }

  /**
   * Sets the tooltip background color.
   *
   * @param tooltipBackgroundColor the tooltip background color
   */
  public void setTooltipBackgroundColor(Color tooltipBackgroundColor) {
    this.tooltipBackgroundColor.setColor(tooltipBackgroundColor);
  }

  /**
   * Sets the background color for a {@link javax.swing.JDesktopPane}.
   *
   * @param desktopColor the background color for a {@link javax.swing.JDesktopPane}
   */
  public void setDesktopColor(Color desktopColor) {
    this.desktopColor.setColor(desktopColor);
    updateColors();
  }

  /**
   * Sets the background color for the expand/collapse icons in a {@link javax.swing.JTree}.
   *
   * @param treeIconBackgroundColor the background color for the expand/collapse icons in a {@link
   *     javax.swing.JTree}
   */
  public void setTreeIconBackgroundColor(Color treeIconBackgroundColor) {
    this.treeIconBackgroundColor.setColor(treeIconBackgroundColor);
  }

  /**
   * Sets the background color for a selected menu item.
   *
   * @param selectedMenuBackgroundColor the background color for a selected menu item
   */
  public void setSelectedMenuBackgroundColor(Color selectedMenuBackgroundColor) {
    this.selectedMenuBackgroundColor.setColor(selectedMenuBackgroundColor);
    updateColors();
  }

  /**
   * Sets the foreground color for a selected menu item.
   *
   * @param selectedMenuForegroundColor the foreground color for a selected menu item
   */
  public void setSelectedMenuForegroundColor(Color selectedMenuForegroundColor) {
    this.selectedMenuForegroundColor.setColor(selectedMenuForegroundColor);
  }

  /**
   * Sets the inactive text color.
   *
   * @param inactiveTextColor the inactive text color
   */
  public void setInactiveTextColor(Color inactiveTextColor) {
    this.inactiveTextColor.setColor(inactiveTextColor);
  }

  /**
   * Sets the {@link javax.swing.JScrollBar} background color.
   *
   * @param scrollBarBackgroundColor the {@link javax.swing.JScrollBar} background color
   */
  public void setScrollBarBackgroundColor(Color scrollBarBackgroundColor) {
    this.scrollBarBackgroundColor.setColor(scrollBarBackgroundColor);
    updateColors();
  }

  /**
   * Sets the background color for the title of an active {@link javax.swing.JInternalFrame}.
   *
   * @param activeInternalFrameTitleBackgroundColor the background color for the title of an active
   *     {@link javax.swing.JInternalFrame}
   */
  public void setActiveInternalFrameTitleBackgroundColor(
      Color activeInternalFrameTitleBackgroundColor) {
    this.activeInternalFrameTitleBackgroundColor.setColor(activeInternalFrameTitleBackgroundColor);
    updateColors();
  }

  /**
   * Sets the foreground color for the title of an active {@link javax.swing.JInternalFrame}.
   *
   * @param activeInternalFrameTitleForegroundColor the background color for the title of an active
   *     {@link javax.swing.JInternalFrame}
   */
  public void setActiveInternalFrameTitleForegroundColor(
      Color activeInternalFrameTitleForegroundColor) {
    this.activeInternalFrameTitleForegroundColor.setColor(activeInternalFrameTitleForegroundColor);
    updateColors();
  }

  /**
   * Sets the gradient color for the title of an active {@link javax.swing.JInternalFrame}.
   *
   * @param activeInternalFrameTitleGradientColor the gradient color for the title of an active
   *     {@link javax.swing.JInternalFrame}
   */
  public void setActiveInternalFrameTitleGradientColor(
      Color activeInternalFrameTitleGradientColor) {
    this.activeInternalFrameTitleGradientColor.setColor(activeInternalFrameTitleGradientColor);
    updateColors();
  }

  /**
   * Sets the background color for the title of an inactive {@link javax.swing.JInternalFrame}.
   *
   * @param inactiveInternalFrameTitleBackgroundColor the background color for the title of an
   *     inactive {@link javax.swing.JInternalFrame}
   */
  public void setInactiveInternalFrameTitleBackgroundColor(
      Color inactiveInternalFrameTitleBackgroundColor) {
    this.inactiveInternalFrameTitleBackgroundColor.setColor(
        inactiveInternalFrameTitleBackgroundColor);
    updateColors();
  }

  /**
   * Sets the foreground color for the title of an inactive {@link javax.swing.JInternalFrame}.
   *
   * @param inactiveInternalFrameTitleForegroundColor the background color for the title of an
   *     active {@link javax.swing.JInternalFrame}
   */
  public void setInactiveInternalFrameTitleForegroundColor(
      Color inactiveInternalFrameTitleForegroundColor) {
    this.inactiveInternalFrameTitleForegroundColor.setColor(
        inactiveInternalFrameTitleForegroundColor);
    updateColors();
  }

  /**
   * Sets the gradient color for the title of an inactive {@link javax.swing.JInternalFrame}.
   *
   * @param inactiveInternalFrameTitleGradientColor the gradient color for the title of an inactive
   *     {@link javax.swing.JInternalFrame}
   */
  public void setInactiveInternalFrameTitleGradientColor(
      Color inactiveInternalFrameTitleGradientColor) {
    this.inactiveInternalFrameTitleGradientColor.setColor(inactiveInternalFrameTitleGradientColor);
    updateColors();
  }

  /**
   * Sets the title font of an {@link javax.swing.JInternalFrame}.
   *
   * @param frameTitleFont the title font of an {@link javax.swing.JInternalFrame}
   */
  public void setInternalFrameTitleFont(Font frameTitleFont) {
    this.internalFrameTitleFont.setFont(frameTitleFont);
  }

  /**
   * Sets the button font for a {@link javax.swing.JOptionPane}. Default to the text font with bold
   * style.
   *
   * @param optionPaneButtonFont the button font for a {@link javax.swing.JOptionPane}
   */
  public void setOptionPaneButtonFont(Font optionPaneButtonFont) {
    this.optionPaneButtonFont.setFont(optionPaneButtonFont);
  }

  /**
   * Sets the border for the cells of a {@link javax.swing.table.JTableHeader}.
   *
   * @param tableHeaderCellBorder the border for the cells of a {@link
   *     javax.swing.table.JTableHeader}
   */
  public void setTableHeaderCellBorder(BorderUIResource tableHeaderCellBorder) {
    this.tableHeaderCellBorder.setBorder(tableHeaderCellBorder);
  }

  /**
   * Gets the width of a {@link javax.swing.JScrollBar}.
   *
   * @return the width of a {@link javax.swing.JScrollBar}
   */
  public int getScrollBarWidth() {
    return scrollBarWidth;
  }

  /**
   * Sets the width of a {@link javax.swing.JScrollBar}.
   *
   * @param scrollBarWidth the width of a {@link javax.swing.JScrollBar}
   */
  public void setScrollBarWidth(int scrollBarWidth) {
    this.scrollBarWidth = scrollBarWidth;
  }

  /**
   * Gets the margin of a {@link javax.swing.JButton}.
   *
   * @return the margin of a {@link javax.swing.JButton}
   */
  public InsetsUIResource getButtonMargin() {
    return buttonMargin;
  }

  /**
   * Sets the margin of a {@link javax.swing.JButton}.
   *
   * @param buttonMargin the margin of a {@link javax.swing.JButton}
   */
  public void setButtonMargin(InsetsUIResource buttonMargin) {
    this.buttonMargin = buttonMargin;
  }

  /**
   * Gets the border of a {@link javax.swing.JPopupMenu}.
   *
   * @return the border of a {@link javax.swing.JPopupMenu}
   */
  public BorderUIResource getPopupMenuBorder() {
    return popupMenuBorder.getBorder();
  }

  /**
   * Sets the border of a {@link javax.swing.JPopupMenu}.
   *
   * @param popupMenuBorder the border of a {@link javax.swing.JPopupMenu}
   */
  public void setPopupMenuBorder(BorderUIResource popupMenuBorder) {
    this.popupMenuBorder.setBorder(popupMenuBorder);
  }

  /**
   * Gets the icon used in the iconify button in the title of a {@link javax.swing.JInternalFrame}.
   *
   * @return the icon used in the iconify button in the title of a {@link
   *     javax.swing.JInternalFrame}
   */
  public IconUIResource getInternalFrameIconifyIcon() {
    return internalFrameIconifyIcon;
  }

  /**
   * Sets the icon used in the iconify button in the title of a {@link javax.swing.JInternalFrame}.
   *
   * @param internalFrameIconifyIcon the icon used in the iconify button in the title of a {@link
   *     javax.swing.JInternalFrame}
   */
  public void setInternalFrameIconifyIcon(IconUIResource internalFrameIconifyIcon) {
    this.internalFrameIconifyIcon = internalFrameIconifyIcon;
  }

  /**
   * Gets the background color used in {@link javax.swing.JToolTip}.
   *
   * @return the background color used in {@link javax.swing.JToolTip}
   */
  public ColorUIResource getTooltipForegroundColor() {
    return tooltipForegroundColor.getColor();
  }

  /**
   * Sets the foreground color used in {@link javax.swing.JToolTip}.
   *
   * @param tooltipForegroundColor the foreground color used in {@link javax.swing.JToolTip}
   */
  public void setTooltipForegroundColor(ColorUIResource tooltipForegroundColor) {
    this.tooltipForegroundColor.setColor(tooltipForegroundColor);
    updateColors();
  }

  /**
   * Gets the border used around list items in {@link javax.swing.JList}'s and {@link
   * javax.swing.JComboBox}'s.
   *
   * @return the border used around list items in {@link javax.swing.JList}'s and {@link
   *     javax.swing.JComboBox}'s
   */
  public BorderUIResource getListItemBorder() {
    return listItemBorder.getBorder();
  }

  /**
   * Sets the border used around list items in {@link javax.swing.JList}'s and {@link
   * javax.swing.JComboBox}'s.
   *
   * @param listItemBorder the border used around list items in {@link javax.swing.JList}'s and
   *     {@link javax.swing.JComboBox}'s
   */
  public void setListItemBorder(BorderUIResource listItemBorder) {
    this.listItemBorder.setBorder(listItemBorder);
  }

  /**
   * Gets the border used around the focused list item in {@link javax.swing.JList}'s and {@link
   * javax.swing.JComboBox}'s.
   *
   * @return the border used around the focused list item in {@link javax.swing.JList}'s and {@link
   *     javax.swing.JComboBox}'s
   */
  public BorderUIResource getListFocusedItemBorder() {
    return listFocusedItemBorder.getBorder();
  }

  /**
   * Sets the border used around the focused list item in {@link javax.swing.JList}'s and {@link
   * javax.swing.JComboBox}'s.
   *
   * @param listFocusedItemBorder the border used around the focused list item in {@link
   *     javax.swing.JList}'s and {@link javax.swing.JComboBox}'s
   */
  public void setListFocusedItemBorder(BorderUIResource listFocusedItemBorder) {
    this.listFocusedItemBorder.setBorder(listFocusedItemBorder);
  }
}
 public static java.awt.Color getContrastingColor(java.awt.Color color) {
   float[] hsbvals = new float[3];
   java.awt.Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsbvals);
   java.awt.Color c = Color.getHSBColor(0, 0, (hsbvals[2] + 0.5f) % 1f);
   return new java.awt.Color(c.getRed(), c.getGreen(), c.getBlue(), color.getAlpha());
 }
示例#21
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;
    }