Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.port80.graph.impl
Class GraphShape  view GraphShape download GraphShape.java

java.lang.Object
  extended bycom.port80.graph.impl.GraphShape
All Implemented Interfaces:
java.lang.Cloneable, com.port80.graph.IGraphShape, java.awt.Shape

public class GraphShape
extends java.lang.Object
implements com.port80.graph.IGraphShape

Basic graph shape class that implements IGraphShape interface. . Wrapper around a java.awt.Shape objects and an enclosed unit square. When the unit square is scaled to accommodate the label bounds, the shape is scaled accordingly.


Field Summary
private  int[] aligns
           
private  double baseX
           
private  double baseY
           
private  java.awt.Color borderColor
           
private  com.port80.graph.IGraphStroke borderStroke
           
private  java.awt.geom.Rectangle2D clientRect
           
private static boolean DEBUG
           
private static java.awt.Graphics2D defaultGraphics
           
private  boolean dirty
           
private  int exclude
           
private  java.awt.Color fillColor
           
private  java.awt.Font font
           
private  java.awt.Color fontColor
           
private  double hrSpacing
           
private  java.awt.image.BufferedImage imageBuffer
           
private  boolean keepRatio
           
private  java.lang.String label
           
private  java.awt.font.TextLayout[] layouts
           
private  int minHeight
           
private  int minWidth
           
private  java.lang.String name
           
private static java.lang.String NAME
           
private  java.awt.geom.Point2D origin
           
private  java.awt.Shape original
           
private  java.awt.Shape shapeObject
           
private  double textSpacing
           
private  double xPadding
           
private  double xScale
           
private  double yPadding
           
private  double yScale
           
 
Constructor Summary
GraphShape(java.lang.String name, com.port80.graph.IGraphShape gs)
           
GraphShape(java.lang.String name, java.awt.Shape shape, java.awt.geom.Rectangle2D rect, boolean keepratio)
           
 
Method Summary
 java.lang.Object clone()
          This method may be called to create a new copy of the Object.
 boolean contains(double x, double y)
          Test if the coordinates lie in the shape.
 boolean contains(double x, double y, double w, double h)
          Test if a high-precision rectangle lies completely in the shape.
 boolean contains(java.awt.geom.Point2D p)
          Test if the point lie in the shape.
 boolean contains(java.awt.geom.Rectangle2D r)
          Test if a high-precision rectangle lies completely in the shape.
 double getBaseX()
           
 double getBaseY()
           
 java.awt.Rectangle getBounds()
          Returns a Rectange that bounds the shape.
 java.awt.geom.Rectangle2D getBounds2D()
          Returns a high precision bounding box of the shape.
 java.awt.geom.Rectangle2D getClientRect()
           
 java.awt.image.BufferedImage getImageBuffer()
           
 java.awt.font.TextLayout[] getLayouts()
           
 java.lang.String getName()
           
 java.awt.geom.Point2D getOrigin()
           
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform t)
          Return an iterator along the shape boundary.
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform t, double flatness)
          Return an iterator along the flattened version of the shape boundary.
 java.awt.Shape getShape()
           
 java.awt.Shape getTemplateShape()
           
 boolean intersects(double x, double y, double w, double h)
          Test if a high-precision rectangle intersects the shape.
 boolean intersects(java.awt.geom.Rectangle2D r)
          Test if a high-precision rectangle intersects the shape.
 boolean isKeepRatio()
           
 void render(java.awt.Graphics2D g2d)
          Render shape content to given Graphics2D.
 void reshape(double xscale, double yscale, java.awt.geom.Point2D neworigin, double textwidth, double textheight)
          Scale shape and set new original.
 void setOrigin(java.awt.geom.Point2D p)
           
 java.lang.String toString()
          Convert this Object to a human-readable String.
 void update(java.awt.Graphics2D g2d, java.lang.String label, java.awt.geom.Point2D pos, int minwidth, int minheight, java.awt.Font font, com.port80.graph.IGraphStroke stroke, java.awt.Color fontcolor, java.awt.Color bordercolor, java.awt.Color fillcolor, int exclude)
          Update shape size and label and render content into an image buffer.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NAME

private static final java.lang.String NAME
See Also:
Constant Field Values

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

defaultGraphics

