Package net.ontopia.topicmaps.viz
Class TopicMapView
- java.lang.Object
-
- net.ontopia.topicmaps.viz.TopicMapView
-
public class TopicMapView extends Object
INTERNAL: Maintains the TouchGraph view of the topic map.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classTopicMapView.DebugINTERNAL: PRIVATE: Purpose: Output debug information
-
Field Summary
Fields Modifier and Type Field Description protected VizTopicMapConfigurationManagerconfigmanprotected VizControllercontrollerprotected TopicIFcurrentScopingTopicprotected TopicMapView.Debugdebugstatic intEDGE_LOCALITYprotected ListforegroundQueueprotected MotionKillermotionKillerprotected ArrayListnewNodesstatic intNODE_LOCALITYprotected CollectionnodesUpdateCountprotected ArrayListobjectsByTypeprotected ArrayListobjectTypeIndexPerformanceStatstatPerformanceStatstat1protected VizigatorUservizigatorUser
-
Constructor Summary
Constructors Constructor Description TopicMapView(VizController controller, TopicMapIF topicmap, com.touchgraph.graphlayout.TGPanel tgPanel, VizTopicMapConfigurationManager configman)Creates the view and updates the TGPanel to show the new view.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddAssociation(VizTMObjectIF object)voidaddAssociationScopeFilterTopic(TopicIF scopingTopic)protected TMTopicNodeassertNode(TopicIF topic, boolean create)protected voidbuild()Clears the panel and builds a new view.protected voidbuildAll()voidbuildAllSilent()EXPERIMENTAL: method to redraw the map, without starting a new thread or displaying the progress barprotected TMTopicNodebuildTopic(TopicIF topic)voidclearFocusNode()voidclearModel()voidcreateAssociations(TMAbstractNode abstractNode)Creates all edges for this node, including type -> instance, instance -> type, and ordinary associations.voidcreateAssociations(TMAbstractNode abstractNode, boolean create)voidcreateAssociations(TMAbstractNode abstractNode, boolean create, boolean createEdgesToExistingNodes)Creates all edges for this node, including type -> instance, instance -> type, and ordinary associations.voiddeleteEdge(VizTMObjectIF vizTMObject)voiddeleteEdges(Collection edges)voiddeleteEdgeUndoable(VizTMObjectIF edge)voiddeleteNode(TMAssociationNode node)voiddeleteNode(TMTopicNode node)voiddeleteSingleEdge(VizTMObjectIF edge)protected VizTMObjectIFfindObject(Object object, TopicIF type)protected voidfocusNode(TMAbstractNode node)static StringfullName(com.touchgraph.graphlayout.Node node)CollectiongetAllTopicTypes()Returns a collection of all topic types in the topic map.CollectiongetAllTopicTypesWithNull()Returns a collection of all topic types in the topic map including null (untyped).CollectiongetAssociationTypes()Returns a collection of all association types in the topic map.protected TMAssociationEdgegetEdge(AssociationIF association)protected TMRoleEdgegetEdge(AssociationRoleIF role)protected TMClassInstanceAssociationgetEdge(TopicIF type, TopicIF instance)TMAbstractNodegetFocusNode()protected VizController.VizHoverHelpManagergetHoverHelpManager()intgetLocality()intgetLocalityAlgorithm()intgetMaxTopicNameLength()protected TMAssociationNodegetNode(AssociationIF association)CollectiongetPagesFor(TopicIF topic)TMTopicNodegetStartNode()com.touchgraph.graphlayout.TGPanelgetTGPanel()TopicMapIFgetTopicMap()protected ListgetTopicNodesFor(TopicIF type)voidheadedDebug(String header, Object object)voidhideNode(TMAbstractNode node)Delete a node, all incident edges and all nodes and edges that no longer have a path to the focus node as a consequence of this.protected voidinitializeAssociation(VizTMAssociationIF anInstance)Initialize those things only associated with Association Objectsprotected voidlenientAddNode(TMAbstractNode node)This method was created as a work-around for bug #1898, which happens when two nodes have the same ID (the second node failing to get added to tgPanel.CollectionloadNodesInLocality(TMAbstractNode startNode, boolean create, boolean delete)If create is true, adds all nodes within locality's reach that were not already visible.protected VizTMObjectIFmakeAssociation(AssociationIF assoc, TMTopicNode activePlayer, boolean create)Create an associations, or, in the case of an n-ary association, if the activePlayer is not null, create the associatin node itself and then only the role that active player is involved in.protected TMRoleEdgemakeRole(TMAssociationNode assoc, AssociationRoleIF role, boolean create)protected TMClassInstanceAssociationmakeTypeInstanceEdge(TMTopicNode instance, TMTopicNode type)voidoutputDebugInfo(String operation)ListperformSearch(String searchString)protected voidprocessForegroundQueue(Graphics graphics)protected voidqueueInForeground(TMAbstractEdge edge)protected voidqueueInForeground(TMAbstractNode node)voidremoveAssociationScopeFilterTopic(TopicIF scopingTopic)voidremoveDisconnectedNodes()voidresetDamper()voidretainNodes(Collection nodes)voidretainObjects(Collection nodes)voidsetAllNodesFixed(boolean fixed)Sets all nodes to fixed (sticky) or not fixed.voidsetAssociationScopeFilterStrictness(int strictness)Set the current level of strictness of the association scope filter and remove/add edges where needed.voidsetAssociationTypeLineWeight(TopicIF type, int lineWeight)voidsetAssociationTypeShape(TopicIF type, int shape)voidsetAssociationTypeVisible(TopicIF type, boolean visible)NOTE: The calling method is responsible for calling the method: updateAssociationCountForAllTopics();voidsetConfigManager(VizTopicMapConfigurationManager configman)Called when a new configuration has been loaded.protected voidsetFocusNodeOf(TMObjectIF tmObject)Find the node of the given TMObjectIF.protected voidsetHighlightNode(TMAbstractNode node, Graphics g)voidsetLocality(int newLocality)Set the locality to a given value and adds/removes nodes where appropriate.voidsetMaxTopicNameLength(int length)voidsetMotionKillerEnabled(boolean enabled)voidsetPanelBackgroundColour(Color aColor)voidsetScopingTopic(TopicIF aScope)voidsetTopicTypeExcluded(TopicIF aType, boolean excluded)voidsetTopicTypeShape(TopicIF type, int shape)voidsetTopicTypeShapePadding(TopicIF type, int value)voidsetTopicTypeVisible(TopicIF type, boolean visible)NOTE! The calling mehtod is itself responsible for calling the method: updateAssociationCountForAllTopics().voidsetTypeColor(TopicIF type, Color c)voidsetTypeFont(TopicIF type, Font font)voidsetTypeIcon(TopicIF type, Icon icon)voidshouldDisplayRoleHoverHelp(boolean newValue)voidshouldDisplayScopedAssociationNames(boolean newValue)voidupdateAssociationCountForAllTopics()voidupdateAssociationCountForMarkedTopics()voidupdateDisplay()voidupdateDisplayLazily()voidupdateDisplayNoWork()voidupdateType(TopicIF type)booleanuseNodeLocality()
-
-
-
Field Detail
-
configman
protected VizTopicMapConfigurationManager configman
-
controller
protected VizController controller
-
newNodes
protected ArrayList newNodes
-
objectTypeIndex
protected ArrayList objectTypeIndex
-
objectsByType
protected ArrayList objectsByType
-
currentScopingTopic
protected TopicIF currentScopingTopic
-
debug
protected TopicMapView.Debug debug
-
nodesUpdateCount
protected Collection nodesUpdateCount
-
stat
public PerformanceStat stat
-
stat1
public PerformanceStat stat1
-
motionKiller
protected MotionKiller motionKiller
-
vizigatorUser
protected VizigatorUser vizigatorUser
-
foregroundQueue
protected List foregroundQueue
-
NODE_LOCALITY
public static int NODE_LOCALITY
-
EDGE_LOCALITY
public static int EDGE_LOCALITY
-
-
Constructor Detail
-
TopicMapView
public TopicMapView(VizController controller, TopicMapIF topicmap, com.touchgraph.graphlayout.TGPanel tgPanel, VizTopicMapConfigurationManager configman)
Creates the view and updates the TGPanel to show the new view. The TGPanel may be showing an old view.
-
-
Method Detail
-
updateDisplay
public void updateDisplay()
-
updateDisplayLazily
public void updateDisplayLazily()
-
updateDisplayNoWork
public void updateDisplayNoWork()
-
resetDamper
public void resetDamper()
-
retainNodes
public void retainNodes(Collection nodes)
-
retainObjects
public void retainObjects(Collection nodes)
-
setLocality
public void setLocality(int newLocality)
Set the locality to a given value and adds/removes nodes where appropriate. After a locality increase, all nodes and edges within locality's reach in addition to all nodes and edges that were there before will be visible. After a locality decrease, all nodes and edges that were visible before and that are still within locality's reach will be visible.- Parameters:
newLocality- The new locality.
-
loadNodesInLocality
public Collection loadNodesInLocality(TMAbstractNode startNode, boolean create, boolean delete)
If create is true, adds all nodes within locality's reach that were not already visible. Then (independent of 'create') collects all edges just beyond locality's reach and returns them. An edge with both end-points within locality's reach is counted as within locality's reach.. ALTERNATIVE EDGE ALGORITHM: An edge is within locality's reach if one end-point is attached to a node at least one step closer than locality's reach.- Parameters:
startNode- The node to start from.create- Whether to create new nodes and edges.- Returns:
- edges beyond locality's reach.
-
setTopicTypeShape
public void setTopicTypeShape(TopicIF type, int shape)
-
setTopicTypeShapePadding
public void setTopicTypeShapePadding(TopicIF type, int value)
-
updateType
public void updateType(TopicIF type)
-
setAssociationTypeShape
public void setAssociationTypeShape(TopicIF type, int shape)
-
setAssociationTypeLineWeight
public void setAssociationTypeLineWeight(TopicIF type, int lineWeight)
-
focusNode
protected void focusNode(TMAbstractNode node)
-
clearFocusNode
public void clearFocusNode()
-
setConfigManager
public void setConfigManager(VizTopicMapConfigurationManager configman)
Called when a new configuration has been loaded. Switches the view over to the new configuration.
-
hideNode
public void hideNode(TMAbstractNode node)
Delete a node, all incident edges and all nodes and edges that no longer have a path to the focus node as a consequence of this.- Parameters:
node- The base node to delete.
-
fullName
public static String fullName(com.touchgraph.graphlayout.Node node)
-
setTopicTypeVisible
public void setTopicTypeVisible(TopicIF type, boolean visible)
NOTE! The calling mehtod is itself responsible for calling the method: updateAssociationCountForAllTopics().
-
setAssociationTypeVisible
public void setAssociationTypeVisible(TopicIF type, boolean visible)
NOTE: The calling method is responsible for calling the method: updateAssociationCountForAllTopics();- Parameters:
type- The type to set (in)visible.visible- true if 'type' should be set visible. Otherwise false.
-
setAssociationScopeFilterStrictness
public void setAssociationScopeFilterStrictness(int strictness)
Set the current level of strictness of the association scope filter and remove/add edges where needed.- Parameters:
strictness- The new level of strictness
-
removeAssociationScopeFilterTopic
public void removeAssociationScopeFilterTopic(TopicIF scopingTopic)
-
addAssociationScopeFilterTopic
public void addAssociationScopeFilterTopic(TopicIF scopingTopic)
-
updateAssociationCountForAllTopics
public void updateAssociationCountForAllTopics()
-
updateAssociationCountForMarkedTopics
public void updateAssociationCountForMarkedTopics()
-
getTopicMap
public TopicMapIF getTopicMap()
-
getPagesFor
public Collection getPagesFor(TopicIF topic)
-
getAssociationTypes
public Collection getAssociationTypes()
Returns a collection of all association types in the topic map. Does not work with remote topic maps.
-
getAllTopicTypesWithNull
public Collection getAllTopicTypesWithNull()
Returns a collection of all topic types in the topic map including null (untyped). Does not work with remote topic maps.
-
getAllTopicTypes
public Collection getAllTopicTypes()
Returns a collection of all topic types in the topic map. Does not work with remote topic maps.
-
build
protected void build()
Clears the panel and builds a new view. Assumes there is no existing graph.
-
buildTopic
protected TMTopicNode buildTopic(TopicIF topic)
-
buildAllSilent
public void buildAllSilent()
EXPERIMENTAL: method to redraw the map, without starting a new thread or displaying the progress bar
-
buildAll
protected void buildAll()
-
assertNode
protected TMTopicNode assertNode(TopicIF topic, boolean create)
-
queueInForeground
protected void queueInForeground(TMAbstractNode node)
-
queueInForeground
protected void queueInForeground(TMAbstractEdge edge)
-
setHighlightNode
protected void setHighlightNode(TMAbstractNode node, Graphics g)
-
processForegroundQueue
protected void processForegroundQueue(Graphics graphics)
-
findObject
protected VizTMObjectIF findObject(Object object, TopicIF type)
-
makeTypeInstanceEdge
protected TMClassInstanceAssociation makeTypeInstanceEdge(TMTopicNode instance, TMTopicNode type)
-
makeAssociation
protected VizTMObjectIF makeAssociation(AssociationIF assoc, TMTopicNode activePlayer, boolean create)
Create an associations, or, in the case of an n-ary association, if the activePlayer is not null, create the associatin node itself and then only the role that active player is involved in.
-
lenientAddNode
protected void lenientAddNode(TMAbstractNode node)
This method was created as a work-around for bug #1898, which happens when two nodes have the same ID (the second node failing to get added to tgPanel. I don't know why two nodes sometimes get the same ID, which is important information needed to avoid it, hence this work-around. Adds a systematic suffix and tries to add the node until no exception occurrs.- Parameters:
node- The node that should be added to tgPanel.
-
setFocusNodeOf
protected void setFocusNodeOf(TMObjectIF tmObject)
Find the node of the given TMObjectIF. If no such node exists, then it should be created. Then set that node to be the focus node, recomputing the graph from this new focus node. Supports TMObjectsIFs instanceof TopicIF or AssociationIF.- Parameters:
tmObject- from which to create the node.
-
makeRole
protected TMRoleEdge makeRole(TMAssociationNode assoc, AssociationRoleIF role, boolean create)
-
initializeAssociation
protected void initializeAssociation(VizTMAssociationIF anInstance)
Initialize those things only associated with Association Objects- Parameters:
anInstance-
-
addAssociation
protected void addAssociation(VizTMObjectIF object)
-
getHoverHelpManager
protected VizController.VizHoverHelpManager getHoverHelpManager()
-
createAssociations
public void createAssociations(TMAbstractNode abstractNode)
Creates all edges for this node, including type -> instance, instance -> type, and ordinary associations.
-
createAssociations
public void createAssociations(TMAbstractNode abstractNode, boolean create)
-
createAssociations
public void createAssociations(TMAbstractNode abstractNode, boolean create, boolean createEdgesToExistingNodes)
Creates all edges for this node, including type -> instance, instance -> type, and ordinary associations. If create, then newnodes are created.
-
getLocalityAlgorithm
public int getLocalityAlgorithm()
-
useNodeLocality
public boolean useNodeLocality()
-
deleteEdges
public void deleteEdges(Collection edges)
-
deleteEdgeUndoable
public void deleteEdgeUndoable(VizTMObjectIF edge)
-
deleteEdge
public void deleteEdge(VizTMObjectIF vizTMObject)
-
deleteSingleEdge
public void deleteSingleEdge(VizTMObjectIF edge)
-
deleteNode
public void deleteNode(TMAssociationNode node)
-
deleteNode
public void deleteNode(TMTopicNode node)
-
getEdge
protected TMAssociationEdge getEdge(AssociationIF association)
-
getEdge
protected TMRoleEdge getEdge(AssociationRoleIF role)
-
getEdge
protected TMClassInstanceAssociation getEdge(TopicIF type, TopicIF instance)
-
getNode
protected TMAssociationNode getNode(AssociationIF association)
-
shouldDisplayRoleHoverHelp
public void shouldDisplayRoleHoverHelp(boolean newValue)
-
setMotionKillerEnabled
public void setMotionKillerEnabled(boolean enabled)
-
shouldDisplayScopedAssociationNames
public void shouldDisplayScopedAssociationNames(boolean newValue)
-
setPanelBackgroundColour
public void setPanelBackgroundColour(Color aColor)
-
removeDisconnectedNodes
public void removeDisconnectedNodes()
-
setTopicTypeExcluded
public void setTopicTypeExcluded(TopicIF aType, boolean excluded)
-
getLocality
public int getLocality()
-
getStartNode
public TMTopicNode getStartNode()
-
getFocusNode
public TMAbstractNode getFocusNode()
-
getTGPanel
public com.touchgraph.graphlayout.TGPanel getTGPanel()
-
outputDebugInfo
public void outputDebugInfo(String operation)
-
setScopingTopic
public void setScopingTopic(TopicIF aScope)
-
clearModel
public void clearModel()
-
setAllNodesFixed
public void setAllNodesFixed(boolean fixed)
Sets all nodes to fixed (sticky) or not fixed.- Parameters:
fixed- true(/false) if all nodes should get a (un)fixed position.
-
getMaxTopicNameLength
public int getMaxTopicNameLength()
-
setMaxTopicNameLength
public void setMaxTopicNameLength(int length)
-
-