public class SynthGraphicsUtils extends Object
| Constructor and Description |
|---|
SynthGraphicsUtils()
Creates a
SynthGraphicsUtils.
|
| Modifier and Type | Method and Description |
|---|---|
int |
computeStringWidth(SynthContext
Returns the size of the passed in string.
|
void |
drawLine(SynthContext
Draws a line between the two end points.
|
void |
drawLine(SynthContext
Draws a line between the two end points.
|
int |
getMaximumCharHeight(SynthContext
Returns the maximum height of the the Font from the passed in SynthContext.
|
Dimension |
getMaximumSize(SynthContext
Returns the maximum size needed to properly render an icon and text.
|
Dimension |
getMinimumSize(SynthContext
Returns the minimum size needed to properly render an icon and text.
|
Dimension |
getPreferredSize(SynthContext
Returns the preferred size needed to properly render an icon and text.
|
String |
layoutText(SynthContext
Lays out text and an icon returning, by reference, the location to place the icon and text.
|
void |
paintText(SynthContext
Paints an icon and text.
|
void |
paintText(SynthContext
Paints text at the specified location.
|
void |
paintText(SynthContext
Paints text at the specified location.
|
public void drawLine(SynthContextcontext, Object paintKey, Graphics g, int x1, int y1, int x2, int y2)
context - Identifies hosting region.
paintKey - Identifies the portion of the component being asked to paint, may be null.
g - Graphics object to paint to
x1 - x origin
y1 - y origin
x2 - x destination
y2 - y destination
public void drawLine(SynthContextcontext, Object paintKey, Graphics g, int x1, int y1, int x2, int y2, Object styleKey)
This implementation supports only one line style key, "dashed". The "dashed" line style is applied only to vertical and horizontal lines.
Specifying null or any key different from "dashed" will draw solid lines.
context - identifies hosting region
paintKey - identifies the portion of the component being asked to paint, may be null
g - Graphics object to paint to
x1 - x origin
y1 - y origin
x2 - x destination
y2 - y destination
styleKey - identifies the requested style of the line (e.g. "dashed")
public StringlayoutText(SynthContext ss, FontMetrics fm, String text, Icon icon, int hAlign, int vAlign, int hTextPosition, int vTextPosition, Rectangle viewR, Rectangle iconR, Rectangle textR, int iconTextGap)
ss - SynthContext
fm - FontMetrics for the Font to use, this may be ignored
text - Text to layout
icon - Icon to layout
hAlign - horizontal alignment
vAlign - vertical alignment
hTextPosition - horizontal text position
vTextPosition - vertical text position
viewR - Rectangle to layout text and icon in.
iconR - Rectangle to place icon bounds in
textR - Rectangle to place text in
iconTextGap - gap between icon and text
public int computeStringWidth(SynthContextss, Font font, FontMetrics metrics, String text)
ss - SynthContext
font - Font to use
metrics - FontMetrics, may be ignored
text - Text to get size of.
public DimensiongetMinimumSize(SynthContext ss, Font font, String text, Icon icon, int hAlign, int vAlign, int hTextPosition, int vTextPosition, int iconTextGap, int mnemonicIndex)
ss - SynthContext
font - Font to use
text - Text to layout
icon - Icon to layout
hAlign - horizontal alignment
vAlign - vertical alignment
hTextPosition - horizontal text position
vTextPosition - vertical text position
iconTextGap - gap between icon and text
mnemonicIndex - Index into text to render the mnemonic at, -1 indicates no mnemonic.
public DimensiongetMaximumSize(SynthContext ss, Font font, String text, Icon icon, int hAlign, int vAlign, int hTextPosition, int vTextPosition, int iconTextGap, int mnemonicIndex)
ss - SynthContext
font - Font to use
text - Text to layout
icon - Icon to layout
hAlign - horizontal alignment
vAlign - vertical alignment
hTextPosition - horizontal text position
vTextPosition - vertical text position
iconTextGap - gap between icon and text
mnemonicIndex - Index into text to render the mnemonic at, -1 indicates no mnemonic.
public int getMaximumCharHeight(SynthContextcontext)
context - SynthContext used to determine font.
public DimensiongetPreferredSize(SynthContext ss, Font font, String text, Icon icon, int hAlign, int vAlign, int hTextPosition, int vTextPosition, int iconTextGap, int mnemonicIndex)
ss - SynthContext
font - Font to use
text - Text to layout
icon - Icon to layout
hAlign - horizontal alignment
vAlign - vertical alignment
hTextPosition - horizontal text position
vTextPosition - vertical text position
iconTextGap - gap between icon and text
mnemonicIndex - Index into text to render the mnemonic at, -1 indicates no mnemonic.
public void paintText(SynthContextss, Graphics g, String text, Rectangle bounds, int mnemonicIndex)
ss - SynthContext
g - Graphics used to render string in.
text - Text to render
bounds - Bounds of the text to be drawn.
mnemonicIndex - Index to draw string at.
public void paintText(SynthContextss, Graphics g, String text, int x, int y, int mnemonicIndex)
ss - SynthContext
g - Graphics used to render string in.
text - Text to render
x - X location to draw text at.
y - Upper left corner to draw text at.
mnemonicIndex - Index to draw string at.
public void paintText(SynthContextss, Graphics g, String text, Icon icon, int hAlign, int vAlign, int hTextPosition, int vTextPosition, int iconTextGap, int mnemonicIndex, int textOffset)
ss - SynthContext
g - Graphics to render string and icon into
text - Text to layout
icon - Icon to layout
hAlign - horizontal alignment
vAlign - vertical alignment
hTextPosition - horizontal text position
vTextPosition - vertical text position
iconTextGap - gap between icon and text
mnemonicIndex - Index into text to render the mnemonic at, -1 indicates no mnemonic.
textOffset - Amount to offset the text when painting