/** * Paints the major ticks for a slider with a vertical orientation. * * @param g the graphics device. * @param tickBounds the tick bounds. * @param y the y value for the tick. */ protected void paintMajorTickForVertSlider(Graphics g, Rectangle tickBounds, int y) { // Note the incoming 'g' has a translation in place to get us to the // start of the tick rect already... if (slider.isEnabled()) g.setColor(slider.getForeground()); else g.setColor(MetalLookAndFeel.getControlShadow()); g.drawLine(TICK_BUFFER, y, TICK_BUFFER + tickLength, y); }
/* */ public void paintIndeterminate(Graphics paramGraphics, JComponent paramJComponent) /* */ { /* 143 */ super.paintIndeterminate(paramGraphics, paramJComponent); /* */ /* 145 */ if ((!this.progressBar.isBorderPainted()) || (!(paramGraphics instanceof Graphics2D))) { /* 146 */ return; /* */ } /* */ /* 149 */ Insets localInsets = this.progressBar.getInsets(); /* 150 */ int i = this.progressBar.getWidth() - (localInsets.left + localInsets.right); /* 151 */ int j = this.progressBar.getHeight() - (localInsets.top + localInsets.bottom); /* 152 */ int k = getAmountFull(localInsets, i, j); /* 153 */ boolean bool = MetalUtils.isLeftToRight(paramJComponent); /* */ /* 155 */ Rectangle localRectangle = null; /* 156 */ localRectangle = getBox(localRectangle); /* */ /* 161 */ int m = localInsets.left; /* 162 */ int n = localInsets.top; /* 163 */ int i1 = localInsets.left + i - 1; /* 164 */ int i2 = localInsets.top + j - 1; /* */ /* 166 */ Graphics2D localGraphics2D = (Graphics2D) paramGraphics; /* 167 */ localGraphics2D.setStroke(new BasicStroke(1.0F)); /* */ /* 169 */ if (this.progressBar.getOrientation() == 0) /* */ { /* 171 */ localGraphics2D.setColor(MetalLookAndFeel.getControlShadow()); /* 172 */ localGraphics2D.drawLine(m, n, i1, n); /* 173 */ localGraphics2D.drawLine(m, n, m, i2); /* */ /* 176 */ localGraphics2D.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow()); /* 177 */ localGraphics2D.drawLine( localRectangle.x, n, localRectangle.x + localRectangle.width - 1, n); /* */ } /* */ else /* */ { /* 181 */ localGraphics2D.setColor(MetalLookAndFeel.getControlShadow()); /* 182 */ localGraphics2D.drawLine(m, n, m, i2); /* 183 */ localGraphics2D.drawLine(m, n, i1, n); /* */ /* 186 */ localGraphics2D.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow()); /* 187 */ localGraphics2D.drawLine( m, localRectangle.y, m, localRectangle.y + localRectangle.height - 1); /* */ } /* */ }
/** This draws a variant "Flush 3D Border" It is used for things like pressed buttons. */ static void drawPressed3DBorder(Graphics g, int x, int y, int w, int h) { g.translate(x, y); drawFlush3DBorder(g, 0, 0, w, h); g.setColor(MetalLookAndFeel.getControlShadow()); g.drawLine(1, 1, 1, h - 2); g.drawLine(1, 1, w - 2, 1); g.translate(-x, -y); }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { Color background; Color highlight; Color shadow; Window window = SwingUtilities.getWindowAncestor(c); if (window != null && window.isActive()) { background = MetalLookAndFeel.getPrimaryControlDarkShadow(); highlight = MetalLookAndFeel.getPrimaryControlShadow(); shadow = MetalLookAndFeel.getPrimaryControlInfo(); } else { background = MetalLookAndFeel.getControlDarkShadow(); highlight = MetalLookAndFeel.getControlShadow(); shadow = MetalLookAndFeel.getControlInfo(); } g.setColor(background); // Draw outermost lines g.drawLine(x + 1, y + 0, x + w - 2, y + 0); g.drawLine(x + 0, y + 1, x + 0, y + h - 2); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 2); g.drawLine(x + 1, y + h - 1, x + w - 2, y + h - 1); // Draw the bulk of the border for (int i = 1; i < 5; i++) { g.drawRect(x + i, y + i, w - (i * 2) - 1, h - (i * 2) - 1); } if ((window instanceof Frame) && ((Frame) window).isResizable()) { g.setColor(highlight); // Draw the Long highlight lines g.drawLine(corner + 1, 3, w - corner, 3); g.drawLine(3, corner + 1, 3, h - corner); g.drawLine(w - 2, corner + 1, w - 2, h - corner); g.drawLine(corner + 1, h - 2, w - corner, h - 2); g.setColor(shadow); // Draw the Long shadow lines g.drawLine(corner, 2, w - corner - 1, 2); g.drawLine(2, corner, 2, h - corner - 1); g.drawLine(w - 3, corner, w - 3, h - corner - 1); g.drawLine(corner, h - 3, w - corner - 1, h - 3); } }
/** Paints the horizontal bars for the */ public void paintIcon(Component c, Graphics g, int x, int y) { JComponent component = (JComponent) c; int iconWidth = getIconWidth(); g.translate(x, y); g.setColor( component.isEnabled() ? MetalLookAndFeel.getControlInfo() : MetalLookAndFeel.getControlShadow()); g.drawLine(0, 0, iconWidth - 1, 0); g.drawLine(1, 1, 1 + (iconWidth - 3), 1); g.drawLine(2, 2, 2 + (iconWidth - 5), 2); g.drawLine(3, 3, 3 + (iconWidth - 7), 3); g.drawLine(4, 4, 4 + (iconWidth - 9), 4); g.translate(-x, -y); }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { Color background; Color highlight; Color shadow; if (c instanceof JInternalFrame && ((JInternalFrame) c).isSelected()) { background = MetalLookAndFeel.getPrimaryControlDarkShadow(); highlight = MetalLookAndFeel.getPrimaryControlShadow(); shadow = MetalLookAndFeel.getPrimaryControlInfo(); } else { background = MetalLookAndFeel.getControlDarkShadow(); highlight = MetalLookAndFeel.getControlShadow(); shadow = MetalLookAndFeel.getControlInfo(); } g.setColor(background); // Draw outermost lines g.drawLine(1, 0, w - 2, 0); g.drawLine(0, 1, 0, h - 2); g.drawLine(w - 1, 1, w - 1, h - 2); g.drawLine(1, h - 1, w - 2, h - 1); // Draw the bulk of the border for (int i = 1; i < 5; i++) { g.drawRect(x + i, y + i, w - (i * 2) - 1, h - (i * 2) - 1); } if (c instanceof JInternalFrame && ((JInternalFrame) c).isResizable()) { g.setColor(highlight); // Draw the Long highlight lines g.drawLine(corner + 1, 3, w - corner, 3); g.drawLine(3, corner + 1, 3, h - corner); g.drawLine(w - 2, corner + 1, w - 2, h - corner); g.drawLine(corner + 1, h - 2, w - corner, h - 2); g.setColor(shadow); // Draw the Long shadow lines g.drawLine(corner, 2, w - corner - 1, 2); g.drawLine(2, corner, 2, h - corner - 1); g.drawLine(w - 3, corner, w - 3, h - corner - 1); g.drawLine(corner, h - 3, w - corner - 1, h - 3); } }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { g.translate(x, y); if (MetalLookAndFeel.usingOcean()) { // Only paint a border if we're not next to a horizontal // toolbar if (!MetalToolBarUI.doesMenuBarBorderToolBar((JMenuBar) c)) { g.setColor(MetalLookAndFeel.getControl()); g.drawLine(0, h - 2, w, h - 2); g.setColor(UIManager.getColor("MenuBar.borderColor")); g.drawLine(0, h - 1, w, h - 1); } } else { g.setColor(MetalLookAndFeel.getControlShadow()); g.drawLine(0, h - 1, w, h - 1); } g.translate(-x, -y); }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { g.translate(x, y); if (MetalLookAndFeel.usingOcean()) { g.setColor(MetalLookAndFeel.getControlDarkShadow()); g.drawRect(0, 0, w, h - 1); g.setColor(MetalLookAndFeel.getControlShadow()); g.drawRect(1, 1, w - 2, h - 3); } else { g.setColor(MetalLookAndFeel.getControlDarkShadow()); g.drawLine(0, 0, w - 1, 0); g.drawLine(0, 0, 0, h - 2); g.drawLine(0, h - 2, w - 1, h - 2); g.setColor(MetalLookAndFeel.getControlHighlight()); g.drawLine(1, 1, w - 1, 1); g.drawLine(1, 1, 1, h - 1); g.drawLine(1, h - 1, w - 1, h - 1); g.setColor(MetalLookAndFeel.getControl()); g.drawLine(1, h - 2, 1, h - 2); } g.translate(-x, -y); }
public void paint(Graphics g) { boolean leftToRight = MetalUtils.isLeftToRight(this); boolean isEnabled = getParent().isEnabled(); Color arrowColor = isEnabled ? MetalLookAndFeel.getControlInfo() : MetalLookAndFeel.getControlDisabled(); boolean isPressed = getModel().isPressed(); int width = getWidth(); int height = getHeight(); int w = width; int h = height; int arrowHeight = (height + 1) / 4; int arrowWidth = (height + 1) / 2; if (isPressed) { g.setColor(MetalLookAndFeel.getControlShadow()); } else { g.setColor(getBackground()); } g.fillRect(0, 0, width, height); if (getDirection() == NORTH) { if (!isFreeStanding) { height += 1; g.translate(0, -1); width += 2; if (!leftToRight) { g.translate(-1, 0); } } // Draw the arrow g.setColor(arrowColor); int startY = ((h + 1) - arrowHeight) / 2; int startX = (w / 2); // System.out.println( "startX :" + startX + " startY :"+startY); for (int line = 0; line < arrowHeight; line++) { g.drawLine(startX - line, startY + line, startX + line + 1, startY + line); } /* g.drawLine( 7, 6, 8, 6 ); g.drawLine( 6, 7, 9, 7 ); g.drawLine( 5, 8, 10, 8 ); g.drawLine( 4, 9, 11, 9 );*/ if (isEnabled) { g.setColor(highlightColor); if (!isPressed) { g.drawLine(1, 1, width - 3, 1); g.drawLine(1, 1, 1, height - 1); } g.drawLine(width - 1, 1, width - 1, height - 1); g.setColor(shadowColor); g.drawLine(0, 0, width - 2, 0); g.drawLine(0, 0, 0, height - 1); g.drawLine(width - 2, 2, width - 2, height - 1); } else { MetalUtils.drawDisabledBorder(g, 0, 0, width, height + 1); } if (!isFreeStanding) { height -= 1; g.translate(0, 1); width -= 2; if (!leftToRight) { g.translate(1, 0); } } } else if (getDirection() == SOUTH) { if (!isFreeStanding) { height += 1; width += 2; if (!leftToRight) { g.translate(-1, 0); } } // Draw the arrow g.setColor(arrowColor); int startY = (((h + 1) - arrowHeight) / 2) + arrowHeight - 1; int startX = (w / 2); // System.out.println( "startX2 :" + startX + " startY2 :"+startY); for (int line = 0; line < arrowHeight; line++) { g.drawLine(startX - line, startY - line, startX + line + 1, startY - line); } /* g.drawLine( 4, 5, 11, 5 ); g.drawLine( 5, 6, 10, 6 ); g.drawLine( 6, 7, 9, 7 ); g.drawLine( 7, 8, 8, 8 ); */ if (isEnabled) { g.setColor(highlightColor); if (!isPressed) { g.drawLine(1, 0, width - 3, 0); g.drawLine(1, 0, 1, height - 3); } g.drawLine(1, height - 1, width - 1, height - 1); g.drawLine(width - 1, 0, width - 1, height - 1); g.setColor(shadowColor); g.drawLine(0, 0, 0, height - 2); g.drawLine(width - 2, 0, width - 2, height - 2); g.drawLine(2, height - 2, width - 2, height - 2); } else { MetalUtils.drawDisabledBorder(g, 0, -1, width, height + 1); } if (!isFreeStanding) { height -= 1; width -= 2; if (!leftToRight) { g.translate(1, 0); } } } else if (getDirection() == EAST) { if (!isFreeStanding) { height += 2; width += 1; } // Draw the arrow g.setColor(arrowColor); int startX = (((w + 1) - arrowHeight) / 2) + arrowHeight - 1; int startY = (h / 2); // System.out.println( "startX2 :" + startX + " startY2 :"+startY); for (int line = 0; line < arrowHeight; line++) { g.drawLine(startX - line, startY - line, startX - line, startY + line + 1); } /* g.drawLine( 5, 4, 5, 11 ); g.drawLine( 6, 5, 6, 10 ); g.drawLine( 7, 6, 7, 9 ); g.drawLine( 8, 7, 8, 8 );*/ if (isEnabled) { g.setColor(highlightColor); if (!isPressed) { g.drawLine(0, 1, width - 3, 1); g.drawLine(0, 1, 0, height - 3); } g.drawLine(width - 1, 1, width - 1, height - 1); g.drawLine(0, height - 1, width - 1, height - 1); g.setColor(shadowColor); g.drawLine(0, 0, width - 2, 0); g.drawLine(width - 2, 2, width - 2, height - 2); g.drawLine(0, height - 2, width - 2, height - 2); } else { MetalUtils.drawDisabledBorder(g, -1, 0, width + 1, height); } if (!isFreeStanding) { height -= 2; width -= 1; } } else if (getDirection() == WEST) { if (!isFreeStanding) { height += 2; width += 1; g.translate(-1, 0); } // Draw the arrow g.setColor(arrowColor); int startX = (((w + 1) - arrowHeight) / 2); int startY = (h / 2); for (int line = 0; line < arrowHeight; line++) { g.drawLine(startX + line, startY - line, startX + line, startY + line + 1); } /* g.drawLine( 6, 7, 6, 8 ); g.drawLine( 7, 6, 7, 9 ); g.drawLine( 8, 5, 8, 10 ); g.drawLine( 9, 4, 9, 11 );*/ if (isEnabled) { g.setColor(highlightColor); if (!isPressed) { g.drawLine(1, 1, width - 1, 1); g.drawLine(1, 1, 1, height - 3); } g.drawLine(1, height - 1, width - 1, height - 1); g.setColor(shadowColor); g.drawLine(0, 0, width - 1, 0); g.drawLine(0, 0, 0, height - 2); g.drawLine(2, height - 2, width - 1, height - 2); } else { MetalUtils.drawDisabledBorder(g, 0, 0, width + 1, height); } if (!isFreeStanding) { height -= 2; width -= 1; g.translate(1, 0); } } }
/* */ public void paintDeterminate(Graphics paramGraphics, JComponent paramJComponent) /* */ { /* 63 */ super.paintDeterminate(paramGraphics, paramJComponent); /* */ /* 65 */ if (!(paramGraphics instanceof Graphics2D)) { /* 66 */ return; /* */ } /* */ /* 69 */ if (this.progressBar.isBorderPainted()) { /* 70 */ Insets localInsets = this.progressBar.getInsets(); /* 71 */ int i = this.progressBar.getWidth() - (localInsets.left + localInsets.right); /* 72 */ int j = this.progressBar.getHeight() - (localInsets.top + localInsets.bottom); /* 73 */ int k = getAmountFull(localInsets, i, j); /* 74 */ boolean bool = MetalUtils.isLeftToRight(paramJComponent); /* */ /* 80 */ int m = localInsets.left; /* 81 */ int n = localInsets.top; /* 82 */ int i1 = localInsets.left + i - 1; /* 83 */ int i2 = localInsets.top + j - 1; /* */ /* 85 */ Graphics2D localGraphics2D = (Graphics2D) paramGraphics; /* 86 */ localGraphics2D.setStroke(new BasicStroke(1.0F)); /* */ /* 88 */ if (this.progressBar.getOrientation() == 0) /* */ { /* 90 */ localGraphics2D.setColor(MetalLookAndFeel.getControlShadow()); /* 91 */ localGraphics2D.drawLine(m, n, i1, n); /* */ /* 93 */ if (k > 0) /* */ { /* 95 */ localGraphics2D.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow()); /* */ /* 97 */ if (bool) { /* 98 */ localGraphics2D.drawLine(m, n, m + k - 1, n); /* */ } /* */ else { /* 101 */ localGraphics2D.drawLine(i1, n, i1 - k + 1, n); /* */ /* 103 */ if (this.progressBar.getPercentComplete() != 1.0D) { /* 104 */ localGraphics2D.setColor(MetalLookAndFeel.getControlShadow()); /* */ } /* */ } /* */ /* */ } /* */ /* 110 */ localGraphics2D.drawLine(m, n, m, i2); /* */ } /* */ else /* */ { /* 114 */ localGraphics2D.setColor(MetalLookAndFeel.getControlShadow()); /* 115 */ localGraphics2D.drawLine(m, n, m, i2); /* */ /* 117 */ if (k > 0) /* */ { /* 119 */ localGraphics2D.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow()); /* 120 */ localGraphics2D.drawLine(m, i2, m, i2 - k + 1); /* */ } /* */ /* 125 */ localGraphics2D.setColor(MetalLookAndFeel.getControlShadow()); /* */ /* 127 */ if (this.progressBar.getPercentComplete() == 1.0D) { /* 128 */ localGraphics2D.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow()); /* */ } /* 130 */ localGraphics2D.drawLine(m, n, i1, n); /* */ } /* */ } /* */ }
/** * Paints the track along which the thumb control moves. * * @param g the graphics device. */ public void paintTrack(Graphics g) { Color shadowColor = MetalLookAndFeel.getControlShadow(); if (slider.getOrientation() == JSlider.HORIZONTAL) { int trackX = trackRect.x; int trackY = trackRect.y + (trackRect.height - getTrackWidth()) / 2; int trackW = trackRect.width; int trackH = getTrackWidth(); // draw border if (slider.isEnabled()) BasicGraphicsUtils.drawEtchedRect( g, trackX, trackY, trackW, trackH, darkShadowColor, shadowColor, darkShadowColor, highlightColor); else { g.setColor(MetalLookAndFeel.getControlShadow()); g.drawRect(trackX, trackY, trackW - 2, trackH - 2); } // fill track (if required) if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme) { if (slider.isEnabled()) { int xPos = xPositionForValue(slider.getValue()); int x = slider.getInverted() ? xPos : trackRect.x; int w = slider.getInverted() ? trackX + trackW - xPos : xPos - trackRect.x; g.setColor(MetalLookAndFeel.getWhite()); g.drawLine(x + 1, trackY + 1, x + w - 3, trackY + 1); g.setColor(UIManager.getColor("Slider.altTrackColor")); g.drawLine(x + 1, trackY + 2, x + w - 3, trackY + 2); g.setColor(MetalLookAndFeel.getControlShadow()); g.drawLine(x + 1, trackY + 3, x + w - 3, trackY + 3); g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); g.drawLine(x + 1, trackY + 4, x + w - 3, trackY + 4); } } else if (filledSlider) { int xPos = xPositionForValue(slider.getValue()); int x = slider.getInverted() ? xPos : trackRect.x; int w = slider.getInverted() ? trackX + trackW - xPos : xPos - trackRect.x; g.setColor(MetalLookAndFeel.getControlShadow()); g.fillRect(x + 1, trackY + 1, w - 3, getTrackWidth() - 3); if (slider.isEnabled()) { g.setColor(MetalLookAndFeel.getControl()); g.drawLine(x + 1, trackY + 1, x + w - 3, trackY + 1); g.drawLine(x + 1, trackY + 1, x + 1, trackY + getTrackWidth() - 3); } } } else { int trackX = trackRect.x + (trackRect.width - getTrackWidth()) / 2; int trackY = trackRect.y; int trackW = getTrackWidth(); int trackH = trackRect.height; if (slider.isEnabled()) BasicGraphicsUtils.drawEtchedRect( g, trackX, trackY, trackW, trackH, darkShadowColor, shadowColor, darkShadowColor, highlightColor); else { g.setColor(MetalLookAndFeel.getControlShadow()); g.drawRect(trackX, trackY, trackW - 2, trackH - 2); } // Fill track if necessary. if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme) { if (slider.isEnabled()) { int yPos = yPositionForValue(slider.getValue()); int y = slider.getInverted() ? trackY : yPos; int h = slider.getInverted() ? yPos - trackY : trackY + trackH - yPos; g.setColor(MetalLookAndFeel.getWhite()); g.drawLine(trackX + 1, y + 1, trackX + 1, y + h - 3); g.setColor(UIManager.getColor("Slider.altTrackColor")); g.drawLine(trackX + 2, y + 1, trackX + 2, y + h - 3); g.setColor(MetalLookAndFeel.getControlShadow()); g.drawLine(trackX + 3, y + 1, trackX + 3, y + h - 3); g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); g.drawLine(trackX + 4, y + 1, trackX + 4, y + h - 3); } } else if (filledSlider) { int yPos = yPositionForValue(slider.getValue()); int y = slider.getInverted() ? trackY : yPos; int h = slider.getInverted() ? yPos - trackY : trackY + trackH - yPos; g.setColor(MetalLookAndFeel.getControlShadow()); g.fillRect(trackX + 1, y + 1, getTrackWidth() - 3, h - 3); if (slider.isEnabled()) { g.setColor(MetalLookAndFeel.getControl()); g.drawLine(trackX + 1, y + 1, trackX + trackW - 3, y + 1); g.drawLine(trackX + 1, y + 1, trackX + 1, y + h - 3); } } } }
protected Color getInactiveHighlight() { return MetalLookAndFeel.getControlShadow(); }
static void drawDisabledBorder(Graphics g, int x, int y, int w, int h) { g.translate(x, y); g.setColor(MetalLookAndFeel.getControlShadow()); g.drawRect(0, 0, w - 1, h - 1); g.translate(-x, -y); }