|
UC Berkeley Group for User Interface Research Updated November 17, 2000 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.berkeley.guir.lib.satin.graphics.GraphicsLib
This software is distributed under the Berkeley Software License.
Revisions: - SATIN-v1.0-1.0.0, Jul 22 1999, JH Created class - SATIN-v2.1-1.0.0, Aug 11 2000, JH Touched for SATIN release
Fields inherited from interface edu.berkeley.guir.lib.satin.graphics.GraphicsConstants |
BOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT, CENTER, HIGH_QUALITY, HIGHEST_QUALITY, LEFT, LOW_QUALITY, LOWEST_QUALITY, MEDIUM_QUALITY, RIGHT, TOP, TOP_LEFT, TOP_RIGHT |
Method Summary | |
static Rectangle |
calculateBoundingBox(String str,
Font f,
int x,
int y,
int pos)
Calculate the bounding box for this String. |
static Rectangle |
calculateBoundingBox(String str,
FontMetrics fmetric,
int x,
int y,
int pos)
Calculate the bounding box for this String. |
static Point |
calculateNewPosition(Shape shape,
int pos)
Shift an object to have new coordinates. |
static int |
calculateTotalHeight(String str,
Font font)
Using the specified font, calculate the height (in pixels) of the specified String. |
static int |
calculateTotalHeight(String str,
FontMetrics fmetric)
First, calculate how many rows there are. |
static int |
calculateTotalWidth(String str,
Font font)
Using the specified font, calculate the width (in pixels) of the specified String. |
static int |
calculateTotalWidth(String str,
FontMetrics fmetric)
Using the specified font metric, calculate the max width of this String in pixels, that is the longest width among each of the rows of this String. |
static Point |
calculateTranslation(Shape shape,
int x,
int y,
int pos)
Calculate how much a Shape should be translated along x- and y- such that the specified position of the Shape will be at the specified (x,y) coordinate. |
static Color |
makeTransparent(Color c,
float aa)
Set the transparency for drawing. |
static Color |
makeTransparent(Color c,
int aa)
Set the transparency for draw. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static Point calculateNewPosition(Shape shape, int pos)
Suppose you have a Rectangle, and you want to draw it such that it is centered at (0,0). Just call calculateNewPosition(rect, GraphicsLib.CENTER) to figure out where the top-left corner of the Rectangle should be drawn. Pretty neat, eh?
shape
- is some shape to draw.pos
- specifies where to shift the drawing to (CENTER,
TOP_LEFT, etc).public static Point calculateTranslation(Shape shape, int x, int y, int pos)
For example, say you already have a circle, and want to draw this circle with (0,0) as its center. Just call calculateTranslation(circle, 0, 0, CENTER) to figure out how much the shape should be translated.
shape
- is the Shape to determine how much to move. Make sure
that the coordinates of shape are in the same coordinate
system as x and y below.x
- is the x-coordinate to move it to.y
- is the y-coordinate to move it to.pos
- is the position that x and y represent (e.g. CENTER,
TOP_LEFT, etc).public static int calculateTotalWidth(String str, Font font)
str
- is the String whose max width in pixels we want.font
- is the font to use for this String.calculateTotalWidth(java.lang.String, java.awt.FontMetrics)
public static int calculateTotalWidth(String str, FontMetrics fmetric)
str
- is the String whose max width in pixels we want.fmetric
- is the FontMetrics to use for calculation.public static int calculateTotalHeight(String str, Font font)
str
- is the String whose max width in pixels we want.font
- is the font to use for this String.calculateTotalHeight(java.lang.String, java.awt.FontMetrics)
public static int calculateTotalHeight(String str, FontMetrics fmetric)
str
- is the String whose max width in pixels we want.fmetric
- is the FontMetrics to use for calculation.public static Rectangle calculateBoundingBox(String str, Font f, int x, int y, int pos)
str
- is the String whose bounding box we want.f
- is the Font to use.x
- is the left side of the bounding box.y
- is the top side of the bounding box (NOT bottom).pos
- specifies what (x,y) are relative to the bounding box
(e.g. the CENTER, TOP_LEFT, etc).calculateBoundingBox(String, FontMetrics, int, int, int)
public static Rectangle calculateBoundingBox(String str, FontMetrics fmetric, int x, int y, int pos)
str
- is the String whose bounding box we want.fmetric
- is the FontMetric to use.x
- is the left side of the bounding box.y
- is the top side of the bounding box (NOT bottom).pos
- specifies what (x,y) are relative to the bounding box
(e.g. the CENTER, TOP_LEFT, etc).public static final Color makeTransparent(Color c, float aa)
aa
- is the transparency value, from 0 to 1, 0 being transparent and
1 being solid.public static final Color makeTransparent(Color c, int aa)
aa
- is the transparency value (0-255). Sets to 0 if less than
0, or to 255 if greater than 255.
|
Copyright Information | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |