Пример #1
0
  protected void paintIndeterminate(Graphics g, JComponent c) {
    if (!(g instanceof Graphics2D)) {
      return;
    }
    Graphics2D g2D = (Graphics2D) g;

    Insets b = progressBar.getInsets(); // area for border
    int barRectWidth = progressBar.getWidth() - (b.right + b.left);
    int barRectHeight = progressBar.getHeight() - (b.top + b.bottom);

    Color colors[];
    if (progressBar.getForeground() instanceof UIResource) {
      if (!Utilities.isActive(c)) {
        colors = BaseLookAndFeel.getTheme().getInActiveColors();
      } else if (c.isEnabled()) {
        colors = BaseLookAndFeel.getTheme().getProgressBarColors();
      } else {
        colors = BaseLookAndFeel.getTheme().getDisabledColors();
      }
    } else {
      Color hiColor = ColorHelper.brighter(progressBar.getForeground(), 40);
      Color loColor = ColorHelper.darker(progressBar.getForeground(), 20);
      colors = ColorHelper.createColorArr(hiColor, loColor, 20);
    }

    Color cHi = ColorHelper.darker(colors[colors.length - 1], 5);
    Color cLo = ColorHelper.darker(colors[colors.length - 1], 10);

    // Paint the bouncing box.
    Rectangle box = getBox(null);
    if (box != null) {
      g2D.setColor(progressBar.getForeground());
      Utilities.draw3DBorder(g, cHi, cLo, box.x + 1, box.y + 1, box.width - 2, box.height - 2);
      if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
        Utilities.fillHorGradient(g, colors, box.x + 2, box.y + 2, box.width - 4, box.height - 4);
      } else {
        Utilities.fillVerGradient(g, colors, box.x + 2, box.y + 2, box.width - 4, box.height - 4);
      }

      // Deal with possible text painting
      if (progressBar.isStringPainted()) {
        Object savedRenderingHint = null;
        if (BaseLookAndFeel.getTheme().isTextAntiAliasingOn()) {
          savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
          g2D.setRenderingHint(
              RenderingHints.KEY_TEXT_ANTIALIASING,
              BaseLookAndFeel.getTheme().getTextAntiAliasingHint());
        }
        if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
          paintString(g2D, b.left, b.top, barRectWidth, barRectHeight, box.width, b);
        } else {
          paintString(g2D, b.left, b.top, barRectWidth, barRectHeight, box.height, b);
        }
        if (BaseLookAndFeel.getTheme().isTextAntiAliasingOn()) {
          g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint);
        }
      }
    }
  }
Пример #2
0
 public void paintBorder(Graphics g) {
   if (isActive()) {
     g.setColor(ColorHelper.darker(AbstractLookAndFeel.getWindowBorderColor(), 10));
   } else {
     g.setColor(ColorHelper.darker(AbstractLookAndFeel.getWindowInactiveBorderColor(), 10));
   }
   g.drawLine(0, getHeight() - 1, getWidth(), getHeight() - 1);
 }
Пример #3
0
 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
   Color logoColor = AbstractLookAndFeel.getMenuSelectionBackgroundColor();
   Color borderColorLo = AbstractLookAndFeel.getFrameColor();
   Color borderColorHi =
       ColorHelper.brighter(AbstractLookAndFeel.getMenuSelectionBackgroundColor(), 40);
   g.setColor(logoColor);
   if (JTattooUtilities.isLeftToRight(c)) {
     int dx = getBorderInsets(c).left;
     g.fillRect(x, y, dx - 1, h - 1);
     paintLogo(c, g, x, y, w, h);
     // - highlight
     g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getMenuBackgroundColor(), 40));
     g.drawLine(x + dx, y + 1, x + w - 2, y + 1);
     g.setColor(borderColorHi);
     g.drawLine(x + 1, y, x + 1, y + h - 2);
     // - outer frame
     g.setColor(borderColorLo);
     if (isMenuBarPopup(c)) {
       // top
       g.drawLine(x + dx - 1, y, x + w, y);
       // left
       g.drawLine(x, y, x, y + h - 1);
       // bottom
       g.drawLine(x, y + h - 1, x + w, y + h - 1);
       // right
       g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
     } else {
       g.drawRect(x, y, w - 1, h - 1);
     }
     // - logo separator
     g.drawLine(x + dx - 1, y + 1, x + dx - 1, y + h - 1);
   } else {
     int dx = getBorderInsets(c).right;
     g.fillRect(x + w - dx, y, dx, h - 1);
     paintLogo(c, g, x, y, w, h);
     // - highlight
     g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getMenuBackgroundColor(), 40));
     g.drawLine(x + 1, y + 1, x + w - dx - 1, y + 1);
     g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
     // - outer frame
     g.setColor(borderColorLo);
     if (isMenuBarPopup(c)) {
       // top
       g.drawLine(x, y, x + w - dx, y);
       // left
       g.drawLine(x, y, x, y + h - 1);
       // bottom
       g.drawLine(x, y + h - 1, x + w, y + h - 1);
       // right
       g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
     } else {
       g.drawRect(x, y, w - 1, h - 1);
     }
     // - logo separator
     g.drawLine(x + w - dx, y + 1, x + w - dx, y + h - 1);
   }
 }
Пример #4
0
 protected Color[] getContentBorderColors(int tabPlacement) {
   Color SEP_COLORS[] = {
     ColorHelper.brighter(AcrylLookAndFeel.getControlColorLight(), 20),
     AcrylLookAndFeel.getControlColorLight(),
     ColorHelper.brighter(AcrylLookAndFeel.getControlColorDark(), 20),
     AcrylLookAndFeel.getControlColorDark(),
     ColorHelper.darker(AcrylLookAndFeel.getControlColorDark(), 20),
   };
   return SEP_COLORS;
 }
Пример #5
0
 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
   AbstractButton button = (AbstractButton) c;
   ButtonModel model = button.getModel();
   Color frameColor = AbstractLookAndFeel.getToolbarBackgroundColor();
   Color frameHiColor = ColorHelper.brighter(frameColor, 10);
   Color frameLoColor = ColorHelper.darker(frameColor, 30);
   JTattooUtilities.draw3DBorder(g, frameHiColor, frameLoColor, x, y, w, h);
   if ((model.isPressed() && model.isArmed()) || model.isSelected()) {
     JTattooUtilities.draw3DBorder(g, frameLoColor, frameHiColor, x, y, w, h);
   } else {
     JTattooUtilities.draw3DBorder(g, frameLoColor, frameHiColor, x, y, w, h);
     JTattooUtilities.draw3DBorder(g, frameHiColor, frameLoColor, x + 1, y + 1, w - 2, h - 2);
   }
 }
Пример #6
0
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
      AbstractButton button = (AbstractButton) c;
      Graphics2D g2D = (Graphics2D) g;
      Color frameColor = AbstractLookAndFeel.getTheme().getFrameColor();
      if (!JTattooUtilities.isFrameActive(button)) {
        frameColor = ColorHelper.brighter(frameColor, 40);
      }

      if (AbstractLookAndFeel.getTheme().doDrawSquareButtons()) {
        g2D.setColor(Color.white);
        g2D.drawRect(x, y, w - 1, h - 1);

        if (button.getRootPane() != null
            && button.equals(button.getRootPane().getDefaultButton())
            && !button.hasFocus()) {
          g2D.setColor(ColorHelper.darker(frameColor, 20));
          g2D.drawRect(x, y, w - 1, h - 2);
          if (!button.getModel().isRollover()) {
            g2D.setColor(defaultColorHi);
            g2D.drawRect(x + 1, y + 1, w - 3, h - 4);
            g2D.setColor(defaultColorLo);
            g2D.drawRect(x + 2, y + 2, w - 5, h - 6);
          }
        } else {
          g2D.setColor(frameColor);
          g2D.drawRect(x, y, w - 2, h - 2);
        }
      } else {
        Object savedRederingHint = g2D.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
        g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

        if (button.getRootPane() != null
            && button.equals(button.getRootPane().getDefaultButton())) {
          if (!button.getModel().isRollover()) {
            g2D.setColor(defaultColorHi);
            g2D.drawRoundRect(x + 1, y + 1, w - 4, h - 2, 6, 6);
            g2D.setColor(defaultColorLo);
            g2D.drawRoundRect(x + 2, y + 2, w - 6, h - 6, 6, 6);
          }
        }

        g2D.setColor(Color.white);
        g2D.drawRoundRect(x, y, w - 1, h - 1, 6, 6);

        g2D.setColor(frameColor);
        g2D.drawRoundRect(x, y, w - 2, h - 2, 6, 6);

        g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, savedRederingHint);
      }
    }
Пример #7
0
 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
   JMenuItem b = (JMenuItem) c;
   ButtonModel model = b.getModel();
   Color borderColorLo = AbstractLookAndFeel.getFrameColor();
   Color borderColorHi =
       ColorHelper.brighter(AbstractLookAndFeel.getMenuSelectionBackgroundColor(), 40);
   if (c.getParent() instanceof JMenuBar) {
     if (model.isArmed() || model.isSelected()) {
       g.setColor(borderColorLo);
       g.drawLine(x, y, x + w - 1, y);
       g.drawLine(x, y, x, y + h - 1);
       g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
       g.setColor(borderColorHi);
       g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
       g.drawLine(x + 1, y + 1, x + 1, y + h - 1);
     }
   } else {
     if (model.isArmed() || (c instanceof JMenu && model.isSelected())) {
       g.setColor(borderColorLo);
       g.drawLine(x, y, x + w - 1, y);
       g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
       g.setColor(borderColorHi);
       g.drawLine(x, y + 1, x + w - 2, y + 1);
     }
   }
 }
Пример #8
0
 public MyRenderComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
   super();
   this.table = table;
   this.col = col;
   if (value != null) {
     setText(value.toString());
   } else {
     setText("");
   }
   setOpaque(false);
   setFont(UIManager.getFont("TableHeader.font"));
   setForeground(UIManager.getColor("TableHeader.foreground"));
   setHorizontalAlignment(JLabel.CENTER);
   setHorizontalTextPosition(SwingConstants.LEADING);
   setBorder(UIManager.getBorder("TableHeader.cellBorder"));
   if ((JTattooUtilities.getJavaVersion() >= 1.6)
       && (UIManager.getLookAndFeel() instanceof AbstractLookAndFeel)) {
     RowSorter rowSorter = table == null ? null : table.getRowSorter();
     List keyList = rowSorter == null ? null : rowSorter.getSortKeys();
     if ((keyList != null) && (keyList.size() > 0)) {
       RowSorter.SortKey sortKey = (RowSorter.SortKey) keyList.get(0);
       if (sortKey.getColumn() == table.convertColumnIndexToModel(col)) {
         AbstractIconFactory iconFactory =
             ((AbstractLookAndFeel) UIManager.getLookAndFeel()).getIconFactory();
         if (sortKey.getSortOrder().equals(SortOrder.ASCENDING)) {
           setIcon(iconFactory.getUpArrowIcon());
         } else if (sortKey.getSortOrder().equals(SortOrder.DESCENDING)) {
           setIcon(iconFactory.getDownArrowIcon());
         }
       }
     }
   }
   gv = ColorHelper.getGrayValue(AbstractLookAndFeel.getTheme().getRolloverColor());
 }
Пример #9
0
    public void paint(Graphics g) {
      Dimension size = getSize();
      Color colors[];
      if (isEnabled()) {
        if (getModel().isArmed() && getModel().isPressed()) {
          colors = BaseLookAndFeel.getTheme().getPressedColors();
        } else if (getModel().isRollover()) {
          colors = BaseLookAndFeel.getTheme().getRolloverColors();
        } else {
          colors = BaseLookAndFeel.getTheme().getButtonColors();
        }
      } else {
        colors = BaseLookAndFeel.getTheme().getDisabledColors();
      }
      Utilities.fillHorGradient(g, colors, 0, 0, size.width, size.height);

      boolean inverse = ColorHelper.getGrayValue(colors) < 128;

      Icon icon = inverse ? BaseIcons.getComboBoxInverseIcon() : BaseIcons.getComboBoxIcon();
      int x = (size.width - icon.getIconWidth()) / 2;
      int y = (size.height - icon.getIconHeight()) / 2;

      Graphics2D g2D = (Graphics2D) g;
      Composite savedComposite = g2D.getComposite();
      g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f));
      if (getModel().isPressed() && getModel().isArmed()) {
        icon.paintIcon(this, g, x + 2, y + 1);
      } else {
        icon.paintIcon(this, g, x + 1, y);
      }
      g2D.setComposite(savedComposite);
      paintBorder(g2D);
    }
Пример #10
0
 /**
  * Gets the progress bar border.
  *
  * @return the progress bar border
  */
 public static Border getProgressBarBorder() {
   if (progressBarBorder == null) {
     progressBarBorder =
         BorderFactory.createLineBorder(
             ColorHelper.darker(AbstractLookAndFeel.getBackgroundColor(), 30));
   }
   return progressBarBorder;
 }
Пример #11
0
 public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
   Color hiColor = ColorHelper.brighter(AbstractLookAndFeel.getTheme().getFocusFrameColor(), 60);
   Color loColor = AbstractLookAndFeel.getTheme().getFocusFrameColor();
   g.setColor(loColor);
   g.drawRect(x, y, width - 1, height - 1);
   g.setColor(hiColor);
   g.drawRect(x + 1, y + 1, width - 3, height - 3);
 }
Пример #12
0
 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
   if (JTattooUtilities.isFrameActive((JComponent) c)) {
     g.setColor(AbstractLookAndFeel.getFrameColor());
   } else {
     g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getFrameColor(), 40));
   }
   g.drawRect(x, y, w - 1, h - 1);
 }
Пример #13
0
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
      AbstractButton button = (AbstractButton) c;
      ButtonModel model = button.getModel();
      if (model.isEnabled()) {
        if ((model.isPressed() && model.isArmed()) || model.isSelected()) {
          Color frameColor =
              ColorHelper.darker(AbstractLookAndFeel.getToolbarBackgroundColor(), 30);
          g.setColor(frameColor);
          g.drawRect(x, y, w - 1, h - 1);

          Graphics2D g2D = (Graphics2D) g;
          Composite composite = g2D.getComposite();
          AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f);
          g2D.setComposite(alpha);
          g.setColor(Color.black);
          g.fillRect(x + 1, y + 1, w - 2, h - 2);
          g2D.setComposite(composite);
        } else if (model.isRollover()) {
          Color frameColor = AbstractLookAndFeel.getToolbarBackgroundColor();
          Color frameHiColor = ColorHelper.darker(frameColor, 5);
          Color frameLoColor = ColorHelper.darker(frameColor, 20);
          JTattooUtilities.draw3DBorder(g, frameHiColor, frameLoColor, x, y, w, h);
          frameHiColor = Color.white;
          frameLoColor = ColorHelper.brighter(frameLoColor, 60);
          JTattooUtilities.draw3DBorder(g, frameHiColor, frameLoColor, x + 1, y + 1, w - 2, h - 2);

          Graphics2D g2D = (Graphics2D) g;
          Composite composite = g2D.getComposite();
          AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f);
          g2D.setComposite(alpha);
          g.setColor(Color.white);
          g.fillRect(x + 2, y + 2, w - 4, h - 4);
          g2D.setComposite(composite);

          g.setColor(AbstractLookAndFeel.getFocusColor());
          g.drawLine(x + 1, y + 1, x + w - 1, y + 1);
          g.drawLine(x + 1, y + 2, x + w - 2, y + 2);
        } else if (model.isSelected()) {
          Color frameColor = AbstractLookAndFeel.getToolbarBackgroundColor();
          Color frameHiColor = Color.white;
          Color frameLoColor = ColorHelper.darker(frameColor, 30);
          JTattooUtilities.draw3DBorder(g, frameLoColor, frameHiColor, x, y, w, h);
        }
      }
    }
Пример #14
0
  public static void drawRound3DBorder(Graphics g, Color c1, Color c2, int x, int y, int w, int h) {
    Graphics2D g2D = (Graphics2D) g;
    int x2 = x + w;
    int y2 = y + h;
    int d = h;
    int r = h / 2;
    Color cm = ColorHelper.median(c1, c2);
    Color c1m = ColorHelper.median(c1, cm);
    Color c2m = ColorHelper.median(c2, cm);

    Object savedRederingHint = g2D.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
    g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    // oben
    g2D.setColor(c1);
    g2D.drawLine(x + r, y, x2 - r, y);
    // rechts
    g2D.drawLine(x, y + r, x, y2 - r);
    // unten
    g2D.setColor(c2);
    g2D.drawLine(x + r, y2, x2 - r, y2);
    // links
    g2D.drawLine(x2, y + r, x2, y2 - r);

    // links
    g2D.setColor(c1);
    g2D.drawArc(x, y, d, d, 90, 45);
    g2D.setColor(c1m);
    g2D.drawArc(x, y, d, d, 135, 45);
    g2D.setColor(cm);
    g2D.drawArc(x, y, d, d, 180, 45);
    g2D.setColor(c2m);
    g2D.drawArc(x, y, d, d, 225, 45);
    // rechts
    g2D.setColor(c1m);
    g2D.drawArc(x2 - d, y, d, d, 45, 45);
    g2D.setColor(cm);
    g2D.drawArc(x2 - d, y, d, d, 0, 45);
    g2D.setColor(c2m);
    g2D.drawArc(x2 - d, y, d, d, -45, 45);
    g2D.setColor(c2);
    g2D.drawArc(x2 - d, y, d, d, -90, 45);
    g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, savedRederingHint);
  }
