|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Panel
com.tecnick.jwtm.ConnectorButton
public class ConnectorButton
Title: ConnectorButton Class
Description: Class to create image buttons and behaviour for tree connector
Nested Class Summary | |
---|---|
(package private) class |
ConnectorButton.connectorButtonMouseAdapter
Inner class for handling mouse events. |
Nested classes/interfaces inherited from class java.awt.Panel |
---|
java.awt.Panel.AccessibleAWTPanel |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected java.lang.String |
actionCommand
action command to be returned to the listener |
protected java.awt.event.ActionListener |
actionListener
the action listener (for events) |
private java.applet.AudioClip |
audio_click
audio clip for button click event |
private java.applet.AudioClip |
audio_over
audio clip for mouse over event |
private int |
bh
height of background image in pixels |
static int |
BOTTOM
constant BOTTOM |
private java.awt.Graphics |
bufferGraphics
graphics for double buffering |
private int |
bw
width of background image in pixels |
static int |
CENTER
constant CENTER |
private java.awt.Color |
col_off_bck
background color for mouse-off state |
private java.awt.Color |
col_off_line
line color for mouse-off state |
private java.awt.Color |
col_on_bck
background color for mouse-on state |
private java.awt.Color |
col_on_line
line color for mouse-on state |
private java.awt.Color |
col_over_bck
background color for mouse-over state |
private java.awt.Color |
col_over_line
line color for mouse-over state |
private int |
connector_height
connector height (must be equal to button height) |
private int |
connector_min_width
connector block minimum width |
private boolean |
connector_opened
true if element is a closed node |
private int |
connector_width
connector final width |
private int |
connectorID
menu item id to be returned on event as actionCommand |
private int |
current_action
current button action to send to listener -1 means no action |
private int |
direction
connector direction (right = left-to-right) |
private int |
first_line_x
first connector line position |
private boolean |
first_node
true if element is a first node |
private int |
h_line_lenght
horizontal line lenght |
private int |
h_line_y
first connector line position |
private int |
ih
height of internal button icon image in pixels |
private float |
imageScale
float parameter to scale the image size |
private java.awt.Image |
img
current button icon |
private java.awt.Image |
img_bg
current background button image |
private java.awt.Image |
img_bg_off
button background image for normal state |
private java.awt.Image |
img_bg_on
button background image for button pressed |
private java.awt.Image |
img_bg_over
button background image for mouse over |
private java.awt.Image |
img_off
button icon for normal state |
private java.awt.Image |
img_on
button icon for button pressed |
private java.awt.Image |
img_over
button icon for mouse over |
private int |
item_level
node level |
private int |
iw
width of internal button icon image in pixels |
private int |
ix
horizontal position of internal button icon image |
private int |
iy
vertical position of internal button icon image |
private boolean |
last_node
true if element is a last node |
static int |
LEFT
constant LEFT |
private int |
line_width
connector line width in pixels (0 = no line) |
private java.awt.Image |
offscreen
offscreen image to handle double buffering |
static int |
RIGHT
constant RIGHT |
private static long |
serialVersionUID
serialVersionUID |
static int |
TOP
constant TOP |
private int |
v_line_lenght
vertical line lenght |
private boolean[] |
vertical_connector
connector height (same as button height) |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
ConnectorButton(int w,
int h,
int lw,
int l,
boolean isnode,
boolean f,
boolean n,
boolean[] dvc)
Build a clickable connector for the menu tree. |
Method Summary | |
---|---|
void |
addActionListener(java.awt.event.ActionListener l)
Adds the specified action listener to receive action events from this button. |
void |
addNotify()
Creates the Panel's peer. |
protected void |
connectorButton_Closed(boolean sound_on)
Gets called when the mouse crosses out of the button area. |
protected void |
connectorButton_MouseOver(boolean sound_on)
Gets called when the mouse crosses into the button area. |
protected void |
connectorButton_Opened(boolean sound_on)
Gets called when the mouse button is pressed. |
protected void |
fireActionEvent(int actiontype)
Fire an action event to the listeners. |
java.lang.String |
getActionCommand()
Returns the command name of the action event fired by this button. |
int |
getConnectorID()
Get connectorID (unique numeric identifier for current component) |
boolean |
getNodeStatus()
Get the current node status. |
void |
paint(java.awt.Graphics g)
Draw button elements (border, image and label) at calculated positions. |
void |
removeActionListener(java.awt.event.ActionListener l)
Removes the specified action listener so it no longer receives action events from this button. |
void |
resize()
Set button size and images coordinates. |
void |
setActionCommand(java.lang.String command)
Sets the command name of the action event fired by this button. |
void |
setAudioStateClips(java.applet.AudioClip a,
java.applet.AudioClip b)
Set the audio clip to play when the button is pushed. |
void |
setBgImage(java.awt.Image i)
Set the current background image to be shown. |
private void |
setButtonComponents(java.applet.AudioClip sound,
java.awt.Color foreground,
java.awt.Color background,
java.awt.Image bg,
java.awt.Image icon)
Set and repaint button components |
void |
setConnectorID(int id)
Set connectorID (unique numeric identifier for current component) |
void |
setDirection(int a)
Set the connector direction (left-to-right or right-to-left). |
void |
setEnable(boolean a)
Enables or disables this component, depending on the value of the parameter b. |
void |
setImage(java.awt.Image i)
Set the current image icon to be shown. |
void |
setImageScale(double f)
Scale the image to the given value (1.0 = 100%). |
void |
setImageScale(float pct)
Scale the image to the given value (1.0 = 100%). |
void |
setNodeStatus(boolean status)
Set the current node status (open/closed) |
void |
setStateBgImages(java.awt.Image imgoff,
java.awt.Image imgon,
java.awt.Image imgover)
Set the background state images (one image for each button/mouse state). |
void |
setStateColors(java.awt.Color ba,
java.awt.Color bb,
java.awt.Color bc,
java.awt.Color la,
java.awt.Color lb,
java.awt.Color lc)
Set the button colors for each state (mouse off/on/over) |
void |
setStateImages(java.awt.Image imgoff,
java.awt.Image imgon,
java.awt.Image imgover)
Set the state images (one image for each node/folder state) |
Methods inherited from class java.awt.Panel |
---|
getAccessibleContext |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
private java.awt.Graphics bufferGraphics
private java.awt.Image offscreen
protected java.lang.String actionCommand
protected java.awt.event.ActionListener actionListener
private int connectorID
public static final int LEFT
public static final int TOP
public static final int RIGHT
public static final int BOTTOM
public static final int CENTER
private java.awt.Image img
private java.awt.Image img_off
private java.awt.Image img_on
private java.awt.Image img_over
private java.awt.Image img_bg
private java.awt.Image img_bg_off
private java.awt.Image img_bg_on
private java.awt.Image img_bg_over
private float imageScale
private java.applet.AudioClip audio_click
private java.applet.AudioClip audio_over
private int direction
private int ix
private int iy
private int iw
private int ih
private int bw
private int bh
private java.awt.Color col_off_bck
private java.awt.Color col_over_bck
private java.awt.Color col_on_bck
private java.awt.Color col_off_line
private java.awt.Color col_over_line
private java.awt.Color col_on_line
private int line_width
private int connector_min_width
private int connector_width
private int connector_height
private boolean[] vertical_connector
private int item_level
private boolean first_node
private boolean last_node
private boolean connector_opened
private int first_line_x
private int h_line_y
private int h_line_lenght
private int v_line_lenght
private int current_action
Constructor Detail |
---|
public ConnectorButton(int w, int h, int lw, int l, boolean isnode, boolean f, boolean n, boolean[] dvc)
w
- connector minimum widthh
- connector height (same as button height)lw
- connector line width in pixels (0 = no line)l
- item level (indentation level)isnode
- true if it's a nodef
- true if is the first elementn
- true if element is a last nodedvc
- array of vertical connectors to displayMethod Detail |
---|
public void addNotify()
addNotify
in class java.awt.Panel
public void setStateColors(java.awt.Color ba, java.awt.Color bb, java.awt.Color bc, java.awt.Color la, java.awt.Color lb, java.awt.Color lc)
ba
- background button color when mouse is offbb
- background button color when mouse is overbc
- background button color when button is clickedla
- foreground line color when mouse is offlb
- foreground line color when mouse is overlc
- foreground line color when button is clickedpublic void setConnectorID(int id)
id
- button IDpublic int getConnectorID()
public boolean getNodeStatus()
public void setNodeStatus(boolean status)
status
- New status (true = closed; false = opened).public void setDirection(int a)
a
- TOP, LEFT, RIGHT or BOTTOMpublic void setAudioStateClips(java.applet.AudioClip a, java.applet.AudioClip b)
a
- audio clip when button is clickedb
- audio clip when mouse is overpublic void setStateImages(java.awt.Image imgoff, java.awt.Image imgon, java.awt.Image imgover)
imgoff
- button icon image when mouse is offimgon
- button icon image when button is pressedimgover
- button icon image when mouse is offpublic void setStateBgImages(java.awt.Image imgoff, java.awt.Image imgon, java.awt.Image imgover)
imgoff
- button background image when mouse is offimgon
- button background image when button is pressedimgover
- button background image when mouse is offpublic void setImage(java.awt.Image i)
i
- Button Imagepublic void setBgImage(java.awt.Image i)
i
- Button Background Imagepublic void setImageScale(double f)
f
- floatpublic void setImageScale(float pct)
pct
- floatpublic void setEnable(boolean a)
a
- If true, this component is enabled; otherwise this component is disabledpublic void resize()
public void paint(java.awt.Graphics g)
paint
in class java.awt.Container
g
- the graphic area when diplay button elementspublic void setActionCommand(java.lang.String command)
command
- The name of the action event command fired by this buttonpublic java.lang.String getActionCommand()
public void addActionListener(java.awt.event.ActionListener l)
l
- the action listenerpublic void removeActionListener(java.awt.event.ActionListener l)
l
- the action listenerprotected void fireActionEvent(int actiontype)
actiontype
- ActionEvent.ACTION_PERFORMEDprotected void connectorButton_Opened(boolean sound_on)
sound_on
- boolean to turn off soundprotected void connectorButton_MouseOver(boolean sound_on)
sound_on
- boolean to turn off soundprotected void connectorButton_Closed(boolean sound_on)
sound_on
- boolean to turn off soundprivate void setButtonComponents(java.applet.AudioClip sound, java.awt.Color foreground, java.awt.Color background, java.awt.Image bg, java.awt.Image icon)
sound
- audioclip to playforeground
- foreground colorbackground
- background colorbg
- background imageicon
- image icon
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |