flatscape
Class FGlyph

java.lang.Object
  |
  +--manifold.base.Glyph
        |
        +--flatscape.FGlyph
All Implemented Interfaces:
java.lang.Cloneable, Configurable, javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode
Direct Known Subclasses:
Document, GeometricFigure, ImageGlyph, MapGlyph, Text, Unit

public class FGlyph
extends Glyph
implements javax.swing.tree.MutableTreeNode, Configurable, java.lang.Cloneable

This is a Glyph (view) corresponding to a model Element. It subscribes to the model and listens to the important state changes. It also implements MutableTreeNode and is a node in the scenegraph of a view.

Copyright (c) 2001 Rutgers, The State University of New Jersey

Version:
$Revision: 1.3 $

Field Summary
protected  int curInteractionPoint
           
static double[] DEFAULT
           
protected  java.util.Vector interactionPoints
           
protected  double POINTSIZE
           
protected  boolean selected_
          selection status
 
Fields inherited from class manifold.base.Glyph
model_, TRANSFORM, viewer_, visible_
 
Constructor Summary
FGlyph()
           
 
Method Summary
 void addInteractionPoint(java.awt.geom.Point2D p, int type)
          Adds an interaction Point
 java.util.Enumeration children()
          Returns the children of this Glyph.
 java.lang.Object config(java.lang.Object parent, org.w3c.dom.Element config)
          Implementation of Configurable.
static FGlyph constructGlyph(org.w3c.dom.Element model)
          Static method to create new glyphs.
 void draw(Traversal t)
          FGlyphs can not be drawed - Does nothing.
protected  void drawSelectionBox(java.awt.Graphics2D g)
          Draws the bounding box when a glyph is seleceted.
 boolean getAllowsChildren()
           
protected  java.awt.Shape getBoundingShape()
          Gets the bounding shape of the glyph.
 javax.swing.tree.TreeNode getChildAt(int childIndex)
           
 int getChildCount()
           
 int getIndex(javax.swing.tree.TreeNode node)
           
 java.awt.geom.Point2D getInteractionPoint()
           
 Limits getLimits()
           
 javax.swing.tree.TreeNode getParent()
           
 java.awt.geom.AffineTransform getTransform()
          Gets the transform property of the model UForm and returns it as a Transform2D
 java.awt.geom.AffineTransform getTransform(double[] projectionPlane)
          Gets the transform property of the model Element according to a projectionPlane and returns it as a Transform2D
 void insert(javax.swing.tree.MutableTreeNode child, int index)
          Removes child from its present parent (if it has a parent), sets the child's parent to this node, and then adds the child to this node's child array at index index.
 boolean isLeaf()
           
 java.lang.Object moveInteractionPoint(java.awt.geom.Point2D newPos)
          moves the interaction point to the new position referenced in argument newPos By default, it modifies the width and height of the bounding rectangle accordingly
 void pick(Traversal t)
          Default pick method, which uses getBoundingShape to determine if a glyph has been picked.
protected  boolean pickInteractionPoint(java.awt.geom.Point2D p)
          Tests if the user has picked any of the glyph's interaction points
 void propertyChange(org.w3c.dom.Element model, java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
          Method called by a UForm which had a change of a property.
 void remove(int index)
          Removes the child at the specified index from this node's children and sets that node's parent to null.
 void remove(javax.swing.tree.MutableTreeNode child)
          Removes child from this node's child array, giving it a null parent.
 void removeFromParent()
          Removes the subtree rooted at this node from the tree, giving this node a null parent.
 void setInteractionPoint(int p)
          Sets the current interaction point picked by the user
 void setModel(org.w3c.dom.Element model)
          Sets the model and updates the properties.
 void setParent(javax.swing.tree.MutableTreeNode parent)
          Sets this node's parent to parent but does not change the parent's child array.
 void setSelected(boolean selected)
          Selects or unselects this glyph, depending on the value of selected
 void setUserObject(java.lang.Object object)
          Resets the user object of the receiver to object.
 java.lang.String toString()
           
 void traverse(Traversal t)
          Support for traversal of the scenegraph.
protected  void updateInteractionPoints()
          Updates the interaction points.
protected  void updateProperties()
          Updates the local copies of the properties from the model.
static java.lang.String[] validTypes()
          Returns the valid data types corresponding with glyphs.
 
Methods inherited from class manifold.base.Glyph
getModel, getViewer, isVisible, setViewer, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT

public static final double[] DEFAULT

selected_

protected boolean selected_
selection status


interactionPoints

protected java.util.Vector interactionPoints

POINTSIZE

protected final double POINTSIZE
See Also:
Constant Field Values

curInteractionPoint

protected int curInteractionPoint
Constructor Detail

FGlyph

public FGlyph()
Method Detail

constructGlyph

public static FGlyph constructGlyph(org.w3c.dom.Element model)
Static method to create new glyphs. Given a UForm constructs a Glyph of the type specified in the UForm.

Returns:
Glyph of desired type if available, else a default glyph define by the static variable defaultGlyph

validTypes

public static java.lang.String[] validTypes()
Returns the valid data types corresponding with glyphs.


setModel

public void setModel(org.w3c.dom.Element model)
Sets the model and updates the properties.

Overrides:
setModel in class Glyph
Parameters:
model - the model

getTransform

public java.awt.geom.AffineTransform getTransform()
Gets the transform property of the model UForm and returns it as a Transform2D

Returns:
the transform property if present, else a default transform defined by DEFAULT

getTransform

public java.awt.geom.AffineTransform getTransform(double[] projectionPlane)
Gets the transform property of the model Element according to a projectionPlane and returns it as a Transform2D

Returns:
the transform property if present, else a default transform defined by DEFAULT

getBoundingShape

protected java.awt.Shape getBoundingShape()
Gets the bounding shape of the glyph. Must be overridden by sub-classes if the pick(Traversal t) method of FGlyph is to be used


traverse

public void traverse(Traversal t)
Support for traversal of the scenegraph.

Specified by:
traverse in class Glyph
Parameters:
t - keeps the state of the traversal

pickInteractionPoint

protected boolean pickInteractionPoint(java.awt.geom.Point2D p)
Tests if the user has picked any of the glyph's interaction points


pick

public void pick(Traversal t)
Default pick method, which uses getBoundingShape to determine if a glyph has been picked.

Specified by:
pick in class Glyph
Parameters:
t - keeps the state of the traversal

draw

public void draw(Traversal t)
FGlyphs can not be drawed - Does nothing.

Specified by:
draw in class Glyph
Parameters:
t - keeps the state of the traversal

drawSelectionBox

protected void drawSelectionBox(java.awt.Graphics2D g)
Draws the bounding box when a glyph is seleceted. Note! This method changes the color and stroke properties of the graphic context.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
the name property of the model UForm

config

public java.lang.Object config(java.lang.Object parent,
                               org.w3c.dom.Element config)
                        throws java.lang.Exception
Implementation of Configurable.

Specified by:
config in interface Configurable
Parameters:
parent - The argument passed into the FConfig.getList method
config - The DOM element representing the XML element that loaded this class.
Returns:
The configured class, usually returns this.
Throws:
java.lang.Exception - Thrown if there is any problem configuring this class.

children

public java.util.Enumeration children()
Returns the children of this Glyph.

Specified by:
children in interface javax.swing.tree.TreeNode
Returns:
the children

getAllowsChildren

public boolean getAllowsChildren()
Specified by:
getAllowsChildren in interface javax.swing.tree.TreeNode
Returns:
true if the receiver allows children

getChildAt

public javax.swing.tree.TreeNode getChildAt(int childIndex)
Specified by:
getChildAt in interface javax.swing.tree.TreeNode
Returns:
the child TreeNode at index childIndex

getChildCount

public int getChildCount()
Specified by:
getChildCount in interface javax.swing.tree.TreeNode
Returns:
the number of children TreeNodes the Glyph contains

getIndex

public int getIndex(javax.swing.tree.TreeNode node)
Specified by:
getIndex in interface javax.swing.tree.TreeNode
Returns:
the index of node in the Glyphs children. If the Glyph does not contain node, -1 will be returned

getParent

public javax.swing.tree.TreeNode getParent()
Specified by:
getParent in interface javax.swing.tree.TreeNode
Returns:
the parent TreeNode of the receiver

isLeaf

public boolean isLeaf()
Specified by:
isLeaf in interface javax.swing.tree.TreeNode
Returns:
Returns true if the Glyph is a leaf

insert

public void insert(javax.swing.tree.MutableTreeNode child,
                   int index)
Removes child from its present parent (if it has a parent), sets the child's parent to this node, and then adds the child to this node's child array at index index. child must not be null.

Specified by:
insert in interface javax.swing.tree.MutableTreeNode
Parameters:
child - the MutableTreeNode to insert under this node
index - the index in this node's child array where this node is to be inserted
Throws:
java.lang.IllegalArgumentException - if child is not instance of FGlyph

remove

public void remove(int index)
Removes the child at the specified index from this node's children and sets that node's parent to null. The child node to remove must be a MutableTreeNode.

Specified by:
remove in interface javax.swing.tree.MutableTreeNode
Parameters:
index - the index in this node's child array of the child to remove
Throws:
java.lang.ArrayIndexOutOfBoundsException - if index is out of bounds

remove

public void remove(javax.swing.tree.MutableTreeNode child)
Removes child from this node's child array, giving it a null parent.

Specified by:
remove in interface javax.swing.tree.MutableTreeNode
Parameters:
child - a child of this node to remove
Throws:
java.lang.IllegalArgumentException - if child is null or is not a child of this node

removeFromParent

public void removeFromParent()
Removes the subtree rooted at this node from the tree, giving this node a null parent. Does nothing if this node is the root of its tree.

Specified by:
removeFromParent in interface javax.swing.tree.MutableTreeNode

setParent

public void setParent(javax.swing.tree.MutableTreeNode parent)
Sets this node's parent to parent but does not change the parent's child array. This method is called from insert() and remove() to reassign a child's parent, it should not be messaged from anywhere else.

Specified by:
setParent in interface javax.swing.tree.MutableTreeNode
Parameters:
parent - this node's new parent

setUserObject

public void setUserObject(java.lang.Object object)
Resets the user object of the receiver to object. Does nothing in this implementation.

Specified by:
setUserObject in interface javax.swing.tree.MutableTreeNode

propertyChange

public void propertyChange(org.w3c.dom.Element model,
                           java.lang.String name,
                           java.lang.Object oldValue,
                           java.lang.Object newValue)
Method called by a UForm which had a change of a property.

Parameters:
name - the name of the property
oldValue - the old value of the property
newValue - the new value of the property

setSelected

public void setSelected(boolean selected)
Selects or unselects this glyph, depending on the value of selected

Parameters:
selected - - If true, selects this glyph; otherwise, unselects this glyph.

getLimits

public Limits getLimits()

updateProperties

protected void updateProperties()
Updates the local copies of the properties from the model.


updateInteractionPoints

protected void updateInteractionPoints()
Updates the interaction points. By default, it defines 8 points around the bounding rectangle. Must be overriden if interactions points are used differently.


addInteractionPoint

public void addInteractionPoint(java.awt.geom.Point2D p,
                                int type)
Adds an interaction Point


setInteractionPoint

public void setInteractionPoint(int p)
Sets the current interaction point picked by the user


getInteractionPoint

public java.awt.geom.Point2D getInteractionPoint()

moveInteractionPoint

public java.lang.Object moveInteractionPoint(java.awt.geom.Point2D newPos)
moves the interaction point to the new position referenced in argument newPos By default, it modifies the width and height of the bounding rectangle accordingly



Copyright (c) 2003 Rutgers, The State University of New Jersey