|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuchicago.src.sim.gui.SimGraphics
public class SimGraphics
A Wrapper around java.awt.Graphics2D. Simplifies the drawing of circles, rectangles, and so forth. Rectangles are generally faster to draw than circles. The Displays should take care of layouts while objects that wish to be drawn as a shape need only call the appropriate method.
Many of the draw methods have a drawFast counterpart. This is due to speed problems with the Java2D api. In general the Java2D api is more flexible and usually looks nicer than its ordinary AWT counterpart. Moreover, somethings are easier to do with it (i.e. drawing borders). For now though, the drawFast methods are better.
| Constructor Summary | |
|---|---|
SimGraphics()
|
|
| Method Summary | |
|---|---|
void |
draw4ColorHollowRect(java.awt.Color top,
java.awt.Color bottom,
java.awt.Color left,
java.awt.Color right)
Draws the sides of a hollow rectangle in the four specifed colors. |
void |
drawCircle(java.awt.Color c)
Draws a true circle with the specified color. |
void |
drawDirectedLink(java.awt.Color c,
int fromX,
int toX,
int fromY,
int toY)
Draws a directed link (a line with a square head) from the specified coordinates to the specified coordinates in the specified color. |
void |
drawFastCircle(java.awt.Color c)
Draws a circle of the specified color at the current coordinates faster than drawCircle. |
void |
drawFastOval(java.awt.Color c)
Draws an oval in the specified color faster than drawOval. |
void |
drawFastRect(java.awt.Color color)
Draws a rectangle at the current x and y coordinate with the current width and height in the specified color. |
void |
drawFastRoundRect(java.awt.Color c)
Draws a rounded rectangle of the specified color, faster than drawRoundRect. |
void |
drawHollowFastOval(java.awt.Color color)
Draws a hollow oval in the specified color faster than drawHollowOval. |
void |
drawHollowFastRect(java.awt.Color color)
Draws a hollow rectangle of the specified color faster than drawHollowRect. |
void |
drawHollowFastRoundRect(java.awt.Color c)
Draws a hollow rounded rectangle with the specified color, faster than drawHollowCircle. |
void |
drawHollowOval(java.awt.Color color)
Draws a hollow oval in the specified color. |
void |
drawHollowRect(java.awt.Color color)
Draws a hollow rectangle of the specified color. |
void |
drawHollowRoundRect(java.awt.Color c)
Draws a hollow rounded rectangle of the specified color. |
void |
drawImage(java.awt.Image img)
Draws the specified image. |
void |
drawImageScaled(java.awt.Image img)
Draws the specified image, scaling the image according to the SimGraphic's current scale. |
void |
drawImageToFit(java.awt.Image img)
Draws the specified image, scaling the image to the correct size if necessary. |
void |
drawLine(java.awt.Color color)
|
void |
drawLink(java.awt.Color c,
int fromX,
int toX,
int fromY,
int toY)
Draws a link (a line) from the specified coordinates to the specified coordinates in the specified color. |
void |
drawMultiPolygon(java.awt.Color color,
int[] polys)
|
void |
drawOval(java.awt.Color color)
Draws an oval in the specified color. |
void |
drawOvalBorder(java.awt.BasicStroke stroke,
java.awt.Color color)
Draws an oval shaped border using the current drawing parameters. |
void |
drawPolygon(java.awt.Color color)
|
void |
drawRect(java.awt.Color color)
Draws a rectangle of the specified color. |
void |
drawRectBorder(java.awt.BasicStroke stroke,
java.awt.Color color)
Draws an rectangular border using the current drawing parameters. |
void |
drawRoundRect(java.awt.Color c)
Draws a rounded rectangle of the specified color. |
void |
drawString(java.lang.String string,
java.awt.Color stringColor)
Draws a string using the current drawing parameters. |
void |
drawStringInHollowOval(java.awt.Color ovalColor,
java.awt.Color stringColor,
java.lang.String string)
Draws the specified string in a hollow oval using the specified colors. |
void |
drawStringInHollowRect(java.awt.Color rectColor,
java.awt.Color stringColor,
java.lang.String string)
Draws the specified string in a hollow rectangle using the specified colors. |
void |
drawStringInHollowRoundRect(java.awt.Color rectColor,
java.awt.Color stringColor,
java.lang.String string)
Draws a string of the specified color in a hollow rounded rectangle of the specified color. |
void |
drawStringInOval(java.awt.Color ovalColor,
java.awt.Color stringColor,
java.lang.String string)
Draws the specified string in an oval using the specified colors. |
void |
drawStringInRect(java.awt.Color rectColor,
java.awt.Color stringColor,
java.lang.String string)
Draws the specified string in a rectangle using the specified colors. |
void |
drawStringInRoundRect(java.awt.Color rectColor,
java.awt.Color stringColor,
java.lang.String string)
Draws the specified string inside a rounded rectangle. |
void |
fillPolygon(java.awt.Color color)
|
int |
getCellHeightScale()
|
int |
getCellWidthScale()
|
int |
getCurHeight()
|
int |
getCurWidth()
|
int |
getDisplayHeight()
|
int |
getDisplayWidth()
|
java.awt.Graphics2D |
getGraphics()
Gets the Graphics2D object around which this is a wrapper. |
static SimGraphics |
getInstance()
|
java.awt.geom.Rectangle2D |
getStringBounds(java.lang.String s)
Get the bounding rectangle for the specified string using the current font. |
java.awt.geom.Rectangle2D |
getStringBounds(java.lang.String s,
java.awt.Font f)
Get the bounding rectangle for the specified string and the specified font. |
float |
getXScale()
|
float |
getYScale()
|
void |
setCurLineX(int[] xs)
|
void |
setCurLineY(int[] ys)
|
void |
setDisplaySurface(DisplaySurface surface)
Sets the display surface associated with this SimGraphics instance. |
void |
setDrawingCoordinates(float x,
float y,
float z)
Sets the coordinates for the next drawing operation. |
void |
setDrawingParameters(int width,
int height,
int depth)
Sets the parameters for the next drawing operation. |
void |
setDrawingParametersNoScale(int width,
int height,
int depth)
Sets the parameters for the next drawing operation. |
void |
setFont(java.awt.Font font)
Sets the current font. |
void |
setGraphics(java.awt.Graphics2D g)
Sets the wrapped graphics2D |
void |
setXScale(float scale)
|
void |
setYScale(float scale)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SimGraphics()
| Method Detail |
|---|
public static SimGraphics getInstance()
public void setGraphics(java.awt.Graphics2D g)
g - the Graphics2D to wrappublic java.awt.Graphics2D getGraphics()
public void setDisplaySurface(DisplaySurface surface)
surface - the display surface on which this drawspublic int getDisplayWidth()
public int getDisplayHeight()
public void setFont(java.awt.Font font)
font - the new fontpublic float getXScale()
public void setXScale(float scale)
public int getCellWidthScale()
public float getYScale()
public void setYScale(float scale)
public int getCellHeightScale()
public void setDrawingCoordinates(float x,
float y,
float z)
x - the x coordinatey - the y coordinatez - the z coordinate
public void setDrawingParameters(int width,
int height,
int depth)
width - the new widthheight - the new heightdepth - the new depth
public void setDrawingParametersNoScale(int width,
int height,
int depth)
width - the new widthheight - the new heightdepth - the new depthpublic int getCurWidth()
public int getCurHeight()
public void drawImage(java.awt.Image img)
drawImageToFit will
scale the image appropriately before drawing it.
img - the Image to draw.public void drawImageToFit(java.awt.Image img)
img - the Image to draw.public void drawImageScaled(java.awt.Image img)
drawImageToFit(Image) in that it doesn't scale it to the total
size of the SimGraphics, it just scales it according to the general
scaling. In a different phrasing, it scales the image according to the
scaling of everything else, while drawImageToFit scales to fit in the
total available size.
This is more appropriate for a non-grid display then drawImageToFit.
img - the Image to draw.public void drawRoundRect(java.awt.Color c)
c - the color of the round rectanglepublic void drawFastRoundRect(java.awt.Color c)
c - the color of the round rectanglepublic void drawHollowRoundRect(java.awt.Color c)
c - the color of the round rectanglepublic void drawHollowFastRoundRect(java.awt.Color c)
c - the color of the round rectanglepublic void drawCircle(java.awt.Color c)
c - the color of the circlepublic void drawFastCircle(java.awt.Color c)
c - the color of the circle
public void drawDirectedLink(java.awt.Color c,
int fromX,
int toX,
int fromY,
int toY)
c - the color of the linkfromX - the x coordinate to draw fromtoX - the x coordinate to draw tofromY - the y coordinate to fromtoY - the y coordinate to draw to
public void drawLink(java.awt.Color c,
int fromX,
int toX,
int fromY,
int toY)
c - the color of the linkfromX - the x coordinate to draw fromtoX - the x coordinate to draw tofromY - the y coordinate to fromtoY - the y coordinate to draw to
public void drawStringInRoundRect(java.awt.Color rectColor,
java.awt.Color stringColor,
java.lang.String string)
rectColor - the color of the rounded rectanglestringColor - the color of the stringstring - the string to draw
public void drawStringInHollowRoundRect(java.awt.Color rectColor,
java.awt.Color stringColor,
java.lang.String string)
rectColor - the color of the circlestringColor - the color of the Stringstring - the string to draw.public void drawOval(java.awt.Color color)
color - the color to draw the oval withpublic void drawFastOval(java.awt.Color c)
c - the color to draw the oval withpublic void drawHollowFastOval(java.awt.Color color)
color - public void drawHollowOval(java.awt.Color color)
color - the color to draw the oval with
public void drawStringInOval(java.awt.Color ovalColor,
java.awt.Color stringColor,
java.lang.String string)
ovalColor - the color of the ovalstringColor - the color of the stringstring - the string to draw
public void drawStringInHollowOval(java.awt.Color ovalColor,
java.awt.Color stringColor,
java.lang.String string)
ovalColor - the color of the ovalstringColor - the color of the stringstring - the string to draw
public void drawOvalBorder(java.awt.BasicStroke stroke,
java.awt.Color color)
stroke - the stroke to draw the border withcolor - the color of the border
public java.awt.geom.Rectangle2D getStringBounds(java.lang.String s,
java.awt.Font f)
s - the stringf - the font
public java.awt.geom.Rectangle2D getStringBounds(java.lang.String s)
s - the string
public void drawFastRect(java.awt.Color color)
color - the color of the rectangle to drawpublic void drawRect(java.awt.Color color)
setDrawingParameters.
color - the color of the rectanglepublic void drawHollowRect(java.awt.Color color)
setDrawingParameters.
color - the color of the rectangle
public void draw4ColorHollowRect(java.awt.Color top,
java.awt.Color bottom,
java.awt.Color left,
java.awt.Color right)
top - the color of the top sidebottom - the color of the bottom sideleft - the color of the left sideright - the color of the right sidepublic void drawHollowFastRect(java.awt.Color color)
setDrawingParameters.
color - the color of the rectangle
public void drawStringInRect(java.awt.Color rectColor,
java.awt.Color stringColor,
java.lang.String string)
rectColor - the color of the rectanglestringColor - the color of the stringstring - the string to draw
public void drawStringInHollowRect(java.awt.Color rectColor,
java.awt.Color stringColor,
java.lang.String string)
rectColor - the color of the rectanglestringColor - the color of the stringstring - the string to draw
public void drawRectBorder(java.awt.BasicStroke stroke,
java.awt.Color color)
stroke - the stroke to draw the border withcolor - the color of the border
public void drawString(java.lang.String string,
java.awt.Color stringColor)
string - the string to drawstringColor - the color the the stringpublic void setCurLineX(int[] xs)
public void setCurLineY(int[] ys)
public void drawLine(java.awt.Color color)
public void drawPolygon(java.awt.Color color)
public void fillPolygon(java.awt.Color color)
public void drawMultiPolygon(java.awt.Color color,
int[] polys)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||