public class Metrics extends Object implements GraphicsConstants, AlignmentConstants
Modifier and Type | Field and Description |
---|---|
static int |
METRIC_ASCENT
A Metric value for getFontForMetric().
|
static int |
METRIC_DESCENT
A Metric value for getFontForMetric().
|
static int |
METRIC_HEIGHT
A Metric value for getFontForMetric().
|
static int |
METRIC_HEIGHT_OF_TEXT
A Metric value for getFontForMetric().
|
static int |
METRIC_OPTION_MAKE_SMALLER_ONLY |
static int |
METRIC_WIDTH_OF_TEXT
A Metric value for getFontForMetric().
|
All, BDR_DOTTED, BDR_INNER, BDR_NOBORDER, BDR_OUTER, BDR_OUTLINE, BDR_RAISEDINNER, BDR_RAISEDOUTER, BDR_SUNKENINNER, BDR_SUNKENOUTER, BF_BOTTOM, BF_BOTTOMLEFT, BF_BOTTOMRIGHT, BF_BUTTON, BF_DIAGONAL, BF_DIAGONAL_ENDBOTTOMLEFT, BF_DIAGONAL_ENDBOTTOMRIGHT, BF_DIAGONAL_ENDTOPLEFT, BF_DIAGONAL_ENDTOPRIGHT, BF_EXACT, BF_FLAT, BF_LEFT, BF_MIDDLE, BF_MONO, BF_PALM, BF_RECT, BF_RIGHT, BF_SOFT, BF_SQUARE, BF_TOP, BF_TOPLEFT, BF_TOPRIGHT, Down, EDGE_BUMP, EDGE_ETCHED, EDGE_RAISED, EDGE_SUNKEN, Left, Right, Up
BOTTOM, CELLFLAG, CELLMASK, CENTER, CONTROLMASK, DONTCHANGE, DONTFILL, DONTSTRETCH, EAST, FILL, GROW, HCENTER, HCONTRACT, HEXPAND, HFILL, HGROW, HSHRINK, HSTRETCH, INITIALLY_CLOSED, INITIALLY_MINIMIZED, INITIALLY_PREFERRED_SIZE, LEFT, NORTH, NORTHEAST, NORTHWEST, RIGHT, SHRINK, SOUTH, SOUTHEAST, SOUTHWEST, STRETCH, TAG_BACKGROUND_IMAGE, TAG_BORDER, TAG_FIXEDSIZE, TAG_INSETS, TAG_MAXIMUMSIZE, TAG_MINIMUMSIZE, TAG_PREFERREDSIZE, TAG_RECT, TAG_SPAN, TAG_TEXTSIZE, TOP, VCENTER, VCONTRACT, VEXPAND, VFILL, VGROW, VSHRINK, VSTRETCH, WEST
Constructor and Description |
---|
Metrics() |
Modifier and Type | Method and Description |
---|---|
static void |
anchor(Rect subArea,
Rect largeArea,
int anchor)
Modify subArea so that it is anchored appropriately in largeArea.
|
static void |
anchorTextIn(FontMetrics fm,
Object[] lines,
Rect destination,
int anchor,
FormattedTextSpecs fts)
Find where the text would be given the full destination Rect.
|
static Point |
centerText(FontMetrics fm,
String st,
int width,
int height,
Point destination) |
static Point |
centerText(FontMetrics fm,
SubString st,
int width,
int height,
Point destination) |
static void |
drawImage(Graphics g,
IImage image,
int imageDrawOptions,
Rect dest,
int anchor) |
static void |
drawText(Graphics g,
FontMetrics fm,
Object[] lines,
Rect where,
int alignment,
int anchor) |
static void |
drawText(Graphics g,
FontMetrics fm,
Object[] lines,
Rect where,
int alignment,
int anchor,
int startLine,
int endLine) |
static void |
drawText(Graphics g,
FontMetrics fm,
Object[] lines,
Rect where,
int alignment,
int anchor,
int startLine,
int endLine,
FormattedTextSpecs fts) |
protected static void |
drawTextIn(Graphics g,
FontMetrics fm,
Object[] lines,
Rect where,
int alignment,
int start,
int end,
FormattedTextSpecs fts) |
static Font |
fitInto(Dimension size,
Object data,
FontMetrics baseFont)
Find the biggest Font such that the data provided fits within the size provided.
|
static Font |
fitInto(int width,
int height,
Object data,
FontMetrics baseFont)
Find the biggest Font such that the data provided fits within the size provided.
|
static Dimension |
getAverageSize(FontMetrics fm,
int rows,
int columns,
int xGap,
int yGap,
Dimension destination) |
static Font |
getFontForHeight(int requiredHeight,
FontMetrics baseFont)
Find the biggest Font such that its height is less than or equal to the requiredHeight.
|
static Font |
getFontForMetric(int valueOfMetricInPixels,
int whichMetric,
Object data,
FontMetrics baseFont)
Retrieve the Font which is of the correct size, such that its metric is equal to,
or just smaller than the specified metric in pixels, or for which the metrics of
the supplied data is equal to or just smaller than the specified metric in pixels.
|
static int |
getMetricValue(int whichMetric,
Object data,
FontMetrics fm)
Get the value of a particular Metric for a FontMetrics for a set of data.
|
static Dimension |
getSize(FontMetrics fm,
String[] lines,
int xGap,
int yGap,
Dimension destination) |
static void |
getSize(FontMetrics fm,
String[] lines,
int start,
int end,
Dimension d,
FormattedTextSpecs fts) |
static void |
getSize(FontMetrics fm,
String line,
Dimension d) |
static void |
getSize(FontMetrics fm,
String line,
Dimension d,
FormattedTextSpecs fts) |
static Dimension |
getSize(FontMetrics fm,
String text,
int xGap,
int yGap,
Dimension destination)
Get the size of the text if placed within an imaginary box.
|
static void |
getSize(FontMetrics fm,
StringList lines,
int start,
int end,
Dimension d,
FormattedTextSpecs fts) |
static Dimension |
getSize(FontMetrics fm,
SubString[] lines,
int xGap,
int yGap,
Dimension destination) |
static void |
getSize(FontMetrics fm,
SubString[] lines,
int start,
int end,
Dimension d,
FormattedTextSpecs fts) |
static Dimension |
getSize(FontMetrics fm,
SubString text,
int xGap,
int yGap,
Dimension destination)
Get the size of the text if placed within an imaginary box.
|
static FontMetrics |
shrinkInto(int width,
int height,
Object data,
FontMetrics baseFont,
FontMetrics biggestSoFar) |
public static final int METRIC_HEIGHT
public static final int METRIC_ASCENT
public static final int METRIC_DESCENT
public static final int METRIC_WIDTH_OF_TEXT
public static final int METRIC_HEIGHT_OF_TEXT
public static final int METRIC_OPTION_MAKE_SMALLER_ONLY
public static Dimension getSize(FontMetrics fm, String text, int xGap, int yGap, Dimension destination)
fm
- the FontMetrics to use to measure.text
- a single line of text as a String, SubString, CharArray or char[]xGap
- the width at the left and right of the text.yGap
- the width at the top and bottom of the text.destination
- a destination rectangle.public static Dimension getSize(FontMetrics fm, SubString text, int xGap, int yGap, Dimension destination)
fm
- the FontMetrics to use to measure.text
- a single line of text as a String, SubString, CharArray or char[]xGap
- the width at the left and right of the text.yGap
- the width at the top and bottom of the text.destination
- a destination rectangle.public static Dimension getSize(FontMetrics fm, String[] lines, int xGap, int yGap, Dimension destination)
public static Dimension getSize(FontMetrics fm, SubString[] lines, int xGap, int yGap, Dimension destination)
public static Dimension getAverageSize(FontMetrics fm, int rows, int columns, int xGap, int yGap, Dimension destination)
public static Point centerText(FontMetrics fm, String st, int width, int height, Point destination)
public static Point centerText(FontMetrics fm, SubString st, int width, int height, Point destination)
public static void getSize(FontMetrics fm, String line, Dimension d)
public static void getSize(FontMetrics fm, String line, Dimension d, FormattedTextSpecs fts)
public static void getSize(FontMetrics fm, String[] lines, int start, int end, Dimension d, FormattedTextSpecs fts)
public static void getSize(FontMetrics fm, SubString[] lines, int start, int end, Dimension d, FormattedTextSpecs fts)
public static void getSize(FontMetrics fm, StringList lines, int start, int end, Dimension d, FormattedTextSpecs fts)
public static void anchor(Rect subArea, Rect largeArea, int anchor)
public static void drawImage(Graphics g, IImage image, int imageDrawOptions, Rect dest, int anchor)
public static void drawText(Graphics g, FontMetrics fm, Object[] lines, Rect where, int alignment, int anchor)
public static void drawText(Graphics g, FontMetrics fm, Object[] lines, Rect where, int alignment, int anchor, int startLine, int endLine)
public static void anchorTextIn(FontMetrics fm, Object[] lines, Rect destination, int anchor, FormattedTextSpecs fts)
fm
- The font metrics.lines
- the text.destination
- the destination area to hold the text which will be modified
to be the area that would hold the text exactly.anchor
- an anchor specifier (such as NORTH, SOUTH, etc).fts
- optional FormattedTextSpecs.public static void drawText(Graphics g, FontMetrics fm, Object[] lines, Rect where, int alignment, int anchor, int startLine, int endLine, FormattedTextSpecs fts)
protected static void drawTextIn(Graphics g, FontMetrics fm, Object[] lines, Rect where, int alignment, int start, int end, FormattedTextSpecs fts)
public static int getMetricValue(int whichMetric, Object data, FontMetrics fm)
whichMetric
- one of the METRIC_XXX valuesdata
- This is only needed for METRIC_WIDTH_OF_TEXT or METRIC_HEIGHT_OF_TEXT.
The data must be a String, a SubString or an array of Strings (which is assumed will be placed one above the other)
or a Character (for a single character).fm
- The FontMetrics to use.public static Font getFontForMetric(int valueOfMetricInPixels, int whichMetric, Object data, FontMetrics baseFont)
valueOfMetricInPixels
- The value of the metrics in Pixels.whichMetric
- one of the METRIC_XXX valuesdata
- This is only needed for METRIC_WIDTH_OF_TEXT or METRIC_HEIGHT_OF_TEXT.
The data must be a String, an array of Strings (which is assumed will be placed one above the other)
or a Character (for a single character).baseFont
- The FontMetrics representing the base font to use. The returned Font will have the
same name and style as the baseFont.public static Font fitInto(Dimension size, Object data, FontMetrics baseFont)
size
- The size in pixels.data
- This can be a Character or a String or an Array of Strings.baseFont
- The FontMetrics representing the base font to use. The returned Font will have the
same name and style as the baseFont.public static Font fitInto(int width, int height, Object data, FontMetrics baseFont)
width
- The width in pixels.height
- The height in pixels.data
- This can be a Character or a String or an Array of Strings.baseFont
- The FontMetrics representing the base font to use. The returned Font will have the
same name and style as the baseFont.public static FontMetrics shrinkInto(int width, int height, Object data, FontMetrics baseFont, FontMetrics biggestSoFar)
public static Font getFontForHeight(int requiredHeight, FontMetrics baseFont)
requiredHeight
- The required height for the Font.baseFont
- The FontMetrics representing the base font to use. The returned Font will have the
same name and style as the baseFont.