ch.epfl.craft.maglib.magnet
Class DefaultMagnetNode

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

public class DefaultMagnetNode
extends java.lang.Object
implements MagnetNode

Version:
1.0
Author:
Jerome Caffaro

Field Summary
protected  int force
          The force of the field generated by this node.
protected  java.awt.Point origin
          The origin of the node
protected  java.awt.Point targetOrigin
          The point where the node should be.
protected  java.lang.Object userObject
          The core data of this node
 
Constructor Summary
DefaultMagnetNode()
          Creates a new MagnetNode instance.
DefaultMagnetNode(java.lang.Object userObject)
          Creates a new MagnetNode instance with the given data.
 
Method Summary
 int getForceField()
          Returns the force of the field generated by this magnet.
 java.awt.Point getOrigin()
          Returns the orgin of this MagnetNode instance.
 float getSimilarityWith(MagnetNode aMagnetNode)
          Returns the similarity with aMagnetNode.
 java.lang.Object getUserObject()
          Returns the user object of the receiver.
 void setForceField(int force)
          Sets the force of the field generated by this magnet.
 void setOrigin(java.awt.Point newOrigin)
          Sets the orgin of this MagnetNode instance.
 void setTargetOrigin(java.awt.Point newTargetOrigin)
          Sets the target orgin of this MagnetNode instance.
 void setUserObject(java.lang.Object object)
          Resets the user object of the receiver to object.
 java.lang.String toString()
          Returns the result of sending toString() to this node's user object, or null if this node has no user object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

origin

protected java.awt.Point origin
The origin of the node


targetOrigin

protected java.awt.Point targetOrigin
The point where the node should be. Used to smoothly move nodes


userObject

protected java.lang.Object userObject
The core data of this node


force

protected int force
The force of the field generated by this node. From 0 to 100

Constructor Detail

DefaultMagnetNode

public DefaultMagnetNode()
Creates a new MagnetNode instance.


DefaultMagnetNode

public DefaultMagnetNode(java.lang.Object userObject)
Creates a new MagnetNode instance with the given data.

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

getOrigin

public java.awt.Point getOrigin()
Returns the orgin of this MagnetNode instance.

Specified by:
getOrigin in interface MagnetNode
Returns:
the origin of this MagnetNode instance.

setOrigin

public void setOrigin(java.awt.Point newOrigin)
Sets the orgin of this MagnetNode instance. Using this method will set the origin of the node immediately, while using setTargetOrigin(java.awt.Point) would do it progressively at some given speed.

Specified by:
setOrigin in interface MagnetNode
Parameters:
newOrigin - the new origin of this MagnetNode instance.

setTargetOrigin

public void setTargetOrigin(java.awt.Point newTargetOrigin)
Sets the target orgin of this MagnetNode instance. Using this method will set the origin of the node progressively, while using setOrigin(java.awt.Point) would do it immediately. If the node was still moving to a previous target origin when setting a new target, the previous one is "forgotten".

Specified by:
setTargetOrigin in interface MagnetNode
Parameters:
newTargetOrigin - the target origin of this MagnetNode instance.

setForceField

public void setForceField(int force)
Sets the force of the field generated by this magnet.

Specified by:
setForceField in interface MagnetNode
Parameters:
force - the force of the field

getForceField

public int getForceField()
Returns the force of the field generated by this magnet.

Specified by:
getForceField in interface MagnetNode
Returns:
force the force of the field

getSimilarityWith

public float getSimilarityWith(MagnetNode aMagnetNode)
Returns the similarity with aMagnetNode.

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

setUserObject

public void setUserObject(java.lang.Object object)
Resets the user object of the receiver to object.

Specified by:
setUserObject in interface MagnetNode
Parameters:
object - the object that represents the data of this node.

getUserObject

public java.lang.Object getUserObject()
Returns the user object of the receiver.

Returns:
the user object of this node.

toString

public java.lang.String toString()
Returns the result of sending toString() to this node's user object, or null if this node has no user object.

Returns:
a string representation of the object.


Copyright © CRAFT EPFL. All Rights Reserved.