com.jstatcom.table
Class JSCCellRendererTypes

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JLabel
                  extended by com.jstatcom.table.JSCCellRendererTypes
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.SwingConstants, javax.swing.table.TableCellRenderer

public class JSCCellRendererTypes
extends javax.swing.JLabel
implements javax.swing.table.TableCellRenderer

The class defines different JSCCellRenderers for the JSCAbstractDataTable, which can be used in different modeling contexts, for example to display coefficients matrizes or subset matrizes. It is possible to extend this enumeration to provide special renderers for different contexts.

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

Author:
A.Benkwitz, Markus Kraetzig
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
static JSCCellRendererTypes COEFF_DEFAULT
          Default TableCellRenderer for coefficients.
static JSCCellRendererTypes COEFF_SCIENTIFIC
          Scientific TableCellRenderer for coefficients.
static JSCCellRendererTypes DEFAULT
          Default TableCellRenderer.
static JSCCellRendererTypes DIAG_01M1NEGINF
          A TableCellRenderer for the A and B matrizes of an SVAR model.
static JSCCellRendererTypes DIAGONAL_01
          A TableCellRenderer for the special subset matrizes.
static JSCCellRendererTypes EQUATION_NAMES
          Equation String TableCellRenderer.
static JSCCellRendererTypes SCIENTIFIC
          TableCellRenderer with scientific notation, for example 1.23E-2.
static JSCCellRendererTypes SUBSET_01
          A TableCellRenderer for the subset matrizes.
static JSCCellRendererTypes SUBSET_01_GRAY
          A TableCellRenderer for the non editable subset matrizes with a gray background.
static JSCCellRendererTypes SUBSET_012
          A TableCellRenderer for subset matrizes.
static JSCCellRendererTypes SUBSET_01M1NEGINF
          A TableCellRenderer for the A and B matrizes of an SVAR model.
static JSCCellRendererTypes VARIABLE_NAMES
          String TableCellRenderer for variable names.
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Method Summary
 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.
 java.awt.Component getTableCellRendererComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, boolean hasFocus, int row, int col)
          Defines how the cell is painted.
 int hashCode()
          Override prevention method invokes super method.
 java.lang.String toString()
          Gets a string representing this type, do not use for comparisons.
 
Methods inherited from class javax.swing.JLabel
getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT

public static final JSCCellRendererTypes DEFAULT
Default TableCellRenderer. It displays doubles as they appear with a given precision set by the underlying table, using the default number format.


SCIENTIFIC

public static final JSCCellRendererTypes SCIENTIFIC
TableCellRenderer with scientific notation, for example 1.23E-2. It also takes the precision into account.


COEFF_DEFAULT

public static final JSCCellRendererTypes COEFF_DEFAULT
Default TableCellRenderer for coefficients. It displays doubles as they appear with a given precision set by the underlying table. If an element is restricted by the underlying restricion matrix, it is displayed as "---". This is also true for values that are exactly 0.


COEFF_SCIENTIFIC

public static final JSCCellRendererTypes COEFF_SCIENTIFIC
Scientific TableCellRenderer for coefficients. It displays doubles as they appear with a given precision set by the underlying table. If an element is restricted by the underlying restricion matrix, it is displayed as "---"


SUBSET_01

public static final JSCCellRendererTypes SUBSET_01
A TableCellRenderer for the subset matrizes. It displays "0" for 0, "*" for 1 and "---" for all other values. If a subset restriction is set in the coefficients table, the corresponding element is set to Double.NaN and displayed as "---".


SUBSET_01_GRAY

public static final JSCCellRendererTypes SUBSET_01_GRAY
A TableCellRenderer for the non editable subset matrizes with a gray background. It displays "0" for 0, "*" for 1 and "---" for all other values. If a subset restriction is set in the coefficients table, the corresponding element is set to Double.NaN and displayed as "---".


SUBSET_012

public static final JSCCellRendererTypes SUBSET_012
A TableCellRenderer for subset matrizes. It displays "0" for 0, "*" for 1 and "!" for 2. All other values are displayed as "---". If a subset restriction is set in the underlying coefficients table, the corresponding element is set to Double.NaN and displayed as "---".


DIAGONAL_01

public static final JSCCellRendererTypes DIAGONAL_01
A TableCellRenderer for the special subset matrizes. It displays "0" for 0, "*" for 1 and "---" for all other values. The diagonal elements are rendered with a gray background, because they are usually not editable. If a subset restriction is set in the coefficients table, the corresponding element is set to Double.NaN and displayed as "---". This renderer might be used for the matrix of structural coefficients.


EQUATION_NAMES

public static final JSCCellRendererTypes EQUATION_NAMES
Equation String TableCellRenderer. It is used as a left hand side equation description.


VARIABLE_NAMES

public static final JSCCellRendererTypes VARIABLE_NAMES
String TableCellRenderer for variable names. It displays an index if it is set for a VarNamesVector and isShowingIndex is true.


DIAG_01M1NEGINF

public static final JSCCellRendererTypes DIAG_01M1NEGINF
A TableCellRenderer for the A and B matrizes of an SVAR model. It displays "0" for 0, "*" for -INF, "1" for 1, "-1" for -1 and all other values "as is". The diagonal elements are rendered with a gray background, because they are usually not editable.


SUBSET_01M1NEGINF

public static final JSCCellRendererTypes SUBSET_01M1NEGINF
A TableCellRenderer for the A and B matrizes of an SVAR model. It displays "0" for 0, "*" for -INF, "1" for 1, "-1" for -1 and all other values "as is".

Method Detail

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.

Overrides:
getName in class java.awt.Component
Returns:
a descriptive name

getTableCellRendererComponent

public final java.awt.Component getTableCellRendererComponent(javax.swing.JTable table,
                                                              java.lang.Object value,
                                                              boolean isSelected,
                                                              boolean hasFocus,
                                                              int row,
                                                              int col)
Defines how the cell is painted. It is a template method here, because the set and get methods can be redefined by subclasses of JSCDataTableRendererTypes without changing the general structure of the algorithm. The ordering of calls is the following:
  1. setFirst (always)
  2. getDoubleValue (if data table contains number types)
  3. setDoubleValue (if data table contains number types)
  4. getStringValue (if data table contains String types)
  5. setStringValue (if data table contains String types)
  6. setValue (if data table contains other types)

Specified by:
getTableCellRendererComponent in interface javax.swing.table.TableCellRenderer
Parameters:
table - the table to render
value - the value to display
isSelected - true if cell is selected
hasFocus - true if cell has focus
row - index for row
col - index for column
Returns:
the assembled renderer component

hashCode

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

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

toString

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

Overrides:
toString in class java.awt.Component
Returns:
string representation