com.imagero.swing.shape
Class ShapeUnit

java.lang.Object
  extended bycom.imagero.swing.shape.ShapeUnit
All Implemented Interfaces:
java.awt.image.ImageObserver

public class ShapeUnit
extends java.lang.Object
implements java.awt.image.ImageObserver

ShapeUnit consists of Shape and drawing options - AffineTransform, Paint, Image and so on.


Field Summary
static com.imagero.swing.shape.ShapeUnit.EventKey MOUSE_CLICKED
           
static com.imagero.swing.shape.ShapeUnit.EventKey MOUSE_DRAGGED
           
static com.imagero.swing.shape.ShapeUnit.EventKey MOUSE_ENTERED
           
static com.imagero.swing.shape.ShapeUnit.EventKey MOUSE_EXITED
           
static com.imagero.swing.shape.ShapeUnit.EventKey MOUSE_MOVED
           
static com.imagero.swing.shape.ShapeUnit.EventKey MOUSE_PRESSED
           
static com.imagero.swing.shape.ShapeUnit.EventKey MOUSE_RELEASED
           
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ShapeUnit(java.awt.Shape shape)
          create new ShapeUnit with supplied Shape without AffineTransform
ShapeUnit(java.awt.Shape shape, java.awt.geom.AffineTransform transform)
          create new ShapeUnit
ShapeUnit(java.awt.Shape shape, java.awt.geom.AffineTransform transform, java.awt.Paint paint)
           
ShapeUnit(java.awt.Shape shape, java.awt.Paint paint)
          create new ShapeUnit
 
Method Summary
 void addAction(com.imagero.swing.shape.ShapeUnit.EventKey eventKey, javax.swing.Action a)
           
 boolean contains(int x, int y)
           
 javax.swing.Action getAction(com.imagero.swing.shape.ShapeUnit.EventKey eventKey, int index)
           
 int getActionCount(com.imagero.swing.shape.ShapeUnit.EventKey eventKey)
           
 float getAlpha()
           
 java.awt.Rectangle getBounds()
          get bounds of this ShapeUnit
 java.awt.Paint getFillPaint()
           
 java.awt.Image getImage()
          get Image
 java.awt.Point getImageLocation()
          get location of top left Image corner
 java.awt.Point getImageLocation(java.awt.Point p)
          get location of top left Image corner
 java.awt.Paint getOutlinePaint()
           
 java.awt.Shape getShape()
           
 java.awt.Stroke getStroke()
          get stroke for shape outline drawing
 java.awt.geom.AffineTransform getTransform()
          get AffineTransform
 java.awt.Shape getTransformedShape()
          get Shape transformed with currently defined AffineTransform
 boolean imageUpdate(java.awt.Image img, int infoflags, int x, int y, int w, int h)
           
 void invalidateShape()
           
 boolean isDrawShapeOutline()
          get current setting for drawShapeOutline option
 void paint(java.awt.Graphics2D g)
          paint ShapeUnit into supplied Graphics
 void removeAction(javax.swing.Action a)
           
 boolean removeAction(javax.swing.Action a, com.imagero.swing.shape.ShapeUnit.EventKey eventKey)
           
 void resetTransform()
          reset current transform (set to default one - which was supplied in constructor or setted by setTransform)
 void setAlpha(float alpha)
           
 void setDrawShapeOutline(boolean drawShapeOutline)
          set drawShapeOutline option
 void setFillPaint(java.awt.Paint fillPaint)
           
 void setImage(java.awt.Image image)
          set Image used (instead of Paint) to fill current Shape
 void setImageLocation(int x, int y)
          set top left location of Image
 void setImageLocation(java.awt.Point location)
          set top left location of Image
 void setOutlinePaint(java.awt.Paint drawPaint)
           
 void setStroke(java.awt.Stroke stroke)
          set Stroke for Shape outline drawing
 void setTransform(java.awt.geom.AffineTransform transform)
          set current and default AffineTransform.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MOUSE_CLICKED

public static final com.imagero.swing.shape.ShapeUnit.EventKey MOUSE_CLICKED

MOUSE_ENTERED

public static final com.imagero.swing.shape.ShapeUnit.EventKey MOUSE_ENTERED

MOUSE_EXITED

public static final com.imagero.swing.shape.ShapeUnit.EventKey MOUSE_EXITED

MOUSE_PRESSED

public static final com.imagero.swing.shape.ShapeUnit.EventKey MOUSE_PRESSED

MOUSE_RELEASED

public static final com.imagero.swing.shape.ShapeUnit.EventKey MOUSE_RELEASED

MOUSE_MOVED

public static final com.imagero.swing.shape.ShapeUnit.EventKey MOUSE_MOVED

MOUSE_DRAGGED

public static final com.imagero.swing.shape.ShapeUnit.EventKey MOUSE_DRAGGED
Constructor Detail

ShapeUnit

public ShapeUnit(java.awt.Shape shape)
create new ShapeUnit with supplied Shape without AffineTransform

Parameters:
shape -

ShapeUnit

public ShapeUnit(java.awt.Shape shape,
                 java.awt.geom.AffineTransform transform)
create new ShapeUnit

Parameters:
shape -
transform -

ShapeUnit

public ShapeUnit(java.awt.Shape shape,
                 java.awt.Paint paint)
create new ShapeUnit

Parameters:
shape - Shape
paint - Paint

ShapeUnit

public ShapeUnit(java.awt.Shape shape,
                 java.awt.geom.AffineTransform transform,
                 java.awt.Paint paint)
Method Detail

addAction

public void addAction(com.imagero.swing.shape.ShapeUnit.EventKey eventKey,
                      javax.swing.Action a)

removeAction

public boolean removeAction(javax.swing.Action a,
                            com.imagero.swing.shape.ShapeUnit.EventKey eventKey)

removeAction

public void removeAction(javax.swing.Action a)

getAlpha

public float getAlpha()

setAlpha

public void setAlpha(float alpha)

getActionCount

public int getActionCount(com.imagero.swing.shape.ShapeUnit.EventKey eventKey)

getAction

public javax.swing.Action getAction(com.imagero.swing.shape.ShapeUnit.EventKey eventKey,
                                    int index)

invalidateShape

public void invalidateShape()

getTransformedShape

public java.awt.Shape getTransformedShape()
get Shape transformed with currently defined AffineTransform

Returns:
Shape (guarantied to return not null)

contains

public boolean contains(int x,
                        int y)

getShape

public java.awt.Shape getShape()

getTransform

public java.awt.geom.AffineTransform getTransform()
get AffineTransform

Returns:
null or current AffineTransform

setTransform

public void setTransform(java.awt.geom.AffineTransform transform)
set current and default AffineTransform.

Parameters:
transform - new AffineTransform

resetTransform

public void resetTransform()
reset current transform (set to default one - which was supplied in constructor or setted by setTransform)


getBounds

public java.awt.Rectangle getBounds()
get bounds of this ShapeUnit

Returns:
Rectangle

getImage

public java.awt.Image getImage()
get Image

Returns:
null or Image

setImage

public void setImage(java.awt.Image image)
set Image used (instead of Paint) to fill current Shape

Parameters:
image - Image

setImageLocation

public void setImageLocation(java.awt.Point location)
set top left location of Image

Parameters:
location - Point

setImageLocation

public void setImageLocation(int x,
                             int y)
set top left location of Image


getImageLocation

public java.awt.Point getImageLocation()
get location of top left Image corner

Returns:
Point

getImageLocation

public java.awt.Point getImageLocation(java.awt.Point p)
get location of top left Image corner

Parameters:
p - Point - if not null, then its x and y fields filled with actual values, otherwise new Point is created
Returns:
Point

getFillPaint

public java.awt.Paint getFillPaint()

setFillPaint

public void setFillPaint(java.awt.Paint fillPaint)

getOutlinePaint

public java.awt.Paint getOutlinePaint()

setOutlinePaint

public void setOutlinePaint(java.awt.Paint drawPaint)

isDrawShapeOutline

public boolean isDrawShapeOutline()
get current setting for drawShapeOutline option

Returns:
true if shape outline painted

setDrawShapeOutline

public void setDrawShapeOutline(boolean drawShapeOutline)
set drawShapeOutline option

Parameters:
drawShapeOutline - new value

getStroke

public java.awt.Stroke getStroke()
get stroke for shape outline drawing

Returns:
null or current Stroke

setStroke

public void setStroke(java.awt.Stroke stroke)
set Stroke for Shape outline drawing

Parameters:
stroke - new Stroke

paint

public void paint(java.awt.Graphics2D g)
paint ShapeUnit into supplied Graphics

Parameters:
g - Graphics

imageUpdate

public boolean imageUpdate(java.awt.Image img,
                           int infoflags,
                           int x,
                           int y,
                           int w,
                           int h)
Specified by:
imageUpdate in interface java.awt.image.ImageObserver