Пример #15
0
 public void paint(Graphics g, JComponent c) {
   boolean horizontal = true;
   if (c instanceof JSeparator) {
     horizontal = (((JSeparator) c).getOrientation() == JSeparator.HORIZONTAL);
   }
   if (horizontal) {
     int w = c.getWidth();
     g.setColor(AbstractLookAndFeel.getBackgroundColor());
     g.drawLine(0, 0, w, 0);
     g.setColor(ColorHelper.darker(AbstractLookAndFeel.getBackgroundColor(), 30));
     g.drawLine(0, 1, w, 1);
     g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getBackgroundColor(), 50));
     g.drawLine(0, 2, w, 2);
   } else {
     int h = c.getHeight();
     g.setColor(ColorHelper.darker(AbstractLookAndFeel.getBackgroundColor(), 30));
     g.drawLine(0, 0, 0, h);
     g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getBackgroundColor(), 50));
     g.drawLine(1, 0, 1, h);
   }
 }
Пример #16
0
 protected Color[] getTabColors(int tabIndex, boolean isSelected) {
   if ((tabIndex >= 0) && (tabIndex < tabPane.getTabCount())) {
     boolean isEnabled = tabPane.isEnabledAt(tabIndex);
     Color backColor = tabPane.getBackgroundAt(tabIndex);
     Color colorArr[] = AbstractLookAndFeel.getTheme().getTabColors();
     if ((backColor instanceof UIResource)) {
       if (isSelected) {
         colorArr = AbstractLookAndFeel.getTheme().getDefaultColors();
       } else if (tabIndex == rolloverIndex && isEnabled) {
         colorArr = AbstractLookAndFeel.getTheme().getRolloverColors();
       } else {
         colorArr = AbstractLookAndFeel.getTheme().getTabColors();
       }
     } else {
       if (isSelected) {
         if (tabPane.getTabPlacement() == BOTTOM) {
           colorArr =
               ColorHelper.createColorArr(backColor, ColorHelper.brighter(backColor, 50), 20);
         } else {
           colorArr =
               ColorHelper.createColorArr(ColorHelper.brighter(backColor, 50), backColor, 20);
         }
       } else {
         if (tabIndex == rolloverIndex && isEnabled) {
           colorArr =
               ColorHelper.createColorArr(
                   ColorHelper.brighter(backColor, 80), ColorHelper.brighter(backColor, 20), 20);
         } else {
           colorArr =
               ColorHelper.createColorArr(
                   ColorHelper.brighter(backColor, 40), ColorHelper.darker(backColor, 10), 20);
         }
       }
     }
     return colorArr;
   }
   return AbstractLookAndFeel.getTheme().getTabColors();
 }
Пример #17
0
 public void paintText(Graphics g, int x, int y, String title) {
   x += paintIcon(g, x, y);
   Graphics2D g2D = (Graphics2D) g;
   Color fc = AbstractLookAndFeel.getWindowTitleForegroundColor();
   if (fc.equals(Color.white)) {
     Color bc = AbstractLookAndFeel.getWindowTitleColorDark();
     g2D.setColor(bc);
     JTattooUtilities.drawString(rootPane, g, title, x - 1, y - 1);
     g2D.setColor(ColorHelper.darker(bc, 30));
     JTattooUtilities.drawString(rootPane, g, title, x + 1, y + 1);
   }
   g.setColor(fc);
   JTattooUtilities.drawString(rootPane, g, title, x, y);
 }
Пример #18
0
 protected void paintRoundedBottomTabBorder(
     int tabIndex, Graphics g, int x1, int y1, int x2, int y2, boolean isSelected) {
   Graphics2D g2D = (Graphics2D) g;
   Object savedRederingHint = g2D.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
   g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   int d = 2 * GAP;
   if (isSelected) {
     g.setColor(AbstractLookAndFeel.getTheme().getFrameColor());
   } else {
     g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getTheme().getFrameColor(), 40));
   }
   g.drawLine(x1 + GAP, y2, x2 - GAP, y2);
   g.drawArc(x1, y2 - d, d, d, 180, 90);
   g.drawArc(x2 - d, y2 - d, d, d, -90, 90);
   g.drawLine(x1, y1, x1, y2 - GAP - 1);
   g.drawLine(x2, y1, x2, y2 - GAP - 1);
   g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, savedRederingHint);
 }
Пример #19
0
  protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) {
    ButtonModel model = b.getModel();
    FontMetrics fm = JTattooUtilities.getFontMetrics(b, g, b.getFont());
    int mnemIndex;
    if (JTattooUtilities.getJavaVersion() >= 1.4) {
      mnemIndex = b.getDisplayedMnemonicIndex();
    } else {
      mnemIndex = JTattooUtilities.findDisplayedMnemonicIndex(b.getText(), model.getMnemonic());
    }
    int offs = 0;
    if (model.isArmed() && model.isPressed()) {
      offs = 1;
    }

    Graphics2D g2D = (Graphics2D) g;
    Composite composite = g2D.getComposite();
    AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f);
    g2D.setComposite(alpha);
    Color foreground = b.getForeground();
    Color background = b.getBackground();
    if (background instanceof ColorUIResource) {
      if (model.isPressed() && model.isArmed()) {
        foreground = AbstractLookAndFeel.getTheme().getSelectionForegroundColor();
      } else if (model.isRollover()) {
        foreground = AbstractLookAndFeel.getTheme().getRolloverForegroundColor();
      }
    }
    if (!model.isEnabled()) {
      foreground = AbstractLookAndFeel.getTheme().getDisabledForegroundColor();
    }
    if (ColorHelper.getGrayValue(foreground) > 64) {
      g2D.setColor(Color.black);
    } else {
      g2D.setColor(Color.white);
    }
    JTattooUtilities.drawStringUnderlineCharAt(
        b, g, text, mnemIndex, textRect.x + offs + 1, textRect.y + offs + fm.getAscent() + 1);
    g2D.setComposite(composite);
    g2D.setColor(foreground);
    JTattooUtilities.drawStringUnderlineCharAt(
        b, g, text, mnemIndex, textRect.x + offs, textRect.y + offs + fm.getAscent());
  }
Пример #20
0
 protected void paintText(Graphics g, JComponent c, String text, Rectangle textRect) {
   View v = (View) c.getClientProperty(BasicHTML.propertyKey);
   if (v != null) {
     v.paint(g, textRect);
   } else {
     AbstractButton b = (AbstractButton) c;
     ButtonModel model = b.getModel();
     int mnemIndex = -1;
     if (JTattooUtilities.getJavaVersion() >= 1.4) {
       mnemIndex = b.getDisplayedMnemonicIndex();
     } else {
       mnemIndex = JTattooUtilities.findDisplayedMnemonicIndex(b.getText(), model.getMnemonic());
     }
     Font f = c.getFont();
     g.setFont(f);
     FontMetrics fm = g.getFontMetrics();
     if (model.isEnabled()) {
       Color fc = b.getForeground();
       if (AbstractLookAndFeel.getTheme().isTextShadowOn() && ColorHelper.getGrayValue(fc) > 128) {
         g.setColor(Color.black);
         JTattooUtilities.drawStringUnderlineCharAt(
             c, g, text, mnemIndex, textRect.x + 1, textRect.y + 1 + fm.getAscent());
       }
       g.setColor(fc);
       JTattooUtilities.drawStringUnderlineCharAt(
           c, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent());
     } else {
       g.setColor(Color.black);
       JTattooUtilities.drawStringUnderlineCharAt(
           c, g, text, mnemIndex, textRect.x + 1, textRect.y + 1 + fm.getAscent());
       g.setColor(AbstractLookAndFeel.getDisabledForegroundColor());
       JTattooUtilities.drawStringUnderlineCharAt(
           c, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent());
     }
   }
 }
Пример #21
0
  public void paintTrack(Graphics g) {
    boolean leftToRight = JTattooUtilities.isLeftToRight(slider);

    g.translate(trackRect.x, trackRect.y);
    int overhang = 4;
    int trackLeft = 0;
    int trackTop = 0;
    int trackRight = 0;
    int trackBottom = 0;

    if (slider.getOrientation() == JSlider.HORIZONTAL) {
      trackBottom = (trackRect.height - 1) - overhang;
      trackTop = trackBottom - (getTrackWidth() - 1);
      trackRight = trackRect.width - 1;
    } else {
      if (leftToRight) {
        trackLeft = (trackRect.width - overhang) - getTrackWidth();
        trackRight = (trackRect.width - overhang) - 1;
      } else {
        trackLeft = overhang;
        trackRight = overhang + getTrackWidth() - 1;
      }
      trackBottom = trackRect.height - 1;
    }

    g.setColor(AbstractLookAndFeel.getFrameColor());
    g.drawRect(trackLeft, trackTop, (trackRight - trackLeft) - 1, (trackBottom - trackTop) - 1);

    int middleOfThumb = 0;
    int fillTop = 0;
    int fillLeft = 0;
    int fillBottom = 0;
    int fillRight = 0;

    if (slider.getOrientation() == JSlider.HORIZONTAL) {
      middleOfThumb = thumbRect.x + (thumbRect.width / 2);
      middleOfThumb -= trackRect.x;
      fillTop = trackTop + 1;
      fillBottom = trackBottom - 2;

      if (!drawInverted()) {
        fillLeft = trackLeft + 1;
        fillRight = middleOfThumb;
      } else {
        fillLeft = middleOfThumb;
        fillRight = trackRight - 2;
      }
      Color colors[] = null;
      if (!JTattooUtilities.isActive(slider)) {
        colors = AbstractLookAndFeel.getTheme().getInActiveColors();
      } else {
        if (slider.isEnabled()) {
          colors = AbstractLookAndFeel.getTheme().getSliderColors();
        } else {
          colors = AbstractLookAndFeel.getTheme().getDisabledColors();
        }
      }
      JTattooUtilities.fillHorGradient(
          g, colors, fillLeft + 2, fillTop + 2, fillRight - fillLeft - 2, fillBottom - fillTop - 2);
      Color cHi = ColorHelper.darker(colors[colors.length - 1], 5);
      Color cLo = ColorHelper.darker(colors[colors.length - 1], 10);
      JTattooUtilities.draw3DBorder(
          g,
          cHi,
          cLo,
          fillLeft + 1,
          fillTop + 1,
          fillRight - fillLeft - 1,
          fillBottom - fillTop - 1);
    } else {
      middleOfThumb = thumbRect.y + (thumbRect.height / 2);
      middleOfThumb -= trackRect.y;
      fillLeft = trackLeft + 1;
      fillRight = trackRight - 2;

      if (!drawInverted()) {
        fillTop = middleOfThumb;
        fillBottom = trackBottom - 2;
      } else {
        fillTop = trackTop + 1;
        fillBottom = middleOfThumb;
      }
      Color colors[] = null;
      if (!JTattooUtilities.isActive(slider)) {
        colors = AbstractLookAndFeel.getTheme().getInActiveColors();
      } else {
        if (slider.isEnabled()) {
          colors = AbstractLookAndFeel.getTheme().getSliderColors();
        } else {
          colors = AbstractLookAndFeel.getTheme().getDisabledColors();
        }
      }
      JTattooUtilities.fillVerGradient(
          g, colors, fillLeft + 2, fillTop + 2, fillRight - fillLeft - 2, fillBottom - fillTop - 2);
      Color cHi = ColorHelper.darker(colors[colors.length - 1], 5);
      Color cLo = ColorHelper.darker(colors[colors.length - 1], 10);
      JTattooUtilities.draw3DBorder(
          g,
          cHi,
          cLo,
          fillLeft + 1,
          fillTop + 1,
          fillRight - fillLeft - 1,
          fillBottom - fillTop - 1);
    }
    g.translate(-trackRect.x, -trackRect.y);
  }
Пример #22
0
    public void paintIcon(Component c, Graphics g, int x, int y) {
      if (!JTattooUtilities.isLeftToRight(c)) {
        x += GAP;
      }
      int w = getIconWidth() - GAP;
      int h = getIconHeight();
      AbstractButton button = (AbstractButton) c;
      ButtonModel model = button.getModel();
      Graphics2D g2D = (Graphics2D) g;
      if (button.isEnabled()) {
        if ((button.isRolloverEnabled() && model.isRollover())) {
          JTattooUtilities.fillHorGradient(
              g, AbstractLookAndFeel.getTheme().getRolloverColors(), x + 1, y + 1, w - 1, h - 1);
        } else {
          if (AbstractLookAndFeel.getTheme().doShowFocusFrame() && button.hasFocus()) {
            JTattooUtilities.fillHorGradient(
                g, AbstractLookAndFeel.getTheme().getFocusColors(), x + 1, y + 1, w - 1, h - 1);
          } else {
            JTattooUtilities.fillHorGradient(
                g, AbstractLookAndFeel.getTheme().getCheckBoxColors(), x + 1, y + 1, w - 1, h - 1);
          }
        }
      } else {
        JTattooUtilities.fillHorGradient(
            g, AbstractLookAndFeel.getTheme().getDisabledColors(), x + 1, y + 1, w - 1, h - 1);
      }

      Color frameColor =
          ColorHelper.brighter(AbstractLookAndFeel.getTheme().getButtonBackgroundColor(), 6);
      Color loFrameColor =
          ColorHelper.darker(AbstractLookAndFeel.getTheme().getButtonBackgroundColor(), 50);

      g.setColor(frameColor);
      g.drawRect(x, y, w, h);
      Composite savedComposite = g2D.getComposite();
      AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
      g2D.setComposite(alpha);
      g.setColor(loFrameColor);
      g.drawLine(x + 1, y + 1, x + w - 1, y + 1);
      g.drawLine(x + 1, y + 1, x + 1, y + h - 1);
      g2D.setComposite(savedComposite);

      Icon checkIcon;
      Icon checkDisabledIcon;
      Icon checkInverseIcon;
      if (AbstractLookAndFeel.getTheme().isSmallFontSize()) {
        checkIcon = SMALL_CHECK_ICON;
        checkDisabledIcon = SMALL_CHECK_DISABLED_ICON;
        checkInverseIcon = SMALL_CHECK_INVERSE_ICON;
      } else if (AbstractLookAndFeel.getTheme().isMediumFontSize()) {
        checkIcon = MEDIUM_CHECK_ICON;
        checkDisabledIcon = MEDIUM_CHECK_DISABLED_ICON;
        checkInverseIcon = MEDIUM_CHECK_INVERSE_ICON;
      } else {
        checkIcon = LARGE_CHECK_ICON;
        checkDisabledIcon = LARGE_CHECK_DISABLED_ICON;
        checkInverseIcon = LARGE_CHECK_INVERSE_ICON;
      }
      int xi = x + ((w - checkIcon.getIconWidth()) / 2) + 1;
      int yi = y + ((h - checkIcon.getIconHeight()) / 2);
      int gv = ColorHelper.getGrayValue(AbstractLookAndFeel.getButtonForegroundColor());
      if (model.isPressed() && model.isArmed()) {
        Color bc =
            gv > 128
                ? AbstractLookAndFeel.getTheme().getSelectionForegroundColor()
                : AbstractLookAndFeel.getTheme().getSelectionBackgroundColor();
        Color fc = gv > 128 ? ColorHelper.brighter(bc, 20) : ColorHelper.darker(bc, 40);
        g.setColor(fc);
        g.drawRect(x + 4, y + 4, w - 8, h - 8);
        g.setColor(bc);
        g.fillRect(x + 5, y + 5, w - 9, h - 9);
      } else if (model.isSelected()) {
        if (!model.isEnabled()) {
          checkDisabledIcon.paintIcon(c, g, xi + 1, yi);
        } else {
          if (gv > 128) {
            checkIcon.paintIcon(c, g, xi, yi);
          } else {
            checkInverseIcon.paintIcon(c, g, xi + 1, yi + 1);
          }
        }
      }
    }
Пример #23
0
    public void paintIcon(Component c, Graphics g, int x, int y) {
      if (!JTattooUtilities.isLeftToRight(c)) {
        x += GAP;
      }
      int w = getIconWidth() - GAP;
      int h = getIconHeight();

      Graphics2D g2D = (Graphics2D) g;
      AbstractButton button = (AbstractButton) c;
      ButtonModel model = button.getModel();
      Color colors[];
      if (button.isEnabled()) {
        if ((button.isRolloverEnabled() && model.isRollover())
            || (model.isPressed() && model.isArmed())) {
          colors = AbstractLookAndFeel.getTheme().getRolloverColors();
        } else {
          if (AbstractLookAndFeel.getTheme().doShowFocusFrame() && button.hasFocus()) {
            colors = AbstractLookAndFeel.getTheme().getFocusColors();
          } else {
            colors = AbstractLookAndFeel.getTheme().getCheckBoxColors();
          }
        }
      } else {
        colors = AbstractLookAndFeel.getTheme().getDisabledColors();
      }

      Color frameColor =
          ColorHelper.brighter(AbstractLookAndFeel.getTheme().getButtonBackgroundColor(), 6);
      Shape savedClip = g.getClip();
      Area clipArea = new Area(new Ellipse2D.Double(x, y, w + 1, h + 1));
      if (savedClip != null) {
        clipArea.intersect(new Area(savedClip));
      }
      g2D.setClip(clipArea);
      JTattooUtilities.fillHorGradient(g, colors, x, y, w, h);
      g2D.setClip(savedClip);

      Object savedRederingHint = g2D.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
      g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      g.setColor(frameColor);
      g.drawOval(x, y, w, h);

      if (model.isSelected()) {
        if (model.isEnabled()) {
          Color fc = AbstractLookAndFeel.getForegroundColor();
          if (ColorHelper.getGrayValue(colors[0]) < 128) {
            if (ColorHelper.getGrayValue(fc) < 128) {
              g2D.setColor(Color.white);
            } else {
              g2D.setColor(fc);
            }
          } else {
            if (ColorHelper.getGrayValue(fc) > 128) {
              g2D.setColor(Color.black);
            } else {
              g2D.setColor(fc);
            }
          }
        } else {
          g.setColor(AbstractLookAndFeel.getDisabledForegroundColor());
        }
        if (AbstractLookAndFeel.getTheme().isSmallFontSize()) {
          g2D.fillOval(x + 4, y + 4, w - 7, h - 7);
        } else if (AbstractLookAndFeel.getTheme().isMediumFontSize()) {
          g2D.fillOval(x + 4, y + 4, w - 7, h - 7);
        } else {
          g2D.fillOval(x + 5, y + 5, w - 9, h - 9);
        }
      }
      g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, savedRederingHint);
    }
Пример #24
0
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
      Graphics2D g2D = (Graphics2D) g;
      Composite savedComposite = g2D.getComposite();
      AlphaComposite alpha =
          AlphaComposite.getInstance(
              AlphaComposite.SRC_OVER, AbstractLookAndFeel.getTheme().getMenuAlpha());
      g2D.setComposite(alpha);
      Color logoColor = AbstractLookAndFeel.getTheme().getMenuSelectionBackgroundColor();
      Color borderColorLo = AbstractLookAndFeel.getFrameColor();
      Color borderColorHi =
          ColorHelper.brighter(AbstractLookAndFeel.getMenuSelectionBackgroundColor(), 40);
      g.setColor(logoColor);
      if (JTattooUtilities.isLeftToRight(c)) {
        int dx = getBorderInsets(c).left;
        g.fillRect(x, y, dx - 1, h - 1 - shadowSize);
        paintLogo(c, g, x, y, w, h);
        // - highlight
        g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getMenuBackgroundColor(), 40));
        g.drawLine(x + dx, y + 1, x + w - shadowSize - 2, y + 1);
        g.setColor(borderColorHi);
        g.drawLine(x + 1, y, x + 1, y + h - shadowSize - 2);
        // - outer frame
        g.setColor(borderColorLo);
        if (isMenuBarPopup(c)) {
          // top
          g.drawLine(x + dx - 1, y, x + w - shadowSize - 1, y);
          // left
          g.drawLine(x, y, x, y + h - shadowSize - 1);
          // bottom
          g.drawLine(x, y + h - shadowSize - 1, x + w - shadowSize - 1, y + h - shadowSize - 1);
          // right
          g.drawLine(x + w - shadowSize - 1, y + 1, x + w - shadowSize - 1, y + h - shadowSize - 1);
        } else {
          g.drawRect(x, y, w - shadowSize - 1, h - shadowSize - 1);
        }
        // - logo separator
        g.drawLine(x + dx - 1, y + 1, x + dx - 1, y + h - shadowSize - 1);
      } else {
        int dx = getBorderInsets(c).right - shadowSize;
        g.fillRect(x + w - dx - shadowSize, y, dx - 1, h - 1 - shadowSize);
        paintLogo(c, g, x, y, w, h);
        // - highlight
        g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getMenuBackgroundColor(), 40));
        g.drawLine(x + 1, y + 1, x + w - dx - shadowSize - 1, y + 1);
        g.drawLine(x + 1, y + 1, x + 1, y + h - shadowSize - 2);
        // - outer frame
        g.setColor(borderColorLo);
        if (isMenuBarPopup(c)) {
          // top
          g.drawLine(x, y, x + w - dx - shadowSize, y);
          // left
          g.drawLine(x, y, x, y + h - shadowSize - 1);
          // bottom
          g.drawLine(x, y + h - shadowSize - 1, x + w - shadowSize - 1, y + h - shadowSize - 1);
          // right
          g.drawLine(x + w - shadowSize - 1, y, x + w - shadowSize - 1, y + h - shadowSize - 1);
        } else {
          g.drawRect(x, y, w - shadowSize - 1, h - shadowSize - 1);
        }
        // - logo separator
        g.drawLine(x + w - dx - shadowSize, y + 1, x + w - dx - shadowSize, y + h - shadowSize - 1);
      }

      // paint the shadow
      g2D.setColor(AbstractLookAndFeel.getTheme().getShadowColor());
      float alphaValue = 0.4f;
      for (int i = 0; i < shadowSize; i++) {
        alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alphaValue);
        g2D.setComposite(alpha);
        g.drawLine(
            x + w - shadowSize + i,
            y + shadowSize,
            x + w - shadowSize + i,
            y + h - shadowSize - 1 + i);
        g.drawLine(
            x + shadowSize, y + h - shadowSize + i, x + w - shadowSize + i, y + h - shadowSize + i);
        alphaValue -= (alphaValue / 2);
      }

      g2D.setComposite(savedComposite);
    }
Пример #25
0
  protected void paintDeterminate(Graphics g, JComponent c) {
    if (!(g instanceof Graphics2D)) {
      return;
    }

    Graphics2D g2D = (Graphics2D) g;
    Insets b = progressBar.getInsets(); // area for border
    int w = progressBar.getWidth() - (b.right + b.left);
    int h = progressBar.getHeight() - (b.top + b.bottom);

    // amount of progress to draw
    int amountFull = getAmountFull(b, w, h);
    Color colors[];
    if (progressBar.getForeground() instanceof UIResource) {
      if (!Utilities.isActive(c)) {
        colors = BaseLookAndFeel.getTheme().getInActiveColors();
      } else if (c.isEnabled()) {
        colors = BaseLookAndFeel.getTheme().getProgressBarColors();
      } else {
        colors = BaseLookAndFeel.getTheme().getDisabledColors();
      }
    } else {
      Color hiColor = ColorHelper.brighter(progressBar.getForeground(), 40);
      Color loColor = ColorHelper.darker(progressBar.getForeground(), 20);
      colors = ColorHelper.createColorArr(hiColor, loColor, 20);
    }
    Color cHi = ColorHelper.darker(colors[colors.length - 1], 5);
    Color cLo = ColorHelper.darker(colors[colors.length - 1], 10);
    if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
      if (Utilities.isLeftToRight(progressBar)) {
        Utilities.draw3DBorder(g, cHi, cLo, 1 + b.left, 2, amountFull - 2, h - 2);
        Utilities.fillHorGradient(g, colors, 2 + b.left, 3, amountFull - 4, h - 4);
      } else {
        Utilities.draw3DBorder(
            g,
            cHi,
            cLo,
            progressBar.getWidth() - amountFull - b.right + 2,
            2,
            amountFull - 2,
            h - 2);
        Utilities.fillHorGradient(
            g, colors, progressBar.getWidth() - amountFull - b.right + 3, 3, amountFull - 4, h - 4);
      }
    } else { // VERTICAL
      Utilities.draw3DBorder(g, cHi, cLo, 2, h - amountFull + 2, w - 2, amountFull - 2);
      Utilities.fillVerGradient(g, colors, 3, h - amountFull + 3, w - 4, amountFull - 4);
    }

    // Deal with possible text painting
    if (progressBar.isStringPainted()) {
      Object savedRenderingHint = null;
      if (BaseLookAndFeel.getTheme().isTextAntiAliasingOn()) {
        savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
        g2D.setRenderingHint(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            BaseLookAndFeel.getTheme().getTextAntiAliasingHint());
      }
      paintString(g, b.left, b.top, w, h, amountFull, b);
      if (BaseLookAndFeel.getTheme().isTextAntiAliasingOn()) {
        g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint);
      }
    }
  }
