Ejemplo n.º 1
0
 protected void paintBackground(Graphics g) {
   int draggedColumn = -1;
   if ((header != null) && (header.getTable() != null) && header.getDraggedColumn() != null) {
     draggedColumn =
         header.getColumnModel().getColumnIndex(header.getDraggedColumn().getIdentifier());
   }
   int w = getWidth();
   int h = getHeight();
   if ((table != null) && table.isEnabled() && (col == rolloverCol || col == draggedColumn)) {
     JTattooUtilities.fillHorGradient(
         g, AbstractLookAndFeel.getTheme().getRolloverColors(), 0, 0, w, h);
     if (drawRolloverBar()) {
       g.setColor(AbstractLookAndFeel.getFocusColor());
       g.drawLine(0, 0, w - 1, 0);
       g.drawLine(0, 1, w - 1, 1);
       g.drawLine(0, 2, w - 1, 2);
     }
   } else if (drawAllwaysActive() || JTattooUtilities.isFrameActive(header)) {
     if (header.getBackground() instanceof ColorUIResource) {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getColHeaderColors(), 0, 0, w, h);
     } else {
       g.setColor(header.getBackground());
       g.fillRect(0, 0, w, h);
     }
   } else {
     if (header.getBackground() instanceof ColorUIResource) {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getInActiveColors(), 0, 0, w, h);
     } else {
       g.setColor(header.getBackground());
       g.fillRect(0, 0, w, h);
     }
   }
 }
Ejemplo n.º 2
0
  public void paintText(Graphics g, int x, int y, String title) {
    x += paintIcon(g, x, y);
    Graphics2D g2D = (Graphics2D) g;
    Shape savedClip = g2D.getClip();
    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);

    Area clipArea = new Area(new Rectangle2D.Double(x, 0, getWidth(), getHeight() / 2));
    clipArea.intersect(new Area(savedClip));
    g2D.setClip(clipArea);
    JTattooUtilities.drawString(rootPane, g, title, x, y);

    clipArea = new Area(new Rectangle2D.Double(x, (getHeight() / 2), getWidth(), getHeight()));
    clipArea.intersect(new Area(savedClip));
    g2D.setClip(clipArea);
    g.setColor(ColorHelper.darker(fc, 20));
    JTattooUtilities.drawString(rootPane, g, title, x, y);

    g2D.setClip(savedClip);
  }
Ejemplo n.º 3
0
 protected void paintEnabledText(JLabel l, Graphics g, String s, int textX, int textY) {
   int mnemIndex = -1;
   if (JTattooUtilities.getJavaVersion() >= 1.4) {
     mnemIndex = l.getDisplayedMnemonicIndex();
   } else {
     mnemIndex =
         JTattooUtilities.findDisplayedMnemonicIndex(l.getText(), l.getDisplayedMnemonic());
   }
   g.setColor(l.getForeground());
   JTattooUtilities.drawStringUnderlineCharAt(l, g, s, mnemIndex, textX, textY);
 }
Ejemplo n.º 4
0
 protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
   int w = c.getWidth();
   int h = c.getHeight();
   if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
     JTattooUtilities.fillVerGradient(
         g, AbstractLookAndFeel.getTheme().getTrackColors(), 0, 0, w, h);
   } else {
     JTattooUtilities.fillHorGradient(
         g, AbstractLookAndFeel.getTheme().getTrackColors(), 0, 0, w, h);
   }
 }
Ejemplo n.º 5
0
 protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) {
   int mnemIndex = -1;
   if (JTattooUtilities.getJavaVersion() >= 1.4) {
     mnemIndex = l.getDisplayedMnemonicIndex();
   } else {
     mnemIndex =
         JTattooUtilities.findDisplayedMnemonicIndex(l.getText(), l.getDisplayedMnemonic());
   }
   g.setColor(Color.white);
   JTattooUtilities.drawStringUnderlineCharAt(l, g, s, mnemIndex, textX + 1, textY + 1);
   g.setColor(AbstractLookAndFeel.getDisabledForegroundColor());
   JTattooUtilities.drawStringUnderlineCharAt(l, g, s, mnemIndex, textX, textY);
 }
Ejemplo n.º 6
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);
   }
 }
