Package org.jdesktop.swingx.rollover
Class RolloverProducer
- java.lang.Object
-
- org.jdesktop.swingx.rollover.RolloverProducer
-
- All Implemented Interfaces:
java.awt.event.MouseListener
,java.awt.event.MouseMotionListener
,java.util.EventListener
public class RolloverProducer extends java.lang.Object implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener
Mouse/Motion/Listener which maps mouse coordinates to client coordinates and stores these as client properties in the target JComponent. The exact mapping process is left to subclasses. Typically, they will map to "cell" coordinates.Note: this class assumes that the target component is of type JComponent.
Note: this implementation is stateful, it can't be shared across different instances of a target component.
PENDING JW: why isn't this abstract? Subclasses should be forced to implement the mapping?
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CLICKED_KEY
Key for client property mapped from mouse-triggered action.protected java.awt.Point
rollover
Current mouse location in client coordinates.static java.lang.String
ROLLOVER_KEY
Key for client property mapped from rollover events
-
Constructor Summary
Constructors Constructor Description RolloverProducer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
mouseClicked(java.awt.event.MouseEvent e)
Implemented to do nothing.void
mouseDragged(java.awt.event.MouseEvent e)
Implemented to do nothing.void
mouseEntered(java.awt.event.MouseEvent e)
Implemented to map to client property rollover and fire only if client coordinate changed.void
mouseExited(java.awt.event.MouseEvent e)
Implemented to remove client properties rollover and clicked.void
mouseMoved(java.awt.event.MouseEvent e)
Implemented to map to client property rollover and fire only if client coordinate changed.void
mousePressed(java.awt.event.MouseEvent e)
Implemented to do nothing.void
mouseReleased(java.awt.event.MouseEvent e)
Implemented to map to client property clicked and fire always.protected void
updateClientProperty(javax.swing.JComponent component, java.lang.String property, boolean fireAlways)
Sets the given client property to the value of current mouse location in client coordinates.protected void
updateRollover(java.awt.event.MouseEvent e, java.lang.String property, boolean fireAlways)
Controls the mapping of the given mouse event to a client property.protected void
updateRolloverPoint(javax.swing.JComponent component, java.awt.Point mousePoint)
Subclasses must override to map the given mouse coordinates into appropriate client coordinates.
-
-
-
Field Detail
-
CLICKED_KEY
public static final java.lang.String CLICKED_KEY
Key for client property mapped from mouse-triggered action. Note that the actual mouse-event which results in setting the property depends on the implementation of the concrete RolloverProducer.- See Also:
- Constant Field Values
-
ROLLOVER_KEY
public static final java.lang.String ROLLOVER_KEY
Key for client property mapped from rollover events- See Also:
- Constant Field Values
-
rollover
protected java.awt.Point rollover
Current mouse location in client coordinates.
-
-
Method Detail
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
Implemented to map to client property clicked and fire always.- Specified by:
mouseReleased
in interfacejava.awt.event.MouseListener
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent e)
Implemented to map to client property rollover and fire only if client coordinate changed.- Specified by:
mouseEntered
in interfacejava.awt.event.MouseListener
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)
Implemented to remove client properties rollover and clicked. if the source is a JComponent. Does nothing otherwise.- Specified by:
mouseExited
in interfacejava.awt.event.MouseListener
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent e)
Implemented to do nothing.- Specified by:
mouseClicked
in interfacejava.awt.event.MouseListener
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
Implemented to do nothing.- Specified by:
mousePressed
in interfacejava.awt.event.MouseListener
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
Implemented to do nothing. PENDING JW: probably should do something? Mapped coordinates will be out of synch after a drag.- Specified by:
mouseDragged
in interfacejava.awt.event.MouseMotionListener
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)
Implemented to map to client property rollover and fire only if client coordinate changed.- Specified by:
mouseMoved
in interfacejava.awt.event.MouseMotionListener
-
updateRollover
protected void updateRollover(java.awt.event.MouseEvent e, java.lang.String property, boolean fireAlways)
Controls the mapping of the given mouse event to a client property. This implementation first calls updateRolloverPoint to convert the mouse coordinates. Then calls updateClientProperty to actually set the client property in the- Parameters:
e
- the MouseEvent to map to client coordinatesproperty
- the client property to map tofireAlways
- a flag indicating whether a client event should be fired if unchanged.- See Also:
updateRolloverPoint(JComponent, Point)
,updateClientProperty(JComponent, String, boolean)
-
updateClientProperty
protected void updateClientProperty(javax.swing.JComponent component, java.lang.String property, boolean fireAlways)
Sets the given client property to the value of current mouse location in client coordinates. If fireAlways, the property is force to fire a change.- Parameters:
component
- the target componentproperty
- the client property to setfireAlways
- a flag indicating whether a client property should be forced to fire an event.
-
updateRolloverPoint
protected void updateRolloverPoint(javax.swing.JComponent component, java.awt.Point mousePoint)
Subclasses must override to map the given mouse coordinates into appropriate client coordinates. The result must be stored in the rollover field. Here: does nothing.- Parameters:
component
-mousePoint
-
-
-