net.sourceforge.sillyview
Class JPanelView

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.Box
                  extended by net.sourceforge.sillyview.JPanelView
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, WidgetView

public class JPanelView
extends javax.swing.Box
implements WidgetView

This is a central class in sillyview. It displays a given WidgetModel as a JLabel, a JEditorPane, or a HTMLPane. For implementation reasons it extends javax.swing.Box, instead of javax.swing.JPanel.

Version:
1.0
Author:
T.J. Willis
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.Box
javax.swing.Box.AccessibleBox, javax.swing.Box.Filler
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  Category cat
           
protected  java.lang.Object comp
          The component that the data is displayed in.
protected  javax.swing.JEditorPane ed
          If data displayed in a JEditorPane, this is that JEditorPane.
static int HTMLPANE
          If you want data displayed in a HTMLPane.
static java.lang.String HYPERLINK_LISTENER
          A token for setting the view's hyperlink listener.
static int JEDITORPANE
          If you want data displayed in a JEditorPane.
static int JLABEL
          If you want data displayed in a JLabel.
protected  javax.swing.JLabel lab
          If data displayed as a JLabel, this is that JLabel.
private static int MIN
           
protected  WidgetModel mod
          The model this view gets its data from.
private static int PREF
           
static java.lang.String TEXT
          A token for setting the view's text.
protected  java.lang.String title
          This panel's title.
 
Fields inherited from class javax.swing.Box
accessibleContext
 
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, 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 net.sourceforge.sillyview.WidgetView
FALSE, TITLE, TRUE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JPanelView(WidgetModel model, int componentType)
          Creates a new JPanelView instance backed by the given WidgetModel and of type JLABEL, JEDITORPANE, or HTMLPANE.
 
Method Summary
 void addTokens(java.util.Map<java.lang.Object,java.lang.Object> props)
          Adds all the name/value pairs and then updates the model.
 WidgetModel getModel()
          Returns the backing model.
 java.lang.String getText()
          Gets this view's text.
 java.lang.Object getValue(java.lang.Object key)
          Gets the named value.
private  void resizeComponent(int which, java.awt.Dimension size)
           
 void setAutoDump(boolean b)
          If the view component is a HTMLPane, will set its autodump property.
 void setMinimumSize(java.awt.Dimension size)
          Sets the minimum size of this panel as well as the view component.
 void setModel(WidgetModel newModel)
          Sets the backing model.
 void setPreferredSize(java.awt.Dimension size)
          Sets the preferred size of this panel as well as the view component.
protected  void setText(java.lang.String txt)
          Sets this views text.
protected  void setTitle(java.lang.String val)
          Sets the panel's title to the given text, providing a titled border.
 void setToken(java.lang.Object key, java.lang.Object value)
          Sets the named token to the given value and then recalculates my text.
 
Methods inherited from class javax.swing.Box
createGlue, createHorizontalBox, createHorizontalGlue, createHorizontalStrut, createRigidArea, createVerticalBox, createVerticalGlue, createVerticalStrut, getAccessibleContext, setLayout
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, 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, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, 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, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN

private static final int MIN
See Also:
Constant Field Values

PREF

private static final int PREF
See Also:
Constant Field Values

cat

private Category cat

title

protected java.lang.String title
This panel's title.


lab

protected javax.swing.JLabel lab
If data displayed as a JLabel, this is that JLabel.


ed

protected javax.swing.JEditorPane ed
If data displayed in a JEditorPane, this is that JEditorPane.


comp

protected java.lang.Object comp
The component that the data is displayed in.


mod

protected WidgetModel mod
The model this view gets its data from.


TEXT

public static final java.lang.String TEXT
A token for setting the view's text.

See Also:
Constant Field Values

HYPERLINK_LISTENER

public static final java.lang.String HYPERLINK_LISTENER
A token for setting the view's hyperlink listener.

See Also:
Constant Field Values

JLABEL

public static final int JLABEL
If you want data displayed in a JLabel.

See Also:
Constant Field Values

JEDITORPANE

public static final int JEDITORPANE
If you want data displayed in a JEditorPane.

See Also:
Constant Field Values

HTMLPANE

public static final int HTMLPANE
If you want data displayed in a HTMLPane.

See Also:
Constant Field Values
Constructor Detail

JPanelView

public JPanelView(WidgetModel model,
                  int componentType)
Creates a new JPanelView instance backed by the given WidgetModel and of type JLABEL, JEDITORPANE, or HTMLPANE.

Parameters:
model - a WidgetModel value
componentType - an int value
Method Detail

setText

protected void setText(java.lang.String txt)
Sets this views text.

Parameters:
txt - a String value

getText

public java.lang.String getText()
Gets this view's text.

Returns:
a String value

addTokens

public final void addTokens(java.util.Map<java.lang.Object,java.lang.Object> props)
Adds all the name/value pairs and then updates the model. If the named token already exists, replace the value. This is more efficient than many calls to setToken(), because model.getCurrentModel is only called once.

Specified by:
addTokens in interface WidgetView
Parameters:
props - a Map value

setToken

public final void setToken(java.lang.Object key,
                           java.lang.Object value)
Sets the named token to the given value and then recalculates my text. Most tokens, other than TITLE and HYPERLINK_LISTENER will be passed on to the model for handling.

Specified by:
setToken in interface WidgetView
Parameters:
key - an Object value
value - an Object value

getValue

public final java.lang.Object getValue(java.lang.Object key)
Gets the named value. Most values will come from the backing model.

Specified by:
getValue in interface WidgetView
Parameters:
key - an Object value
Returns:
an Object value

setTitle

protected final void setTitle(java.lang.String val)
Sets the panel's title to the given text, providing a titled border.

Parameters:
val - a String value

getModel

public final WidgetModel getModel()
Returns the backing model.

Specified by:
getModel in interface WidgetView
Returns:
a WidgetModel value

setModel

public final void setModel(WidgetModel newModel)
Sets the backing model.

Specified by:
setModel in interface WidgetView
Parameters:
newModel - a WidgetModel value

setPreferredSize

public void setPreferredSize(java.awt.Dimension size)
Sets the preferred size of this panel as well as the view component.

Overrides:
setPreferredSize in class javax.swing.JComponent
Parameters:
size - a java.awt.Dimension value

resizeComponent

private void resizeComponent(int which,
                             java.awt.Dimension size)

setMinimumSize

public void setMinimumSize(java.awt.Dimension size)
Sets the minimum size of this panel as well as the view component.

Overrides:
setMinimumSize in class javax.swing.JComponent
Parameters:
size - a java.awt.Dimension value

setAutoDump

public void setAutoDump(boolean b)
If the view component is a HTMLPane, will set its autodump property.

Parameters:
b - a boolean value