예제 #1
0
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {

      Color background;
      Color highlight;
      Color shadow;

      Window window = SwingUtilities.getWindowAncestor(c);
      if (window != null && window.isActive()) {
        background = MetalLookAndFeel.getPrimaryControlDarkShadow();
        highlight = MetalLookAndFeel.getPrimaryControlShadow();
        shadow = MetalLookAndFeel.getPrimaryControlInfo();
      } else {
        background = MetalLookAndFeel.getControlDarkShadow();
        highlight = MetalLookAndFeel.getControlShadow();
        shadow = MetalLookAndFeel.getControlInfo();
      }

      g.setColor(background);
      // Draw outermost lines
      g.drawLine(x + 1, y + 0, x + w - 2, y + 0);
      g.drawLine(x + 0, y + 1, x + 0, y + h - 2);
      g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 2);
      g.drawLine(x + 1, y + h - 1, x + w - 2, y + h - 1);

      // Draw the bulk of the border
      for (int i = 1; i < 5; i++) {
        g.drawRect(x + i, y + i, w - (i * 2) - 1, h - (i * 2) - 1);
      }

      if ((window instanceof Frame) && ((Frame) window).isResizable()) {
        g.setColor(highlight);
        // Draw the Long highlight lines
        g.drawLine(corner + 1, 3, w - corner, 3);
        g.drawLine(3, corner + 1, 3, h - corner);
        g.drawLine(w - 2, corner + 1, w - 2, h - corner);
        g.drawLine(corner + 1, h - 2, w - corner, h - 2);

        g.setColor(shadow);
        // Draw the Long shadow lines
        g.drawLine(corner, 2, w - corner - 1, 2);
        g.drawLine(2, corner, 2, h - corner - 1);
        g.drawLine(w - 3, corner, w - 3, h - corner - 1);
        g.drawLine(corner, h - 3, w - corner - 1, h - 3);
      }
    }
예제 #2
0
  /** Paints the horizontal bars for the */
  public void paintIcon(Component c, Graphics g, int x, int y) {
    JComponent component = (JComponent) c;
    int iconWidth = getIconWidth();

    g.translate(x, y);

    g.setColor(
        component.isEnabled()
            ? MetalLookAndFeel.getControlInfo()
            : MetalLookAndFeel.getControlShadow());
    g.drawLine(0, 0, iconWidth - 1, 0);
    g.drawLine(1, 1, 1 + (iconWidth - 3), 1);
    g.drawLine(2, 2, 2 + (iconWidth - 5), 2);
    g.drawLine(3, 3, 3 + (iconWidth - 7), 3);
    g.drawLine(4, 4, 4 + (iconWidth - 9), 4);

    g.translate(-x, -y);
  }
예제 #3
0
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {

      Color background;
      Color highlight;
      Color shadow;

      if (c instanceof JInternalFrame && ((JInternalFrame) c).isSelected()) {
        background = MetalLookAndFeel.getPrimaryControlDarkShadow();
        highlight = MetalLookAndFeel.getPrimaryControlShadow();
        shadow = MetalLookAndFeel.getPrimaryControlInfo();
      } else {
        background = MetalLookAndFeel.getControlDarkShadow();
        highlight = MetalLookAndFeel.getControlShadow();
        shadow = MetalLookAndFeel.getControlInfo();
      }

      g.setColor(background);
      // Draw outermost lines
      g.drawLine(1, 0, w - 2, 0);
      g.drawLine(0, 1, 0, h - 2);
      g.drawLine(w - 1, 1, w - 1, h - 2);
      g.drawLine(1, h - 1, w - 2, h - 1);

      // Draw the bulk of the border
      for (int i = 1; i < 5; i++) {
        g.drawRect(x + i, y + i, w - (i * 2) - 1, h - (i * 2) - 1);
      }

      if (c instanceof JInternalFrame && ((JInternalFrame) c).isResizable()) {
        g.setColor(highlight);
        // Draw the Long highlight lines
        g.drawLine(corner + 1, 3, w - corner, 3);
        g.drawLine(3, corner + 1, 3, h - corner);
        g.drawLine(w - 2, corner + 1, w - 2, h - corner);
        g.drawLine(corner + 1, h - 2, w - corner, h - 2);

        g.setColor(shadow);
        // Draw the Long shadow lines
        g.drawLine(corner, 2, w - corner - 1, 2);
        g.drawLine(2, corner, 2, h - corner - 1);
        g.drawLine(w - 3, corner, w - 3, h - corner - 1);
        g.drawLine(corner, h - 3, w - corner - 1, h - 3);
      }
    }
  public void paint(Graphics g) {
    boolean leftToRight = MetalUtils.isLeftToRight(this);
    boolean isEnabled = getParent().isEnabled();

    Color arrowColor =
        isEnabled ? MetalLookAndFeel.getControlInfo() : MetalLookAndFeel.getControlDisabled();
    boolean isPressed = getModel().isPressed();
    int width = getWidth();
    int height = getHeight();
    int w = width;
    int h = height;
    int arrowHeight = (height + 1) / 4;
    int arrowWidth = (height + 1) / 2;

    if (isPressed) {
      g.setColor(MetalLookAndFeel.getControlShadow());
    } else {
      g.setColor(getBackground());
    }

    g.fillRect(0, 0, width, height);

    if (getDirection() == NORTH) {
      if (!isFreeStanding) {
        height += 1;
        g.translate(0, -1);
        width += 2;
        if (!leftToRight) {
          g.translate(-1, 0);
        }
      }

      // Draw the arrow
      g.setColor(arrowColor);
      int startY = ((h + 1) - arrowHeight) / 2;
      int startX = (w / 2);
      //                  System.out.println( "startX :" + startX + " startY :"+startY);
      for (int line = 0; line < arrowHeight; line++) {
        g.drawLine(startX - line, startY + line, startX + line + 1, startY + line);
      }
      /*      g.drawLine( 7, 6, 8, 6 );
      g.drawLine( 6, 7, 9, 7 );
      g.drawLine( 5, 8, 10, 8 );
      g.drawLine( 4, 9, 11, 9 );*/

      if (isEnabled) {
        g.setColor(highlightColor);

        if (!isPressed) {
          g.drawLine(1, 1, width - 3, 1);
          g.drawLine(1, 1, 1, height - 1);
        }

        g.drawLine(width - 1, 1, width - 1, height - 1);

        g.setColor(shadowColor);
        g.drawLine(0, 0, width - 2, 0);
        g.drawLine(0, 0, 0, height - 1);
        g.drawLine(width - 2, 2, width - 2, height - 1);
      } else {
        MetalUtils.drawDisabledBorder(g, 0, 0, width, height + 1);
      }
      if (!isFreeStanding) {
        height -= 1;
        g.translate(0, 1);
        width -= 2;
        if (!leftToRight) {
          g.translate(1, 0);
        }
      }
    } else if (getDirection() == SOUTH) {
      if (!isFreeStanding) {
        height += 1;
        width += 2;
        if (!leftToRight) {
          g.translate(-1, 0);
        }
      }

      // Draw the arrow
      g.setColor(arrowColor);

      int startY = (((h + 1) - arrowHeight) / 2) + arrowHeight - 1;
      int startX = (w / 2);

      //          System.out.println( "startX2 :" + startX + " startY2 :"+startY);

      for (int line = 0; line < arrowHeight; line++) {
        g.drawLine(startX - line, startY - line, startX + line + 1, startY - line);
      }

      /*      g.drawLine( 4, 5, 11, 5 );
      g.drawLine( 5, 6, 10, 6 );
      g.drawLine( 6, 7, 9, 7 );
      g.drawLine( 7, 8, 8, 8 ); */

      if (isEnabled) {
        g.setColor(highlightColor);

        if (!isPressed) {
          g.drawLine(1, 0, width - 3, 0);
          g.drawLine(1, 0, 1, height - 3);
        }

        g.drawLine(1, height - 1, width - 1, height - 1);
        g.drawLine(width - 1, 0, width - 1, height - 1);

        g.setColor(shadowColor);
        g.drawLine(0, 0, 0, height - 2);
        g.drawLine(width - 2, 0, width - 2, height - 2);
        g.drawLine(2, height - 2, width - 2, height - 2);
      } else {
        MetalUtils.drawDisabledBorder(g, 0, -1, width, height + 1);
      }

      if (!isFreeStanding) {
        height -= 1;
        width -= 2;
        if (!leftToRight) {
          g.translate(1, 0);
        }
      }
    } else if (getDirection() == EAST) {
      if (!isFreeStanding) {
        height += 2;
        width += 1;
      }

      // Draw the arrow
      g.setColor(arrowColor);

      int startX = (((w + 1) - arrowHeight) / 2) + arrowHeight - 1;
      int startY = (h / 2);

      // System.out.println( "startX2 :" + startX + " startY2 :"+startY);

      for (int line = 0; line < arrowHeight; line++) {
        g.drawLine(startX - line, startY - line, startX - line, startY + line + 1);
      }

      /*              g.drawLine( 5, 4, 5, 11 );
      g.drawLine( 6, 5, 6, 10 );
      g.drawLine( 7, 6, 7, 9 );
      g.drawLine( 8, 7, 8, 8 );*/

      if (isEnabled) {
        g.setColor(highlightColor);

        if (!isPressed) {
          g.drawLine(0, 1, width - 3, 1);
          g.drawLine(0, 1, 0, height - 3);
        }

        g.drawLine(width - 1, 1, width - 1, height - 1);
        g.drawLine(0, height - 1, width - 1, height - 1);

        g.setColor(shadowColor);
        g.drawLine(0, 0, width - 2, 0);
        g.drawLine(width - 2, 2, width - 2, height - 2);
        g.drawLine(0, height - 2, width - 2, height - 2);
      } else {
        MetalUtils.drawDisabledBorder(g, -1, 0, width + 1, height);
      }
      if (!isFreeStanding) {
        height -= 2;
        width -= 1;
      }
    } else if (getDirection() == WEST) {
      if (!isFreeStanding) {
        height += 2;
        width += 1;
        g.translate(-1, 0);
      }

      // Draw the arrow
      g.setColor(arrowColor);

      int startX = (((w + 1) - arrowHeight) / 2);
      int startY = (h / 2);

      for (int line = 0; line < arrowHeight; line++) {
        g.drawLine(startX + line, startY - line, startX + line, startY + line + 1);
      }

      /*      g.drawLine( 6, 7, 6, 8 );
      g.drawLine( 7, 6, 7, 9 );
      g.drawLine( 8, 5, 8, 10 );
      g.drawLine( 9, 4, 9, 11 );*/

      if (isEnabled) {
        g.setColor(highlightColor);

        if (!isPressed) {
          g.drawLine(1, 1, width - 1, 1);
          g.drawLine(1, 1, 1, height - 3);
        }

        g.drawLine(1, height - 1, width - 1, height - 1);

        g.setColor(shadowColor);
        g.drawLine(0, 0, width - 1, 0);
        g.drawLine(0, 0, 0, height - 2);
        g.drawLine(2, height - 2, width - 1, height - 2);
      } else {
        MetalUtils.drawDisabledBorder(g, 0, 0, width + 1, height);
      }

      if (!isFreeStanding) {
        height -= 2;
        width -= 1;
        g.translate(1, 0);
      }
    }
  }
예제 #5
0
 protected Color getInactiveShadow() {
   return MetalLookAndFeel.getControlInfo();
 }