com.bbn.openmap.tools.icon
Class BasicIconPart

java.lang.Object
  extended by com.bbn.openmap.tools.icon.BasicIconPart
All Implemented Interfaces:
IconPart, java.lang.Cloneable
Direct Known Subclasses:
BasicAppIconPart

public class BasicIconPart
extends java.lang.Object
implements IconPart, java.lang.Cloneable

The BasicIconPart is an implementation of the IconPart. In addition to the geometry and DrawingAttributes adjustments that can be done on an IconPart, the BasicIconPart also lets you use an AffineTransform to rotate, translate or scale the geometrym and will create GradientPaints for the Colors from the DrawingAttribtues if desired.


Field Summary
protected  java.awt.geom.AffineTransform baseTransform
          AffineTransform to adjust geometry if needed.
protected  java.awt.Shape clip
          Shape clipping area for this IconPart.
protected  java.awt.Shape geometry
          Shape geometry for this IconPart.
protected  boolean gradient
          Flag to modifying DrawingAttributes Colors into GradientPaints, for that 3D lighting look.
protected  DrawingAttributes renderingAttributes
          DrawingAttributes for this IconPart.
 
Constructor Summary
BasicIconPart(java.awt.Shape shape)
          Create a BasicIconPart with a java.awt.Shape object for a geometry.
BasicIconPart(java.awt.Shape shape, java.awt.geom.AffineTransform transform)
          Create a BasicIconPart with a java.awt.Shape object for a geometry, along with an AffineTransform that may be applied to the geometry at rendertime.
BasicIconPart(java.awt.Shape shape, java.awt.geom.AffineTransform transform, DrawingAttributes da)
          Create a BasicIconPart with a java.awt.Shape object for a geometry, along with an AffineTransform that may be applied to the geometry at rendertime.
BasicIconPart(java.awt.Shape shape, DrawingAttributes da)
          Create a BasicIconPart with a java.awt.Shape object for a geometry.
 
Method Summary
 java.lang.Object clone()
           
protected  DrawingAttributes getAttributesForRendering(DrawingAttributes da)
          Get the DrawingAttributes that should be used for rendering.
 java.awt.Shape getClip()
          Get a clip area for the IconPart.
 java.awt.Shape getGeometry()
          Get the geometry for this IconPart.
 DrawingAttributes getRenderingAttributes()
          Get the rendering attributes for this IconPart.
 java.awt.geom.AffineTransform getTransform()
           
 boolean isGradient()
          Get whether colors should be replaced by GradientPaints.
 void render(java.awt.Graphics g, int width, int height)
          Have the IconPart render itself into the Graphic object for a given height and width.
 void render(java.awt.Graphics g, int width, int height, DrawingAttributes appDA)
          Have the IconPart render itself into the Graphic object for a given height and width.
 void setClip(java.awt.Shape clipArea)
          Set a clip area for the IconPart to draw only certain parts of the geometry.
 void setGeometry(java.awt.Shape shape)
          Set the geometry for this IconPart.
 void setGradient(boolean value)
          Set whether colors should be replaced by GradientPaints.
 void setRenderingAttributes(DrawingAttributes da)
          Set the rendering attributes for this IconPart.
 void setTransform(java.awt.geom.AffineTransform af)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

baseTransform

protected java.awt.geom.AffineTransform baseTransform
AffineTransform to adjust geometry if needed.


geometry

protected java.awt.Shape geometry
Shape geometry for this IconPart.


clip

protected java.awt.Shape clip
Shape clipping area for this IconPart.


renderingAttributes

protected DrawingAttributes renderingAttributes
DrawingAttributes for this IconPart.


gradient

protected boolean gradient
Flag to modifying DrawingAttributes Colors into GradientPaints, for that 3D lighting look.

Constructor Detail

BasicIconPart

public BasicIconPart(java.awt.Shape shape)
Create a BasicIconPart with a java.awt.Shape object for a geometry.


