Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Draw2d
3.3

org.eclipse.draw2d
Class Clickable

java.lang.Object
  extended by

org.eclipse.draw2d.Figure
      extended by
org.eclipse.draw2d.Clickable
All Implemented Interfaces:
IFigure
Direct Known Subclasses:
Button, Toggle

public class Clickable
extends Figure

A Clickable responds to mouse clicks in some way (determined by a ClickBehavior) and fires action events. No visual appearance of feedback is offered. Depends on a model holder and an event handler which understands the model and updates the model accordingly. ButtonModel is used by default. Any figure can be set as contents to a Clickable. Clickable->EventHandler->Model->ModelObserver->Listeners of actions.


Nested Class Summary
 
Nested classes inherited from class org.eclipse.draw2d. Figure
Figure.FigureIterator, Figure.IdentitySearch
 
Nested classes inherited from class org.eclipse.draw2d. IFigure
IFigure.NoInsets
 
Field Summary
static int DEFAULT_FIRING
          An action is performed every time the mouse is released.
protected static int MAX_FLAG
          The highest reserved flag used by this class
static int REPEAT_FIRING
          Firing starts as soon as the mouse is pressed on this Clickable, and keeps firing at prefixed intervals until the mouse is released.
static int STYLE_BUTTON
          Style constant that defines a push button.
static int STYLE_TOGGLE
          Style constant that defines a toggle button.
 
Fields inherited from class org.eclipse.draw2d. Figure
bgColor, border, bounds, fgColor, flags, font, maxSize, minSize, NO_MANAGER, prefSize, toolTip
 
Fields inherited from interface org.eclipse.draw2d. IFigure
MAX_DIMENSION, MIN_DIMENSION, NO_INSETS
 
Constructor Summary
Clickable ()
          Constructs a Clickable with no contents.
Clickable ( IFigure contents)
          Constructs a Clickable whose contents are provided as input.
Clickable ( IFigure contents, int style)
          Constructs a Clickable whose contents are provided as input.
 
Method Summary
 void addActionListener ( ActionListener listener)
          Adds the given listener to the list of action listeners of this Figure.
 void addChangeListener ( ChangeListener listener)
          Adds the given listener to the list of state change listeners of this figure.
protected   ButtonModel createDefaultModel ()
          Returns a newly created ButtonModel as the default model to be used by this Clickable based on the button style.
protected  org.eclipse.draw2d.ClickableEventHandler createEventHandler ()
          Returns a newly created event handler for this Clickable and its model.
protected  org.eclipse.draw2d.Clickable.ModelObserver createModelObserver ()
          Returns a newly created model observer which listens to the model, and fires any action or state changes.
 void doClick ()
          Fires an action performed event.
protected  void fireActionPerformed ()
          Called when there has been an action performed by this Clickable, which is determined by the model.
protected  void fireStateChanged ( ChangeEvent modelChange)
          Called when there has been a change of state in the model of this clickable.
  ButtonModel getModel ()
          Returns the behavior model used by this Clickable.
protected  void hookEventHandler (org.eclipse.draw2d.ClickableEventHandler handler)
          Adds the given ClickableEventHandler to this clickable.
protected  void init ()
          Initializes this Clickable by setting a default model and adding a clickable event handler for that model.
 boolean isRolloverEnabled ()
          Returns true if rollover feedback is enabled.
 boolean isSelected ()
          Returns true if this Clickable is in a selected state.
 boolean isStyle (int style)
          Returns true if this Clickable's style is the same as the passed style.
protected  void paintBorder ( Graphics graphics)
          If this Clickable has focus, this method paints a focus rectangle.
protected  void paintClientArea ( Graphics graphics)
          Paints the area of this figure excluded by the borders.
 void removeActionListener ( ActionListener listener)
          Removes the given listener from the list of ActionListener's of this Clickable.
 void removeChangeListener ( ChangeListener listener)
          Removes the given listener from the list of ChangeListener's of this clickable.
protected  void setContents ( IFigure contents)
          Sets the Figure which is the contents of this Clickable.
 void setEnabled (boolean value)
          Sets this IFigure to be enabled.
 void setEventHandler (org.eclipse.draw2d.ClickableEventHandler h)
          Sets the event handler which interacts with the model to determine the behavior of this Clickable.
 void setFiringMethod (int type)
          Determines how this clickable is to fire notifications to its listeners.
 void setModel ( ButtonModel model)
          Sets the model to be used by this clickable for its state and behavior determination.
 void setRolloverEnabled (boolean value)
          Enables or disables rollover feedback of this figure.
 void setSelected (boolean value)
          Sets the selected state of this Clickable.
 void setStyle (int style)
          Sets this Clickable's style to the passed value, either STYLE_BUTTON or STYLE_TOGGLE.
protected  void unhookEventHandler (org.eclipse.draw2d.ClickableEventHandler handler)
          Removes the given ClickableEventHandler containing listeners from this Clickable.
 
Methods inherited from class org.eclipse.draw2d. Figure
add, add, add, add, addAncestorListener, addCoordinateListener, addFigureListener, addFocusListener, addKeyListener, addLayoutListener, addListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, containsPoint, containsPoint, erase, findDescendantAtExcluding, findFigureAt, findFigureAt, findFigureAt, findFigureAtExcluding, findMouseEventTargetAt, findMouseEventTargetInDescendantsAt, fireCoordinateSystemChanged, fireFigureMoved, fireMoved, firePropertyChange, firePropertyChange, firePropertyChange, getBackgroundColor, getBorder, getBounds, getChildren, getClientArea, getClientArea, getCursor, getFlag, getFont, getForegroundColor, getInsets, getLayoutManager, getListeners, getLocalBackgroundColor, getLocalFont, getLocalForegroundColor, getLocation, getMaximumSize, getMinimumSize, getMinimumSize, getParent, getPreferredSize, getPreferredSize, getSize, getToolTip, getUpdateManager, handleFocusGained, handleFocusLost, handleKeyPressed, handleKeyReleased, handleMouseDoubleClicked, handleMouseDragged, handleMouseEntered, handleMouseExited, handleMouseHover, handleMouseMoved, handleMousePressed, handleMouseReleased, hasFocus, internalGetEventDispatcher, intersects, invalidate, invalidateTree, isCoordinateSystem, isEnabled, isFocusTraversable, isMirrored, isMouseEventTarget, isOpaque, isRequestFocusEnabled, isShowing, isValid, isValidationRoot, isVisible, layout, paint, paintChildren, paintFigure, primTranslate, remove, removeAll, removeAncestorListener, removeCoordinateListener, removeFigureListener, removeFocusListener, removeKeyListener, removeLayoutListener, removeListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, revalidate, setBackgroundColor, setBorder, setBounds, setChildrenDirection, setChildrenEnabled, setChildrenOrientation, setConstraint, setCursor, setFlag, setFocusTraversable, setFont, setForegroundColor, setLayoutManager, setLocation, setMaximumSize, setMinimumSize, setOpaque, setParent, setPreferredSize, setPreferredSize, setRequestFocusEnabled, setSize, setSize, setToolTip, setValid, setVisible, translate, translateFromParent, translateToAbsolute, translateToParent, translateToRelative, useLocalCoordinates, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_FLAG

protected static int MAX_FLAG
The highest reserved flag used by this class


STYLE_BUTTON

public static final int STYLE_BUTTON
Style constant that defines a push button. The button will be pressed when the mouse is pressed on top of it. The button will be released when the mouse is released or is move off of the button.


STYLE_TOGGLE

public static final int STYLE_TOGGLE
Style constant that defines a toggle button. The button will toggle between 2 states when the mouse is clicked on the button.


DEFAULT_FIRING

public static final int DEFAULT_FIRING
An action is performed every time the mouse is released.

See Also:
Constant Field Values

REPEAT_FIRING

public static final int REPEAT_FIRING
Firing starts as soon as the mouse is pressed on this Clickable, and keeps firing at prefixed intervals until the mouse is released.

See Also:
Constant Field Values
Constructor Detail

Clickable

public Clickable()
Constructs a Clickable with no contents.


Clickable

public Clickable(
IFigure contents)
Constructs a Clickable whose contents are provided as input. The content figure occupies the entire region of the Clickable.

Parameters:
contents - The content figure

Clickable

public Clickable(
IFigure contents,
                 int style)
Constructs a Clickable whose contents are provided as input. The content figure occupies the entire region of the Clickable. Sets the style to the given style (either STYLE_BUTTON or STYLE_TOGGLE).

Parameters:
contents - The content figure
style - The button style
Method Detail

addActionListener

public void addActionListener(
ActionListener listener)
Adds the given listener to the list of action listeners of this Figure. Listener is called whenever an action is performed.

Parameters:
listener - The ActionListener to be added
Since:
2.0

addChangeListener

public void addChangeListener(
ChangeListener listener)
Adds the given listener to the list of state change listeners of this figure. A ChangeListener is informed if there is any state change in the model requiring action by the listener.

Parameters:
listener - The ChangeListener to be added
Since:
2.0

createDefaultModel

protected 
ButtonModel createDefaultModel()
Returns a newly created ButtonModel as the default model to be used by this Clickable based on the button style.

Returns:
The model to be used by default
Since:
2.0

createEventHandler

protected org.eclipse.draw2d.ClickableEventHandler createEventHandler()
Returns a newly created event handler for this Clickable and its model.

Returns:
The event handler
Since:
2.0

createModelObserver

protected org.eclipse.draw2d.Clickable.ModelObserver createModelObserver()
Returns a newly created model observer which listens to the model, and fires any action or state changes. A ModelObserver holds both an action listener and a state change listener.

Returns:
The newly created model observer
Since:
2.0

doClick

public void doClick()
Fires an action performed event.

Since:
2.0

fireActionPerformed

protected void fireActionPerformed()
Called when there has been an action performed by this Clickable, which is determined by the model. Notifies all ActionListener type listeners of an action performed.

Since:
2.0

fireStateChanged

protected void fireStateChanged(
ChangeEvent modelChange)
Called when there has been a change of state in the model of this clickable. Notifies all ChangeListener type listeners of the state change.

Parameters:
modelChange - The ChangeEvent
Since:
2.0

getModel

public 
ButtonModel getModel()
Returns the behavior model used by this Clickable.

Returns:
The model used by this Clickable
Since:
2.0

hookEventHandler

protected void hookEventHandler(org.eclipse.draw2d.ClickableEventHandler handler)
Adds the given ClickableEventHandler to this clickable. A ClickableEventHandler should be a MouseListener, MouseMotionListener, ChangeListener, KeyListener, and FocusListener.

Parameters:
handler - The new event handler
Since:
2.0

init

protected void init()
Initializes this Clickable by setting a default model and adding a clickable event handler for that model.

Since:
2.0

isRolloverEnabled

public boolean isRolloverEnabled()
Returns true if rollover feedback is enabled.

Returns:
true rollover feedback is enabled
Since:
2.0

isSelected

public boolean isSelected()
Returns true if this Clickable is in a selected state. The model is the one which holds all this state based information.

Returns:
true if this Clickable is in a selected state
Since:
2.0

isStyle

public boolean isStyle(int style)
Returns true if this Clickable's style is the same as the passed style.

Parameters:
style - The style to be checked
Returns:
true if this Clickable's style is the same as the passed style
Since:
2.0

paintBorder

protected void paintBorder(
Graphics graphics)
If this Clickable has focus, this method paints a focus rectangle.

Overrides:
paintBorder in class Figure
Parameters:
graphics - Graphics handle for painting
See Also:
Border.paint(IFigure, Graphics, Insets)

paintClientArea

protected void paintClientArea(
Graphics graphics)
Paints the area of this figure excluded by the borders. Induces a (1,1) pixel shift in the painting if the mouse is armed, giving it the pressed appearance.

Overrides:
paintClientArea in class Figure
Parameters:
graphics - Graphics handle for painting
Since:
2.0

removeActionListener

public void removeActionListener(
ActionListener listener)
Removes the given listener from the list of ActionListener's of this Clickable.

Parameters:
listener - Listener to be removed from this figure
Since:
2.0

removeChangeListener

public void removeChangeListener(
ChangeListener listener)
Removes the given listener from the list of ChangeListener's of this clickable.

Parameters:
listener - Listener to be removed from this figure
Since:
2.0

setContents

protected void setContents(
IFigure contents)
Sets the Figure which is the contents of this Clickable. This Figure occupies the entire clickable region.

Parameters:
contents - Contents of the clickable
Since:
2.0

setEnabled

public void setEnabled(boolean value)
Description copied from interface: IFigure
Sets this IFigure to be enabled.

Specified by:
setEnabled in interface IFigure
Overrides:
setEnabled in class Figure
See Also:
IFigure.setEnabled(boolean)

setEventHandler

public void setEventHandler(org.eclipse.draw2d.ClickableEventHandler h)
Sets the event handler which interacts with the model to determine the behavior of this Clickable.

Parameters:
h - Event handler for this clickable
Since:
2.0

setFiringMethod

public void setFiringMethod(int type)
Determines how this clickable is to fire notifications to its listeners. In the default firing method ( DEFAULT_FIRING), an action is performed every time the mouse is released. In the repeat firing method ( REPEAT_FIRING), firing starts as soon as it is pressed on this clickable, and keeps firing at prefixed intervals until the mouse is released.

Parameters:
type - Type of firing
Since:
2.0

setModel

public void setModel(
ButtonModel model)
Sets the model to be used by this clickable for its state and behavior determination. This clickable removes any observers from the previous model before adding new ones to the new model.

Parameters:
model - The new model of this Clickable
Since:
2.0

setRolloverEnabled

public void setRolloverEnabled(boolean value)
Enables or disables rollover feedback of this figure. Generally used in conjunction with the model to determine if feedback is to be shown.

Parameters:
value - The rollover state to be set
Since:
2.0

setSelected

public void setSelected(boolean value)
Sets the selected state of this Clickable. Since the model is responsible for all state based information, it is informed of the state change. Extending classes can choose selection information, if they do not represent any selection.

Parameters:
value - New selected state of this clickable.
Since:
2.0
See Also:
isSelected()

setStyle

public void setStyle(int style)
Sets this Clickable's style to the passed value, either STYLE_BUTTON or STYLE_TOGGLE.

Parameters:
style - The button style
Since:
2.0

unhookEventHandler

protected void unhookEventHandler(org.eclipse.draw2d.ClickableEventHandler handler)
Removes the given ClickableEventHandler containing listeners from this Clickable.

Parameters:
handler - The event handler to be removed
Since:
2.0

Eclipse Draw2d
3.3

Copyright (c) IBM Corp. and others 2000, 2007. All Rights Reserved.

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire