javax.swing.plaf.basic
public class BasicGraphicsUtils extends Object
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
{@link #drawEtchedRect}.
|
static Insets | getGrooveInsets()
Determines the width of the border that gets painted by
{@link #drawGroove}.
|
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.
|
Parameters: 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.
g
.
Any other pixels are left unchanged.
Parameters: 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.
Parameters: 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.
See Also: getEtchedInsets EtchedBorder
Parameters: 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.
See Also: getGrooveInsets EtchedBorder
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.
Parameters: 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.
text
, the text will be
drawn without underlining. Drawing is performed in the current
color and font of g
.
Parameters: 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
{@link java.awt.Graphics#drawString(java.lang.String,
int, int)}.
y the y coordinate of the text, as it would be passed to
{@link java.awt.Graphics#drawString(java.lang.String,
int, int)}.
g
.
Parameters: 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
{@link java.awt.Graphics#drawString(java.lang.String,
int, int)}.
y the y coordinate of the text, as it would be passed to
{@link java.awt.Graphics#drawString(java.lang.String,
int, int)}.
Since: 1.4
Returns: an Insets
object whose top
,
left
, bottom
and
right
field contain the border width at the
respective edge in pixels.
Returns: an Insets
object whose top
,
left
, bottom
and
right
field contain the border width at the
respective edge in pixels.
Parameters: b the button whose preferred size is determined. textIconGap the gap between the button’s text and icon.
Returns: a Dimension
object whose width
and height
fields indicate the preferred
extent in pixels.
See Also: SwingUtilities