public class SynthGraphicsUtils extends Object
Constructor and Description |
---|
SynthGraphicsUtils()
Creates a
SynthGraphicsUtils . |
Modifier and Type | Method and Description |
---|---|
int |
computeStringWidth(SynthContext ss,
Font font,
FontMetrics metrics,
String text)
Returns the size of the passed in string.
|
void |
drawLine(SynthContext context,
Object paintKey,
Graphics g,
int x1,
int y1,
int x2,
int y2)
Draws a line between the two end points.
|
void |
drawLine(SynthContext context,
Object paintKey,
Graphics g,
int x1,
int y1,
int x2,
int y2,
Object styleKey)
Draws a line between the two end points.
|
static int |
getIconHeight(Icon icon,
SynthContext context)
Returns the icon's height.
|
static int |
getIconWidth(Icon icon,
SynthContext context)
Returns the icon's width.
|
int |
getMaximumCharHeight(SynthContext context)
Returns the maximum height of the Font from the passed in
SynthContext.
|
Dimension |
getMaximumSize(SynthContext ss,
Font font,
String text,
Icon icon,
int hAlign,
int vAlign,
int hTextPosition,
int vTextPosition,
int iconTextGap,
int mnemonicIndex)
Returns the maximum size needed to properly render an icon and text.
|
Dimension |
getMinimumSize(SynthContext ss,
Font font,
String text,
Icon icon,
int hAlign,
int vAlign,
int hTextPosition,
int vTextPosition,
int iconTextGap,
int mnemonicIndex)
Returns the minimum size needed to properly render an icon and text.
|
Dimension |
getPreferredSize(SynthContext ss,
Font font,
String text,
Icon icon,
int hAlign,
int vAlign,
int hTextPosition,
int vTextPosition,
int iconTextGap,
int mnemonicIndex)
Returns the preferred size needed to properly render an icon and text.
|
String |
layoutText(SynthContext ss,
FontMetrics fm,
String text,
Icon icon,
int hAlign,
int vAlign,
int hTextPosition,
int vTextPosition,
Rectangle viewR,
Rectangle iconR,
Rectangle textR,
int iconTextGap)
Lays out text and an icon returning, by reference, the location to
place the icon and text.
|
static void |
paintIcon(Icon icon,
SynthContext context,
Graphics g,
int x,
int y,
int width,
int height)
Paints the icon.
|
void |
paintText(SynthContext ss,
Graphics g,
String text,
Icon icon,
int hAlign,
int vAlign,
int hTextPosition,
int vTextPosition,
int iconTextGap,
int mnemonicIndex,
int textOffset)
Paints an icon and text.
|
void |
paintText(SynthContext ss,
Graphics g,
String text,
int x,
int y,
int mnemonicIndex)
Paints text at the specified location.
|
void |
paintText(SynthContext ss,
Graphics g,
String text,
Rectangle bounds,
int mnemonicIndex)
Paints text at the specified location.
|
public void drawLine(SynthContext context, 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 tox1
- x originy1
- y originx2
- x destinationy2
- y destinationpublic void drawLine(SynthContext context, 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 regionpaintKey
- identifies the portion of the component being asked
to paint, may be nullg
- Graphics object to paint tox1
- x originy1
- y originx2
- x destinationy2
- y destinationstyleKey
- identifies the requested style of the line (e.g. "dashed")public String layoutText(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
- SynthContextfm
- FontMetrics for the Font to use, this may be ignoredtext
- Text to layouticon
- Icon to layouthAlign
- horizontal alignmentvAlign
- vertical alignmenthTextPosition
- horizontal text positionvTextPosition
- vertical text positionviewR
- Rectangle to layout text and icon in.iconR
- Rectangle to place icon bounds intextR
- Rectangle to place text iniconTextGap
- gap between icon and textpublic int computeStringWidth(SynthContext ss, Font font, FontMetrics metrics, String text)
ss
- SynthContextfont
- Font to usemetrics
- FontMetrics, may be ignoredtext
- Text to get size of.public Dimension getMinimumSize(SynthContext ss, Font font, String text, Icon icon, int hAlign, int vAlign, int hTextPosition, int vTextPosition, int iconTextGap, int mnemonicIndex)
ss
- SynthContextfont
- Font to usetext
- Text to layouticon
- Icon to layouthAlign
- horizontal alignmentvAlign
- vertical alignmenthTextPosition
- horizontal text positionvTextPosition
- vertical text positioniconTextGap
- gap between icon and textmnemonicIndex
- Index into text to render the mnemonic at, -1
indicates no mnemonic.public Dimension getMaximumSize(SynthContext ss, Font font, String text, Icon icon, int hAlign, int vAlign, int hTextPosition, int vTextPosition, int iconTextGap, int mnemonicIndex)
ss
- SynthContextfont
- Font to usetext
- Text to layouticon
- Icon to layouthAlign
- horizontal alignmentvAlign
- vertical alignmenthTextPosition
- horizontal text positionvTextPosition
- vertical text positioniconTextGap
- gap between icon and textmnemonicIndex
- Index into text to render the mnemonic at, -1
indicates no mnemonic.public int getMaximumCharHeight(SynthContext context)
context
- SynthContext used to determine font.public Dimension getPreferredSize(SynthContext ss, Font font, String text, Icon icon, int hAlign, int vAlign, int hTextPosition, int vTextPosition, int iconTextGap, int mnemonicIndex)
ss
- SynthContextfont
- Font to usetext
- Text to layouticon
- Icon to layouthAlign
- horizontal alignmentvAlign
- vertical alignmenthTextPosition
- horizontal text positionvTextPosition
- vertical text positioniconTextGap
- gap between icon and textmnemonicIndex
- Index into text to render the mnemonic at, -1
indicates no mnemonic.public void paintText(SynthContext ss, Graphics g, String text, Rectangle bounds, int mnemonicIndex)
ss
- SynthContextg
- Graphics used to render string in.text
- Text to renderbounds
- Bounds of the text to be drawn.mnemonicIndex
- Index to draw string at.public void paintText(SynthContext ss, Graphics g, String text, int x, int y, int mnemonicIndex)
ss
- SynthContextg
- Graphics used to render string in.text
- Text to renderx
- X location to draw text at.y
- Upper left corner to draw text at.mnemonicIndex
- Index to draw string at.public void paintText(SynthContext ss, Graphics g, String text, Icon icon, int hAlign, int vAlign, int hTextPosition, int vTextPosition, int iconTextGap, int mnemonicIndex, int textOffset)
ss
- SynthContextg
- Graphics to render string and icon intotext
- Text to layouticon
- Icon to layouthAlign
- horizontal alignmentvAlign
- vertical alignmenthTextPosition
- horizontal text positionvTextPosition
- vertical text positioniconTextGap
- gap between icon and textmnemonicIndex
- Index into text to render the mnemonic at, -1
indicates no mnemonic.textOffset
- Amount to offset the text when paintingpublic static int getIconWidth(Icon icon, SynthContext context)
getIconWidth(context)
method is called for SynthIcon
.icon
- the iconcontext
- SynthContext
requesting the icon, may be null.public static int getIconHeight(Icon icon, SynthContext context)
getIconHeight(context)
method is called for SynthIcon
.icon
- the iconcontext
- SynthContext
requesting the icon, may be null.public static void paintIcon(Icon icon, SynthContext context, Graphics g, int x, int y, int width, int height)
paintIcon(context, g, x, y, width, height)
method is called for SynthIcon
.icon
- the iconcontext
- identifies hosting region, may be null.g
- the graphics contextx
- the x location to paint toy
- the y location to paint towidth
- the width of the region to paint to, may be 0height
- the height of the region to paint to, may be 0 Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2016, Oracle and/or its affiliates. All rights reserved.
DRAFT 9-internal+0-2016-01-26-133437.ivan.openjdk9onspinwait