public void paintIcon(Component c,
Graphics g,
int x,
int y) {
boolean leftToRight = MetalUtils.isLeftToRight(c);
g.translate( x, y );
// Draw the frame
if ( c.hasFocus() ) {
g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
}
else {
g.setColor( c.isEnabled() ? MetalLookAndFeel.getPrimaryControlInfo() :
MetalLookAndFeel.getControlDarkShadow() );
}
if (leftToRight) {
g.drawLine( 1,0 , 8,0 ); // top
g.drawLine( 0,1 , 0,13 ); // left
g.drawLine( 1,14 , 8,14 ); // bottom
g.drawLine( 9,1 , 15,7 ); // top slant
g.drawLine( 9,13 , 15,7 ); // bottom slant
}
else {
g.drawLine( 7,0 , 14,0 ); // top
g.drawLine( 15,1 , 15,13 ); // right
g.drawLine( 7,14 , 14,14 ); // bottom
g.drawLine( 0,7 , 6,1 ); // top slant
g.drawLine( 0,7 , 6,13 ); // bottom slant
}
// Fill in the background
if ( c.hasFocus() ) {
g.setColor( c.getForeground() );
}
else {
g.setColor( MetalLookAndFeel.getControl() );
}
if (leftToRight) {
g.fillRect( 1,1 , 8,13 );
g.drawLine( 9,2 , 9,12 );
g.drawLine( 10,3 , 10,11 );
g.drawLine( 11,4 , 11,10 );
g.drawLine( 12,5 , 12,9 );
g.drawLine( 13,6 , 13,8 );
g.drawLine( 14,7 , 14,7 );
}
else {
g.fillRect( 7,1, 8,13 );
g.drawLine( 6,3 , 6,12 );
g.drawLine( 5,4 , 5,11 );
g.drawLine( 4,5 , 4,10 );
g.drawLine( 3,6 , 3,9 );
g.drawLine( 2,7 , 2,8 );
}
// Draw the bumps
int offset = (leftToRight) ? 2 : 8;
if ( c.isEnabled() ) {
if ( c.hasFocus() ) {
primaryBumps.paintIcon( c, g, offset, 2 );
}
else {
controlBumps.paintIcon( c, g, offset, 2 );
}
}
// Draw the highlight
if ( c.isEnabled() ) {
g.setColor( c.hasFocus() ? MetalLookAndFeel.getPrimaryControl()
: MetalLookAndFeel.getControlHighlight() );
if (leftToRight) {
g.drawLine( 1, 1, 8, 1 );
g.drawLine( 1, 1, 1, 13 );
}
else {
g.drawLine( 8,1 , 14,1 ); // top
g.drawLine( 1,7 , 7,1 ); // top slant
}
}
g.translate( -x, -y );
}
|