public class CubeNodeRenderer extends java.lang.Object implements Animatable, java.awt.image.ImageObserver, NodeRenderer
Animatable.Animation
Constructor and Description |
---|
CubeNodeRenderer() |
Modifier and Type | Method and Description |
---|---|
protected void |
drawAnimationStep(java.awt.Graphics g,
java.lang.Object node,
java.awt.Point loc)
Draws the intermediate animation step.
|
protected void |
drawBox(java.awt.Graphics g,
int x,
int y,
int width,
int height,
java.awt.Color color)
Draws the box with side and top.
|
void |
drawNode(java.awt.Graphics g,
java.lang.Object node,
java.awt.Point loc)
Draws the node into the Graphics Context.
|
protected void |
drawNodeText(java.awt.Graphics g,
java.lang.Object node,
int startX,
int startY,
int width,
int height)
draws the text associated with the node on the box.
|
protected void |
drawRotateStep(java.awt.Graphics g,
java.lang.Object node,
java.awt.Point location)
Draws an intermediate rotation step in an animation.
|
protected java.lang.String |
fitString(java.lang.String inString,
int maxwidth,
java.awt.FontMetrics metrics)
Attempt to fit a string on the front face of the cube.
|
Animatable.Animation |
getAnimationFlag()
returns the animation type flag
|
double |
getAnimationStep()
returns the fractional step along the animation
|
double |
getAspect()
Gets the aspect ratio used for the boxes when drawn.
|
java.awt.Color |
getColor()
Gets the color for the Renderer, if any
|
int |
getCurrentFace()
Gets the index of the current face.
|
java.awt.Font |
getFont()
Gets the font used by the NodeRenderer.
|
protected java.awt.Image |
getImage(int face)
Get the image associated with the specified face.
|
java.awt.Rectangle |
getNodeBounds(java.lang.Object node,
java.awt.Point loc)
Returns the bounding box for the node using this renderer.
|
protected java.awt.Color |
getNodeColor(java.lang.Object node)
Get the color used for the node.
|
protected int |
getNodeSize(java.lang.Object node)
Get the size used for the cube node.
|
java.awt.Color |
getSelectColor()
Gets the selection color.
|
double |
getShadowFactor()
Returns the shadow factor.
|
java.awt.Color |
getTextColor()
Get the text color for the node being rendered.
|
void |
highlightNode(java.awt.Graphics g,
java.lang.Object node,
java.awt.Point loc)
Draws the node into the Graphics Context in a highlighted fashion.
|
boolean |
imageUpdate(java.awt.Image img,
int infoflags,
int x,
int y,
int width,
int height)
This method is called when information about an image which was
previously requested using an asynchronous interface becomes available.
|
boolean |
pickNode(java.lang.Object node,
java.awt.Point loc,
java.awt.Point pickPoint)
Checks whether the specified pickpoint is within the drawn area for the
node.
|
void |
setAnimationFlag(Animatable.Animation flag)
sets a flag indicating the type of transformation.
|
void |
setAnimationStep(double frac)
sets the fractional step along the animation.
|
void |
setAspect(double aspectRatio)
Sets the aspect ratio used for the boxes when drawn.
|
void |
setBackgroundImage(java.awt.Image image)
Sets the background image that is rendered on the boxes.
|
void |
setColor(java.awt.Color color)
Set the surface color to be used for rendering nodes.
|
void |
setCurrentFace(int newFace)
Sets the index of the current face.
|
void |
setFont(java.awt.Font newFont)
Sets the font used by the NodeRenderer.
|
void |
setSelectColor(java.awt.Color newColor)
Sets the selection color.
|
void |
setShadowFactor(double shadowFactor)
Sets the amount the shadow (the side face) extends beyond the side of
the node.
|
void |
setTextColor(java.awt.Color color)
Set the text color for the node being rendered.
|
protected void drawAnimationStep(java.awt.Graphics g, java.lang.Object node, java.awt.Point loc)
g
- the Graphics context to display the nodenode
- the node to displayprotected void drawBox(java.awt.Graphics g, int x, int y, int width, int height, java.awt.Color color)
g
- the Graphics context to display the nodex
- the upper left X coordinate of the box front facey
- the upper left Y coordinate of the box front facewidth
- the width of the boxheight
- the height of the boxcolor
- the base color to use for the box's front face.public void drawNode(java.awt.Graphics g, java.lang.Object node, java.awt.Point loc)
drawNode
in interface NodeRenderer
g
- the Graphics context to display the nodenode
- the node to displayloc
- The node locationprotected void drawNodeText(java.awt.Graphics g, java.lang.Object node, int startX, int startY, int width, int height)
toString()
on the node.g
- the Graphics context to display the nodenode
- the node to display the image onstartX
- the x start point to draw the textstartY
- the y start point to draw the textwidth
- the maximum width to draw the imageheight
- the maximum height to draw the imageprotected void drawRotateStep(java.awt.Graphics g, java.lang.Object node, java.awt.Point location)
g
- the Graphics context to display the nodenode
- the node to display the image onlocation
- the node's location, interpolated if in the middle of a
translationprotected java.lang.String fitString(java.lang.String inString, int maxwidth, java.awt.FontMetrics metrics)
inString
- the string to display on the cubemaxwidth
- The maximum width allowed for the text.metrics
- FontMetrics corresponding to the font used for text on
the cube facepublic Animatable.Animation getAnimationFlag()
getAnimationFlag
in interface Animatable
public double getAnimationStep()
getAnimationStep
in interface Animatable
public double getAspect()
public java.awt.Color getColor()
getColor
in interface NodeRenderer
public int getCurrentFace()
public java.awt.Font getFont()
protected java.awt.Image getImage(int face)
face
- which face the image is requested forpublic java.awt.Rectangle getNodeBounds(java.lang.Object node, java.awt.Point loc)
getNodeBounds
in interface NodeRenderer
node
- the node to checkloc
- The node locationprotected java.awt.Color getNodeColor(java.lang.Object node)
node
- the node to query for the colorprotected int getNodeSize(java.lang.Object node)
node
- the node to query for the sizepublic java.awt.Color getSelectColor()
public double getShadowFactor()
public java.awt.Color getTextColor()
public void highlightNode(java.awt.Graphics g, java.lang.Object node, java.awt.Point loc)
highlightNode
in interface NodeRenderer
g
- the Graphics context to display the nodenode
- the node to displayloc
- The node locationpublic boolean imageUpdate(java.awt.Image img, int infoflags, int x, int y, int width, int height)
imageUpdate
in interface java.awt.image.ImageObserver
img
- the image being observed.infoflags
- the bitwise inclusive OR of the following flags: WIDTH,
HEIGHT, PROPERTIES, SOMEBITS, FRAMEBITS, ALLBITS, ERROR,
ABORT.x
- the x coordinate.y
- the y coordinate.width
- the width.height
- the height.public boolean pickNode(java.lang.Object node, java.awt.Point loc, java.awt.Point pickPoint)
pickNode
in interface NodeRenderer
node
- the node to check for pickingloc
- The node locationpickPoint
- the coordinate of the point to checkpublic void setAnimationFlag(Animatable.Animation flag)
setAnimationFlag
in interface Animatable
flag
- indicates the type of transformationpublic void setAnimationStep(double frac)
setAnimationStep
in interface Animatable
frac
- the fractional step along the animationpublic void setAspect(double aspectRatio)
aspectRatio
- the new aspect ratiopublic void setBackgroundImage(java.awt.Image image)
image
- the new background imagepublic void setColor(java.awt.Color color)
setColor
in interface NodeRenderer
color
- Surface background color.public void setCurrentFace(int newFace)
newFace
- the new current face.public void setFont(java.awt.Font newFont)
newFont
- the new fontpublic void setSelectColor(java.awt.Color newColor)
newColor
- the selection colorpublic void setShadowFactor(double shadowFactor)
shadowFactor
- the new Shadow factorpublic void setTextColor(java.awt.Color color)
color
- Text color for node being renderer.