protected void paintToImage(Component c,
Image image,
Graphics g2,
int w,
int h,
Object[] args) {
Graphics2D g = (Graphics2D)g2;
boolean hasFocus = ((Boolean)args[0]).booleanValue();
boolean enabled = ((Boolean)args[1]).booleanValue();
// Fill in the background
Rectangle clip = g.getClipBounds();
g.clip(THUMB_SHAPE);
if (!enabled) {
g.setColor(MetalLookAndFeel.getControl());
g.fillRect(1, 1, 13, 14);
}
else if (hasFocus) {
MetalUtils.drawGradient(c, g, "Slider.focusGradient",
1, 1, 13, 14, true);
}
else {
MetalUtils.drawGradient(c, g, "Slider.gradient",
1, 1, 13, 14, true);
}
g.setClip(clip);
// Draw the frame
if (hasFocus) {
g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
}
else {
g.setColor(enabled ? MetalLookAndFeel.getPrimaryControlInfo() :
MetalLookAndFeel.getControlDarkShadow());
}
g.drawLine( 1,0 , 13,0 ); // top
g.drawLine( 0,1 , 0,8 ); // left
g.drawLine( 14,1 , 14,8 ); // right
g.drawLine( 1,9 , 7,15 ); // left slant
g.drawLine( 7,15 , 14,8 ); // right slant
if (hasFocus && enabled) {
// Inner line.
g.setColor(MetalLookAndFeel.getPrimaryControl());
g.fillRect(1, 1, 13, 1);
g.fillRect(1, 2, 1, 7);
g.fillRect(13, 2, 1, 7);
g.drawLine(2, 9, 7, 14);
g.drawLine(8, 13, 12, 9);
}
}
|