|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectJTP.Geom
public class Geom
Geometry related support methods
Constructor Summary | |
---|---|
Geom()
|
Method Summary | |
---|---|
static Point |
absPos(ScreenFrames frames,
Point p,
int tileHeight)
Calculates absolute location (in pixels) of centre of tile face. |
static Point |
calcCharOnTileOffset(char c,
Font f,
ScreenFrames frames,
Graphics2D g)
Calculates offset for drawing a single character on the face of a tile |
static Dimension |
calcMaxLineDimensions(String[] lines,
Font f,
Graphics2D g)
Calculates maximum line height and width for a set lines of text. |
static Rectangle |
calcTextBounds(String s,
Font f,
Graphics2D g)
Calculates space taken up by given string and its offset |
static Square |
calcTileClip(ScreenFrames frames,
Point tile)
Calculates maximum clip area for one tile |
static Rectangle |
calcTilesClip(ScreenFrames frames,
Point tile1,
Point tile2)
Calculates maximum clip area for two tiles |
static void |
drawChar(char c,
int x,
int y,
Color clr,
Graphics2D g)
Draws a character at the given location in the specified color |
static void |
drawGrid(Rectangle gridArea,
int gridSize,
int tileSize,
Color c,
Graphics2D g)
Draws grid in editor |
static void |
drawImage(BufferedImage img,
Rectangle r,
Color bgColor,
Graphics2D g)
Renders an image at the specified location, clearing the background first with the specified color. |
static void |
drawLineRel(ScreenFrames frames,
Point relP1,
int p1Height,
Point relP2,
int p2Height,
Color c,
Graphics2D g)
Draws a line between tile locations on grid (relative positioning dependant on tile height) |
static void |
drawNumber(int n,
int x,
int y,
Color c,
Graphics2D g)
Draws a number at the given location in the specified color |
static void |
drawRect(Rectangle r,
Color c,
Graphics2D g)
Draws a rectangle. |
static void |
drawRoundRect(Rectangle r,
int arc,
Color c,
Stroke s,
Graphics2D g)
Draws a rectangle with rounded edges. |
static void |
drawString(String s,
int x,
int y,
Color c,
Graphics2D g)
Draws a string at the given location in the specified color |
static void |
drawString(String s,
Point p,
Color c,
Graphics2D g)
Draws a string at the given location in the specified color |
static void |
drawString(String s,
Point p,
Point offset,
Color c,
Graphics2D g)
Draws a string at the given location with an offset. |
static void |
fillRect(Rectangle r,
Color c,
Graphics2D g)
Draws a filled rectangle. |
protected static void |
fillRect(Rectangle r,
int topCrop,
int bottomCrop,
Color c,
Graphics2D g)
Modified version of fillRect() for use in editor for correct cropping |
static void |
fillRectMax(Rectangle r,
Color c,
Graphics2D g)
Fills a rectangle exactly as specified in Graphics2D.fillRect() |
static void |
fillRectOversize(Rectangle r,
Color c,
Graphics2D g)
Like fillRectMax except offset by one pixel horizontally
and vertically, i.e.: x - 1, y - 1, width + 2, height + 2. |
static void |
fillRoundRect(Rectangle r,
int arc,
Color c,
Graphics2D g)
Fills a rectangle with rounded edges. |
static String |
getMaxString(String s,
String addition,
int maxWidth,
Font f,
Graphics2D g)
Calculates maximum substring which can fit in the given absolute width |
static int |
getTileButtonWidth(String s,
boolean is3D,
ScreenFrames frames)
Calculates width required for a button rendered with tiles |
static Point |
gridPos(ScreenFrames frames,
Point mouseLocation)
Calculates relative grid position given absolute mouse location |
static Square |
tilePosToArea(ScreenFrames frames,
Point tile)
Calculates absolute locations and size of a tile |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Geom()
Method Detail |
---|
public static void drawLineRel(ScreenFrames frames, Point relP1, int p1Height, Point relP2, int p2Height, Color c, Graphics2D g)
frames
- dimensions required for calculating absolute locationsrelP1
- relative position of 1st pointp1Height
- height of pile for 1st locationrelP2
- relative position of 2nd pointp2Height
- height of pile for 2st locationc
- color of the lineg
- graphics context for drawingpublic static void drawRect(Rectangle r, Color c, Graphics2D g)
Graphics2D
version of drawRect were called.
r
- size and location of rectangle to drawc
- color of rectangle outlineg
- graphics context for drawingpublic static void fillRect(Rectangle r, Color c, Graphics2D g)
r
- size and location of rectangle to drawc
- color of rectangleg
- graphics context for drawingprotected static void fillRect(Rectangle r, int topCrop, int bottomCrop, Color c, Graphics2D g)
public static void fillRectMax(Rectangle r, Color c, Graphics2D g)
Graphics2D.fillRect()
r
- size and location of rectangle to drawc
- color of rectangle outlineg
- graphics context for drawingpublic static void fillRectOversize(Rectangle r, Color c, Graphics2D g)
fillRectMax
except offset by one pixel horizontally
and vertically, i.e.: x - 1, y - 1, width + 2, height + 2.
r
- size and location of rectangle to drawc
- color of rectangle outlineg
- graphics context for drawingpublic static void fillRoundRect(Rectangle r, int arc, Color c, Graphics2D g)
Graphics2D.fillRect()
r
- size and location of rectangle to drawarc
- amount of curvature
(see Graphics2D.fillRoundRect()
for more details)c
- color of rectangleg
- graphics context for drawingpublic static void drawRoundRect(Rectangle r, int arc, Color c, Stroke s, Graphics2D g)
Graphics2D.fillRect()
r
- size and location of rectangle to drawarc
- amount of curvature
(see Graphics2D.fillRoundRect()
for more details)c
- color of rectangle outlineg
- graphics context for drawingpublic static void drawChar(char c, int x, int y, Color clr, Graphics2D g)
c
- character to drawx
- absolute horizontal positiony
- absolute vertical positionclr
- color of characterg
- graphics context for drawingpublic static void drawNumber(int n, int x, int y, Color c, Graphics2D g)
n
- number to drawx
- absolute horizontal positiony
- absolute vertical positionc
- color of characterg
- graphics context for drawingpublic static void drawString(String s, int x, int y, Color c, Graphics2D g)
s
- string to drawx
- absolute horizontal positiony
- absolute vertical positionc
- color of characterg
- graphics context for drawingpublic static void drawString(String s, Point p, Color c, Graphics2D g)
s
- string to drawp
- absolute positionc
- color of characterg
- graphics context for drawingpublic static void drawString(String s, Point p, Point offset, Color c, Graphics2D g)
Geom.calcTextBounds()
)
s
- string to drawp
- absolute positionoffset
- deviation from absolute positionc
- color of characterg
- graphics context for drawingpublic static void drawImage(BufferedImage img, Rectangle r, Color bgColor, Graphics2D g)
img
- image to renderr
- size of image and absolute position for renderingbgColor
- color with which to clear area firstg
- graphics context for drawingpublic static void drawGrid(Rectangle gridArea, int gridSize, int tileSize, Color c, Graphics2D g)
gridArea
- where grid starts on screengridSize
- specifies number of rows and columns to drawtileSize
- size of each grid squarec
- color of the gridg
- graphics context for drawingpublic static Square tilePosToArea(ScreenFrames frames, Point tile) throws NullPointerException
frames
- dimensions required for calculating absolute locationstile
- relative position on grid
NullPointerException
- if either of the parameters is
null
.public static Square calcTileClip(ScreenFrames frames, Point tile)
frames
- dimensions required for calculating absolute locationstile
- relative position on grid
public static Rectangle calcTilesClip(ScreenFrames frames, Point tile1, Point tile2)
frames
- dimensions required for calculating absolute locationstile1
- 1st tiletile2
- 2nd tile
public static Point gridPos(ScreenFrames frames, Point mouseLocation)
frames
- dimensions required for calculating absolute locationsmouseLocation
- absolute location of mouse cursor
null
if mouse
not on gridpublic static Point absPos(ScreenFrames frames, Point p, int tileHeight)
frames
- dimensions required for calculating absolute locationsp
- relative grid positiontileHeight
- height of pile at given position
public static Rectangle calcTextBounds(String s, Font f, Graphics2D g)
s
- string to calculate required space forf
- font to calculate space usage forg
- graphics context for off-screen renderingpublic static Point calcCharOnTileOffset(char c, Font f, ScreenFrames frames, Graphics2D g)
c
- the character for which to calculate the offsetf
- font to calculate offset forframes
- dimensions required for calculating absolute locationsg
- graphics context for off-screen renderingpublic static String getMaxString(String s, String addition, int maxWidth, Font f, Graphics2D g)
s
- the string for which to calculate fitting substringaddition
- string to append to substring if all will not fitmaxWidth
- maximum width of whole string in pixelsf
- font to calculate dimensions forg
- graphics context for off-screen renderingpublic static int getTileButtonWidth(String s, boolean is3D, ScreenFrames frames)
s
- string which will be rendered on buttonis3D
- indicates whether button is raised or notframes
- dimensions required for calculating absolute locations
public static Dimension calcMaxLineDimensions(String[] lines, Font f, Graphics2D g)
lines
- text to analyzef
- font with which to calculate text dimensions
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |