MetalUtilspublic class MetalUtils extends Object This is a dumping ground for random stuff we want to use in several places. |
Methods Summary |
---|
static void | drawActiveButtonBorder(java.awt.Graphics g, int x, int y, int w, int h)
drawFlush3DBorder(g, x, y, w, h);
g.setColor( MetalLookAndFeel.getPrimaryControl() );
g.drawLine( x+1, y+1, x+1, h-3 );
g.drawLine( x+1, y+1, w-3, x+1 );
g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );
g.drawLine( x+2, h-2, w-2, h-2 );
g.drawLine( w-2, y+2, w-2, h-2 );
| static void | drawButtonBorder(java.awt.Graphics g, int x, int y, int w, int h, boolean active)
if (active) {
drawActiveButtonBorder(g, x, y, w, h);
} else {
drawFlush3DBorder(g, x, y, w, h);
}
| static void | drawDark3DBorder(java.awt.Graphics g, java.awt.Rectangle r)This draws a variant "Flush 3D Border"
It is used for things like active toggle buttons.
This is used rarely.
drawDark3DBorder(g, r.x, r.y, r.width, r.height);
| static void | drawDark3DBorder(java.awt.Graphics g, int x, int y, int w, int h)This draws a variant "Flush 3D Border"
It is used for things like active toggle buttons.
This is used rarely.
g.translate( x, y);
drawFlush3DBorder(g, 0, 0, w, h);
g.setColor( MetalLookAndFeel.getControl() );
g.drawLine( 1, 1, 1, h-2 );
g.drawLine( 1, 1, w-2, 1 );
g.setColor( MetalLookAndFeel.getControlShadow() );
g.drawLine( 1, h-2, 1, h-2 );
g.drawLine( w-2, 1, w-2, 1 );
g.translate( -x, -y);
| static void | drawDefaultButtonBorder(java.awt.Graphics g, int x, int y, int w, int h, boolean active)
drawButtonBorder(g, x+1, y+1, w-1, h-1, active);
g.translate(x, y);
g.setColor( MetalLookAndFeel.getControlDarkShadow() );
g.drawRect( 0, 0, w-3, h-3 );
g.drawLine( w-2, 0, w-2, 0);
g.drawLine( 0, h-2, 0, h-2);
g.translate(-x, -y);
| static void | drawDefaultButtonPressedBorder(java.awt.Graphics g, int x, int y, int w, int h)
drawPressed3DBorder(g, x + 1, y + 1, w - 1, h - 1);
g.translate(x, y);
g.setColor(MetalLookAndFeel.getControlDarkShadow());
g.drawRect(0, 0, w - 3, h - 3);
g.drawLine(w - 2, 0, w - 2, 0);
g.drawLine(0, h - 2, 0, h - 2);
g.setColor(MetalLookAndFeel.getControl());
g.drawLine(w - 1, 0, w - 1, 0);
g.drawLine(0, h - 1, 0, h - 1);
g.translate(-x, -y);
| static void | drawDisabledBorder(java.awt.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);
| static void | drawFlush3DBorder(java.awt.Graphics g, java.awt.Rectangle r)
drawFlush3DBorder(g, r.x, r.y, r.width, r.height);
| static void | drawFlush3DBorder(java.awt.Graphics g, int x, int y, int w, int h)This draws the "Flush 3D Border" which is used throughout the Metal L&F
g.translate( x, y);
g.setColor( MetalLookAndFeel.getControlDarkShadow() );
g.drawRect( 0, 0, w-2, h-2 );
g.setColor( MetalLookAndFeel.getControlHighlight() );
g.drawRect( 1, 1, w-2, h-2 );
g.setColor( MetalLookAndFeel.getControl() );
g.drawLine( 0, h-1, 1, h-2 );
g.drawLine( w-1, 0, w-2, 1 );
g.translate( -x, -y);
| static boolean | drawGradient(java.awt.Component c, java.awt.Graphics g, java.lang.String key, int x, int y, int w, int h, boolean vertical)Draws a radial type gradient. The gradient will be drawn vertically if
vertical is true, otherwise horizontally.
The UIManager key consists of five values:
r1 r2 c1 c2 c3. The gradient is broken down into four chunks drawn
in order from the origin.
- Gradient r1 % of the size from c1 to c2
- Rectangle r2 % of the size in c2.
- Gradient r1 % of the size from c2 to c1
- The remaining size will be filled with a gradient from c1 to c3.
java.util.List gradient = (java.util.List)UIManager.get(key);
if (gradient == null || !(g instanceof Graphics2D)) {
return false;
}
if (w <= 0 || h <= 0) {
return true;
}
GradientPainter.INSTANCE.paint(
c, (Graphics2D)g, gradient, x, y, w, h, vertical);
return true;
| static void | drawPressed3DBorder(java.awt.Graphics g, java.awt.Rectangle r)This draws a variant "Flush 3D Border"
It is used for things like pressed buttons.
drawPressed3DBorder( g, r.x, r.y, r.width, r.height );
| static void | drawPressed3DBorder(java.awt.Graphics g, int x, int y, int w, int h)This draws a variant "Flush 3D Border"
It is used for things like pressed buttons.
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);
| static int | getInt(java.lang.Object key, int defaultValue)
Object value = UIManager.get(key);
if (value instanceof Integer) {
return ((Integer)value).intValue();
}
if (value instanceof String) {
try {
return Integer.parseInt((String)value);
} catch (NumberFormatException nfe) {}
}
return defaultValue;
| static javax.swing.Icon | getOceanDisabledButtonIcon(java.awt.Image image)
Object[] range = (Object[])UIManager.get("Button.disabledGrayRange");
int min = 180;
int max = 215;
if (range != null) {
min = ((Integer)range[0]).intValue();
max = ((Integer)range[1]).intValue();
}
ImageProducer prod = new FilteredImageSource(image.getSource(),
new OceanDisabledButtonImageFilter(min , max));
return new IconUIResource(new ImageIcon(
Toolkit.getDefaultToolkit().createImage(prod)));
| static javax.swing.Icon | getOceanToolBarIcon(java.awt.Image i)
ImageProducer prod = new FilteredImageSource(i.getSource(),
new OceanToolBarImageFilter());
return new IconUIResource(new ImageIcon(
Toolkit.getDefaultToolkit().createImage(prod)));
| static boolean | isLeftToRight(java.awt.Component c)
return c.getComponentOrientation().isLeftToRight();
| static boolean | isToolBarButton(javax.swing.JComponent c)Returns true if the specified widget is in a toolbar.
return (c.getParent() instanceof JToolBar);
|
|