ch.epfl.craft.magmap.magnet
Class MagMapMagnetNode

java.lang.Object
  extended bych.epfl.craft.maglib.magnet.DefaultMagnetNode
      extended bych.epfl.craft.magmap.magnet.MagMapMagnetNode
All Implemented Interfaces:
MagnetNode

public class MagMapMagnetNode
extends DefaultMagnetNode

This class represents that data used by the MagnetView. Each node either encapsulates a blog or a topic, so that it is possible to drop both of them on the MagnetView.

A MagMapMagnetNode instance retrieves data from the internal userObject that it encapsulates. This means that we have to deal with multiple kind of data, whoose loading classes were automatically generated by XML Spy. Internally the type for a blog is ThingType, the type for a topic is rType, but in other MagMap classes, we refer to them as MagMapMagnetNode instances,of a kind TOPIC, BLOG, NEWS, PERSON which can be found via getKind().

To simplify drag and drop of these node on the MagnetView, each node has a unique identifier id.

To do : implements support for news and persons

Finally, we implment TextFilterable interace provided by the Glazed List library to enable live filtering

Version:
1.0
Author:
Jerome Caffaro
See Also:
MagnetView

Field Summary
static int BLOG
          The blog kind of node
protected static java.util.HashMap blogToColumnMap
          Mapping from blog (idInFile) to column number in the similarity matrix
protected  int id
          The unique identifier for this node
protected  int idinFile
          The identifier for this node in the XML file
protected static int lastID
          The class counter for the identifiers
static int NEWS
          The news kind of node
static int PERSON
          The person kind of node
 java.util.HashMap similarities
          The Similarity matrix under hashmap form (faster): it can already have a computed blog-blog or topic-topic similarity inside.
protected static float[][] similaritiesMatrix
          The Similarity matrix
protected static com.schema.MatrixType similarityMatrix
          The Similarity matrix
static int TOPIC
          The topic kind of node
protected static java.util.HashMap topicToRowMap
          Mapping from topic (instance) to row number in the similarity matrix
 
Fields inherited from class ch.epfl.craft.maglib.magnet.DefaultMagnetNode
force, origin, targetOrigin, userObject
 
Constructor Summary
MagMapMagnetNode()
          Creates a new MagMapMagnetNode instance.
MagMapMagnetNode(java.lang.Object userObject)
          Creates a new MagMapMagnetNode instance with the given data.
 
Method Summary
 java.lang.String getAuthor()
          Returns the author of the node data
 java.lang.String getDescription()
          Returns the description (body of the content) of the node data
 void getFilterStrings(java.util.List baseList)
          Returns the text attribute on of that node on which a search can be done.
 int getID()
          Returns the unique identifier for this node.
 int getIDinFile()
          Returns the identifier of the node in the XML.
 int getKind()
          Returns the kind of userObject that this MagMapMagnetNode instance encapsulates.
 float getSimilarityWith(MagnetNode aMagnetNode)
          Returns the similarity with aMagnetNode.
 java.lang.String getTitle()
          Returns the title (subject of the content) of the node data
 java.lang.String getURL()
          Returns a URL of the original data of that node.
static void setSimilarityMatrix(com.schema.MatrixType matrix)
          Sets the similarity matrix for this class.
 java.lang.String toString()
          Returns the title (subject of the content) of the node data
 
Methods inherited from class ch.epfl.craft.maglib.magnet.DefaultMagnetNode
getForceField, getOrigin, getUserObject, setForceField, setOrigin, setTargetOrigin, setUserObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TOPIC

public static final int TOPIC
The topic kind of node

See Also:
Constant Field Values

BLOG

public static final int BLOG
The blog kind of node

See Also:
Constant Field Values

NEWS

public static final int NEWS
The news kind of node

See Also:
Constant Field Values

PERSON

public static final int PERSON
The person kind of node

See Also:
Constant Field Values

id

protected int id
The unique identifier for this node


idinFile

protected int idinFile
The identifier for this node in the XML file


lastID

protected static int lastID
The class counter for the identifiers


similarityMatrix

protected static com.schema.MatrixType similarityMatrix
The Similarity matrix


similaritiesMatrix

protected static float[][] similaritiesMatrix
The Similarity matrix


topicToRowMap

protected static java.util.HashMap topicToRowMap
Mapping from topic (instance) to row number in the similarity matrix


blogToColumnMap

protected static java.util.HashMap blogToColumnMap
Mapping from blog (idInFile) to column number in the similarity matrix


similarities

public java.util.HashMap similarities
The Similarity matrix under hashmap form (faster): it can already have a computed blog-blog or topic-topic similarity inside. Note that it is not static, there is one for each node

Constructor Detail

MagMapMagnetNode

public MagMapMagnetNode()
Creates a new MagMapMagnetNode instance.


MagMapMagnetNode

public MagMapMagnetNode(java.lang.Object userObject)
Creates a new MagMapMagnetNode instance with the given data. For this class, this will either be a blog or a topic.

Parameters:
userObject - the object to be used by this node as internal data
Method Detail

setSimilarityMatrix

public static void setSimilarityMatrix(com.schema.MatrixType matrix)
Sets the similarity matrix for this class.

Parameters:
matrix - the MagMap similarity matrix

getID

public int getID()
Returns the unique identifier for this node. Different from getIDinFile() as this one returns the unique identifier of the nodes. (Incremented by this class)

Returns:
the id of this node.

getIDinFile

public int getIDinFile()
Returns the identifier of the node in the XML. Different from getID() as this one returns the id as written in the blogs collection or topic collection (depending on its kind). Returns -1 if the id could not be found

Returns:
the id of this node in the XML file.

getSimilarityWith

public float getSimilarityWith(MagnetNode aMagnetNode)
Returns the similarity with aMagnetNode. We will either look in the similarity matrix under table form, or, if the similarity has already been computed, in the similarity saved in a hashMap The similarities, depending on the type of nodes, are found in that way:

Specified by:
getSimilarityWith in interface MagnetNode
Overrides:
getSimilarityWith in class DefaultMagnetNode
Parameters:
aMagnetNode - a aMagnetNode.
Returns:
the similarity between this MagnetNode instance and aMagnetNode.

getTitle

public java.lang.String getTitle()
Returns the title (subject of the content) of the node data

Returns:
the title of the node data

getDescription

public java.lang.String getDescription()
Returns the description (body of the content) of the node data

Returns:
the title of the node data

getAuthor

public java.lang.String getAuthor()
Returns the author of the node data

Returns:
the author of the node data

getURL

public java.lang.String getURL()
Returns a URL of the original data of that node.

Returns:
the URL of the node data

getKind

public int getKind()
Returns the kind of userObject that this MagMapMagnetNode instance encapsulates.

This methods will return one of these:

Returns:
the kind of data node

toString

public java.lang.String toString()
Returns the title (subject of the content) of the node data

Overrides:
toString in class DefaultMagnetNode
Returns:
the title of the node data

getFilterStrings

public void getFilterStrings(java.util.List baseList)
Returns the text attribute on of that node on which a search can be done. Used by the Glazed List library to implement live search

Parameters:
baseList - the base list in which we add this node's attributes.


Copyright © CRAFT EPFL. All Rights Reserved.