public class GGBackground
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the background buffer by painting it with the current background color.
|
void |
clear(java.awt.Color color)
Clears the background buffer by painting
it with the given background color.
|
void |
drawArc(java.awt.Point pt,
int radius,
double startAngle,
double extentAngle)
Draws an arc with given center, radius, start angle and angle extent.
|
void |
drawCircle(java.awt.Point center,
int radius)
Draws a circle with given center and given radius.
|
void |
drawGeneralPath(java.awt.geom.GeneralPath gp)
Draws a figure defined by the given GeneralPath.
|
void |
drawGridLines(java.awt.Color color)
Draws the grid lines using the given color.
|
void |
drawImage(java.awt.image.BufferedImage bi)
Draws the given image at position (0, 0) into the background buffer.
|
void |
drawImage(java.awt.image.BufferedImage bi,
int x,
int y)
Draws the given image into the background buffer.
|
void |
drawImage(java.lang.String imagePath,
int x,
int y)
Retrieves the image either from the jar resource, from local drive or
from a internet server and draws it into the background buffer.
|
void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draws a line from one coordinate pair to another coordinate pair.
|
void |
drawLine(java.awt.Point pt1,
java.awt.Point pt2)
Draws a line from one coordinate pair to another coordinate pair.
|
void |
drawPoint(java.awt.Point pt)
Draws a single point.
|
void |
drawPolygon(java.awt.Point[] vertexes)
Draws a polygon with given vertexes.
|
void |
drawRectangle(java.awt.Point pt1,
java.awt.Point pt2)
Draws a rectangle with given opposite corners.
|
void |
drawText(java.lang.String text,
java.awt.Point pt)
Displays the given text at the given position using the current font.
|
void |
fillArc(java.awt.Point pt,
int radius,
double startAngle,
double extentAngle)
Fills an arc with given center, radius, start angle and angle extent.
|
void |
fillCell(Location location,
java.awt.Color fillColor)
Fills a cell with given color.
|
void |
fillCell(Location location,
java.awt.Color fillColor,
boolean boundary)
Fills a cell with given color.
|
void |
fillCircle(java.awt.Point center,
int radius)
Draws a filled circle with given center and given radius.
|
void |
fillGeneralPath(java.awt.geom.GeneralPath gp)
Fills a figure defined by the given GeneralPath.
|
void |
fillPolygon(java.awt.Point[] vertexes)
Draws a filled polygon with given vertexes.
|
void |
fillRectangle(java.awt.Point pt1,
java.awt.Point pt2)
Draws a filled rectangle with given opposite corners.
|
static java.lang.String[] |
getAvailableFontFamilies()
Returns the available font families for the current platform.
|
java.awt.image.BufferedImage |
getBackgroundImage()
Returns the BufferedImage of the current background.
|
java.awt.Color |
getBgColor()
Returns the current background color.
|
java.awt.Color |
getColor(Location location)
Returns the color of the pixel of the background at given cell's center.
|
java.awt.Color |
getColor(java.awt.Point pt)
Returns the color of the pixel of the background at given point.
|
java.awt.Graphics2D |
getContext()
Returns the graphics device context of the background.
|
int |
getLineWidth()
Returns the current line width in pixels.
|
java.awt.Color |
getPaintColor()
Returns the current paint color.
|
void |
restore()
Restores a previously saved background.
|
void |
save()
Saves the current background to an extra buffer.
|
void |
setBgColor(java.awt.Color color)
Sets the given new background color.
|
void |
setFont(java.awt.Font font)
Sets the font for displaying text with setText()
|
void |
setLineWidth(int width)
Sets the current line width in pixels.
|
void |
setPaintColor(java.awt.Color color)
Sets the given new paint color (for drawing and filling).
|
void |
setPaintMode()
Sets the paint mode of the graphics context to overwrite
with current color.
|
void |
setXORMode(java.awt.Color c)
Sets the paint mode to alternate between the current color and the given color.
|
public java.awt.image.BufferedImage getBackgroundImage()
public void save()
public void restore()
public void drawImage(java.lang.String imagePath, int x, int y)
imagePath
- the file name or urlx
- x-coordinate of upper left cornery
- y-coordinate of upper left cornerpublic void drawImage(java.awt.image.BufferedImage bi, int x, int y)
x
- x-coordinate of upper left cornery
- y-coordinate of upper left cornerpublic void drawImage(java.awt.image.BufferedImage bi)
public void clear(java.awt.Color color)
color
- the color of the backgroundpublic void clear()
public void drawGridLines(java.awt.Color color)
color
- the color of the grid linespublic int getLineWidth()
public void setLineWidth(int width)
width
- the new line widthpublic java.awt.Color getPaintColor()
public void setPaintColor(java.awt.Color color)
color
- the new line colorpublic java.awt.Color getBgColor()
public void setBgColor(java.awt.Color color)
color
- the new background colorpublic void drawLine(int x1, int y1, int x2, int y2)
x1
- the x-coordinate of the start pointy1
- the y-coordinate of the start pointx2
- the x-coordinate of the endpointy2
- the y-coordinate of the endpointpublic void drawLine(java.awt.Point pt1, java.awt.Point pt2)
pt1
- the start pointpt2
- the endpointpublic void drawCircle(java.awt.Point center, int radius)
radius
- the radius of the circlepublic void fillCircle(java.awt.Point center, int radius)
center
- the center of the circleradius
- the radius of the circlepublic void drawRectangle(java.awt.Point pt1, java.awt.Point pt2)
pt1
- upper left vertex of the rectanglept2
- lower right vertex of the rectanglepublic void fillRectangle(java.awt.Point pt1, java.awt.Point pt2)
pt1
- upper left vertex of the rectanglept2
- lower right vertex of the rectanglepublic void drawArc(java.awt.Point pt, int radius, double startAngle, double extentAngle)
pt
- the center of the arcradius
- the radius of the arcstartAngle
- the start angle in degrees (zero to east, positive counterclockwise)extentAngle
- the angle extent of the arc in degreespublic void fillArc(java.awt.Point pt, int radius, double startAngle, double extentAngle)
pt
- the center of the arcradius
- the radius of the arcstartAngle
- the start angle in degrees (zero to east, positive counterclockwise)extentAngle
- the angle extent of the arc in degreespublic void drawPolygon(java.awt.Point[] vertexes)
vertexes
- the vertexes of the polygonpublic void fillPolygon(java.awt.Point[] vertexes)
vertexes
- the vertexes of the polygonpublic void drawGeneralPath(java.awt.geom.GeneralPath gp)
gp
- the GeneralPath that defines the shapepublic void fillGeneralPath(java.awt.geom.GeneralPath gp)
gp
- the GeneralPath that defines the shapepublic void drawPoint(java.awt.Point pt)
pt
- the point to drawpublic void fillCell(Location location, java.awt.Color fillColor)
location
- the cell's location (cell indices).fillColor
- the filling color of the cellpublic void fillCell(Location location, java.awt.Color fillColor, boolean boundary)
location
- the cell's location (cell indices).fillColor
- the filling color of the cellboundary
- if true the boundary lines are considered to be part of the cell;
otherwise the boundary lines are left intactpublic java.awt.Color getColor(java.awt.Point pt)
pt
- point, where to pick the color; if pt is outside
the grid, returns Color.black.public java.awt.Color getColor(Location location)
location
- cell's location where to pick the color; if location is outside
the grid, returns Color.black.public void setFont(java.awt.Font font)
font
- public void drawText(java.lang.String text, java.awt.Point pt)
text
- the text to displaypt
- the start point of the text baselinepublic static java.lang.String[] getAvailableFontFamilies()
public java.awt.Graphics2D getContext()
public void setPaintMode()
public void setXORMode(java.awt.Color c)