private static final java.awt.Graphics2D defaultGraphics

name

private java.lang.String name

original

private java.awt.Shape original

clientRect

private java.awt.geom.Rectangle2D clientRect

keepRatio

private boolean keepRatio

label

private java.lang.String label

origin

private java.awt.geom.Point2D origin

font

private java.awt.Font font

borderStroke

private com.port80.graph.IGraphStroke borderStroke

fontColor

private java.awt.Color fontColor

borderColor

private java.awt.Color borderColor

fillColor

private java.awt.Color fillColor

minWidth

private int minWidth

minHeight

private int minHeight

exclude

private int exclude

layouts

private java.awt.font.TextLayout[] layouts

aligns

private int[] aligns

imageBuffer

private java.awt.image.BufferedImage imageBuffer

shapeObject

private java.awt.Shape shapeObject

xScale

private double xScale

yScale

private double yScale

baseX

private double baseX

baseY

private double baseY

dirty

private boolean dirty

xPadding

private double xPadding

yPadding

private double yPadding

textSpacing

private double textSpacing

hrSpacing

private double hrSpacing
Constructor Detail

GraphShape

public GraphShape(java.lang.String name,
                  java.awt.Shape shape,
                  java.awt.geom.Rectangle2D rect,
                  boolean keepratio)

GraphShape

public GraphShape(java.lang.String name,
                  com.port80.graph.IGraphShape gs)
Method Detail

getName

public java.lang.String getName()
Specified by:
getName in interface com.port80.graph.IGraphShape

getShape

public java.awt.Shape getShape()
Specified by:
getShape in interface com.port80.graph.IGraphShape

getTemplateShape

public java.awt.Shape getTemplateShape()
Specified by:
getTemplateShape in interface com.port80.graph.IGraphShape

getClientRect

public java.awt.geom.Rectangle2D getClientRect()
Specified by:
getClientRect in interface com.port80.graph.IGraphShape

isKeepRatio

public boolean isKeepRatio()
Specified by:
isKeepRatio in interface com.port80.graph.IGraphShape

getOrigin

public java.awt.geom.Point2D getOrigin()
Specified by:
getOrigin in interface com.port80.graph.IGraphShape

getBaseX

public double getBaseX()
Specified by:
getBaseX in interface com.port80.graph.IGraphShape

getBaseY

public double getBaseY()
Specified by:
getBaseY in interface com.port80.graph.IGraphShape

getLayouts

public java.awt.font.TextLayout[] getLayouts()

getImageBuffer

public java.awt.image.BufferedImage getImageBuffer()

setOrigin

public void setOrigin(java.awt.geom.Point2D p)
Specified by:
setOrigin in interface com.port80.graph.IGraphShape

update

public void update(java.awt.Graphics2D g2d,
                   java.lang.String label,
                   java.awt.geom.Point2D pos,
                   int minwidth,
                   int minheight,
                   java.awt.Font font,
                   com.port80.graph.IGraphStroke stroke,
                   java.awt.Color fontcolor,
                   java.awt.Color bordercolor,
                   java.awt.Color fillcolor,
                   int exclude)
Update shape size and label and render content into an image buffer.

Specified by:
update in interface com.port80.graph.IGraphShape

render

public void render(java.awt.Graphics2D g2d)
Render shape content to given Graphics2D.

Specified by:
render in interface com.port80.graph.IGraphShape

reshape

public void reshape(double xscale,
                    double yscale,
                    java.awt.geom.Point2D neworigin,
                    double textwidth,
                    double textheight)
Scale shape and set new original. . xscale and yscale is usually the same as textwidth and textheight. However, xscale may > textwidth to set a minimium width regardless of textwidth or add more margins to the text.

Specified by:
reshape in interface com.port80.graph.IGraphShape

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


clone

public java.lang.Object clone()
Description copied from class: java.lang.Object
This method may be called to create a new copy of the Object. The typical behavior is as follows:
  • o == o.clone() is false
  • o.getClass() == o.clone().getClass() is true
  • o.equals(o) is true

However, these are not strict requirements, and may be violated if necessary. Of the three requirements, the last is the most commonly violated, particularly if the subclass does not override Object.equals(Object)>Object.equals(Object) 55 .

