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); } } }
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); }
protected Color[] getThumbColors() { if (isRollover || isDragging) { return AbstractLookAndFeel.getTheme().getRolloverColors(); } else if (!JTattooUtilities.isActive(scrollbar)) { return AbstractLookAndFeel.getTheme().getInActiveColors(); } else { return AbstractLookAndFeel.getTheme().getThumbColors(); } }
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); } }
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); }
public void paintThumb(Graphics g) { Icon icon = null; if (slider.getOrientation() == JSlider.HORIZONTAL) { if (isRollover && slider.isEnabled()) { icon = getThumbHorIconRollover(); } else { icon = getThumbHorIcon(); } } else { if (isRollover && slider.isEnabled()) { icon = getThumbVerIconRollover(); } else { icon = getThumbVerIcon(); } } Graphics2D g2D = (Graphics2D) g; Composite savedComposite = g2D.getComposite(); if (!slider.isEnabled()) { g.setColor(AbstractLookAndFeel.getBackgroundColor()); g.fillRect(thumbRect.x + 1, thumbRect.y + 1, thumbRect.width - 2, thumbRect.height - 2); AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f); g2D.setComposite(alpha); } icon.paintIcon(null, g, thumbRect.x, thumbRect.y); g2D.setComposite(savedComposite); }
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()); }
public void paintBackground(Graphics g, JComponent c) { if (c.isOpaque()) { if (c.getBackground() instanceof ColorUIResource) { g.setColor(AbstractLookAndFeel.getBackgroundColor()); } else { g.setColor(c.getBackground()); } g.fillRect(0, 0, c.getWidth(), c.getHeight()); } }
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); } }
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); } }
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); }
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); }
protected void layoutHScrollbar(JScrollBar sb) { if (AbstractLookAndFeel.getTheme().isLinuxStyleScrollBarOn()) { Dimension sbSize = sb.getSize(); Insets sbInsets = sb.getInsets(); int sizeW = sbSize.width - sbInsets.left - sbInsets.right; /* * Height and top edge of the buttons and thumb. */ int itemY = sbInsets.top; int itemH = sbSize.height - (sbInsets.top + sbInsets.bottom); // Math.min(itemW, sizeH / 2); int itemW = Math.min(itemH, sizeW / 2); // sbSize.width - (sbInsets.left + sbInsets.right); /* Nominal locations of the buttons, assuming their preferred * size will fit. */ int decrButtonX = sbSize.width - sbInsets.right - itemW - itemW + 1; int incrButtonX = sbSize.width - sbInsets.right - itemW; /* Compute the width and origin of the thumb. The case * where the thumb is at the right edge is handled specially * to avoid numerical problems in computing thumbX. Enforce * the thumbs min/max dimensions. If the thumb doesn't * fit in the track (trackW) we'll hide it later. */ float trackW = sbSize.width - sbInsets.left - sbInsets.right - itemH - itemH + 1; float min = sb.getMinimum(); float max = sb.getMaximum(); float extent = sb.getVisibleAmount(); float range = max - min; float value = sb.getValue(); int maxThumbW = getMaximumThumbSize().width; int minThumbW = getMinimumThumbSize().width; int thumbW = (range <= 0) ? maxThumbW : (int) (trackW * (extent / range)); thumbW = Math.max(thumbW, minThumbW); thumbW = Math.min(thumbW, maxThumbW); int thumbX = decrButtonX - thumbW; if (value < (max - extent)) { float thumbRange = trackW - thumbW; thumbX = (int) (0.5f + (thumbRange * ((value - min) / (range - extent)))); } /* If the thumb isn't going to fit, zero it's bounds. Otherwise * make sure it fits between the buttons. Note that setting the * thumbs bounds will cause a repaint. */ if (thumbW > trackW) { setThumbBounds(0, 0, 0, 0); } else { setThumbBounds(thumbX, itemY, thumbW, itemH); } decrButton.setBounds(decrButtonX, itemY, itemW, itemH); incrButton.setBounds(incrButtonX, itemY, itemW, itemH); /* Update the trackRect field. */ trackRect.setBounds(0, itemY, (int) trackW, itemH); } else { super.layoutHScrollbar(sb); } }
protected int getVerSpacing() { return AbstractLookAndFeel.getTheme().isMacStyleWindowDecorationOn() ? 3 : 0; }