|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--fdda.graphics.java2d.GraphicalSystem
Represents a graphical system - that means mostly nodes and lines. These are stored both in a TreeSet (so the order of their adding is retained) and a HashMap (wrapped in a special class), which allows a fast search. Messages are just stored in a LinkedList, since they must mostly only be run through to move and draw them.
| Nested Class Summary | |
(package private) static class |
GraphicalSystem.ComponentWrapper
Wraps a component: adds an attribute ID, enables comparing of the components so the TreeSet can be used to store them. |
(package private) static class |
GraphicalSystem.WrapperComparator
Compares two ComponentWrappers by using their IDs. |
| Field Summary | |
protected boolean |
changed
was the system changed since the last save operation? |
protected Comparator |
comparator
Comparator to compare two wrapped components |
protected int |
lineID
ID for the next line |
protected HashMap |
lineMap
map for fast finding of lines |
protected TreeSet |
lines
The lines. |
protected LinkedList |
messages
the messages |
protected int |
nodeID
ID for the the next node |
protected HashMap |
nodeMap
map for fast finding of nodes |
protected TreeSet |
nodes
The nodes. |
| Constructor Summary | |
GraphicalSystem()
Constructor |
|
| Method Summary | |
void |
addLine(Line line)
Adds a line to the system. |
void |
addMessage(Message message)
Adds a message to the system |
void |
addNode(Node node)
Adds a node to the system. |
void |
clear()
Removes all nodes and all lines from the system. |
void |
clearMessages()
Removes all messages from the system |
void |
draw(Graphics2D graphContext)
Draws the system - first the lines (and their points), than the nodes, finally the messages. |
Collection |
getAllMessages()
Returns all messages in the system. |
Component |
getElementAt(double x,
double y)
Returns the 'topmost' component at a certain point. |
Rectangle2D |
getEnclosingRectangle()
Returns a rectangle that just encloses all components in the system. |
GraphicHolder |
getGraphicHolder()
Returns the graphic holder for the system |
Component |
getMovableComponents()
Returns all movable components in the graphical system. |
Component |
getMovableComponentsInArea(Area area)
Returns all movable components that lie in the specified area. |
Project |
getProject()
Returns the project which includes this graphical system. |
void |
recalculateShapes()
Recalculates the shapes of all components in the system. |
void |
removeLine(Line line)
Removes a line from the system. |
void |
removeMessage(Message message)
Removes a message from the system |
void |
removeNode(Node node)
Removes a node from the system. |
void |
setChanged(boolean changed)
Sets whether the system was changed since the last save operation. |
void |
setGraphicHolder(GraphicHolder holder)
sets the graphic holder for the system |
void |
setProject(Project project)
Sets the project which includes this graphical system. |
boolean |
wasChanged()
Returns whether the graphical system was changed since the last save operation. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected TreeSet nodes
protected TreeSet lines
protected HashMap nodeMap
protected HashMap lineMap
protected LinkedList messages
protected boolean changed
protected int nodeID
protected int lineID
protected Comparator comparator
| Constructor Detail |
public GraphicalSystem()
| Method Detail |
public void setProject(Project project)
GraphicalSystem
setProject in interface GraphicalSystemproject - the projectpublic Project getProject()
GraphicalSystem
getProject in interface GraphicalSystempublic void addNode(Node node)
GraphicalSystem
addNode in interface GraphicalSystemnode - the nodepublic void addLine(Line line)
GraphicalSystem
addLine in interface GraphicalSystemline - the linepublic void removeNode(Node node)
GraphicalSystem
removeNode in interface GraphicalSystemnode - the nodepublic void removeLine(Line line)
GraphicalSystem
removeLine in interface GraphicalSystemline - the line
public Component getElementAt(double x,
double y)
GraphicalSystem
getElementAt in interface GraphicalSystemx - the x coordinate of the pointy - the y coordinate of the point
public Component getMovableComponentsInArea(Area area)
GraphicalSystem
getMovableComponentsInArea in interface GraphicalSystemarea - the area
public void draw(Graphics2D graphContext)
graphContext - the graphicspublic Rectangle2D getEnclosingRectangle()
GraphicalSystem
getEnclosingRectangle in interface GraphicalSystempublic GraphicHolder getGraphicHolder()
public void setGraphicHolder(GraphicHolder holder)
holder - the graphic holderpublic void recalculateShapes()
GraphicalSystem
recalculateShapes in interface GraphicalSystempublic void clear()
GraphicalSystem
clear in interface GraphicalSystempublic Component getMovableComponents()
GraphicalSystem
getMovableComponents in interface GraphicalSystempublic boolean wasChanged()
GraphicalSystem
wasChanged in interface GraphicalSystempublic void setChanged(boolean changed)
GraphicalSystem
setChanged in interface GraphicalSystemchanged - whether the system was changedpublic void addMessage(Message message)
GraphicalSystem
addMessage in interface GraphicalSystemmessage - the messagepublic void removeMessage(Message message)
GraphicalSystem
removeMessage in interface GraphicalSystemmessage - the messagepublic void clearMessages()
GraphicalSystem
clearMessages in interface GraphicalSystempublic Collection getAllMessages()
GraphicalSystem
getAllMessages in interface GraphicalSystem
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||