model
Class GraphicalObject

java.lang.Object
  extended by model.GraphicalObject
All Implemented Interfaces:
java.awt.Shape

public class GraphicalObject
extends java.lang.Object
implements java.awt.Shape

A graphical object is used for drawing and enabling the selection of ontology objects.


Nested Class Summary
static class GraphicalObject.Type
          possible graphics type
 
Field Summary
private  float[] coordinates
          The vertices of the object.
private  java.awt.Color fillColor
          the fill color
private  java.awt.BasicStroke fillStroke
          the fill stroke
private  java.awt.Color highlightColor
          the hightlight color
private  java.awt.Color lineColor
          the outline color
private  java.awt.BasicStroke lineStroke
          the outline stroke
private  boolean selected
          specifies if the object is selected
private  java.awt.Shape shape
          the shape representation of the coordinates
private  double size
          the radius of a point
private  java.lang.String style
          the SVG style
private  GraphicalObject.Type type
          the graphics type
 
Constructor Summary
GraphicalObject(GraphicalObject.Type type, java.lang.String style, java.lang.String points, double size)
          Constructs a new graphical object.
 
Method Summary
private  void buildShape()
          Builds the shape from the coordinates of the object.
 boolean contains(double x, double y)
           
 boolean contains(double arg0, double arg1, double arg2, double arg3)
           
 boolean contains(java.awt.geom.Point2D arg0)
           
 boolean contains(java.awt.geom.Rectangle2D arg0)
           
static double getArea(GraphicalObject object)
          Utility method for getting the area of a graphical object.
 java.awt.Rectangle getBounds()
           
 java.awt.geom.Rectangle2D getBounds2D()
           
 java.awt.geom.Point2D getCentroid()
          Gets the centroid of this shape.
 float[] getCoordinates()
          Gets the coordinates of the object.
static float[] getCoords(java.lang.String points)
          Utility method for converting a string of coordinates into an array of floating point values.
 java.awt.Color getFillColor()
          Gets the fill color.
 java.awt.Stroke getFillStroke()
          Gets the fill stroke.
static GraphicalObject.Type getGraphicsType(java.lang.String type)
          Utility method for getting the graphical Type of an object from a string.
static double getLength(GraphicalObject object)
          Utility method for getting the length of a graphical object.
 java.awt.Color getLineColor()
          Gets the outline color.
 java.awt.BasicStroke getLineStroke()
          Gets the outline stroke.
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform arg0)
           
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform arg0, double arg1)
           
static java.lang.String getPoints(GraphicalObject object)
          Utility method for converting an array of floats into a string representation.
 double getRadius()
          Gets the radius of the object.
 java.awt.Color getSelectedColor()
          Gets the objects highlight color.
 java.lang.String getStyle()
          Gets the SVG style of the object.
 GraphicalObject.Type getType()
          Gets the graphics type.
 boolean intersects(double arg0, double arg1, double arg2, double arg3)
           
 boolean intersects(java.awt.geom.Rectangle2D arg0)
           
 boolean isSelected()
          Gets if the object is currently selected.
private  void parseStyle()
          Parses the style of the object to determine the outline and fill colors.
 void setCoordinates(float[] coords)
          Sets the coordinates of the graphical object and rebuilds the shape representation of the object.
 void setFillColor(java.awt.Color fill)
          Sets the fill color.
 void setLineColor(java.awt.Color line)
          Sets the outline color.
 void setRadius(double size)
          Sets the radius of the object and rebuilds the shape representation of the object.
 void setSelected(boolean selected)
          Sets if the object is selected.
private  void updateStyle()
          Modifies the style of the object to store modifications of the fill or line color of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

private GraphicalObject.Type type
the graphics type


style

private java.lang.String style
the SVG style


coordinates

private float[] coordinates
The vertices of the object. The coordinates are specified by interlaced x and y values.


shape

private java.awt.Shape shape
the shape representation of the coordinates


size

private double size
the radius of a point


selected

private boolean selected
specifies if the object is selected


fillColor

private java.awt.Color fillColor
the fill color


lineColor

private java.awt.Color lineColor
the outline color


highlightColor

private java.awt.Color highlightColor
the hightlight color


fillStroke

