- java.lang.Object
-
- javax.swing.plaf.synth.SynthGraphicsUtils
-
public class SynthGraphicsUtils extends Object
Wrapper for primitive graphics calls.- Since:
- 1.5
-
-
Constructor Summary
Constructors Constructor and Description SynthGraphicsUtils()
Creates aSynthGraphicsUtils
.
-
Method Summary
Methods 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.int
getMaximumCharHeight(SynthContext context)
Returns the maximum height of the 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.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.
-
-
-
Method Detail
-
drawLine
public void drawLine(SynthContext context, Object paintKey, Graphics g, int x1, int y1, int x2, int y2)
Draws a line between the two end points.- Parameters:
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 destination
-
drawLine
public 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.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.- Parameters:
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")- Since:
- 1.6
-
layoutText
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)
Lays out text and an icon returning, by reference, the location to place the icon and text.- Parameters:
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 text
-
computeStringWidth
public int computeStringWidth(SynthContext ss, Font font, FontMetrics metrics, String text)
Returns the size of the passed in string.- Parameters:
ss
- SynthContextfont
- Font to usemetrics
- FontMetrics, may be ignoredtext
- Text to get size of.
-
getMinimumSize
public 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.- Parameters:
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.
-
getMaximumSize
public 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.- Parameters:
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.
-
getMaximumCharHeight
public int getMaximumCharHeight(SynthContext context)
Returns the maximum height of the the Font from the passed in SynthContext.- Parameters:
context
- SynthContext used to determine font.- Returns:
- maximum height of the characters for the font from the passed in context.
-
getPreferredSize
public 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.- Parameters:
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.
-
paintText
public void paintText(SynthContext ss, Graphics g, String text, Rectangle bounds, int mnemonicIndex)
Paints text at the specified location. This will not attempt to render the text as html nor will it offset by the insets of the component.- Parameters:
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.
-
paintText
public void paintText(SynthContext ss, Graphics g, String text, int x, int y, int mnemonicIndex)
Paints text at the specified location. This will not attempt to render the text as html nor will it offset by the insets of the component.- Parameters:
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.
-
paintText
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)
Paints an icon and text. This will render the text as html, if necessary, and offset the location by the insets of the component.- Parameters:
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 painting
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/swing/plaf/synth/synthgraphicsutils.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.