Пример #26
0
 /**
  * Gets the logo color lo.
  *
  * @return the logo color lo
  */
 public Color getLogoColorLo() {
   return ColorHelper.darker(
       AbstractLookAndFeel.getTheme().getMenuSelectionBackgroundColor(), 20);
 }
Пример #27
0
 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
   g.setColor(AbstractLookAndFeel.getTheme().getFrameColor());
   g.drawRect(x, y, w - 1, h - 1);
   g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getTheme().getBackgroundColor(), 50));
   g.drawRect(x + 1, y + 1, w - 3, h - 3);
 }
Пример #28
0
  protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
    if (!c.isEnabled()) {
      return;
    }

    g.translate(thumbBounds.x, thumbBounds.y);

    Color colors[] = getThumbColors();

    Color frameColorHi = ColorHelper.brighter(colors[1], 20);
    Color frameColorLo = ColorHelper.darker(colors[colors.length - 1], 10);

    Graphics2D g2D = (Graphics2D) g;
    Composite savedComposite = g2D.getComposite();
    if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
      JTattooUtilities.fillVerGradient(
          g, colors, 1, 1, thumbBounds.width - 1, thumbBounds.height - 1);
      JTattooUtilities.draw3DBorder(
          g,
          frameColorLo,
          ColorHelper.darker(frameColorLo, 15),
          0,
          0,
          thumbBounds.width,
          thumbBounds.height);

      g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f));
      g.setColor(frameColorHi);
      g.drawLine(1, 1, thumbBounds.width - 2, 1);
      g.drawLine(1, 1, 1, thumbBounds.height - 2);

      int dx = 5;
      int dy = thumbBounds.height / 2 - 3;
      int dw = thumbBounds.width - 11;

      Color c1 = Color.white;
      Color c2 = Color.darkGray;

      for (int i = 0; i < 4; i++) {
        g.setColor(c1);
        g.drawLine(dx, dy, dx + dw, dy);
        dy++;
        g.setColor(c2);
        g.drawLine(dx, dy, dx + dw, dy);
        dy++;
      }
      g2D.setComposite(savedComposite);
    } else { // HORIZONTAL
      JTattooUtilities.fillHorGradient(
          g, colors, 1, 1, thumbBounds.width - 1, thumbBounds.height - 1);
      JTattooUtilities.draw3DBorder(
          g,
          frameColorLo,
          ColorHelper.darker(frameColorLo, 10),
          0,
          0,
          thumbBounds.width,
          thumbBounds.height);

      g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f));
      g.setColor(frameColorHi);
      g.drawLine(1, 1, thumbBounds.width - 2, 1);
      g.drawLine(1, 1, 1, thumbBounds.height - 2);

      int dx = thumbBounds.width / 2 - 3;
      int dy = 5;
      int dh = thumbBounds.height - 11;

      Color c1 = Color.white;
      Color c2 = Color.darkGray;

      for (int i = 0; i < 4; i++) {
        g.setColor(c1);
        g.drawLine(dx, dy, dx, dy + dh);
        dx++;
        g.setColor(c2);
        g.drawLine(dx, dy, dx, dy + dh);
        dx++;
      }
    }
    g2D.setComposite(savedComposite);

    g.translate(-thumbBounds.x, -thumbBounds.y);
  }
Пример #29
0
 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
   Color frameColor = AbstractLookAndFeel.getTheme().getBackgroundColor();
   JTattooUtilities.draw3DBorder(
       g, ColorHelper.darker(frameColor, 20), ColorHelper.brighter(frameColor, 80), x, y, w, h);
 }
Пример #30
0
  protected void initComponentDefaults(UIDefaults table) {
    super.initComponentDefaults(table);

    BaseBorders.initDefaults();
    BaseIcons.initDefaults();

    Object textFieldBorder = getBorderFactory().getTextFieldBorder();
    Object comboBoxBorder = getBorderFactory().getComboBoxBorder();
    Object scrollPaneBorder = getBorderFactory().getScrollPaneBorder();
    Object tableScrollPaneBorder = getBorderFactory().getTableScrollPaneBorder();
    Object tabbedPaneBorder = getBorderFactory().getTabbedPaneBorder();
    Object buttonBorder = getBorderFactory().getButtonBorder();
    Object toggleButtonBorder = getBorderFactory().getToggleButtonBorder();
    Object titledBorderBorder =
        new UIDefaults.ProxyLazyValue(
            "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
            new Object[] {getFrameColor()});
    Object menuBarBorder = getBorderFactory().getMenuBarBorder();
    Object popupMenuBorder = getBorderFactory().getPopupMenuBorder();
    Object menuItemBorder = getBorderFactory().getMenuItemBorder();
    Object toolBarBorder = getBorderFactory().getToolBarBorder();
    Object progressBarBorder = getBorderFactory().getProgressBarBorder();
    Object toolTipBorder =
        new UIDefaults.ProxyLazyValue(
            "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
            new Object[] {getFrameColor()});
    Object focusCellHighlightBorder =
        new UIDefaults.ProxyLazyValue(
            "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
            new Object[] {getFocusCellColor()});
    Object optionPaneBorder = BorderFactory.createEmptyBorder(0, 0, 0, 0);
    Object optionPaneMessageAreaBorder = BorderFactory.createEmptyBorder(8, 8, 8, 8);
    Object optionPaneButtonAreaBorder = BorderFactory.createEmptyBorder(0, 8, 8, 8);
    Object windowBorder = getBorderFactory().getInternalFrameBorder();

    Color c = getBackgroundColor();
    ColorUIResource progressBarBackground = new ColorUIResource(ColorHelper.brighter(c, 20));

    // DEFAULTS TABLE
    Object[] defaults = {
      "controlTextFont", getControlTextFont(),
      "systemTextFont ", getSystemTextFont(),
      "userTextFont", getUserTextFont(),
      "menuTextFont", getMenuTextFont(),
      "windowTitleFont", getWindowTitleFont(),
      "subTextFont", getSubTextFont(),
      "Label.font", getUserTextFont(),
      "Label.background", getBackgroundColor(),
      "Label.foreground", getForegroundColor(),
      "Label.disabledText", getDisabledForegroundColor(),
      "Label.disabledShadow", getWhite(),
      // Text (Note: many are inherited)
      "TextField.border", textFieldBorder,
      "TextField.foreground", getInputForegroundColor(),
      "TextField.background", getInputBackgroundColor(),
      "TextField.disabledForeground", getDisabledForegroundColor(),
      "TextField.disabledBackground", getDisabledBackgroundColor(),
      "TextField.inactiveForeground", getDisabledForegroundColor(),
      "TextField.inactiveBackground", getDisabledBackgroundColor(),
      "TextArea.foreground", getInputForegroundColor(),
      "TextArea.background", getInputBackgroundColor(),
      "TextArea.disabledForeground", getDisabledForegroundColor(),
      "TextArea.disabledBackground", getDisabledBackgroundColor(),
      "TextArea.inactiveForeground", getDisabledForegroundColor(),
      "TextArea.inactiveBackground", getDisabledBackgroundColor(),
      "EditorPane.foreground", getInputForegroundColor(),
      "EditorPane.background", getInputBackgroundColor(),
      "EditorPane.disabledForeground", getDisabledForegroundColor(),
      "EditorPane.disabledBackground", getDisabledBackgroundColor(),
      "EditorPane.inactiveForeground", getDisabledForegroundColor(),
      "EditorPane.inactiveBackground", getDisabledBackgroundColor(),
      "FormattedTextField.border", textFieldBorder,
      "FormattedTextField.foreground", getInputForegroundColor(),
      "FormattedTextField.background", getInputBackgroundColor(),
      "FormattedTextField.disabledForeground", getDisabledForegroundColor(),
      "FormattedTextField.disabledBackground", getDisabledBackgroundColor(),
      "FormattedTextField.inactiveForeground", getDisabledForegroundColor(),
      "FormattedTextField.inactiveBackground", getDisabledBackgroundColor(),
      "PasswordField.border", textFieldBorder,
      "PasswordField.foreground", getInputForegroundColor(),
      "PasswordField.background", getInputBackgroundColor(),
      "PasswordField.disabledForeground", getDisabledForegroundColor(),
      "PasswordField.disabledBackground", getDisabledBackgroundColor(),
      "PasswordField.inactiveForeground", getDisabledForegroundColor(),
      "PasswordField.inactiveBackground", getDisabledBackgroundColor(),
      // Buttons
      "Button.background", getButtonBackgroundColor(),
      "Button.foreground", getButtonForegroundColor(),
      "Button.disabledText", getDisabledForegroundColor(),
      "Button.disabledShadow", getWhite(),
      "Button.select", getSelectionBackgroundColor(),
      "Button.border", buttonBorder,
      "Button.frame", getFrameColor(),
      "Button.focus", getFocusColor(),
      "Button.rolloverColor", getTheme().getRolloverColor(),
      "CheckBox.font", getUserTextFont(),
      "CheckBox.background", getBackgroundColor(),
      "CheckBox.foreground", getForegroundColor(),
      "CheckBox.disabledText", getDisabledForegroundColor(),
      "CheckBox.disabledShadow", getWhite(),
      "Checkbox.select", getSelectionBackgroundColor(),
      "CheckBox.focus", getFocusColor(),
      "CheckBox.icon", getIconFactory().getCheckBoxIcon(),
      "RadioButton.font", getUserTextFont(),
      "RadioButton.background", getBackgroundColor(),
      "RadioButton.foreground", getForegroundColor(),
      "RadioButton.disabledText", getDisabledForegroundColor(),
      "RadioButton.disabledShadow", getWhite(),
      "RadioButton.select", getSelectionBackgroundColor(),
      "RadioButton.icon", getIconFactory().getRadioButtonIcon(),
      "RadioButton.focus", getFocusColor(),
      "ToggleButton.background", getButtonBackgroundColor(),
      "ToggleButton.foreground", getButtonForegroundColor(),
      "ToggleButton.select", getSelectionBackgroundColor(),
      "ToggleButton.text", getButtonForegroundColor(),
      "ToggleButton.disabledText", getDisabledForegroundColor(),
      "ToggleButton.disabledShadow", getWhite(),
      "ToggleButton.disabledSelectedText", getDisabledForegroundColor(),
      "ToggleButton.disabledBackground", getButtonBackgroundColor(),
      "ToggleButton.disabledSelectedBackground", getSelectionBackgroundColor(),
      "ToggleButton.focus", getFocusColor(),
      "ToggleButton.border", toggleButtonBorder,
      // ToolTip
      "ToolTip.border", toolTipBorder,
      "ToolTip.foreground", getTooltipForegroundColor(),
      "ToolTip.background", getTooltipBackgroundColor(),
      // Slider
      "Slider.border", null,
      "Slider.foreground", getFrameColor(),
      "Slider.background", getBackgroundColor(),
      "Slider.focus", getFocusColor(),
      "Slider.focusInsets", new InsetsUIResource(0, 0, 0, 0),
      "Slider.trackWidth", new Integer(7),
      "Slider.majorTickLength", new Integer(6),
      // Progress Bar
      "ProgressBar.border", progressBarBorder,
      "ProgressBar.background", progressBarBackground,
      "ProgressBar.selectionForeground", getSelectionForegroundColor(),
      "ProgressBar.selectionBackground", getForegroundColor(),
      // Combo Box
      "ComboBox.border", comboBoxBorder,
      "ComboBox.background", getInputBackgroundColor(),
      "ComboBox.foreground", getInputForegroundColor(),
      "ComboBox.selectionBackground", getSelectionBackgroundColor(),
      "ComboBox.selectionForeground", getSelectionForegroundColor(),
      "ComboBox.selectionBorderColor", getFocusColor(),
      "ComboBox.disabledBackground", getDisabledBackgroundColor(),
      "ComboBox.disabledForeground", getDisabledForegroundColor(),
      "ComboBox.listBackground", getInputBackgroundColor(),
      "ComboBox.listForeground", getInputForegroundColor(),
      "ComboBox.font", getUserTextFont(),
      // Panel
      "Panel.foreground", getForegroundColor(),
      "Panel.background", getBackgroundColor(),
      "Panel.darkBackground", getTheme().getBackgroundColorDark(),
      "Panel.lightBackground", getTheme().getBackgroundColorLight(),
      "Panel.alterBackground", getTheme().getAlterBackgroundColor(),
      "Panel.font", getUserTextFont(),
      // RootPane
      "RootPane.frameBorder", windowBorder,
      "RootPane.plainDialogBorder", windowBorder,
      "RootPane.informationDialogBorder", windowBorder,
      "RootPane.errorDialogBorder", windowBorder,
      "RootPane.colorChooserDialogBorder", windowBorder,
      "RootPane.fileChooserDialogBorder", windowBorder,
      "RootPane.questionDialogBorder", windowBorder,
      "RootPane.warningDialogBorder", windowBorder,
      // InternalFrame
      "InternalFrame.border", getBorderFactory().getInternalFrameBorder(),
      "InternalFrame.font", getWindowTitleFont(),
      "InternalFrame.paletteBorder", getBorderFactory().getPaletteBorder(),
      "InternalFrame.paletteTitleHeight", new Integer(11),
      "InternalFrame.paletteCloseIcon", getIconFactory().getPaletteCloseIcon(),
      "InternalFrame.icon", getIconFactory().getMenuIcon(),
      "InternalFrame.iconifyIcon", getIconFactory().getIconIcon(),
      "InternalFrame.maximizeIcon", getIconFactory().getMaxIcon(),
      "InternalFrame.minimizeIcon", getIconFactory().getMinIcon(),
      "InternalFrame.closeIcon", getIconFactory().getCloseIcon(),

      // Titled Border
      "TitledBorder.titleColor", getForegroundColor(),
      "TitledBorder.border", titledBorderBorder,
      // List
      "List.focusCellHighlightBorder", focusCellHighlightBorder,
      "List.font", getUserTextFont(),
      "List.foreground", getInputForegroundColor(),
      "List.background", getInputBackgroundColor(),
      "List.selectionForeground", getSelectionForegroundColor(),
      "List.selectionBackground", getSelectionBackgroundColor(),
      "List.disabledForeground", getDisabledForegroundColor(),
      "List.disabledBackground", getDisabledBackgroundColor(),
      // ScrollBar
      "ScrollBar.background", getControlBackgroundColor(),
      "ScrollBar.highlight", getControlHighlightColor(),
      "ScrollBar.shadow", getControlShadowColor(),
      "ScrollBar.darkShadow", getControlDarkShadowColor(),
      "ScrollBar.thumb", getControlBackgroundColor(),
      "ScrollBar.thumbShadow", getControlShadowColor(),
      "ScrollBar.thumbHighlight", getControlHighlightColor(),
      "ScrollBar.width", new Integer(17),
      "ScrollBar.allowsAbsolutePositioning", Boolean.TRUE,
      // ScrollPane
      "ScrollPane.border", scrollPaneBorder,
      "ScrollPane.foreground", getForegroundColor(),
      "ScrollPane.background", getBackgroundColor(),
      // Viewport
      "Viewport.foreground", getForegroundColor(),
      "Viewport.background", getBackgroundColor(),
      "Viewport.font", getUserTextFont(),

      // Tabbed Pane
      "TabbedPane.boder", tabbedPaneBorder,
      "TabbedPane.background", getBackgroundColor(),
      "TabbedPane.tabAreaBackground", getTabAreaBackgroundColor(),
      "TabbedPane.unselectedBackground", getControlColorDark(),
      "TabbedPane.foreground", getControlForegroundColor(),
      "TabbedPane.selected", getBackgroundColor(),
      "TabbedPane.selectedForeground", getTabSelectionForegroundColor(),
      "TabbedPane.tabAreaInsets", new InsetsUIResource(5, 5, 5, 5),
      "TabbedPane.contentBorderInsets", new InsetsUIResource(0, 0, 0, 0),
      "TabbedPane.tabInsets", new InsetsUIResource(1, 6, 1, 6),
      "TabbedPane.focus", getFocusColor(),
      // TabbedPane ScrollButton
      "TabbedPane.selected", getButtonBackgroundColor(),
      "TabbedPane.shadow", new ColorUIResource(180, 180, 180),
      "TabbedPane.darkShadow", new ColorUIResource(120, 120, 120),
      "TabbedPane.highlight", new ColorUIResource(Color.white),
      // Tab Colors in Netbeans
      "tab_unsel_fill", getControlBackgroundColor(),
      "tab_sel_fill", getControlBackgroundColor(),
      // Table
      "Table.focusCellHighlightBorder", focusCellHighlightBorder,
      "Table.scrollPaneBorder", tableScrollPaneBorder,
      "Table.foreground", getInputForegroundColor(),
      "Table.background", getInputBackgroundColor(),
      "Table.gridColor", getGridColor(),
      "TableHeader.foreground", getControlForegroundColor(),
      "TableHeader.background", getBackgroundColor(),
      "TableHeader.cellBorder", getBorderFactory().getTableHeaderBorder(),
      // MenuBar
      "MenuBar.border", menuBarBorder,
      "MenuBar.foreground", getMenuForegroundColor(),
      "MenuBar.background", getMenuBackgroundColor(),
      // Menu
      "Menu.border", menuItemBorder,
      "Menu.borderPainted", Boolean.TRUE,
      "Menu.foreground", getMenuForegroundColor(),
      "Menu.background", getMenuBackgroundColor(),
      "Menu.selectionForeground", getMenuSelectionForegroundColor(),
      "Menu.selectionBackground", getMenuSelectionBackgroundColor(),
      "Menu.disabledForeground", getDisabledForegroundColor(),
      "Menu.acceleratorForeground", getMenuForegroundColor(),
      "Menu.acceleratorSelectionForeground", getMenuSelectionForegroundColor(),
      "Menu.arrowIcon", getIconFactory().getMenuArrowIcon(),
      // Popup Menu
      "PopupMenu.background", getMenuBackgroundColor(),
      "PopupMenu.border", popupMenuBorder,
      // Menu Item
      "MenuItem.border", menuItemBorder,
      "MenuItem.borderPainted", Boolean.TRUE,
      "MenuItem.foreground", getMenuForegroundColor(),
      "MenuItem.background", getMenuBackgroundColor(),
      "MenuItem.selectionForeground", getMenuSelectionForegroundColor(),
      "MenuItem.selectionBackground", getMenuSelectionBackgroundColor(),
      "MenuItem.disabledForeground", getDisabledForegroundColor(),
      "MenuItem.disabledShadow", getWhite(),
      "MenuItem.acceleratorForeground", getMenuForegroundColor(),
      "MenuItem.acceleratorSelectionForeground", getMenuSelectionForegroundColor(),
      "CheckBoxMenuItem.border", menuItemBorder,
      "CheckBoxMenuItem.borderPainted", Boolean.TRUE,
      "CheckBoxMenuItem.foreground", getMenuForegroundColor(),
      "CheckBoxMenuItem.background", getMenuBackgroundColor(),
      "CheckBoxMenuItem.selectionForeground", getMenuSelectionForegroundColor(),
      "CheckBoxMenuItem.selectionBackground", getMenuSelectionBackgroundColor(),
      "CheckBoxMenuItem.disabledForeground", getDisabledForegroundColor(),
      "CheckBoxMenuItem.disabledShadow", getWhite(),
      "CheckBoxMenuItem.acceleratorForeground", getMenuForegroundColor(),
      "CheckBoxMenuItem.acceleratorSelectionForeground", getMenuSelectionForegroundColor(),
      "CheckBoxMenuItem.checkIcon", getIconFactory().getMenuCheckBoxIcon(),
      "RadioButtonMenuItem.border", menuItemBorder,
      "RadioButtonMenuItem.borderPainted", Boolean.TRUE,
      "RadioButtonMenuItem.foreground", getMenuForegroundColor(),
      "RadioButtonMenuItem.background", getMenuBackgroundColor(),
      "RadioButtonMenuItem.selectionForeground", getMenuSelectionForegroundColor(),
      "RadioButtonMenuItem.selectionBackground", getMenuSelectionBackgroundColor(),
      "RadioButtonMenuItem.disabledForeground", getDisabledForegroundColor(),
      "RadioButtonMenuItem.disabledShadow", getWhite(),
      "RadioButtonMenuItem.acceleratorForeground", getMenuForegroundColor(),
      "RadioButtonMenuItem.acceleratorSelectionForeground", getMenuSelectionForegroundColor(),
      "RadioButtonMenuItem.checkIcon", getIconFactory().getMenuRadioButtonIcon(),
      // OptionPane.
      "OptionPane.errorIcon", getIconFactory().getOptionPaneErrorIcon(),
      "OptionPane.informationIcon", getIconFactory().getOptionPaneInformationIcon(),
      "OptionPane.warningIcon", getIconFactory().getOptionPaneWarningIcon(),
      "OptionPane.questionIcon", getIconFactory().getOptionPaneQuestionIcon(),
      "OptionPane.border", optionPaneBorder,
      "OptionPane.messageAreaBorder", optionPaneMessageAreaBorder,
      "OptionPane.buttonAreaBorder", optionPaneButtonAreaBorder,
      // File View
      "FileView.directoryIcon", getIconFactory().getTreeFolderIcon(),
      "FileView.fileIcon", getIconFactory().getTreeLeafIcon(),
      "FileView.computerIcon", getIconFactory().getTreeComputerIcon(),
      "FileView.hardDriveIcon", getIconFactory().getTreeHardDriveIcon(),
      "FileView.floppyDriveIcon", getIconFactory().getTreeFloppyDriveIcon(),
      // File Chooser
      "FileChooser.detailsViewIcon", getIconFactory().getFileChooserDetailViewIcon(),
      "FileChooser.homeFolderIcon", getIconFactory().getFileChooserHomeFolderIcon(),
      "FileChooser.listViewIcon", getIconFactory().getFileChooserListViewIcon(),
      "FileChooser.newFolderIcon", getIconFactory().getFileChooserNewFolderIcon(),
      "FileChooser.upFolderIcon", getIconFactory().getFileChooserUpFolderIcon(),
      // Separator
      "Separator.background", getBackgroundColor(),
      "Separator.foreground", getControlForegroundColor(),
      // SplitPane
      "SplitPane.centerOneTouchButtons", Boolean.TRUE,
      "SplitPane.dividerSize", new Integer(7),
      "SplitPane.border", BorderFactory.createEmptyBorder(),
      // Tree
      "Tree.background", getInputBackgroundColor(),
      "Tree.foreground", getInputForegroundColor(),
      "Tree.textForeground", getInputForegroundColor(),
      "Tree.textBackground", getInputBackgroundColor(),
      "Tree.openIcon", getIconFactory().getTreeFolderIcon(),
      "Tree.closedIcon", getIconFactory().getTreeFolderIcon(),
      "Tree.leafIcon", getIconFactory().getTreeLeafIcon(),
      "Tree.expandedIcon", getIconFactory().getTreeExpandedIcon(),
      "Tree.collapsedIcon", getIconFactory().getTreeCollapsedIcon(),
      "Tree.selectionBorderColor", getFocusCellColor(),
      "Tree.line", getFrameColor(), // horiz lines
      "Tree.hash", getFrameColor(), // legs

      // ToolBar
      "JToolBar.isRollover", Boolean.TRUE,
      "ToolBar.border", toolBarBorder,
      "ToolBar.background", getToolbarBackgroundColor(),
      "ToolBar.foreground", getToolbarForegroundColor(),
      "ToolBar.dockingBackground", getToolbarBackgroundColor(),
      "ToolBar.dockingForeground", getToolbarDockingColor(),
      "ToolBar.floatingBackground", getToolbarBackgroundColor(),
      "ToolBar.floatingForeground", getToolbarForegroundColor(),
    };
    table.putDefaults(defaults);

    if (JTattooUtilities.getJavaVersion() >= 1.5) {
      table.put("Spinner.font", getControlTextFont());
      table.put("Spinner.background", getButtonBackgroundColor());
      table.put("Spinner.foreground", getButtonForegroundColor());
      table.put("Spinner.border", getBorderFactory().getSpinnerBorder());
      table.put("Spinner.arrowButtonInsets", null);
      table.put("Spinner.arrowButtonBorder", BorderFactory.createEmptyBorder());
      table.put("Spinner.editorBorderPainted", Boolean.FALSE);
    }
  }