BasicIconPart

public BasicIconPart(java.awt.Shape shape,
                     java.awt.geom.AffineTransform transform)
Create a BasicIconPart with a java.awt.Shape object for a geometry, along with an AffineTransform that may be applied to the geometry at rendertime.


BasicIconPart

public BasicIconPart(java.awt.Shape shape,
                     DrawingAttributes da)
Create a BasicIconPart with a java.awt.Shape object for a geometry.


BasicIconPart

public BasicIconPart(java.awt.Shape shape,
                     java.awt.geom.AffineTransform transform,
                     DrawingAttributes da)
Create a BasicIconPart with a java.awt.Shape object for a geometry, along with an AffineTransform that may be applied to the geometry at rendertime.

Method Detail

getAttributesForRendering

protected DrawingAttributes getAttributesForRendering(DrawingAttributes da)
Get the DrawingAttributes that should be used for rendering.

Parameters:
da - DrawingAttributes passed in that may affect rendering choices. Can be null, and the IconPart may decide to ignore it.
Returns:
DrawingAttribute for this part.

render

public void render(java.awt.Graphics g,
                   int width,
                   int height)
Description copied from interface: IconPart
Have the IconPart render itself into the Graphic object for a given height and width.

Specified by:
render in interface IconPart
Parameters:
g - a java.awt.Graphics object to render into.
width - pixel width of icon, used to scale geometry.
height - pixel height of icon, used to scale geometry.

render

public void render(java.awt.Graphics g,
                   int width,
                   int height,
                   DrawingAttributes appDA)
Description copied from interface: IconPart
Have the IconPart render itself into the Graphic object for a given height and width. The DrawingAttributes will dictate how the geometries can be drawn, of the IconPart may react to a System setting or last-minute attributes. The IconPart may decide to ignore this provided DrawingAttributes and just use what it has. appDA may be null, in which case the internal DrawingAttributes will be used.

Specified by:
render in interface IconPart
Parameters:
g - a java.awt.Graphics object to render into.
width - pixel width of icon, used to scale geometry.
height - pixel height of icon, used to scale geometry.
appDA - drawing attributes to use under certain conditions. Certain IconParts on this list may use these drawing attributes if they want/should. May be null.

setGradient

public void setGradient(boolean value)
Set whether colors should be replaced by GradientPaints.


isGradient

public boolean isGradient()
Get whether colors should be replaced by GradientPaints.


setClip

public void setClip(java.awt.Shape clipArea)
Description copied from interface: IconPart
Set a clip area for the IconPart to draw only certain parts of the geometry.

Specified by:
setClip in interface IconPart

getClip

public java.awt.Shape getClip()
Description copied from interface: IconPart
Get a clip area for the IconPart.

Specified by:
getClip in interface IconPart

setGeometry

public void setGeometry(java.awt.Shape shape)
Description copied from interface: IconPart
Set the geometry for this IconPart.

Specified by:
setGeometry in interface IconPart

getGeometry

public java.awt.Shape getGeometry()
Description copied from interface: IconPart
Get the geometry for this IconPart.

Specified by:
getGeometry in interface IconPart

setTransform

public void setTransform(java.awt.geom.AffineTransform af)

getTransform

public java.awt.geom.AffineTransform getTransform()

setRenderingAttributes

public void setRenderingAttributes(DrawingAttributes da)
Description copied from interface: IconPart
Set the rendering attributes for this IconPart.

Specified by:
setRenderingAttributes in interface IconPart

getRenderingAttributes

public DrawingAttributes getRenderingAttributes()
Description copied from interface: IconPart
Get the rendering attributes for this IconPart.

Specified by:
getRenderingAttributes in interface IconPart

clone

public java.lang.Object clone()
Specified by:
clone in interface IconPart
Overrides:
clone in class java.lang.Object
Returns:
copy of itself, IconParts need to be Cloneable


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details