Class AbstractStylePanel<S extends Style>
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- ca.cgjennings.apps.arkham.deck.item.AbstractStylePanel<S>
-
- Type Parameters:
S
- the style that this panel edits
- All Implemented Interfaces:
StylePanel<S>
,java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
- Direct Known Subclasses:
BleedMarginStylePanel
public abstract class AbstractStylePanel<S extends Style> extends javax.swing.JPanel implements StylePanel<S>
An abstract base class for implementing aStylePanel
as aJPanel
.- Since:
- 3.0
- Author:
- Chris Jennings
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
-
Nested classes/interfaces inherited from interface ca.cgjennings.apps.arkham.deck.item.StylePanel
StylePanel.StyleEditorCallback
-
-
Field Summary
-
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
-
-
Constructor Summary
Constructors Constructor Description AbstractStylePanel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.Component
getPanelComponent()
Returns the component (typically aJPanel
) that contains the controls used to edit the style.int
getPanelGroup()
Returns the group that his panel belongs to.void
populateCaptureFromPanel(StyleCapture capture)
Copies the current state of the panel controls into a capture.void
populatePanelFromCapture(StyleCapture capture)
Copies the current state of a capture into the controls on this panel.void
setCallback(StylePanel.StyleEditorCallback callback)
The style editor that has created this panel will call this method with a callback instance.protected void
styleChanged()
Notifies the callback, if any, that the style has changed.-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
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, getBaseline, getBaselineResizeBehavior, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
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, setLayout, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ca.cgjennings.apps.arkham.deck.item.StylePanel
getTitle
-
-
-
-
Method Detail
-
getPanelComponent
public java.awt.Component getPanelComponent()
Returns the component (typically aJPanel
) that contains the controls used to edit the style.This implementation returns
this
; the style editing controls should be children of thisJPanel
.- Specified by:
getPanelComponent
in interfaceStylePanel<S extends Style>
- Returns:
- this panel
-
setCallback
public void setCallback(StylePanel.StyleEditorCallback callback)
The style editor that has created this panel will call this method with a callback instance. The instance should be used to notify the editor that the style information in the panel has changed by calling theStylePanel.StyleEditorCallback.styleChanged()
method. Style panels should gracefully handle the case where a callback is not set in case the panel is used for other purposes.This implementation will handle the editor callback for you; when the user edits the style information you need only call
styleChanged()
.- Specified by:
setCallback
in interfaceStylePanel<S extends Style>
- Parameters:
callback
-
-
styleChanged
protected void styleChanged()
Notifies the callback, if any, that the style has changed. Subclasses must call this method when the user edits the style information in the panel.
-
populateCaptureFromPanel
public void populateCaptureFromPanel(StyleCapture capture)
Copies the current state of the panel controls into a capture.This implementation assumes that the panel implements the
Style
subclass that it edits. (So, if this extendsAbstractStylePanel<MyStyle>
then it also implementsMyStyle
.) It populates the specified capture by simply capturing this panel instance (so the panel's getter methods for the style will be called to obtain the panel state). If this panel does not implement the style interface, an exception will be thrown at runtime.- Specified by:
populateCaptureFromPanel
in interfaceStylePanel<S extends Style>
- Parameters:
capture
- the capture to fill in with the panel state
-
populatePanelFromCapture
public void populatePanelFromCapture(StyleCapture capture)
Copies the current state of a capture into the controls on this panel.This implementation assumes that the panel implements the
Style
subclass that it edits. (So, if this extendsAbstractStylePanel<MyStyle>
then it also implementsMyStyle
.) It populates the panel by simply applying the capture to the panel (so the panel's setter methods for the style will be invoked accordingly). If this panel does not implement the style interface, an exception will be thrown at runtime.- Specified by:
populatePanelFromCapture
in interfaceStylePanel<S extends Style>
- Parameters:
capture
- the capture to load this panel's state from
-
getPanelGroup
public int getPanelGroup()
Description copied from interface:StylePanel
Returns the group that his panel belongs to. The group number determines the order that the style panels are presented in.- Specified by:
getPanelGroup
in interfaceStylePanel<S extends Style>
- Returns:
- the group number for this panel
-
-