|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.plaf.basic.BasicGraphicsUtils
public class BasicGraphicsUtils
A utility class providing commonly used drawing and measurement routines.
Constructor Summary | |
---|---|
BasicGraphicsUtils()
Constructor. |
Method Summary | |
---|---|
static void |
drawBezel(Graphics g,
int x,
int y,
int width,
int height,
boolean isPressed,
boolean isDefault,
Color shadow,
Color darkShadow,
Color highlight,
Color lightHighlight)
Draws a border that is suitable for buttons of the Basic look and feel. |
static void |
drawDashedRect(Graphics g,
int x,
int y,
int width,
int height)
Draws a rectangle, simulating a dotted stroke by painting only every second pixel along the one-pixel thick edge. |
static void |
drawEtchedRect(Graphics g,
int x,
int y,
int width,
int height,
Color shadow,
Color darkShadow,
Color highlight,
Color lightHighlight)
Draws a rectangle that appears etched into the surface, given four colors that are used for drawing. |
static void |
drawGroove(Graphics g,
int x,
int y,
int width,
int height,
Color shadow,
Color highlight)
Draws a rectangle that appears etched into the surface, given two colors that are used for drawing. |
static void |
drawLoweredBezel(Graphics g,
int x,
int y,
int width,
int height,
Color shadow,
Color darkShadow,
Color highlight,
Color lightHighlight)
Draws a rectangle that appears lowered into the surface, given four colors that are used for drawing. |
static void |
drawString(Graphics g,
String text,
int underlinedChar,
int x,
int y)
Draws a String at the given location, underlining the first occurence of a specified character. |
static void |
drawStringUnderlineCharAt(Graphics g,
String text,
int underlinedIndex,
int x,
int y)
Draws a String at the given location, underlining the character at the specified index. |
static Insets |
getEtchedInsets()
Determines the width of the border that gets painted by drawEtchedRect(java.awt.Graphics, int, int, int, int, java.awt.Color, java.awt.Color, java.awt.Color, java.awt.Color) . |
static Insets |
getGrooveInsets()
Determines the width of the border that gets painted by drawGroove(java.awt.Graphics, int, int, int, int, java.awt.Color, java.awt.Color) . |
static Dimension |
getPreferredButtonSize(AbstractButton b,
int textIconGap)
Determines the preferred width and height of an AbstractButton, given the gap between the button’s text and icon. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BasicGraphicsUtils()
Method Detail |
---|
public static void drawEtchedRect(Graphics g, int x, int y, int width, int height, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)
g
- the graphics into which the rectangle is drawn.x
- the x coordinate of the rectangle.y
- the y coordinate of the rectangle.width
- the width of the rectangle in pixels.height
- the height of the rectangle in pixels.shadow
- the color that will be used for painting
the outer side of the top and left edges.darkShadow
- the color that will be used for painting
the inner side of the top and left edges.highlight
- the color that will be used for painting
the inner side of the bottom and right edges.lightHighlight
- the color that will be used for painting
the outer side of the bottom and right edges.getEtchedInsets()
,
EtchedBorder
public static Insets getEtchedInsets()
drawEtchedRect(java.awt.Graphics, int, int, int, int, java.awt.Color, java.awt.Color, java.awt.Color, java.awt.Color)
.
Insets
object whose top
,
left
, bottom
and
right
field contain the border width at the
respective edge in pixels.public static void drawGroove(Graphics g, int x, int y, int width, int height, Color shadow, Color highlight)
g
- the graphics into which the rectangle is drawn.x
- the x coordinate of the rectangle.y
- the y coordinate of the rectangle.width
- the width of the rectangle in pixels.height
- the height of the rectangle in pixels.shadow
- the color that will be used for painting the outer
side of the top and left edges, and for the inner side of
the bottom and right ones.highlight
- the color that will be used for painting the
inner side of the top and left edges, and for the outer
side of the bottom and right ones.getGrooveInsets()
,
EtchedBorder
public static Insets getGrooveInsets()
drawGroove(java.awt.Graphics, int, int, int, int, java.awt.Color, java.awt.Color)
.
Insets
object whose top
,
left
, bottom
and
right
field contain the border width at the
respective edge in pixels.public static void drawBezel(Graphics g, int x, int y, int width, int height, boolean isPressed, boolean isDefault, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)
g
- the graphics into which the rectangle is drawn.x
- the x coordinate of the rectangle.y
- the y coordinate of the rectangle.width
- the width of the rectangle in pixels.height
- the height of the rectangle in pixels.isPressed
- true
to draw the button border
with a pressed-in appearance; false
for
normal (unpressed) appearance.isDefault
- true
to draw the border with
the appearance it has when hitting the enter key in a
dialog will simulate a click to this button;
false
for normal appearance.shadow
- the shadow color.darkShadow
- a darker variant of the shadow color.highlight
- the highlight color.lightHighlight
- a brighter variant of the highlight color.public static void drawLoweredBezel(Graphics g, int x, int y, int width, int height, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)
Compatibility with the Sun reference
implementation: The Sun reference implementation seems
to ignore the x
and y
arguments, at
least in JDK 1.3.1 and 1.4.1_01. The method always draws the
rectangular area at location (0, 0). A bug report has been filed
with Sun; its “bug ID” is 4880003. The GNU Classpath
implementation behaves correctly, thus not replicating this bug.
g
- the graphics into which the rectangle is drawn.x
- the x coordinate of the rectangle.y
- the y coordinate of the rectangle.width
- the width of the rectangle in pixels.height
- the height of the rectangle in pixels.shadow
- the color that will be used for painting
the inner side of the top and left edges.darkShadow
- the color that will be used for painting
the outer side of the top and left edges.highlight
- the color that will be used for painting
the inner side of the bottom and right edges.lightHighlight
- the color that will be used for painting
the outer side of the bottom and right edges.public static void drawString(Graphics g, String text, int underlinedChar, int x, int y)
text
, the text will be
drawn without underlining. Drawing is performed in the current
color and font of g
.
g
- the graphics into which the String is drawn.text
- the String to draw.underlinedChar
- the character whose first occurence in
text
will be underlined. It is not clear
why the API specification declares this argument to be
of type int
instead of char
.
While this would allow to pass Unicode characters outside
Basic Multilingual Plane 0 (U+0000 .. U+FFFE), at least
the GNU Classpath implementation does not underline
anything if underlinedChar
is outside
the range of char
.x
- the x coordinate of the text, as it would be passed to
Graphics.drawString(java.lang.String,
int, int)
.y
- the y coordinate of the text, as it would be passed to
Graphics.drawString(java.lang.String,
int, int)
.public static void drawStringUnderlineCharAt(Graphics g, String text, int underlinedIndex, int x, int y)
g
.
g
- the graphics into which the String is drawn.text
- the String to draw.underlinedIndex
- the index of the underlined character in
text
. If underlinedIndex
falls
outside the range [0, text.length() - 1]
, the
text will be drawn without underlining anything.x
- the x coordinate of the text, as it would be passed to
Graphics.drawString(java.lang.String,
int, int)
.y
- the y coordinate of the text, as it would be passed to
Graphics.drawString(java.lang.String,
int, int)
.public static void drawDashedRect(Graphics g, int x, int y, int width, int height)
g
.
Any other pixels are left unchanged.
g
- the graphics into which the rectangle is drawn.x
- the x coordinate of the rectangle.y
- the y coordinate of the rectangle.width
- the width of the rectangle in pixels.height
- the height of the rectangle in pixels.public static Dimension getPreferredButtonSize(AbstractButton b, int textIconGap)
b
- the button whose preferred size is determined.textIconGap
- the gap between the button’s text and
icon.
Dimension
object whose width
and height
fields indicate the preferred
extent in pixels.SwingUtilities.layoutCompoundLabel(JComponent,
FontMetrics, String, Icon, int, int, int, int, Rectangle, Rectangle,
Rectangle, int)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |