net.luniks.jtvd
Class ImagePanel.MenuItem

java.lang.Object
  extended byjava.awt.event.MouseAdapter
      extended bynet.luniks.jtvd.ImagePanel.Item
          extended bynet.luniks.jtvd.ImagePanel.MenuItem
All Implemented Interfaces:
java.util.EventListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener
Enclosing class:
ImagePanel

class ImagePanel.MenuItem
extends ImagePanel.Item

This class is a special type of Item that can draw a shape or change its text color when it is clicked or "mouseovered". These effects are used as highlight or select effects. The purpose of these items is to use them as menu buttons.

Author:
Torsten Römer, luniks.net

Field Summary
protected  boolean deleteable
           
protected  int dx
           
protected  int dy
           
protected  java.awt.Font font
           
private  java.awt.Color fontColor
           
protected  int height
           
protected  int id
           
protected  boolean print
           
protected  boolean selected
           
protected  java.awt.Color selectedColor
           
protected  java.awt.Rectangle selectedRect
           
protected  java.awt.BasicStroke selectedStroke
           
private  boolean shapeEffect
           
private  java.awt.Color shapeEffectColor
           
private  int shapeEffectPad
           
private  java.awt.Rectangle shapeEffectRect
           
private  java.awt.BasicStroke shapeEffectStroke
           
static int SHORT_TEXT_LENGTH
           
protected  java.lang.String text
           
private  boolean textEffect
           
private  java.awt.Color textEffectColor
           
protected  int textX
           
protected  int textY
           
private  java.lang.String title
           
protected  int width
           
protected  int x
           
protected  int y
           
 
Constructor Summary
ImagePanel.MenuItem(int id, java.lang.String title, int x, int y)
           
 
Method Summary
 void draw(java.awt.Graphics2D g2d)
           
 java.awt.Font getFont()
           
 java.awt.Color getFontColor()
           
 int getId()
           
 boolean getPrint()
           
 java.awt.Rectangle getRect()
           
 java.awt.Color getSelectedColor()
           
 boolean getShapeEffect()
           
 java.awt.Color getShapeEffectColor()
           
 int getShapeEffectPad()
           
 java.awt.BasicStroke getShapeEffectStroke()
           
 java.awt.geom.Rectangle2D getShapeRect()
          Returns a Rectangle2D describing the location and size of this MenuItem.
 double getShapeX()
          Returns the x coordinate of this item extended by the bounds of the shape representing the shape effect (if used) of this item.
 double getShapeY()
          Returns the y coordinate of this item extended by the bounds of the shape representing the shape effect (if used) of this item.
 java.lang.String getShortText()
           
 java.lang.String getShortTitle()
           
 java.lang.String getText()
           
 boolean getTextEffect()
           
 java.awt.Color getTextEffectColor()
           
 java.lang.String getTitle()
           
 int getX()
           
 int getY()
           
 boolean isDeleteable()
           
 boolean isSelected()
           
 void keyPressed(java.awt.event.KeyEvent ke)
           
 void keyReleased(java.awt.event.KeyEvent ke)
           
 void keyTyped(java.awt.event.KeyEvent ke)
           
 void mouseDragged(java.awt.event.MouseEvent me)
           
 void mouseMoved(java.awt.event.MouseEvent me)
           
 void mousePressed(java.awt.event.MouseEvent me)
           
 void setDeleteable(boolean deleteable)
           
 void setFont(java.awt.Font font)
           
 void setFontColor(java.awt.Color fontColor)
           
 void setId(int id)
           
 void setLocation(int x, int y)
           
 void setPrint(boolean print)
           
 void setRect(java.awt.Rectangle selectedRect)
           
 void setSelected(boolean selected)
           
 void setSelectedColor(java.awt.Color selectedColor)
           
 void setShapeEffect(boolean shapeEffect)
           
 void setShapeEffectColor(java.awt.Color shapeEffectColor)
           
 void setShapeEffectPad(int shapeEffectPad)
           
 void setShapeEffectStroke(java.awt.BasicStroke shapeEffectStroke)
           
 void setShapeX(int x)
          Sets the x coordinate of this item extended by the bounds of the shape representing the shape effect (if used) of this item.
 void setShapeY(int y)
          Sets the y coordinate of this item extended by the bounds of the shape representing the shape effect (if used) of this item.
 void setText(java.lang.String text)
           
 void setTextEffect(boolean textEffect)
           
 void setTextEffectColor(java.awt.Color textEffectColor)
           
 void setTitle(java.lang.String title)
           
 void setX(int x)
          Sets the x coordinate of this item.
 void setY(int y)
          Sets the y coordinate of this item.
 java.lang.String toString()
           
 void validateLocation()
           
 
Methods inherited from class java.awt.event.MouseAdapter
mouseClicked, mouseEntered, mouseExited, mouseReleased
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

title

private java.lang.String title

shapeEffect

private boolean shapeEffect

textEffect

private boolean textEffect

fontColor

private java.awt.Color fontColor

shapeEffectColor

private java.awt.Color shapeEffectColor

textEffectColor

private java.awt.Color textEffectColor

shapeEffectRect

private java.awt.Rectangle shapeEffectRect

shapeEffectStroke

private java.awt.BasicStroke shapeEffectStroke

shapeEffectPad

private int shapeEffectPad

SHORT_TEXT_LENGTH

public static final int SHORT_TEXT_LENGTH
See Also:
Constant Field Values

id

protected int id

text

protected java.lang.String text

x

protected int x

y

protected int y

dx

protected int dx

dy

protected int dy

selected

protected boolean selected

print

protected boolean print

selectedRect

protected java.awt.Rectangle selectedRect

selectedColor

protected java.awt.Color selectedColor

font

protected java.awt.Font font

selectedStroke

protected java.awt.BasicStroke selectedStroke

width

protected int width

height

protected int height

textX

protected int textX

textY

protected int textY

deleteable

protected boolean deleteable
Constructor Detail

ImagePanel.MenuItem

public ImagePanel.MenuItem(int id,
                           java.lang.String title,
                           int x,
                           int y)
Method Detail

draw

public void draw(java.awt.Graphics2D g2d)
Overrides:
draw in class ImagePanel.Item

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class ImagePanel.Item

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent me)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Overrides:
mouseMoved in class ImagePanel.Item

setTitle

public void setTitle(java.lang.String title)

setShapeEffect

public void setShapeEffect(boolean shapeEffect)

setTextEffect

public void setTextEffect(boolean textEffect)

setTextEffectColor

public void setTextEffectColor(java.awt.Color textEffectColor)

setShapeEffectColor

public void setShapeEffectColor(java.awt.Color shapeEffectColor)

setShapeEffectStroke

public void setShapeEffectStroke(java.awt.BasicStroke shapeEffectStroke)

setShapeEffectPad

public void setShapeEffectPad(int shapeEffectPad)

setShapeX

public void setShapeX(int x)
Sets the x coordinate of this item extended by the bounds of the shape representing the shape effect (if used) of this item. This method ensures that the center x of this item is never outside the ImagePanel.

Parameters:
x - the new x coordinate

setShapeY

public void setShapeY(int y)
Sets the y coordinate of this item extended by the bounds of the shape representing the shape effect (if used) of this item. This method ensures that the center y of this item is never outside the ImagePanel.

Parameters:
y - the new y coordinate

getTitle

public java.lang.String getTitle()

getShortTitle

public java.lang.String getShortTitle()

getShapeEffect

public boolean getShapeEffect()

getTextEffect

public boolean getTextEffect()

getTextEffectColor

public java.awt.Color getTextEffectColor()

getShapeEffectColor

public java.awt.Color getShapeEffectColor()

getShapeEffectStroke

public java.awt.BasicStroke getShapeEffectStroke()

getShapeEffectPad

public int getShapeEffectPad()

getShapeX

public double getShapeX()
Returns the x coordinate of this item extended by the bounds of the shape representing the shape effect (if used) of this item.

Returns:
the x coordinate

getShapeY

public double getShapeY()
Returns the y coordinate of this item extended by the bounds of the shape representing the shape effect (if used) of this item.

Returns:
the y coordinate

getShapeRect

public java.awt.geom.Rectangle2D getShapeRect()
Returns a Rectangle2D describing the location and size of this MenuItem. The size will be at least large enough to contain the text (and therefore the text effect) but also large enough to contain the shape representing the shape effect, if used.

Returns:
a Rectangle2D describing this MenuItem

toString

public java.lang.String toString()
Overrides:
toString in class ImagePanel.Item

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent me)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent ke)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent ke)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent ke)
Specified by:
keyTyped in interface java.awt.event.KeyListener

setId

public void setId(int id)

setText

public void setText(java.lang.String text)

setX

public void setX(int x)
Sets the x coordinate of this item. This method ensures that the center x of this item is never outside the ImagePanel.

Parameters:
x - the new x coordinate

setY

public void setY(int y)
Sets the y coordinate of this item. This method ensures that the center y of this item is never outside the ImagePanel.

Parameters:
y - the new y coordinate

setLocation

public void setLocation(int x,
                        int y)

validateLocation

public void validateLocation()

setSelected

public void setSelected(boolean selected)

setSelectedColor

public void setSelectedColor(java.awt.Color selectedColor)

setPrint

public void setPrint(boolean print)

setRect

public void setRect(java.awt.Rectangle selectedRect)

setFontColor

public void setFontColor(java.awt.Color fontColor)

setFont

public void setFont(java.awt.Font font)

setDeleteable

public void setDeleteable(boolean deleteable)

getId

public int getId()

getText

public java.lang.String getText()

getShortText

public java.lang.String getShortText()

getX

public int getX()

getY

public int getY()

isSelected

public boolean isSelected()

getPrint

public boolean getPrint()

getRect

public java.awt.Rectangle getRect()

getSelectedColor

public java.awt.Color getSelectedColor()

getFont

public java.awt.Font getFont()

getFontColor

public java.awt.Color getFontColor()

isDeleteable

public boolean isDeleteable()


Copyright (c) 2004, 2005 Torsten Römer, dode@luniks.net