org.ceryle.graph.tm
Class TM4JVisualizerImpl

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by javax.swing.JDialog
                      extended by org.ceryle.graph.tm.TM4JVisualizerImpl
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants, TopicMapVisualizer

public class TM4JVisualizerImpl
extends JDialog
implements TopicMapVisualizer

Generate a visualization of a TopicMap object (a TM4J-based TopicMap) using a TMLayoutPanel and other TouchGraph extensions.

Note that this implementation displays TopicMap objects, but does not modify them nor pay attention to how many TopicMaps are currently displayed - this, and any other issues regarding multiple Topic Maps, merging, etc. is left to whatever classes call the visualizer. It has a policy not to modify the visualized TopicMaps.

The visualization process shouldn't in theory make any modifications to the TopicMap, but this needs to be worked out/tested more thoroughly, as it seems that some Topics will get added if they are necessary for visualization and don't exist in the source TopicMap.

Copyright 2001-2007 Murray Altheim. All Rights Reserved.
See LICENSE included with distribution.

Version:
$Id: TM4JVisualizerImpl.java,v 3.3 2007-06-20 01:28:11 altheim Exp $
Author:
Murray Altheim
See Also:
Serialized Form

Nested Class Summary
protected  class TM4JVisualizerImpl.DeferredNodeSet
          Internal class extends Hashtable as a container for deferred addition of GraphNodes to the graph.
 class TM4JVisualizerImpl.DialogHider
           
protected  class TM4JVisualizerImpl.TMViz
          Internal class extends Thread to display a specific TopicMap.
 
Nested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialog
 
Nested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  boolean hideXTM
          A flag that when true suppresses display of Topics having subjects matching any of the XTM 1.0 PSIs.
protected  boolean inProgress
          When true, indicates that the visualizer is currently loading/visualizing a Topic Map.
protected  boolean m_deferred
          Indicates TopicMap size is bigger than threshold; that deferred addition will be done.
protected  TM4JVisualizerImpl.DeferredNodeSet m_deferredSet
          An extension of HashSet used only during deferred addition.
protected  int m_deferredThreshold
          The number of TopicMapObjects to visualize before using the deferred set method.
protected  Desktop m_desktop
           
protected  TopicMap m_topicmap
          The current TopicMap node (org.tm4j.topicmap.TopicMap).
protected  boolean m_verbose
           
protected  boolean m_visible
           
protected  int m_vizDlogThreshold
          The number of TopicMapObjects required before showing the dialog during vizualization.
protected  MessageHandler mh
           
static int minimumAdic
          The minimum number of association members required for Association displayability.
protected  PropertyManager pm
           
protected  Topic[] scope_l10n
          The scope of the default Locale.
protected  Topic[] scope_template
          The scope of the XTM Associations.
protected  boolean showFacets
          A flag that when true indicates that any facet associations be displayed.
protected  boolean showHidden
          A flag that when true indicates that any normally-hidden topics be displayed.
protected  Services srvs
           
protected  TMLayoutPanel tmlp
           
protected  TopicMapProcessor tmproc
           
protected  Topic topic_hasfacet
          The typing Topic of a 'has facet' association.
protected  boolean visualizeScopes
          Variable controlling if scopes should be displayed, ie., if association scopes should receive an explicit node display.
protected  boolean visualizeTemplates
          Variable controlling if Association template relationships should be displayed, ie., if <instanceOf> within an Association should receive an explicit node display.
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TM4JVisualizerImpl(TMLayoutPanel topicMapLayoutPanel, boolean visible)
          Constructor provided the TMLayoutPanel to contain the visualization.
 
Method Summary
protected  boolean dialogWarranted(TopicMap topicmap)
          Returns true if the TopicMap is large enough and has enough visualizable nodes to warrant the dialog be shown.
protected  void displayScope(Topic[] scope, ANode anode, Set tnodes)
           
 Set getAssociationRegistry()
          Returns the Association signature registry as a Set, to be used when re-visualizing associations.
 int getEdgeDirection(Member member)
          Returns an edge direction provided an Association member, by checking its role Topic.
 boolean inProgress()
          Returns true if a visualization is currently being processed/in progress.
protected  ANode instanceOf(Association assoc, TNode classNode, ANode instanceNode)
          Links the TNode classNode to the ANode instanceNode, creating a new class-instance ANode (based on the Association assoc) as an "association template".
protected  ANode instanceOf(Association assoc, TNode classNode, TNode instanceNode)
          Links the TNode classNode to the TNode instanceNode, creating a new class-instance ANode (based on the Association assoc).
 Object instanceOf(Association assoc, Topic classTopic, Topic instanceTopic)
          Links the Topic classTopic to the Topic instanceTopic, creating a new class-instance ANode (based on the Association assoc).
 boolean isDisplayable(Association assoc)
          Returns true if the Association should be displayed.
 boolean isDisplayable(Topic topic)
          Returns true if the Topic should be displayed.
 Object onAssociation(Association assoc)
          Indicates the start of an Association.
 boolean onBaseName(Topic topic, BaseName basename)
          Indicates the start of a BaseName.
 boolean onMember(Association assoc, Member member)
          Indicates the start of a Member.
 boolean onOccurrence(Topic topic, Occurrence occur)
          Currently, occurrences are not visualized.
 void onParameter(Topic param)
          Indicates the start of a Variant Parameter.
 Object onRole(Association assoc, Topic player, Topic role)
          Visualize the Topic role for the provided Topic player in the Association assoc.
 Set onScope(Topic[] scope)
          Indicates the start of a Scope.
 void onSubject(Topic topic, Locator subject)
           
 void onSubjectIndicator(Topic topic, Locator subjectIndicator)
           
 Object onTheme(Topic theme)
          Indicates the start of a Theme (Topic used in a Scope).
 Object onTopic(Topic topic)
          Indicates the start of a Topic, returning the TNode created.
 boolean onTopicMap(TopicMap topicmap)
          Called at the beginning of the processing cycle to initialize various member variables.
 boolean onVariant(BaseName basename, Variant variant)
          Indicates the start of a Variant.
 void onVariantName(Variant variant, VariantName varName)
          Indicates the start of a Variant Name.
 void postProcess(TopicMap topicmap)
          Does any post-visualization processes, like selecting a default node.
 boolean registerAssociation(Association assoc)
          Returns true if successful in registering the provided Association, false if it was already contained in the registry.
 void reset()
          Resets the visualizer so that it has no record of past visualizations.
protected  ANode returnANodeForAssociation(Association assoc)
          Creates a new or returns an existing ANode given Association assoc, based on its ID.
protected  TNode returnTNodeForTopic(Topic topic, boolean merge)
          Creates a new or returns an existing TNode for Topic topic, based on its ID.
 void setEnglishLocale(TopicMap topicmap)
          Sets the default locale for display names to English.
 void setTMLayoutPanel(TMLayoutPanel tmlpanel)
          Set the TMLayoutPanel for this TopicMapVisualizer.
protected  ANode subclassOf(Association assoc, TNode superclass, TNode subclass)
          Links the TNode superclass to the TNode subclass, creating a new superclass-subclass ANode (association).
 Object subclassOf(Association assoc, Topic superclassTopic, Topic subclassTopic)
          Links the Topic superclassTopic to the Topic subclassTopic, creating a new superclass-subclass ANode (based on the Association assoc).
 void updateAssociation(Association assoc)
          Update an already visualized ANode and its edge directions based on the current Association assoc, if available.
 void visualize(TopicMap topicmap, boolean merge)
          Displays the TopicMap topicmap as a graph.
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Dialog
addNotify, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

visualizeTemplates

protected boolean visualizeTemplates
Variable controlling if Association template relationships should be displayed, ie., if <instanceOf> within an Association should receive an explicit node display. Default is false.


visualizeScopes

protected boolean visualizeScopes
Variable controlling if scopes should be displayed, ie., if association scopes should receive an explicit node display. Default is true.


showHidden

protected boolean showHidden
A flag that when true indicates that any normally-hidden topics be displayed.


showFacets

protected boolean showFacets
A flag that when true indicates that any facet associations be displayed.


minimumAdic

public static int minimumAdic
The minimum number of association members required for Association displayability. E.g., setting this to 0 means Associations having no members will be displayed; to 2 requires diadic; 3 requires triadic, etc. Default is 2.


hideXTM

protected boolean hideXTM
A flag that when true suppresses display of Topics having subjects matching any of the XTM 1.0 PSIs.


inProgress

protected boolean inProgress
When true, indicates that the visualizer is currently loading/visualizing a Topic Map. This is not an indicator of incremental editing operations.


m_topicmap

protected TopicMap m_topicmap
The current TopicMap node (org.tm4j.topicmap.TopicMap).


scope_template

protected Topic[] scope_template
The scope of the XTM Associations.


scope_l10n

protected Topic[] scope_l10n
The scope of the default Locale.


topic_hasfacet

protected Topic topic_hasfacet
The typing Topic of a 'has facet' association.


m_deferred

protected boolean m_deferred
Indicates TopicMap size is bigger than threshold; that deferred addition will be done.


m_deferredSet

protected TM4JVisualizerImpl.DeferredNodeSet m_deferredSet
An extension of HashSet used only during deferred addition.


m_deferredThreshold

protected int m_deferredThreshold
The number of TopicMapObjects to visualize before using the deferred set method. This is set from the property http://purl.org/ceryle/prop/#graph-vizDeferredThreshold. The default is 100.


m_vizDlogThreshold

protected int m_vizDlogThreshold
The number of TopicMapObjects required before showing the dialog during vizualization. This is set from the property http://purl.org/ceryle/prop/#graph-vizDlogThreshold. The default is 175, which just exceeds the limit for the upper ontology.


tmlp

protected TMLayoutPanel tmlp

tmproc

protected TopicMapProcessor tmproc

m_desktop

protected Desktop m_desktop

srvs

protected Services srvs

mh

protected MessageHandler mh

pm

protected PropertyManager pm

m_visible

protected boolean m_visible

m_verbose

protected boolean m_verbose
Constructor Detail

TM4JVisualizerImpl

public TM4JVisualizerImpl(TMLayoutPanel topicMapLayoutPanel,
                          boolean visible)
                   throws VisualizationException
Constructor provided the TMLayoutPanel to contain the visualization.

Throws:
VisualizationException
Method Detail

setTMLayoutPanel

public void setTMLayoutPanel(TMLayoutPanel tmlpanel)
Set the TMLayoutPanel for this TopicMapVisualizer. This should be followed at some point by a reset(), though it's not called from here.


setEnglishLocale

public void setEnglishLocale(TopicMap topicmap)
                      throws TopicMapException
Sets the default locale for display names to English.

Throws:
TopicMapException

reset

public void reset()
Resets the visualizer so that it has no record of past visualizations.

Specified by:
reset in interface TopicMapVisualizer

visualize

public void visualize(TopicMap topicmap,
                      boolean merge)
               throws VisualizationException
Displays the TopicMap topicmap as a graph. If reset is true, the current graph is cleared.

Specified by:
visualize in interface TopicMapVisualizer
Throws:
VisualizationException

dialogWarranted

protected boolean dialogWarranted(TopicMap topicmap)
Returns true if the TopicMap is large enough and has enough visualizable nodes to warrant the dialog be shown. This is calculated by comparing the integer threshold T set by the http://purl.org/ceryle/prop/#vizDialogThreshold property against the formula:
    ( topic_count + ( assoc_count / 2 ) ) > T
 


postProcess

public void postProcess(TopicMap topicmap)
Does any post-visualization processes, like selecting a default node.

Specified by:
postProcess in interface TopicMapVisualizer

inProgress

public boolean inProgress()
Returns true if a visualization is currently being processed/in progress.

Specified by:
inProgress in interface TopicMapVisualizer

onTopicMap

public boolean onTopicMap(TopicMap topicmap)
                   throws VisualizationException
Called at the beginning of the processing cycle to initialize various member variables. Returns true if the TopicMap is visualized, false if it has already been visualized.

Specified by:
onTopicMap in interface TopicMapVisualizer
Throws:
VisualizationException

onTopic

public Object onTopic(Topic topic)
               throws VisualizationException
Indicates the start of a Topic, returning the TNode created.

Specified by:
onTopic in interface TopicMapVisualizer
Returns:
a graph Object visualizing the Topic.
Throws:
VisualizationException

onSubject

public void onSubject(Topic topic,
                      Locator subject)
               throws VisualizationException
Throws:
VisualizationException

onSubjectIndicator

public void onSubjectIndicator(Topic topic,
                               Locator subjectIndicator)
                        throws VisualizationException
Throws:
VisualizationException

onScope

public Set onScope(Topic[] scope)
            throws VisualizationException
Description copied from interface: TopicMapVisualizer
Indicates the start of a Scope. If there are no objects, an empty Set is returned (not null).

Specified by:
onScope in interface TopicMapVisualizer
Returns:
a Set containing all the graph Objects acting as scopes.
Throws:
VisualizationException

onTheme

public Object onTheme(Topic theme)
               throws VisualizationException
Description copied from interface: TopicMapVisualizer
Indicates the start of a Theme (Topic used in a Scope).

Specified by:
onTheme in interface TopicMapVisualizer
Returns:
a graph Object visualizing the theme's Topic.
Throws:
VisualizationException

onBaseName

public boolean onBaseName(Topic topic,
                          BaseName basename)
                   throws VisualizationException
Description copied from interface: TopicMapVisualizer
Indicates the start of a BaseName.

Specified by:
onBaseName in interface TopicMapVis