com.jstatcom.table
Class JSCMouseListenerTypes

java.lang.Object
  extended by com.jstatcom.table.JSCMouseListenerTypes
All Implemented Interfaces:
java.awt.event.MouseListener, java.util.EventListener

public abstract class JSCMouseListenerTypes
extends java.lang.Object
implements java.awt.event.MouseListener

A MouseListener to be used with a JSCAbstractDataTable that reacts to mousePressed events and double clicks. Subclasses must override the abstract methods clicked and doubleClicked to define the desired actions. It contains an extendable enumeration of several listeners that are used in certain modeling contexts.

The mouseClicked and mousePressed methods are made final to make sure that JSCMouseListenerTypes have a certain predictable behaviour.

The class implements the typesave enum pattern (Joshua Bloch, "Effective Java", Item 21). If you compare JSCMouseListenerTypes, always use the == operator. This is save, because they are Singletons (Gamma et al., 1995).

Author:
Markus Kraetzig

Field Summary
static JSCMouseListenerTypes DIAG_01NEGINF
          A MouseListener that alternates an element between 0, 1 and -INF by repeatedly clicking on it.
static JSCMouseListenerTypes DIAG_0NEGINF
          A MouseListener that alternates an element between 0 and -INF by repeatedly clicking on it.
static JSCMouseListenerTypes DIAGONAL_01
          A MouseListener that alternates an element between 0 and 1 by repeatedly clicking on it.
static JSCMouseListenerTypes SUBSET_01
          A MouseListener that alternates an element between 0 and 1 by repeatedly clicking on it.
static JSCMouseListenerTypes SUBSET_012
          A MouseListener that alternates an element between 0, 1 and 2 by repeatedly clicking on it.
static JSCMouseListenerTypes SUBSET_01M1
          A MouseListener that alternates an element between 0, 1 and -1 by repeatedly clicking on it.
static JSCMouseListenerTypes SUBSET_0NEGINF
          A MouseListener that alternates an element between 0 and -INF by repeatedly clicking on it.
 
Method Summary
abstract  void clicked(JSCAbstractDataTable table, JSCData data, int row, int col)
          Invoked by mouseClicked if a single click on the underlying data table occured.
abstract  void doubleClicked(JSCAbstractDataTable table, JSCData data, int row, int col)
          Invoked by mouseClicked if a double click on the underlying data table occured.
 boolean equals(java.lang.Object o)
          Override prevention method to enforce a.equals(b) if and only if a==b.
 java.lang.String getName()
          Gets the name of this type.
 int hashCode()
          Override prevention method invokes super method.
 void mouseClicked(java.awt.event.MouseEvent e)
          Implementation of mouseClicked for double click events, that gets the underlying the table model and the corresponding location.
 void mouseEntered(java.awt.event.MouseEvent e)
          Empty default implementation.
 void mouseExited(java.awt.event.MouseEvent e)
          Empty default implementation.
 void mousePressed(java.awt.event.MouseEvent e)
          Implementation of mousePressed, that gets the underlying the table model and the corresponding location.
 void mouseReleased(java.awt.event.MouseEvent e)
          Empty default implementation.
 java.lang.String toString()
          Gets a string representing this type, do not use for comparisons.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SUBSET_01

public static final JSCMouseListenerTypes SUBSET_01
A MouseListener that alternates an element between 0 and 1 by repeatedly clicking on it. If a corresponding subset restriction is set, nothing is done on that element. It can be used for setting a priori subset restrictions.


SUBSET_012

public static final JSCMouseListenerTypes SUBSET_012
A MouseListener that alternates an element between 0, 1 and 2 by repeatedly clicking on it. If a corresponding subset restriction is set, nothing is done on that element. It can be used for setting a priori subset restrictions to be used by a search procedure.


SUBSET_01M1

public static final JSCMouseListenerTypes SUBSET_01M1
A MouseListener that alternates an element between 0, 1 and -1 by repeatedly clicking on it.


DIAGONAL_01

public static final JSCMouseListenerTypes DIAGONAL_01
A MouseListener that alternates an element between 0 and 1 by repeatedly clicking on it. In addition to that it does nothing on the diagonal elements. If a corresponding subset restriction is set, nothing is done on that element. It can be used for the matrix of structural coefficients.


DIAG_01NEGINF

public static final JSCMouseListenerTypes DIAG_01NEGINF
A MouseListener that alternates an element between 0, 1 and -INF by repeatedly clicking on it. It can be used for the A and B matrices of an SVAR model. Diagonal elements are not changed.


SUBSET_0NEGINF

public static final JSCMouseListenerTypes SUBSET_0NEGINF
A MouseListener that alternates an element between 0 and -INF by repeatedly clicking on it. It can be used for the C and PSI matrices of an SVEC model.


DIAG_0NEGINF

public static final JSCMouseListenerTypes DIAG_0NEGINF
A MouseListener that alternates an element between 0 and -INF by repeatedly clicking on it. It can be used for the C and PSI matrices of an SVEC model. Diagonal elements are not changed.

Method Detail

clicked

public abstract void clicked(JSCAbstractDataTable table,
                             JSCData data,
                             int row,
                             int col)
Invoked by mouseClicked if a single click on the underlying data table occured.

Parameters:
table - the data table, where the event originates
data - the data model of the table
row - index for row
col - index for column

doubleClicked

public abstract void doubleClicked(JSCAbstractDataTable table,
                                   JSCData data,
                                   int row,
                                   int col)
Invoked by mouseClicked if a double click on the underlying data table occured.

Parameters:
table - the data table, where the event originates
data - the data model of the table
row - index for row
col - index for column

equals

public final boolean equals(java.lang.Object o)
Override prevention method to enforce a.equals(b) if and only if a==b.

Overrides:
equals in class java.lang.Object
Parameters:
o - object to compare with
Returns:
true if equal, false otherwise

getName

public final java.lang.String getName()
Gets the name of this type.

Returns:
a descriptive name

hashCode

public final int hashCode()
Override prevention method invokes super method.

Overrides:
hashCode in class java.lang.Object
Returns:
hash code

mouseClicked

public final void mouseClicked(java.awt.event.MouseEvent e)
Implementation of mouseClicked for double click events, that gets the underlying the table model and the corresponding location. It then calls the abstract method doubleClicked that needs to be overwritten by subclasses of JSCMouseListenerTypes. The method does nothing for single click events, because mousePressed is more appropriate for this.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Throws:
java.lang.RuntimeException - if underlying model is not JSCData or table is not JSCAbstractDataTable

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Empty default implementation.

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Parameters:
e - a mouse event

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Empty default implementation.

Specified by:
mouseExited in interface java.awt.event.MouseListener
Parameters:
e - eea mouse event

mousePressed

public final void mousePressed(java.awt.event.MouseEvent e)
Implementation of mousePressed, that gets the underlying the table model and the corresponding location. It then calls the abstract method clicked that needs to be overwritten by subclasses of JSCMouseListenerTypes.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Throws:
java.lang.RuntimeException - if underlying model is not JSCData or table is not JSCAbstractDataTable

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Empty default implementation.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
e - a mouse event

toString

public final java.lang.String toString()
Gets a string representing this type, do not use for comparisons.

Overrides:
toString in class java.lang.Object
Returns:
string representation