private java.awt.BasicStroke fillStroke
the fill stroke


lineStroke

private java.awt.BasicStroke lineStroke
the outline stroke

Constructor Detail

GraphicalObject

public GraphicalObject(GraphicalObject.Type type,
                       java.lang.String style,
                       java.lang.String points,
                       double size)
Constructs a new graphical object.

Parameters:
type - - the graphics type
style - - the SVG style
points - - a list of coordinates
size - - the radius of the object (for points), otherwise 0
Method Detail

parseStyle

private void parseStyle()
Parses the style of the object to determine the outline and fill colors.


updateStyle

private void updateStyle()
Modifies the style of the object to store modifications of the fill or line color of the object.


buildShape

private void buildShape()
Builds the shape from the coordinates of the object.


setCoordinates

public void setCoordinates(float[] coords)
Sets the coordinates of the graphical object and rebuilds the shape representation of the object.


setRadius

public void setRadius(double size)
Sets the radius of the object and rebuilds the shape representation of the object.


getStyle

public java.lang.String getStyle()
Gets the SVG style of the object.


setSelected

public void setSelected(boolean selected)
Sets if the object is selected.


isSelected

public boolean isSelected()
Gets if the object is currently selected.


getRadius

public double getRadius()
Gets the radius of the object.


getCoordinates

public float[] getCoordinates()
Gets the coordinates of the object. This method returns a copy of the coordinates.


getLineStroke

public java.awt.BasicStroke getLineStroke()
Gets the outline stroke.


getLineColor

public java.awt.Color getLineColor()
Gets the outline color.


setLineColor

public void setLineColor(java.awt.Color line)
Sets the outline color.


getFillStroke

public java.awt.Stroke getFillStroke()
Gets the fill stroke.


setFillColor

public void setFillColor(java.awt.Color fill)
Sets the fill color.

Parameters:
fill -

getFillColor

public java.awt.Color getFillColor()
Gets the fill color.


getSelectedColor

public java.awt.Color getSelectedColor()
Gets the objects highlight color.


getType

public GraphicalObject.Type getType()
Gets the graphics type.


contains

public boolean contains(double x,
                        double y)
Specified by:
contains in interface java.awt.Shape

getBounds

public java.awt.Rectangle getBounds()
Specified by:
getBounds in interface java.awt.Shape

getBounds2D

public java.awt.geom.Rectangle2D getBounds2D()
Specified by:
getBounds2D in interface java.awt.Shape

contains

public boolean contains(java.awt.geom.Point2D arg0)
Specified by:
contains in interface java.awt.Shape

intersects

public boolean intersects(double arg0,
                          double arg1,
                          double arg2,
                          double arg3)
Specified by:
intersects in interface java.awt.Shape

intersects

public boolean intersects(java.awt.geom.Rectangle2D arg0)
Specified by:
intersects in interface java.awt.Shape

contains

public boolean contains(double arg0,
                        double arg1,
                        double arg2,
                        double arg3)
Specified by:
contains in interface java.awt.Shape

contains

public boolean contains(java.awt.geom.Rectangle2D arg0)
Specified by:
contains in interface java.awt.Shape

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform arg0)
Specified by:
getPathIterator in interface java.awt.Shape

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform arg0,
                                                  double arg1)
Specified by:
getPathIterator in interface java.awt.Shape

getCoords

public static float[] getCoords(java.lang.String points)
Utility method for converting a string of coordinates into an array of floating point values.

Parameters:
points - - a string of space or comma delimited coordinates
Returns:
- an array of the values

getPoints

public static java.lang.String getPoints(GraphicalObject object)
Utility method for converting an array of floats into a string representation.


getGraphicsType

public static GraphicalObject.Type getGraphicsType(java.lang.String type)
Utility method for getting the graphical Type of an object from a string.


getCentroid

public java.awt.geom.Point2D getCentroid()
Gets the centroid of this shape. Note: this function is only implemented for polygons and points. For polylines, it returns the center of the bounding box.

Returns:
- the centroid

getArea

public static double getArea(GraphicalObject object)
Utility method for getting the area of a graphical object.


getLength

public static double getLength(GraphicalObject object)
Utility method for getting the length of a graphical object.