|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgraphics.GraphicsEngine
public class GraphicsEngine
GraphicsEngine class is responsible for rendering graphics viewed on screen. Class gets all information about program's state from DataColletion -class and it renders weather, planes and routes into one bufferedImage. GraphicsEngine uses Java 2D and buffered offScreen-images. Next frame will be rendered when buildNextFrame() -method is called. There are some tricks we have used when generating graphics. First of all, we render the main background image just when weather changes. Background image contains weather map, airport and arrival tree. When weather stays same, we just render airplanes and airplane paths on the top of old background. At the beginning we show the Chopper -logo. GraphicsEngine also takes care of loading public graphics from hard disk. This feature is rather used by window and JPanels.
Field Summary | |
---|---|
private java.awt.BasicStroke |
arcPoints
Java 2D style for arc points. |
private java.awt.BasicStroke |
arrivalTree
Java 2D style for arrival tree. |
private java.awt.Color |
colorArcPoints
Render color for arc points. |
private java.awt.Color |
colorArrivalTree
Render color for arrival tree. |
private DataCollection |
dataCollection
Current instance of DataCollection- class. |
private java.awt.image.BufferedImage[] |
graphicsData
Graphics which is used in window and JPanels. |
private double |
mountedLat
Map latitude and longitude. |
private double |
mountedLon
Map latitude and longitude. |
private java.awt.image.BufferedImage |
nextBufferedImage
Rendered offScreen image. |
private java.awt.image.BufferedImage |
offScreenImage
Working space for Java 2D. |
private java.awt.Image |
offScreenImage2
Working space for Java 2D. |
private Parameters |
parameters
Current instance of Parameters- class. |
private java.awt.BasicStroke |
planes
Java 2D style for planes. |
private double |
relativeCornerPoint
Relative point of corner. |
private boolean |
renderAirspace
Shall we render airspace. |
private boolean |
renderArcPoints
Shall we render arc points. |
private boolean |
renderArrivalTree
Shall we render arc arrival tree. |
private boolean |
renderDebug
Shall we render debug information. |
private boolean |
renderDebug2
Shall we render debug information 2. |
private int |
renderMapHeight
Render map height. |
private int |
renderMapWidth
Render map width. |
private boolean |
renderPlaneAsTriangle
Shall we render plane as triangle. |
private boolean |
renderPlanePath
Shall we render plane path. |
private boolean |
renderWeatherMap
Shall we render weather map. |
private double |
scale
Scale is used to scout out different object to offScreen space. |
private boolean |
status
Status is false until first offScreen image is ready. |
Constructor Summary | |
---|---|
GraphicsEngine(DataCollection dCollection)
Construct new instance of GraphicsEngine-class. |
Method Summary | |
---|---|
boolean |
buildNextFrame()
Render next offScreen image into buffered offScreen -image. |
private void |
debugDrawGraph(java.awt.Graphics2D g2)
This method is for debugging. |
private java.lang.String[] |
getDebugData()
This method is for debugging. |
java.awt.image.BufferedImage |
getFrame()
Returns next frame in bufferedImage. |
java.awt.image.BufferedImage |
getGraphics(int index)
Returns asked graphics -object (bufferedImage). |
boolean |
getStatus()
Returns current status of this instance. |
private void |
graphicsRenderAirport(java.awt.Graphics2D g2,
Vertex root)
Draw airport to offScreen image. |
private boolean |
graphicsRenderAirspace(java.awt.Graphics2D g2,
java.util.ArrayList<Plane> planes)
Render planes and plane paths to OffScreen- image. |
private void |
graphicsRenderArcPoints(java.awt.Graphics2D g2)
Render arcPoints to OffScreen -image. |
private void |
graphicsRenderArrivalTree(java.awt.Graphics2D g2,
TreeNode node)
Method uses pre-order traversal to draw arrival tree into offScreen -image. |
private void |
graphicsRenderPlaneAsTriangle(java.awt.Graphics2D g2,
int x,
int y,
double direction)
Render a plane as a triangle. |
private void |
graphicsRenderRealArcPoints(java.awt.Graphics2D g2,
java.util.ArrayList<Vertex>[] arcPoints)
This method is for debugging. |
private void |
graphicsRenderStuff(java.awt.Graphics2D g2)
This method is for debugging. |
private boolean |
loadCommonGraphics()
Load media and graphics from hard disk. |
private java.awt.image.BufferedImage |
loadImage(java.lang.String filename)
Returns BufferedImage or null if file doesn't exists. |
void |
setDebugMode(boolean mode)
Set demo mode. |
void |
setDebugMode2()
Set demo 2 mode. |
void |
takeSnapshot()
Take snapshot and store it into media -directory defined in parameter class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.awt.BasicStroke arcPoints
private java.awt.BasicStroke arrivalTree
private java.awt.Color colorArcPoints
private java.awt.Color colorArrivalTree
private DataCollection dataCollection
private java.awt.image.BufferedImage[] graphicsData
private double mountedLat
private double mountedLon
private java.awt.image.BufferedImage nextBufferedImage
private java.awt.image.BufferedImage offScreenImage
private java.awt.Image offScreenImage2
private Parameters parameters
private java.awt.BasicStroke planes
private double relativeCornerPoint
private boolean renderAirspace
private boolean renderArcPoints
private boolean renderArrivalTree
private boolean renderDebug
private boolean renderDebug2
private int renderMapHeight
private int renderMapWidth
private boolean renderPlaneAsTriangle
private boolean renderPlanePath
private boolean renderWeatherMap
private double scale
private boolean status
Constructor Detail |
---|
public GraphicsEngine(DataCollection dCollection)
dCollection
- Current DataCollection class.Method Detail |
---|
public boolean buildNextFrame()
private void debugDrawGraph(java.awt.Graphics2D g2)
g2
- OffScreen space for Java 2D.private java.lang.String[] getDebugData()
public java.awt.image.BufferedImage getFrame()
public java.awt.image.BufferedImage getGraphics(int index)
index
- Graphics id.
public final boolean getStatus()
private void graphicsRenderAirport(java.awt.Graphics2D g2, Vertex root)
g2
- Graphics spaceroot
- Root vertex;private boolean graphicsRenderAirspace(java.awt.Graphics2D g2, java.util.ArrayList<Plane> planes)
g2
- OffScreen space for Java 2D.planes
- ArrayList of planes.
private void graphicsRenderArcPoints(java.awt.Graphics2D g2)
g2
- OffScreen space for Java 2D.private void graphicsRenderArrivalTree(java.awt.Graphics2D g2, TreeNode node)
g2
- OffScreen space for Java 2D.node
- Root node of tree.private void graphicsRenderPlaneAsTriangle(java.awt.Graphics2D g2, int x, int y, double direction)
g2
- Graphicsx
- X- coordinatey
- Y- coordinatedirection
- Plane directionprivate void graphicsRenderRealArcPoints(java.awt.Graphics2D g2, java.util.ArrayList<Vertex>[] arcPoints)
g2
- OffScreen space for Java 2D.arcPoints
- ArrayList of arcPoints.private void graphicsRenderStuff(java.awt.Graphics2D g2)
g2
- OffScreen space for Java 2Dprivate boolean loadCommonGraphics()
private java.awt.image.BufferedImage loadImage(java.lang.String filename)
filename
- File path and name.
public final void setDebugMode(boolean mode)
mode
- Set debug mode.public final void setDebugMode2()
public void takeSnapshot()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |