net.sourceforge.toscanaj.model.diagram
Class NestedLineDiagram
java.lang.Object
net.sourceforge.toscanaj.model.diagram.SimpleLineDiagram
net.sourceforge.toscanaj.model.diagram.NestedLineDiagram
- All Implemented Interfaces:
- Diagram2D, WriteableDiagram2D, XMLizable
- public class NestedLineDiagram
- extends SimpleLineDiagram
Stores a nested line diagram.
The derivation from SimpleLineDiagram is just implementation, not design.
- To do:
- Create common abstract class for both types of diagrams.
Methods inherited from class net.sourceforge.toscanaj.model.diagram.SimpleLineDiagram |
addExtraCanvasItem, addLine, addNode, checkCoordinateSystem, createNewDiagramNode, getAttributeLabel, getBottomConcept, getBounds, getDescription, getEventBroker, getExtraCanvasItems, getFromPosition, getLine, getLines, getNode, getNode, getNumberOfLines, getNumberOfNodes, getObjectLabel, getTitle, getTopConcept, getToPosition, isHasseDiagram, readXML, registerExtraCanvasItemFactory, removeExtraCanvasItems, sendChangeEvent, setDescription, setEventBroker, setTitle, toXML |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
NestedLineDiagram
public NestedLineDiagram(Diagram2D outerDiagram,
Diagram2D innerDiagram)
- Creates a new nested line diagram from the given two diagrams.
The inner diagram will be nested in each node of the outer diagram.
The level gives the depth of nesting for this diagram, starting with one
for a diagram on top level.
calculateNeededScaling
protected double calculateNeededScaling(Diagram2D outerDiagram,
Diagram2D innerDiagram)
- Calculates the scaling we need to fit the inner nodes into the outer ones.
The basic algorithm goes like this:
1) minDist := minimal distance between two nodes in the outer diagram
2) maxRadius := half of minDist (this radius would cause two nodes in
the outer diagram to just meet)
3) possibleScaling := maxRadius/currentRadius (we can scale the radius of
the outer nodes by this without getting trouble)
4) neededScaling := (innerSize/2)/currentRadius (this is what we need to fit
the inner diagram)
5) additionalScaling := neededScaling/possibleScaling (we need to scale
that much more to fit the inner diagrams)
The steps can be combined to:
3) additionalScaling := innerSize/minDist
This is of course oversimplified: we ignore the distinction between x and
y sizes, we ignore the distinction between ellipses and rectangles. The
code does more details but the idea is the same.
- To do:
- handle different X and Y radii.
getNodeForConcept
public DiagramNode getNodeForConcept(Concept concept)
- Description copied from interface:
Diagram2D
- Finds the node representing the concept given.
Returns null if no such node exists in this diagram.
- Specified by:
getNodeForConcept
in interface Diagram2D
- Overrides:
getNodeForConcept
in class SimpleLineDiagram
toString
public java.lang.String toString()
getInnerDiagram
public Diagram2D getInnerDiagram()
getOuterDiagram
public Diagram2D getOuterDiagram()
getNodes
public java.util.Iterator getNodes()
- Returns all nodes of all inner diagrams.
- Specified by:
getNodes
in interface Diagram2D
- Overrides:
getNodes
in class SimpleLineDiagram
The ToscanaJ project