Class RolloverController<T extends javax.swing.JComponent>

  • All Implemented Interfaces:
    java.beans.PropertyChangeListener, java.util.EventListener
    Direct Known Subclasses:
    ListRolloverController, TableRolloverController, TreeRolloverController

    public abstract class RolloverController<T extends javax.swing.JComponent>
    extends java.lang.Object
    implements java.beans.PropertyChangeListener
    Controller for "live" behaviour of XXRenderers. Once installed on a component, it updates renderer's rollover state based on the component's rollover properties. Rollover client properties are Points with cell coordinates in the view coordinate system as appropriate for the concrete component (Point.x == column, Point.y == row). Repaints effected component regions. Updates link cursor. Installs a click-action bound to space-released in the target's actionMap/inputMap.
    Author:
    Jeanette Winzenburg, Berlin
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected T component  
      static java.lang.String EXECUTE_BUTTON_ACTIONCOMMAND
      the key of the rollover click action which is installed in the component's actionMap.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void click​(java.awt.Point location)
      called on change of client property Clicked_key.
      protected javax.swing.Action createExecuteButtonAction()
      creates and returns the click action to install in the component's actionMap.
      protected abstract java.awt.Point getFocusedCell()
      The coordinates of the focused cell in view coordinates.
      protected abstract RolloverRenderer getRolloverRenderer​(java.awt.Point location, boolean prepare)
      Returns the rolloverRenderer at the given location.
      protected boolean hasRollover​(java.awt.Point location)
      checks and returns if the cell at the given location has rollover effects.
      void install​(T table)
      Install this as controller for the given component.
      protected boolean isClickable​(java.awt.Point location)
      checks and returns if the cell at the given location is clickable.
      void propertyChange​(java.beans.PropertyChangeEvent evt)  
      protected void registerExecuteButtonAction()
      installs and registers the click action in the component's actionMap/inputMap.
      void release()
      Uninstall this as controller from the component, if any.
      protected abstract void rollover​(java.awt.Point oldLocation, java.awt.Point newLocation)
      called on change of client property Rollover_Key.
      protected void unregisterExecuteButtonAction()
      uninstalls and deregisters the click action from the component's actionMap/inputMap.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EXECUTE_BUTTON_ACTIONCOMMAND

        public static final java.lang.String EXECUTE_BUTTON_ACTIONCOMMAND
        the key of the rollover click action which is installed in the component's actionMap.
        See Also:
        Constant Field Values
      • component

        protected T extends javax.swing.JComponent component
    • Constructor Detail

      • RolloverController

        public RolloverController()
    • Method Detail

      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent evt)
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener
      • install

        public void install​(T table)
        Install this as controller for the given component.
        Parameters:
        table - the component which has renderers to control.
      • release

        public void release()
        Uninstall this as controller from the component, if any.
      • rollover

        protected abstract void rollover​(java.awt.Point oldLocation,
                                         java.awt.Point newLocation)
        called on change of client property Rollover_Key.
        Parameters:
        oldLocation - the old value of the rollover location.
        newLocation - the new value of the rollover location.
      • click

        protected void click​(java.awt.Point location)
        called on change of client property Clicked_key.
        Parameters:
        location - the new value of the clicked location.
      • getRolloverRenderer

        protected abstract RolloverRenderer getRolloverRenderer​(java.awt.Point location,
                                                                boolean prepare)
        Returns the rolloverRenderer at the given location.

        The result may be null if there is none or if rollover is not enabled. If the prepare flag is true, the renderer will be prepared with value and state as appropriate for the given location. Note: PRE - the location must be valid in cell coordinate space.

        Parameters:
        location - a valid location in cell coordinates, p.x == column, p.y == row.
        prepare -
        Returns:
        RolloverRenderer at the given location
      • isClickable

        protected boolean isClickable​(java.awt.Point location)
        checks and returns if the cell at the given location is clickable. Here: same as isRolloverCell.
        Parameters:
        location - in cell coordinates, p.x == column, p.y == row.
        Returns:
        true if the cell at the given location is clickable
      • hasRollover

        protected boolean hasRollover​(java.awt.Point location)
        checks and returns if the cell at the given location has rollover effects.

        Always returns false if the location is not valid.

        Parameters:
        location - in cell coordinates, p.x == column, p.y == row.
        Returns:
        true if the location is valid and has rollover effects, false otherwise.
      • getFocusedCell

        protected abstract java.awt.Point getFocusedCell()
        The coordinates of the focused cell in view coordinates. This method is called if the click action is invoked by a keyStroke. The returned cell coordinates should be related to what is typically interpreted as "focused" in the context of the component. p.x == focused column, p.y == focused row. A null return value or any coordinate value of < 0 is interpreted as "outside".
        Returns:
        the location of the focused cell.
      • unregisterExecuteButtonAction

        protected void unregisterExecuteButtonAction()
        uninstalls and deregisters the click action from the component's actionMap/inputMap.
      • registerExecuteButtonAction

        protected void registerExecuteButtonAction()
        installs and registers the click action in the component's actionMap/inputMap.
      • createExecuteButtonAction

        protected javax.swing.Action createExecuteButtonAction()
        creates and returns the click action to install in the component's actionMap.