net.sourceforge.toscanaj.controller.fca
Class DiagramController

java.lang.Object
  extended bynet.sourceforge.toscanaj.controller.fca.DiagramController
All Implemented Interfaces:
ChangeObservable

public class DiagramController
extends java.lang.Object
implements ChangeObservable

This class encapsulates all code for handling the diagrams and filtering the objects left after zooming. This is implemented as singleton, use getController() to access the only instance. The inner class DiagramHistory can be used to be inserted into a JList for displaying purposes.


Constructor Summary
DiagramController()
           
 
Method Summary
 void addDiagram(Diagram2D diagram)
          Adds a diagram to the history.
 void addObserver(ChangeObserver observer)
          Implements ChangeObservable.addObserver(ChangeObserver).
 void back()
          Goes one step back in the history.
static DiagramController getController()
          Returns the only instance of this class.
 Diagram2D getCurrentDiagram()
          Returns the current diagram to be displayed.
 DiagramHistory getDiagramHistory()
          Returns the history as list model.
protected  Diagram2D getNestedDiagram(int pos)
          Returns a nested diagram using the list of current diagrams.
protected  Diagram2D getSimpleDiagram(int pos)
          Returns a simple (flat) diagram created from the position in the list of current diagrams.
 boolean hasFutureDiagrams()
          Returns true if there a still diagrams to visit.
 void next(Concept zoomedConcept)
          Moves forward to the next diagram.
protected  void notifyObservers()
          Notifies all observers of an update that changes the current diagram.
 void removeLastDiagram()
          Removes the last diagram from the list.
 void removeObserver(ChangeObserver observer)
          Implements ChangeObservable.removeObserver(ChangeObserver).
 void reset()
          Removes all diagrams: past, current and future from the history.
 void setNestingLevel(int level)
          Sets the number of diagrams used for nesting.
 boolean undoIsPossible()
          Returns true if an undo step can be made.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiagramController

public DiagramController()
Method Detail

getController

public static DiagramController getController()
Returns the only instance of this class.


setNestingLevel

public void setNestingLevel(int level)
Sets the number of diagrams used for nesting. This starts with zero (flat, non-nested diagram).


getDiagramHistory

public DiagramHistory getDiagramHistory()
Returns the history as list model. This can be used directly in a JList for displaying purposes.


undoIsPossible

public boolean undoIsPossible()
Returns true if an undo step can be made. This is only true if we have past diagrams, if we have nesting we can call back() but the user should not be allowed to, since this changes nesting levels but is not an undo.

See Also:
back()

addDiagram

public void addDiagram(Diagram2D diagram)
Adds a diagram to the history. If no diagram is open yet it will be used as current diagram, else it will be added to the list of future diagrams.


removeLastDiagram

public void removeLastDiagram()
Removes the last diagram from the list. If this is a currently visible diagram this will include an undo operation. If no diagram is left a NoSuchElementException will be raised.


reset

public void reset()
Removes all diagrams: past, current and future from the history.


hasFutureDiagrams

public boolean hasFutureDiagrams()
Returns true if there a still diagrams to visit.


next

public void next(Concept zoomedConcept)
Moves forward to the next diagram. This is done by putting the outermost current one into the history and getting a new one out of the list of future diagrams.

See Also:
back()

back

public void back()
Goes one step back in the history. This is the undo operation for next(). If we have multiple current diagrams but no past diagrams left this will reduce the nesting level by one until new diagrams are added.

See Also:
next(Concept), undoIsPossible()

getCurrentDiagram

public Diagram2D getCurrentDiagram()
Returns the current diagram to be displayed. This is currently an instance of SimpleLineDiagram which is filtered by the extent of the zoomed concepts in the past diagrams. If there is no diagram selected this will return null.


getSimpleDiagram

protected Diagram2D getSimpleDiagram(int pos)
Returns a simple (flat) diagram created from the position in the list of current diagrams.


getNestedDiagram

protected Diagram2D getNestedDiagram(int pos)
Returns a nested diagram using the list of current diagrams. The parameter pos determines the position in the list of current diagrams.


addObserver

public void addObserver(ChangeObserver observer)
Implements ChangeObservable.addObserver(ChangeObserver).

Specified by:
addObserver in interface ChangeObservable

removeObserver

public void removeObserver(ChangeObserver observer)
Implements ChangeObservable.removeObserver(ChangeObserver).

Specified by:
removeObserver in interface ChangeObservable

notifyObservers

protected void notifyObservers()
Notifies all observers of an update that changes the current diagram. This should not be called if the changes affect only future diagrams.



The ToscanaJ project