If the Object you call clone() on does not implement java.lang.Cloneable (which is a placeholder interface), then a CloneNotSupportedException is thrown. Notice that Object does not implement Cloneable; this method exists as a convenience for subclasses that do.

Object's implementation of clone allocates space for the new Object using the correct class, without calling any constructors, and then fills in all of the new field values with the old field values. Thus, it is a shallow copy. However, subclasses are permitted to make a deep copy.

All array types implement Cloneable, and override this method as follows (it should never fail):

 public Object clone()
 {
   try
     {
       super.clone();
     }
   catch (CloneNotSupportedException e)
     {
       throw new InternalError(e.getMessage());
     }
 }
 

Specified by:
clone in interface com.port80.graph.IGraphShape

contains

public boolean contains(double x,
                        double y)
Description copied from interface: java.awt.Shape
Test if the coordinates lie in the shape.

Specified by:
contains in interface java.awt.Shape

contains

public boolean contains(double x,
                        double y,
                        double w,
                        double h)
Description copied from interface: java.awt.Shape
Test if a high-precision rectangle lies completely in the shape. This is true if all points in the rectangle are in the shape, with the caveat that the operation may include high probability estimates when the actual calculation is prohibitively expensive. The java.awt.geom.Area class can be used for more precise answers.

Specified by:
contains in interface java.awt.Shape

contains

public boolean contains(java.awt.geom.Point2D p)
Description copied from interface: java.awt.Shape
Test if the point lie in the shape.

Specified by:
contains in interface java.awt.Shape

contains

public boolean contains(java.awt.geom.Rectangle2D r)
Description copied from interface: java.awt.Shape
Test if a high-precision rectangle lies completely in the shape. This is true if all points in the rectangle are in the shape, with the caveat that the operation may include high probability estimates when the actual calculation is prohibitively expensive. The java.awt.geom.Area class can be used for more precise answers.

Specified by:
contains in interface java.awt.Shape

getBounds

public java.awt.Rectangle getBounds()
Description copied from interface: java.awt.Shape
Returns a Rectange that bounds the shape. There is no guarantee that this is the minimum bounding box, particularly if the shape overflows the finite integer range of a bound. Generally, getBounds2D returns a tighter bound.

Specified by:
getBounds in interface java.awt.Shape

getBounds2D

public java.awt.geom.Rectangle2D getBounds2D()
Description copied from interface: java.awt.Shape
Returns a high precision bounding box of the shape. There is no guarantee that this is the minimum bounding box, but at least it never overflows.

Specified by:
getBounds2D in interface java.awt.Shape

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform t)
Description copied from interface: java.awt.Shape
Return an iterator along the shape boundary. If the optional transform is provided, the iterator is transformed accordingly. Each call returns a new object, independent from others in use. It is recommended, but not required, that the Shape isolate iterations from future changes to the boundary, and document this fact.

Specified by:
getPathIterator in interface java.awt.Shape

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform t,
                                                  double flatness)
Description copied from interface: java.awt.Shape
Return an iterator along the flattened version of the shape boundary. Only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE points are returned in the iterator. The flatness paramter controls how far points are allowed to differ from the real curve; although a limit on accuracy may cause this parameter to be enlarged if needed.

If the optional transform is provided, the iterator is transformed accordingly. Each call returns a new object, independent from others in use. It is recommended, but not required, that the Shape isolate iterations from future changes to the boundary, and document this fact.

Specified by:
getPathIterator in interface java.awt.Shape

intersects

public boolean intersects(double x,
                          double y,
                          double w,
                          double h)
Description copied from interface: java.awt.Shape
Test if a high-precision rectangle intersects the shape. This is true if any point in the rectangle is in the shape, with the caveat that the operation may include high probability estimates when the actual calculation is prohibitively expensive. The java.awt.geom.Area class can be used for more precise answers.

Specified by:
intersects in interface java.awt.Shape

intersects

public boolean intersects(java.awt.geom.Rectangle2D r)
Description copied from interface: java.awt.Shape
Test if a high-precision rectangle intersects the shape. This is true if any point in the rectangle is in the shape, with the caveat that the operation may include high probability estimates when the actual calculation is prohibitively expensive. The java.awt.geom.Area class can be used for more precise answers.

Specified by:
intersects in interface java.awt.Shape