ch.epfl.craft.magmap.magnet
Class MagMapMagnetModel

java.lang.Object
  extended bych.epfl.craft.maglib.magnet.DefaultMagnetModel
      extended bych.epfl.craft.magmap.magnet.MagMapMagnetModel
All Implemented Interfaces:
MagnetModel

public class MagMapMagnetModel
extends DefaultMagnetModel

Manages the nodes. Knows who is selected, magnetic or visible.

Terminology: We make no difference between a node or a MagnetNode, they are the same. Everything that is handled by this class is a MagnetNode. However not every MagnetNode is magnetic, only those that attracts or repulse other nodes.

We also use this class as model for the JList instance in MagMap. This means that we have to implement a way to filter node based on a string, as the MagMap application offers this feature. This is done thanks to GlazedGists

For peformance reason(to be verified), we maintain two lists of nodes, one in the superclass which is a basic ArrayList, fast to iterate, and we also have a BasicEventList that is needed for the livesearch implementation

Version:
1.0
Author:
Jerome Caffaro

Field Summary
 
Fields inherited from class ch.epfl.craft.maglib.magnet.DefaultMagnetModel
allNodes, listeners, magneticNodes, selectedNodes, visibleNodes
 
Constructor Summary
MagMapMagnetModel()
          Constructs a MagMapMagnetModel instance and initialize the internal model.
 
Method Summary
 void addMagnetNode(MagnetNode newMagnetNode)
          Adds a MagnetNode instance to this model Nothing happens if aMagnetNode is null or already exists in the model.
 void addMagnetNodes(MagnetNode[] newMagnetNodes)
          Adds MagnetNode instances to this model If a node is null or already exists in the model, it is not added to the model.
 BasicEventList getEventList()
          Returns the list that contains all node.
 void removeMagnetNode(MagnetNode aMagnetNode)
          Removes a MagnetNode instance from this model.
 void reset()
          Resets the model.
 
Methods inherited from class ch.epfl.craft.maglib.magnet.DefaultMagnetModel
addListener, clearMagneticNodes, clearVisibleNodes, getIsMagneticNode, getIsSelectedNode, getIsVisibleNode, getMagneticNodes, getMagnetNodes, getSelectedNodes, getSimilarNodes, getVisibleMagnetNodes, getVisibleMagnetNodesInRect, removeListener, setIsMagneticNode, setIsSelectedNode, setIsVisibleNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MagMapMagnetModel

public MagMapMagnetModel()
Constructs a MagMapMagnetModel instance and initialize the internal model.

Method Detail

getEventList

public BasicEventList getEventList()
Returns the list that contains all node. This list automatically propagates changes. This method is somehow required because of the GlazedGists library


addMagnetNode

public void addMagnetNode(MagnetNode newMagnetNode)
Adds a MagnetNode instance to this model Nothing happens if aMagnetNode is null or already exists in the model. This overrides the method from the superclass because we need to add the new node to the secondary internal BasicEventList of nodes

Specified by:
addMagnetNode in interface MagnetModel
Overrides:
addMagnetNode in class DefaultMagnetModel
Parameters:
newMagnetNode - the node to add to the model

addMagnetNodes

public void addMagnetNodes(MagnetNode[] newMagnetNodes)
Adds MagnetNode instances to this model If a node is null or already exists in the model, it is not added to the model. This does not affect other nodes. This overrides the method from the superclass because we need to add the new nodes to the secondary internal BasicEventList of nodes

Specified by:
addMagnetNodes in interface MagnetModel
Overrides:
addMagnetNodes in class DefaultMagnetModel
Parameters:
newMagnetNodes - the nodes to add to the model

removeMagnetNode

public void removeMagnetNode(MagnetNode aMagnetNode)
Removes a MagnetNode instance from this model. Nothing happens if aMagnetNode is null or does not exist in the model. This overrides the method from the superclass because we need to remove the node from the secondary internal BasicEventList of nodes

Specified by:
removeMagnetNode in interface MagnetModel
Overrides:
removeMagnetNode in class DefaultMagnetModel
Parameters:
aMagnetNode - the node to remove from the model

reset

public void reset()
Resets the model.

Specified by:
reset in interface MagnetModel
Overrides:
reset in class DefaultMagnetModel


Copyright © CRAFT EPFL. All Rights Reserved.