public class FunGraphics extends AcceleratedDisplay implements Graphics, DualLayerGraphics
Modifier and Type | Field and Description |
---|---|
(package private) int |
major |
(package private) int |
minor |
backBuffer, backg2d, bufferStrategy, checkBorders, current_fps, DISPLAY_FPS, enableRenderingHints, fHeight, frontBuffer, frontg2d, fWidth, g2d, mainFrame, numBuffers, target_fps, TRANSPARENT, VERBOSE
Constructor and Description |
---|
FunGraphics(int width,
int height)
Creates a graphic window to draw onto
|
FunGraphics(int width,
int height,
int xoffset,
int yoffset,
java.lang.String title,
boolean high_quality)
Creates a graphic window to draw onto.
|
FunGraphics(int width,
int height,
java.lang.String title)
Creates a graphic window to draw onto with a given title
|
FunGraphics(int width,
int height,
java.lang.String title,
boolean high_quality)
Creates a graphic window to draw onto.
|
Modifier and Type | Method and Description |
---|---|
void |
addMouseListener(java.awt.event.MouseListener l)
Adds a
MouseListener to the window
to react on mouse events |
void |
addMouseMotionListener(java.awt.event.MouseMotionListener m)
Adds a
MouseMotionListener to the window
to react on mouse movements |
void |
clear()
Method which cleans up the display.
|
void |
clear(java.awt.Color c)
Method which cleans up the display.
|
void |
drawBackground()
Call this method to modify only the background
|
void |
drawCircle(int posX,
int posY,
int f)
Draws a circle starting from
(Top left X, Top left Y) |
void |
drawFancyString(int posX,
int posY,
java.lang.String str,
java.awt.Color color,
int size)
Draws a text with a shadow
|
void |
drawFilledCircle(int posX,
int posY,
int radius)
Draws a circle starting from
(Top left X, Top left Y) |
void |
drawFilledOval(int posX,
int posY,
int width,
int height)
Draws an oval starting from
(Top left X, Top left Y) |
void |
drawFilledPolygon(java.awt.Polygon p,
java.awt.Color c)
Draw a filled polygon
|
void |
drawFillRect(int posX,
int posY,
int width,
int height)
Draw a filled rectangle in the color selected with setColor.
|
void |
drawFillRect(java.awt.Rectangle rect)
Draw a filled rectangle in the color selected with setColor.
|
void |
drawForeground()
Call this method to modify only the foreground
|
void |
drawLine(int p1x,
int p1y,
int p2x,
int p2y)
Draw a line from P1 to P2 in the color selected with setColor.
|
void |
drawMirroredPicture(int posX,
int posY,
double angle,
GraphicsBitmap bitmap)
Draw a mirrored centered picture from a file (gif, jpg, png) to
(posX, posY) |
void |
drawPicture(int posX,
int posY,
GraphicsBitmap bitmap)
Draw a centered picture from a file (gif, jpg, png) to
(posX, posY) |
void |
drawRect(int posX,
int posY,
int width,
int height)
Draw an empty rectangle in the color selected with setColor().
|
void |
drawRect(java.awt.Rectangle rect) |
void |
drawString(int posX,
int posY,
java.lang.String str)
Draws a string at a given location.
|
void |
drawString(int posX,
int posY,
java.lang.String str,
java.awt.Color color,
int size)
Write the given string at
posX, posY |
void |
drawTransformedPicture(int posX,
int posY,
double angle,
double scale,
GraphicsBitmap bitmap)
Draw a centered picture from a file (gif, jpg, png) to
(posX, posY) |
void |
drawTransformedPicture(int posX,
int posY,
double angle,
double scale,
java.lang.String imageName)
Draw a centered picture from a file (gif, jpg, png) to
(posX, posY) . |
(package private) void |
gameloopSample()
A sample game loop using explicit synchronization (if display flickers)
|
int |
getFrameHeight() |
int |
getFrameWidth()
Getters and setters
|
static void |
main(java.lang.String[] args) |
void |
setColor(java.awt.Color c)
Set the color of the future drawings
|
void |
setKeyManager(java.awt.event.KeyListener k)
Sets a keyboard listener
|
void |
setPenWidth(float width)
Sets the width of the pen
|
void |
setPixel(int x,
int y)
Draw the selected pixel with the color selected with setColor.
|
void |
setPixel(int x,
int y,
java.awt.Color c)
Draws a pixel with a given color.
|
void |
setPixel(int x,
int y,
int c)
Draws a pixel with a given color.
|
displayFPS, syncGameLogic
final int major
final int minor
public FunGraphics(int width, int height, int xoffset, int yoffset, java.lang.String title, boolean high_quality)
width
- Width of the windowheight
- Height of the windowxoffset
- X-Position of the window on the screenyoffset
- Y-Position of the window on the screentitle
- Title of the windowhigh_quality
- Use high quality renderingpublic FunGraphics(int width, int height, java.lang.String title, boolean high_quality)
width
- Width of the display windowheight
- Height of the display windowtitle
- Title of the display windowhigh_quality
- Use high quality rendering (slower)public FunGraphics(int width, int height, java.lang.String title)
FunGraphics(int, int, String, boolean)
public FunGraphics(int width, int height)
FunGraphics(int, int, String, boolean)
public void setKeyManager(java.awt.event.KeyListener k)
k
- The KeyListener to listen topublic void addMouseListener(java.awt.event.MouseListener l)
MouseListener
to the window
to react on mouse eventsl
- The MouseListener
public void addMouseMotionListener(java.awt.event.MouseMotionListener m)
MouseMotionListener
to the window
to react on mouse movementsm
- The MouseMotionListener
public void clear()
Graphics
public void clear(java.awt.Color c)
Graphics
public void setColor(java.awt.Color c)
Graphics
public void setPixel(int x, int y)
Graphics
public void setPixel(int x, int y, java.awt.Color c)
Graphics
setPixel
in interface Graphics
x
- X coordinatey
- Y coordinatec
- Color to use for this pixel (this pixel only, see Graphics.setColor(Color)
public void setPixel(int x, int y, int c)
Graphics
public void setPenWidth(float width)
Graphics
setPenWidth
in interface Graphics
width
- The new width of the penpublic void drawLine(int p1x, int p1y, int p2x, int p2y)
Graphics
public void drawFilledPolygon(java.awt.Polygon p, java.awt.Color c)
Graphics
drawFilledPolygon
in interface Graphics
public void drawRect(int posX, int posY, int width, int height)
Graphics
public void drawFillRect(int posX, int posY, int width, int height)
Graphics
drawFillRect
in interface Graphics
posX
- X coordinate of the top left corner of the rectangleposY
- Y coordinate of the top left corner of the rectanglewidth
- Width of the rectangleheight
- Height of the rectanglepublic void drawRect(java.awt.Rectangle rect)
public void drawFillRect(java.awt.Rectangle rect)
Graphics
drawFillRect
in interface Graphics
rect
- rectangle to drawpublic void drawCircle(int posX, int posY, int f)
Graphics
(Top left X, Top left Y)
drawCircle
in interface Graphics
posX
- X top-left position of the circleposY
- Y top-left position of the circlef
- Diameter of the drawn circlepublic void drawFilledCircle(int posX, int posY, int radius)
Graphics
(Top left X, Top left Y)
drawFilledCircle
in interface Graphics
posX
- X top-left position of the circleposY
- Y top-left position of the circleradius
- Radius of the drawn circlepublic void drawFilledOval(int posX, int posY, int width, int height)
Graphics
(Top left X, Top left Y)
drawFilledOval
in interface Graphics
posX
- X top-left position of the circleposY
- Y top-left position of the circlewidth
- Width of the drawn ovalheight
- Height of the drawn ovalpublic void drawString(int posX, int posY, java.lang.String str)
Graphics
drawString
in interface Graphics
posX
- X position of stringposY
- Y position of stringstr
- the string to writepublic void drawString(int posX, int posY, java.lang.String str, java.awt.Color color, int size)
Graphics
posX, posY
drawString
in interface Graphics
posX
- Position x of the stringposY
- Position y of the stringstr
- The string to be drawncolor
- The color of the stringsize
- The size of the fontpublic void drawFancyString(int posX, int posY, java.lang.String str, java.awt.Color color, int size)
Graphics
drawFancyString
in interface Graphics
public void drawPicture(int posX, int posY, GraphicsBitmap bitmap)
Graphics
(posX, posY)
drawPicture
in interface Graphics
posX
- X position of the imageposY
- Y position of the imagepublic void drawTransformedPicture(int posX, int posY, double angle, double scale, java.lang.String imageName)
Graphics
(posX, posY)
. Warning,
very slow because the image has to be
reloadeddrawTransformedPicture
in interface Graphics
posX
- X position of the imageposY
- Y position of the imageangle
- The rotation angle of the image to be drawnimageName
- path of the image filepublic void drawTransformedPicture(int posX, int posY, double angle, double scale, GraphicsBitmap bitmap)
Graphics
(posX, posY)
drawTransformedPicture
in interface Graphics
posX
- X position of the imageposY
- Y position of the imageangle
- The rotation angle of the image to be drawnbitmap
- A #SimpleGraphicsBitmap()
bitmappublic void drawMirroredPicture(int posX, int posY, double angle, GraphicsBitmap bitmap)
Graphics
(posX, posY)
drawMirroredPicture
in interface Graphics
posX
- X position of the imageposY
- Y position of the imageangle
- The rotation angle of the image to be drawnbitmap
- A #SimpleGraphicsBitmap()
bitmappublic void drawBackground()
DualLayerGraphics
drawBackground
in interface DualLayerGraphics
public void drawForeground()
DualLayerGraphics
drawForeground
in interface DualLayerGraphics
public int getFrameWidth()
Graphics
getFrameWidth
in interface Graphics
public int getFrameHeight()
getFrameHeight
in interface Graphics
void gameloopSample()
public static void main(java.lang.String[] args)