javax.swing.plaf.synth
Class SynthGraphicsUtils

java.lang.Object
  extended by javax.swing.plaf.synth.SynthGraphicsUtils

public class SynthGraphicsUtils
extends Object

Wrapper for graphics primitives used in Synth.

Since:
1.5

Constructor Summary
SynthGraphicsUtils()
          Creates a new SynthGraphicsUtils object.
 
Method Summary
 int computeStringWidth(SynthContext ctx, Font font, FontMetrics fm, String text)
          Returns the width of the string text for the specified font and font metrics.
 void drawLine(SynthContext ctx, Object paintKey, Graphics g, int x1, int y1, int x2, int y2)
          Draws a line from (x1,y1) to (x2,y2).
 int getMaximumCharHeight(SynthContext context)
          Returns the maximum character height of the font from the component of the passed in context.
 Dimension getMaximumSize(SynthContext ctx, Font font, String text, Icon icon, int hAlign, int vAlign, int hTextPosition, int vTextPosition, int iconTextGap, int mnemonicIndex)
          Calculates the maximum size that is needed to render the label with text and icon correctly.
 Dimension getMinimumSize(SynthContext ctx, Font font, String text, Icon icon, int hAlign, int vAlign, int hTextPosition, int vTextPosition, int iconTextGap, int mnemonicIndex)
          Calculates the minimums size that is needed to render the label with text and icon correctly.
 Dimension getPreferredSize(SynthContext ctx, Font font, String text, Icon icon, int hAlign, int vAlign, int hTextPosition, int vTextPosition, int iconTextGap, int mnemonicIndex)
          Calculates the preferred size that is needed to render the label with text and icon correctly.
 String layoutText(SynthContext ctx, FontMetrics fm, String text, Icon icon, int hAlign, int vAlign, int hTextPos, int vTextPos, Rectangle viewR, Rectangle iconR, Rectangle textR, int iconTextGap)
          Lays out a label and (if non-null) an icon.
 void paintText(SynthContext ctx, Graphics g, String text, Icon icon, int hAlign, int vAlign, int hTextPosition, int vTextPosition, int iconTextGap, int mnemonicIndex, int textOffset)
           
 void paintText(SynthContext ctx, Graphics g, String text, int x, int y, int mnemonicIndex)
          Renders the specified text at the specified location.
 void paintText(SynthContext ctx, Graphics g, String text, Rectangle bounds, int mnemonicIndex)
          Renders the specified text within the bounds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SynthGraphicsUtils

public SynthGraphicsUtils()
Creates a new SynthGraphicsUtils object.

Method Detail

drawLine

public void drawLine(SynthContext ctx,
                     Object paintKey,
                     Graphics g,
                     int x1,
                     int y1,
                     int x2,
                     int y2)
Draws a line from (x1,y1) to (x2,y2).

Parameters:
ctx - the synth context, identifies the region
paintKey - identifies the portion of the component to be painted, may be null
g - the graphics context to use for painting
x1 - the x coordinate of the start point
y1 - the y coordinate of the start point
x2 - the x coordinate of the end point
y2 - the y coordinate of the end point

layoutText

public String layoutText(SynthContext ctx,
                         FontMetrics fm,
                         String text,
                         Icon icon,
                         int hAlign,
                         int vAlign,
                         int hTextPos,
                         int vTextPos,
                         Rectangle viewR,
                         Rectangle iconR,
                         Rectangle textR,
                         int iconTextGap)
Lays out a label and (if non-null) an icon. The calculated coordinates are then stored in viewR, iconR and textR. The alignment and position parameters may be one of the alignment or position constants defined in SwingConstants.

Parameters:
ctx - the synth context, identifies the current region
fm - the font metrics to use to fetch the text measures
text - the text to lay out, may be null
icon - the icon to lay out, may be null
hAlign - the horizontal alignment of the label
vAlign - the vertical alignment of the label
hTextPos - the horizontal text position
vTextPos - the vertical text position
viewR - the view rectangle (return parameter)
iconR - the icon rectangle (return parameter)
textR - the text rectangle (return parameter)
iconTextGap - the gap between text and label
Returns:
the label text, may be shortened

computeStringWidth

