public void paintIcon(Component c, Graphics g, int x, int y) {
      Color color = c == null ? Color.GRAY : c.getBackground();
      // In a compound sort, make each succesive triangle 20%
      // smaller than the previous one.
      int dx = (int) (size / 2 * Math.pow(0.8, priority));
      int dy = descending ? dx : -dx;
      // Align icon (roughly) with font baseline.
      y = y + 5 * size / 6 + (descending ? -dy : 0);
      int shift = descending ? 1 : -1;
      g.translate(x, y);

      // Right diagonal.
      g.setColor(color.darker());
      g.drawLine(dx / 2, dy, 0, 0);
      g.drawLine(dx / 2, dy + shift, 0, shift);

      // Left diagonal.
      g.setColor(color.brighter());
      g.drawLine(dx / 2, dy, dx, 0);
      g.drawLine(dx / 2, dy + shift, dx, shift);

      // Horizontal line.
      if (descending) {
        g.setColor(color.darker().darker());
      } else {
        g.setColor(color.brighter().brighter());
      }
      g.drawLine(dx, 0, 0, 0);

      g.setColor(color);
      g.translate(-x, -y);
    }
Esempio n. 2
0
  /**
   * Function: getJavaColor Pre: Takes an ANIMAL color string 'c' Post: Returns the java color for
   * this node (Note: returns "white" as a default)
   */
  private Color getJavaColor(String c) {
    if (!isValidNodeColor(c)) return Color.white;

    // Temporary color to use with numbered colors
    Color temp = Color.white;

    if (c.compareTo("black") == 0) return Color.black;
    if (c.compareTo("white") == 0) return Color.white;
    if (c.compareTo("gray") == 0) return Color.gray;
    if (c.compareTo("yellow") == 0) return Color.yellow;
    if (c.startsWith("blue")) temp = Color.blue;
    if (c.startsWith("cyan")) temp = Color.cyan;
    if (c.startsWith("pink")) temp = Color.pink;
    if (c.startsWith("red")) temp = Color.red;
    if (c.startsWith("magenta")) temp = Color.magenta;
    if (c.startsWith("green")) temp = Color.green;

    // Finally, do some final handling for
    temp = temp.darker().darker();
    if (c.endsWith("2")) return temp.brighter();
    if (c.endsWith("3")) return temp.brighter().brighter();
    if (c.endsWith("4")) return temp.brighter().brighter().brighter();

    return temp;
  }
Esempio n. 3
0
  private void drawColorButton(Graphics g, int no) {
    g.setColor(cDarkShadowColor);
    g.drawLine(mRect[no].x, mRect[no].y, mRect[no].x + mRect[no].width - 2, mRect[no].y);
    g.drawLine(mRect[no].x, mRect[no].y, mRect[no].x, mRect[no].y + mRect[no].height - 2);
    g.drawLine(
        mRect[no].x + mRect[no].width - 2,
        mRect[no].y + 2,
        mRect[no].x + mRect[no].width - 2,
        mRect[no].y + mRect[no].height - 2);
    g.drawLine(
        mRect[no].x + 2,
        mRect[no].y + mRect[no].height - 2,
        mRect[no].x + mRect[no].width - 2,
        mRect[no].y + mRect[no].height - 2);

    if (mPressedButton != no || !mMouseOverButton) g.setColor(Color.white);

    g.drawLine(
        mRect[no].x + 1, mRect[no].y + 1, mRect[no].x + mRect[no].width - 3, mRect[no].y + 1);
    g.drawLine(
        mRect[no].x + 1, mRect[no].y + 1, mRect[no].x + 1, mRect[no].y + mRect[no].height - 3);

    if (mPressedButton == no && mMouseOverButton) g.setColor(Color.white);

    g.drawLine(
        mRect[no].x + mRect[no].width - 1,
        mRect[no].y + 1,
        mRect[no].x + mRect[no].width - 1,
        mRect[no].y + mRect[no].height - 1);
    g.drawLine(
        mRect[no].x + 1,
        mRect[no].y + mRect[no].height - 1,
        mRect[no].x + mRect[no].width - 1,
        mRect[no].y + mRect[no].height - 1);

    if (mColorListMode != VisualizationColor.cColorListModeCategories && no == cColorWedgeButton) {
      int x1 = mRect[no].x + 2;
      int x2 = x1 + mRect[no].width - 4;
      if (x1 < x2) {
        for (int x = x1; x < x2; x++) {
          int c = mWedgeColorList.length * (x - x1) / (x2 - x1);
          g.setColor(
              (mPressedButton == no && mMouseOverButton)
                  ? mWedgeColorList[c].darker()
                  : mWedgeColorList[c]);
          g.drawLine(x, mRect[no].y + 2, x, mRect[no].y + mRect[no].height - 3);
        }
      }
    } else {
      Color color =
          (mColorListMode == VisualizationColor.cColorListModeCategories)
              ? mCategoryColorList[no]
              : mWedgeColorList[no * (mWedgeColorList.length - 1)];
      if (mPressedButton == no && mMouseOverButton) color = color.darker();

      g.setColor(color);
      g.fillRect(mRect[no].x + 2, mRect[no].y + 2, mRect[no].width - 4, mRect[no].height - 4);
    }
  }
Esempio n. 4
0
    public void paintIcon(Component c, Graphics g, int x, int y) {
      if (color == null) return;

      g.setColor(color);
      g.fillRect(x, y, getIconWidth(), getIconHeight());
      g.setColor(color.darker());
      g.drawRect(x, y, getIconWidth() - 1, getIconHeight() - 1);
    }