Wrapper for graphics primitives used in Synth.
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.
ctx
- identifies the current regionfont
- the fontfm
- the font metrics to usetext
- the text to be measured
- the width of the string
text
for the specified font
and font metrics
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).
ctx
- the synth context, identifies the regionpaintKey
- identifies the portion of the component to be painted, may
be null
g
- the graphics context to use for paintingx1
- the x coordinate of the start pointy1
- the y coordinate of the start pointx2
- the x coordinate of the end pointy2
- the y coordinate of the end point
getMaximumCharHeight
public int getMaximumCharHeight(SynthContext context)
Returns the maximum character height of the font from the component of the
passed in context
.
context
- identifies the current component and region
- the maximum character height of the font from the component of the
passed in
context
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.
ctx
- identifies the current regionfont
- the font to usetext
- the label texticon
- the label iconhAlign
- the horizontal alignmentvAlign
- the vertical alignmenthTextPosition
- the horizontal text positionvTextPosition
- the vertical text positioniconTextGap
- the gap between icon and textmnemonicIndex
- index to the mnemonic character within
text
- the maximum size that is needed to render the label with
text
and icon
correctly
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.
ctx
- identifies the current regionfont
- the font to usetext
- the label texticon
- the label iconhAlign
- the horizontal alignmentvAlign
- the vertical alignmenthTextPosition
- the horizontal text positionvTextPosition
- the vertical text positioniconTextGap
- the gap between icon and textmnemonicIndex
- index to the mnemonic character within
text
- the minimums size that is needed to render the label with
text
and icon
correctly
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.
ctx
- identifies the current regionfont
- the font to usetext
- the label texticon
- the label iconhAlign
- the horizontal alignmentvAlign
- the vertical alignmenthTextPosition
- the horizontal text positionvTextPosition
- the vertical text positioniconTextGap
- the gap between icon and textmnemonicIndex
- index to the mnemonic character within
text
- the preferred size that is needed to render the label with
text
and icon
correctly
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
.
ctx
- the synth context, identifies the current regionfm
- the font metrics to use to fetch the text measurestext
- the text to lay out, may be null
icon
- the icon to lay out, may be null
hAlign
- the horizontal alignment of the labelvAlign
- the vertical alignment of the labelhTextPos
- the horizontal text positionvTextPos
- the vertical text positionviewR
- the view rectangle (return parameter)iconR
- the icon rectangle (return parameter)textR
- the text rectangle (return parameter)iconTextGap
- the gap between text and label
- the label text, may be shortened
paintText
public void paintText(SynthContext ctx,
Graphics g,
String text,
int x,
int y,
int mnemonicIndex)
Renders the specified text
at the specified location.
ctx
- identifies the component and regiong
- the graphics context for drawing the tetxtext
- the text to be renderedx
- the X location where the text should be renderedy
- the Y location where the text should be renderedmnemonicIndex
- the index of the mnemonic character within
text
paintText
public void paintText(SynthContext ctx,
Graphics g,
String text,
Rectangle bounds,
int mnemonicIndex)
Renders the specified text
within the bounds
.
ctx
- identifies the component and regiong
- the graphics context for drawing the tetxtext
- the text to be renderedbounds
- the bounds within which the text should be renderedmnemonicIndex
- 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
SynthGraphicsUtils.java -- Wrapper for graphics primitives used in Synth
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.