Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

javax.swing.plaf.basic
Class BasicGraphicsUtils  view BasicGraphicsUtils download BasicGraphicsUtils.java

java.lang.Object
  extended byjavax.swing.plaf.basic.BasicGraphicsUtils

public class BasicGraphicsUtils
extends java.lang.Object

A utility class providing commonly used drawing and measurement routines.


Constructor Summary
BasicGraphicsUtils()
          Constructor.
 
Method Summary
static void drawBezel(java.awt.Graphics g, int x, int y, int width, int height, boolean isPressed, boolean isDefault, java.awt.Color shadow, java.awt.Color darkShadow, java.awt.Color highlight, java.awt.Color lightHighlight)
          Draws a border that is suitable for buttons of the Basic look and feel.
static void drawDashedRect(java.awt.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(java.awt.Graphics g, int x, int y, int width, int height, java.awt.Color shadow, java.awt.Color darkShadow, java.awt.Color highlight, java.awt.Color lightHighlight)
          Draws a rectangle that appears etched into the surface, given four colors that are used for drawing.
static void drawGroove(java.awt.Graphics g, int x, int y, int width, int height, java.awt.Color shadow, java.awt.Color highlight)
          Draws a rectangle that appears etched into the surface, given two colors that are used for drawing.
static void drawLoweredBezel(java.awt.Graphics g, int x, int y, int width, int height, java.awt.Color shadow, java.awt.Color darkShadow, java.awt.Color highlight, java.awt.Color lightHighlight)
          Draws a rectangle that appears lowered into the surface, given four colors that are used for drawing.
static void drawString(java.awt.Graphics g, java.lang.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(java.awt.Graphics g, java.lang.String text, int underlinedIndex, int x, int y)
          Draws a String at the given location, underlining the character at the specified index.
static java.awt.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) 55 .
static java.awt.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) 55 .
static java.awt.Dimension getPreferredButtonSize(javax.swing.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

BasicGraphicsUtils

public BasicGraphicsUtils()
Constructor. It is utterly unclear why this class should be constructable, but this is what the API specification says.

Method Detail

drawEtchedRect

public static void drawEtchedRect(java.awt.Graphics g,
                                  int x,
                                  int y,
                                  int width,
                                  int height,
                                  java.awt.Color shadow,
                                  java.awt.Color darkShadow,
                                  java.awt.Color highlight,
                                  java.awt.Color lightHighlight)
Draws a rectangle that appears etched into the surface, given four colors that are used for drawing.

[An illustration that shows which pixels
 get painted in what color]


getEtchedInsets

public static java.awt.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) 55 .


drawGroove

public static void drawGroove(java.awt.Graphics g,
                              int x,
                              int y,
                              int width,
                              int height,
                              java.awt.Color shadow,
                              java.awt.Color highlight)
Draws a rectangle that appears etched into the surface, given two colors that are used for drawing.

[An illustration that shows which pixels
 get painted in what color]


getGrooveInsets

public static java.awt.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) 55 .


drawBezel

public static void drawBezel(java.awt.Graphics g,
                             int x,
                             int y,
                             int width,
                             int height,
                             boolean isPressed,
                             boolean isDefault,
                             java.awt.Color shadow,
                             java.awt.Color darkShadow,
                             java.awt.Color highlight,
                             java.awt.Color lightHighlight)
Draws a border that is suitable for buttons of the Basic look and feel.

[An illustration that shows which pixels
 get painted in what color]


drawLoweredBezel

public static void drawLoweredBezel(java.awt.Graphics g,
                                    int x,
                                    int y,
                                    int width,
                                    int height,
                                    java.awt.Color shadow,
                                    java.awt.Color darkShadow,
                                    java.awt.Color highlight,
                                    java.awt.Color lightHighlight)
Draws a rectangle that appears lowered into the surface, given four colors that are used for drawing.

[An illustration that shows which pixels
 get painted in what color]

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.


drawString

public static void drawString(java.awt.Graphics g,
                              java.lang.String text,
                              int underlinedChar,
                              int x,
                              int y)
Draws a String at the given location, underlining the first occurence of a specified character. The algorithm for determining the underlined position is not sensitive to case. If the character is not part of text, the text will be drawn without underlining. Drawing is performed in the current color and font of g.

[An illustration showing how to use the
 method]


drawStringUnderlineCharAt

public static void drawStringUnderlineCharAt(java.awt.Graphics g,
                                             java.lang.String text,
                                             int underlinedIndex,
                                             int x,
                                             int y)
Draws a String at the given location, underlining the character at the specified index. Drawing is performed in the current color and font of g.

[An illustration showing how to use the
 method]

Since:
1.4

drawDashedRect

public static void drawDashedRect(java.awt.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. The color of those pixels is the current color of the Graphics g. Any other pixels are left unchanged.

[An illustration that shows which pixels
 get painted]


getPreferredButtonSize

public static java.awt.Dimension getPreferredButtonSize(javax.swing.AbstractButton b,
                                                        int textIconGap)
Determines the preferred width and height of an AbstractButton, given the gap between the button’s text and icon.