Ejemplo n.º 7
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);
 }
 protected void paintBackground(Graphics g, JComponent c, int x, int y, int w, int h) {
   JMenuItem b = (JMenuItem) c;
   ButtonModel model = b.getModel();
   if (model.isArmed() || (c instanceof JMenu && model.isSelected())) {
     JTattooUtilities.fillHorGradient(
         g, AbstractLookAndFeel.getTheme().getMenuSelectionColors(), x, y, w, h);
   } else if (!AbstractLookAndFeel.getTheme().isMenuOpaque()) {
     Graphics2D g2D = (Graphics2D) g;
     Composite composite = g2D.getComposite();
     AlphaComposite alpha =
         AlphaComposite.getInstance(
             AlphaComposite.SRC_OVER, AbstractLookAndFeel.getTheme().getMenuAlpha());
     g2D.setComposite(alpha);
     g.setColor(AbstractLookAndFeel.getMenuBackgroundColor());
     g.fillRect(x, y, w, h);
     g2D.setComposite(composite);
   } else {
     g.setColor(AbstractLookAndFeel.getMenuBackgroundColor());
     g.fillRect(x, y, w, h);
   }
   if (menuItem.isSelected() && menuItem.isArmed()) {
     g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor());
   } else {
     g.setColor(AbstractLookAndFeel.getMenuForegroundColor());
   }
 }
Ejemplo n.º 9
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());
 }
Ejemplo n.º 10
0
 public boolean isActive(Component c) {
   if (c instanceof JComponent) {
     return JTattooUtilities.isActive((JComponent) c);
   } else {
     return true;
   }
 }
Ejemplo n.º 11
0
 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
   if (((JToolBar) c).isFloatable()) {
     Graphics2D g2D = (Graphics2D) g;
     Composite savedComposite = g2D.getComposite();
     AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
     g2D.setComposite(alpha);
     if (((JToolBar) c).getOrientation() == HORIZONTAL) {
       if (!JTattooUtilities.isLeftToRight(c)) {
         x += w - 15;
       }
       g.setColor(Color.white);
       g.drawLine(x + 3, y + 4, x + 3, h - 5);
       g.drawLine(x + 6, y + 3, x + 6, h - 4);
       g.drawLine(x + 9, y + 4, x + 9, h - 5);
       g.setColor(shadow);
       g.drawLine(x + 4, y + 4, x + 4, h - 5);
       g.drawLine(x + 7, y + 3, x + 7, h - 4);
       g.drawLine(x + 10, y + 4, x + 10, h - 5);
     } else {
       // vertical
       g.setColor(Color.white);
       g.drawLine(x + 3, y + 3, w - 4, y + 3);
       g.drawLine(x + 3, y + 6, w - 4, y + 6);
       g.drawLine(x + 3, y + 9, w - 4, y + 9);
       g.setColor(shadow);
       g.drawLine(x + 3, y + 4, w - 4, y + 4);
       g.drawLine(x + 3, y + 7, w - 4, y + 7);
       g.drawLine(x + 3, y + 10, w - 4, y + 10);
     }
     g2D.setComposite(savedComposite);
   }
 }
Ejemplo n.º 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.getWindowBorderColor());
   } else {
     g.setColor(AbstractLookAndFeel.getWindowInactiveBorderColor());
   }
   g.drawRect(x, y, w - 1, h - 1);
 }
 public void paintText(Graphics g, int x, int y, String title) {
   Color shadowColor = AcrylLookAndFeel.getWindowTitleColorDark();
   if (isActive()) {
     shadowColor = ColorHelper.darker(shadowColor, 30);
   }
   g.setColor(shadowColor);
   JTattooUtilities.drawString(frame, g, title, x - 1, y - 1);
   JTattooUtilities.drawString(frame, g, title, x - 1, y + 1);
   JTattooUtilities.drawString(frame, g, title, x + 1, y - 1);
   JTattooUtilities.drawString(frame, g, title, x + 1, y + 1);
   if (isActive()) {
     g.setColor(AbstractLookAndFeel.getWindowTitleForegroundColor());
   } else {
     g.setColor(AbstractLookAndFeel.getWindowInactiveTitleForegroundColor());
   }
   JTattooUtilities.drawString(frame, g, title, x, y);
 }
 public void paintPalette(Graphics g) {
   if (JTattooUtilities.isFrameActive(this)) {
     g.setColor(AbstractLookAndFeel.getWindowTitleBackgroundColor());
   } else {
     g.setColor(AbstractLookAndFeel.getWindowInactiveTitleBackgroundColor());
   }
   g.fillRect(0, 0, getWidth(), getHeight());
 }
Ejemplo n.º 15
0
 // Workaround to avoid a bug in the java 1.3 VM
 static {
   try {
     if (JTattooUtilities.getJavaVersion() < 1.4) {
       UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
     }
   } catch (Exception ex) {
   }
 }
Ejemplo n.º 16
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);
        }
      }
    }
Ejemplo n.º 17
0
 protected Color[] getThumbColors() {
   if (isRollover || isDragging) {
     return AbstractLookAndFeel.getTheme().getRolloverColors();
   } else if (!JTattooUtilities.isActive(scrollbar)) {
     return AbstractLookAndFeel.getTheme().getInActiveColors();
   } else {
     return AbstractLookAndFeel.getTheme().getThumbColors();
   }
 }
Ejemplo n.º 18
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);
   }
 }
Ejemplo n.º 19
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, 0.8f);
   g2D.setComposite(alpha);
   Color cHi = AbstractLookAndFeel.getTheme().getControlHighlightColor();
   Color cLo = AbstractLookAndFeel.getTheme().getControlShadowColor();
   JTattooUtilities.draw3DBorder(g, cHi, cLo, x, y, w, h);
   g2D.setComposite(savedComposite);
 }
Ejemplo n.º 20
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());
  }
Ejemplo n.º 21
0
 protected void paintBackground(Graphics g, Rectangle cellRect, int col) {
   Component component = getHeaderRenderer(col);
   int x = cellRect.x;
   int y = cellRect.y;
   int w = cellRect.width;
   int h = cellRect.height;
   if (header.getBackground() instanceof ColorUIResource) {
     if ((col == rolloverCol) && (component != null) && component.isEnabled()) {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getRolloverColors(), x, y, w, h);
     } else if (drawAllwaysActive() || JTattooUtilities.isFrameActive(header)) {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getColHeaderColors(), x, y, w, h);
     } else {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getInActiveColors(), x, y, w, h);
     }
   } else {
     g.setColor(header.getBackground());
     g.fillRect(x, y, w, h);
   }
 }
Ejemplo n.º 22
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);
      }
    }
 public void paintBackground(Graphics g) {
   if (backgroundImage != null) {
     g.drawImage(backgroundImage, 0, 0, null);
   } else {
     BernsteinUtils.fillComponent(g, this);
   }
   Graphics2D g2D = (Graphics2D) g;
   Composite composite = g2D.getComposite();
   AlphaComposite alpha = null;
   if (backgroundImage != null) {
     alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alphaValue);
   } else {
     alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f);
   }
   g2D.setComposite(alpha);
   JTattooUtilities.fillHorGradient(
       g, AbstractLookAndFeel.getTheme().getDefaultColors(), 0, 0, getWidth(), getHeight());
   g2D.setComposite(composite);
 }
Ejemplo n.º 24
0
 public Insets getBorderInsets(Component c) {
   if (hasLogo(c)) {
     if (JTattooUtilities.isLeftToRight(c)) {
       return new Insets(
           leftLogoInsets.top,
           leftLogoInsets.left,
           leftLogoInsets.bottom + shadowSize,
           leftLogoInsets.right + shadowSize);
     } else {
       return new Insets(
           rightLogoInsets.top,
           rightLogoInsets.left,
           rightLogoInsets.bottom + shadowSize,
           rightLogoInsets.right + shadowSize);
     }
   } else {
     return new Insets(
         insets.top, insets.left, insets.bottom + shadowSize, insets.right + shadowSize);
   }
 }
    public void layoutDefault(Container c) {
      boolean leftToRight = JTattooUtilities.isLeftToRight(frame);

      int spacing = getHorSpacing();
      int w = getWidth();
      int h = getHeight();

      // assumes all buttons have the same dimensions these dimensions include the borders
      int buttonHeight = h - getVerSpacing();
      int buttonWidth = buttonHeight + 10;

      int x = leftToRight ? w - spacing : 0;
      int y = Math.max(0, ((h - buttonHeight) / 2) - 1);

      if (frame.isClosable()) {
        x += leftToRight ? -buttonWidth : spacing;
        closeButton.setBounds(x, y, buttonWidth, buttonHeight);
        if (!leftToRight) {
          x += buttonWidth;
        }
      }

      if (frame.isMaximizable() && !isPalette) {
        x += leftToRight ? -spacing - buttonWidth : spacing;
        maxButton.setBounds(x, y, buttonWidth, buttonHeight);
        if (!leftToRight) {
          x += buttonWidth;
        }
      }

      if (frame.isIconifiable() && !isPalette) {
        x += leftToRight ? -spacing - buttonWidth : spacing;
        iconButton.setBounds(x, y, buttonWidth, buttonHeight);
        if (!leftToRight) {
          x += buttonWidth;
        }
      }

      buttonsWidth = leftToRight ? w - x : x;
    }
Ejemplo n.º 26
0
 public Insets getBorderInsets(Component c) {
   Insets insets = new Insets(2, 2, 2, 2);
   if (((JToolBar) c).isFloatable()) {
     if (((JToolBar) c).getOrientation() == HORIZONTAL) {
       if (JTattooUtilities.isLeftToRight(c)) {
         insets.left = 15;
       } else {
         insets.right = 15;
       }
     } else {
       insets.top = 15;
     }
   }
   Insets margin = ((JToolBar) c).getMargin();
   if (margin != null) {
     insets.left += margin.left;
     insets.top += margin.top;
     insets.right += margin.right;
     insets.bottom += margin.bottom;
   }
   return insets;
 }
Ejemplo n.º 27
0
 public static void fillComponent(Graphics g, Component c, Icon texture) {
   int x = 0;
   int y = 0;
   int w = c.getWidth();
   int h = c.getHeight();
   if (texture != null) {
     int tw = texture.getIconWidth();
     int th = texture.getIconHeight();
     Point p = JTattooUtilities.getRelLocation(c);
     y = -p.y;
     while (y < h) {
       x = -p.x;
       while (x < w) {
         texture.paintIcon(c, g, x, y);
         x += tw;
       }
       y += th;
     }
   } else {
     g.setColor(c.getBackground());
     g.fillRect(x, y, w, h);
   }
 }
Ejemplo n.º 28
0
    public void paintLogo(Component c, Graphics g, int x, int y, int w, int h) {
      if (hasLogo(c)) {
        Graphics2D g2D = (Graphics2D) g;

        Font savedFont = g2D.getFont();
        g.setFont(logoFont);
        FontMetrics fm = JTattooUtilities.getFontMetrics((JComponent) c, g, c.getFont());
        String logo =
            JTattooUtilities.getClippedText(
                AbstractLookAndFeel.getTheme().getLogoString(), fm, h - 16);

        AffineTransform savedTransform = g2D.getTransform();

        Color fc = getLogoColorHi();
        Color bc = getLogoColorLo();

        if (JTattooUtilities.isLeftToRight(c)) {
          g2D.translate(fm.getAscent() + 1, h - shadowSize - 4);
          g2D.rotate(Math.toRadians(-90));
          g2D.setColor(bc);
          JTattooUtilities.drawString((JComponent) c, g, logo, 0, 1);
          g2D.setColor(fc);
          JTattooUtilities.drawString((JComponent) c, g, logo, 1, 0);
        } else {
          g2D.translate(w - shadowSize - 4, h - shadowSize - 4);
          g2D.rotate(Math.toRadians(-90));
          g2D.setColor(bc);
          JTattooUtilities.drawString((JComponent) c, g, logo, 0, 1);
          g2D.setColor(fc);
          JTattooUtilities.drawString((JComponent) c, g, logo, 1, 0);
        }

        g2D.setTransform(savedTransform);
        g2D.setFont(savedFont);
      }
    }
Ejemplo n.º 29
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());
     }
   }
 }
Ejemplo n.º 30
0
  public void paintTicks(Graphics g) {
    boolean leftToRight = JTattooUtilities.isLeftToRight(slider);
    Rectangle tickBounds = tickRect;
    g.setColor(slider.getForeground());
    if (slider.getOrientation() == JSlider.HORIZONTAL) {
      g.translate(0, tickBounds.y);

      int value = slider.getMinimum();
      int xPos = 0;

      if (slider.getMinorTickSpacing() > 0) {
        while (value <= slider.getMaximum()) {
          xPos = xPositionForValue(value);
          paintMinorTickForHorizSlider(g, tickBounds, xPos);
          value += slider.getMinorTickSpacing();
        }
      }

      if (slider.getMajorTickSpacing() > 0) {
        value = slider.getMinimum();
        while (value <= slider.getMaximum()) {
          xPos = xPositionForValue(value);
          paintMajorTickForHorizSlider(g, tickBounds, xPos);
          value += slider.getMajorTickSpacing();
        }
      }

      g.translate(0, -tickBounds.y);
    } else {
      g.translate(tickBounds.x, 0);

      int value = slider.getMinimum();
      int yPos = 0;

      if (slider.getMinorTickSpacing() > 0) {
        int offset = 0;
        if (!leftToRight) {
          offset = tickBounds.width - tickBounds.width / 2;
          g.translate(offset, 0);
        }

        while (value <= slider.getMaximum()) {
          yPos = yPositionForValue(value);
          paintMinorTickForVertSlider(g, tickBounds, yPos);
          value += slider.getMinorTickSpacing();
        }
        if (!leftToRight) {
          g.translate(-offset, 0);
        }
      }

      if (slider.getMajorTickSpacing() > 0) {
        value = slider.getMinimum();
        if (!leftToRight) {
          g.translate(2, 0);
        }

        while (value <= slider.getMaximum()) {
          yPos = yPositionForValue(value);
          paintMajorTickForVertSlider(g, tickBounds, yPos);
          value += slider.getMajorTickSpacing();
        }

        if (!leftToRight) {
          g.translate(-2, 0);
        }
      }
      g.translate(-tickBounds.x, 0);
    }
  }