public int computeStringWidth(SynthContext ctx,
                              Font font,
                              FontMetrics fm,
                              String text)
Returns the width of the string text for the specified font and font metrics.

Parameters:
ctx - identifies the current region
font - the font
fm - the font metrics to use
text - the text to be measured
Returns:
the width of the string text for the specified font and font metrics

getMinimumSize

public Dimension getMinimumSize(SynthContext ctx,
                                Font font,
                                String text,
                                Icon icon,
                                int hAlign,
                                int vAlign,
                                int hTextPosition,
                                int vTextPosition,
                                int iconTextGap,
                                int mnemonicIndex)
                         throws NotImplementedException
Calculates the minimums size that is needed to render the label with text and icon correctly.

Parameters:
ctx - identifies the current region
font - the font to use
text - the label text
icon - the label icon
hAlign - the horizontal alignment
vAlign - the vertical alignment
hTextPosition - the horizontal text position
vTextPosition - the vertical text position
iconTextGap - the gap between icon and text
mnemonicIndex - index to the mnemonic character within text
Returns:
the minimums size that is needed to render the label with text and icon correctly
Throws:
NotImplementedException

getPreferredSize

public Dimension getPreferredSize(SynthContext ctx,
                                  Font font,
                                  String text,
                                  Icon icon,
                                  int hAlign,
                                  int vAlign,
                                  int hTextPosition,
                                  int vTextPosition,
                                  int iconTextGap,
                                  int mnemonicIndex)
                           throws NotImplementedException
Calculates the preferred size that is needed to render the label with text and icon correctly.

Parameters:
ctx - identifies the current region
font - the font to use
text - the label text
icon - the label icon
hAlign - the horizontal alignment
vAlign - the vertical alignment
hTextPosition - the horizontal text position
vTextPosition - the vertical text position
iconTextGap - the gap between icon and text
mnemonicIndex - index to the mnemonic character within text
Returns:
the preferred size that is needed to render the label with text and icon correctly
Throws:
NotImplementedException

getMaximumSize

public Dimension getMaximumSize(SynthContext ctx,
                                Font font,
                                String text,
                                Icon icon,
                                int hAlign,
                                int vAlign,
                                int hTextPosition,
                                int vTextPosition,
                                int iconTextGap,
                                int mnemonicIndex)
                         throws NotImplementedException
Calculates the maximum size that is needed to render the label with text and icon correctly.

Parameters:
ctx - identifies the current region
font - the font to use
text - the label text
icon - the label icon
hAlign - the horizontal alignment
vAlign - the vertical alignment
hTextPosition - the horizontal text position
vTextPosition - the vertical text position
iconTextGap - the gap between icon and text
mnemonicIndex - index to the mnemonic character within text
Returns:
the maximum size that is needed to render the label with text and icon correctly
Throws:
NotImplementedException

getMaximumCharHeight

public int getMaximumCharHeight(SynthContext context)
Returns the maximum character height of the font from the component of the passed in context.

Parameters:
context - identifies the current component and region
Returns:
the maximum character height of the font from the component of the passed in context

paintText

public void paintText(SynthContext ctx,
                      Graphics g,
                      String text,
                      Rectangle bounds,
                      int mnemonicIndex)
Renders the specified text within the bounds.

Parameters:
ctx - identifies the component and region
g - the graphics context for drawing the tetx
text - the text to be rendered
bounds - the bounds within which the text should be rendered
mnemonicIndex - the index of the mnemonic character within text

paintText

public void paintText(SynthContext ctx,
                      Graphics g,
                      String text,
                      int x,
                      int y,
                      int mnemonicIndex)
Renders the specified text at the specified location.

Parameters:
ctx - identifies the component and region
g - the graphics context for drawing the tetx
text - the text to be rendered
x - the X location where the text should be rendered
y - the Y location where the text should be rendered
mnemonicIndex - the index of the mnemonic character within text

paintText

public void paintText(SynthContext ctx,
                      Graphics g,
                      String text,
                      Icon icon,
                      int hAlign,
                      int vAlign,
                      int hTextPosition,
                      int vTextPosition,
                      int iconTextGap,
                      int mnemonicIndex,
                      int textOffset)
               throws NotImplementedException
Throws:
NotImplementedException