net.sourceforge.toscanaj.model.diagram
Class NestedLineDiagram

java.lang.Object
  extended bynet.sourceforge.toscanaj.model.diagram.SimpleLineDiagram
      extended bynet.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.

Field Summary
 
Fields inherited from class net.sourceforge.toscanaj.model.diagram.SimpleLineDiagram
eventBroker
 
Fields inherited from interface net.sourceforge.toscanaj.model.diagram.Diagram2D
DESCRIPTION_ELEMENT_NAME, DIAGRAM_ELEMENT_NAME, EXTRA_CANVAS_ITEMS_ELEMENT_NAME, MINIMUM_STEEPNESS, TITLE_ATTRIBUTE_NAME
 
Constructor Summary
NestedLineDiagram(Diagram2D outerDiagram, Diagram2D innerDiagram)
          Creates a new nested line diagram from the given two diagrams.
 
Method Summary
protected  double calculateNeededScaling(Diagram2D outerDiagram, Diagram2D innerDiagram)
          Calculates the scaling we need to fit the inner nodes into the outer ones.
 Diagram2D getInnerDiagram()
           
 DiagramNode getNodeForConcept(Concept concept)
          Finds the node representing the concept given.
 java.util.Iterator getNodes()
          Returns all nodes of all inner diagrams.
 Diagram2D getOuterDiagram()
           
 java.lang.String toString()
           
 
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
 

Constructor Detail

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.

Method Detail

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