Class CardLayoutEditor
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JInternalFrame
-
- ca.cgjennings.apps.arkham.AbstractStrangeEonsEditor
-
- ca.cgjennings.apps.arkham.AbstractSupportEditor
-
- ca.cgjennings.apps.arkham.editors.CardLayoutEditor
-
- All Implemented Interfaces:
Commandable,Rename.RenameListener,RegionPicker.RegionChangeListener,StrangeEonsEditor,java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,java.util.EventListener,javax.accessibility.Accessible,javax.swing.RootPaneContainer,javax.swing.WindowConstants
public class CardLayoutEditor extends AbstractSupportEditor implements RegionPicker.RegionChangeListener, Rename.RenameListener
A support editor for the construction of cards as an ordered list of layers. The layer arrangement can be exported to code suitable for use with a DIY component. The editor creates lightweight save files that can be included with a plug-in without significantly affecting size.- Author:
- Chris Jennings
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCardLayoutEditor.ExportTypeclassCardLayoutEditor.LayerclassCardLayoutEditor.LayerListPropertiesstatic classCardLayoutEditor.LayerType-
Nested classes/interfaces inherited from class javax.swing.JInternalFrame
javax.swing.JInternalFrame.AccessibleJInternalFrame, javax.swing.JInternalFrame.JDesktopIcon
-
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.StrangeEonsEditor
StrangeEonsEditor.EditorListener, StrangeEonsEditor.FieldPopulationListener, StrangeEonsEditor.HeartbeatListener
-
-
Field Summary
-
Fields inherited from class ca.cgjennings.apps.arkham.AbstractStrangeEonsEditor
DEFAULT_EDITOR_ICON
-
Fields inherited from class javax.swing.JInternalFrame
closable, CONTENT_PANE_PROPERTY, desktopIcon, FRAME_ICON_PROPERTY, frameIcon, GLASS_PANE_PROPERTY, iconable, IS_CLOSED_PROPERTY, IS_ICON_PROPERTY, IS_MAXIMUM_PROPERTY, IS_SELECTED_PROPERTY, isClosed, isIcon, isMaximum, isSelected, LAYERED_PANE_PROPERTY, maximizable, MENU_BAR_PROPERTY, resizable, ROOT_PANE_PROPERTY, rootPane, rootPaneCheckingEnabled, title, TITLE_PROPERTY
-
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
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
-
Constructor Summary
Constructors Constructor Description CardLayoutEditor(java.io.File f)Creates a new card layout editor for the specified layout file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanPerformCommand(AbstractCommand command)Returnstrueif the commandable wishes to handle the given command.protected voidclearImpl()Subclasses should override this to clear the edited document if CLEAR is a supported command.java.lang.StringcreateExportText(CardLayoutEditor.ExportType type, boolean isFrontFace, boolean escapeText)voidexport()Exports the editor content as a different file format.protected voidexportImpl(int type, java.io.File f)Subclasses should override this to export the edited content if EXPORT is a supported command.voidexportPaintImpl(java.lang.StringBuilder b, boolean isFrontFace)voidfileRenamed(Project p, Member m, java.io.File oldFile, java.io.File newFile)Rename listener implementation.javax.swing.border.BordergetBorder()java.lang.StringgetFileNameExtension()Returns the standard file extension for the type of content displayed in this editor.java.lang.StringgetFileTypeDescription()Returns a description of the content displayed in this editor.javax.swing.IcongetFrameIcon()Returns the editor window icon.intgetTemplateLayer()Returns the index of the layer that will represent the card template.booleanisAttached()Returnstrueif this editor is currently attached to the document tab strip.protected voidload(java.io.File f)voidregionChanged(java.lang.Object source, java.awt.Rectangle r)protected voidsaveImpl(java.io.File f)Saves the editor content to the specified file.voidsetAttached(boolean attach)Sets whether this editor is attached to the document tab strip.voidsetFile(java.io.File f)Sets the preferred file to use when saving the edited component.voidsetFrameIcon(javax.swing.Icon icon)Sets the preferred icon to use for this editor window.-
Methods inherited from class ca.cgjennings.apps.arkham.AbstractSupportEditor
getExportDescriptions, getExportExtensions
-
Methods inherited from class ca.cgjennings.apps.arkham.AbstractStrangeEonsEditor
addEditorListener, addHeartbeatListener, clear, close, confirmLossOfUnsavedChanges, createTimer, createTimer, dispose, doDefaultCloseAction, fireHeartbeatEvent, getFile, getGameComponent, getTabStripPopupMenu, getTitle, getToolTipText, hasUnsavedChanges, isCommandApplicable, onHeartbeat, performCommand, print, printImpl, removeAllStrangeEonsListeners, removeEditorListener, removeHeartbeatListener, resumeTimedUpdates, save, saveAs, select, setTitle, setToolTipText, setUnsavedChanges, spinOff, spinOffImpl, stopTimedUpdates, toString
-
Methods inherited from class javax.swing.JInternalFrame
addImpl, addInternalFrameListener, createRootPane, fireInternalFrameEvent, getAccessibleContext, getContentPane, getDefaultCloseOperation, getDesktopIcon, getDesktopPane, getFocusCycleRootAncestor, getFocusOwner, getGlassPane, getInternalFrameListeners, getJMenuBar, getLastCursor, getLayer, getLayeredPane, getMenuBar, getMostRecentFocusOwner, getNormalBounds, getRootPane, getUI, getUIClassID, getWarningString, hide, isClosable, isClosed, isFocusCycleRoot, isIcon, isIconifiable, isMaximizable, isMaximum, isResizable, isRootPaneCheckingEnabled, isSelected, moveToBack, moveToFront, pack, paintComponent, paramString, remove, removeInternalFrameListener, reshape, restoreSubcomponentFocus, setClosable, setClosed, setContentPane, setCursor, setDefaultCloseOperation, setDesktopIcon, setFocusCycleRoot, setGlassPane, setIcon, setIconifiable, setJMenuBar, setLayer, setLayer, setLayeredPane, setLayout, setMaximizable, setMaximum, setMenuBar, setNormalBounds, setResizable, setRootPane, setRootPaneCheckingEnabled, setSelected, setUI, show, toBack, toFront, 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, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, 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, setTransferHandler, setUI, 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, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, 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, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, size, 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.StrangeEonsEditor
getFrameIcon, isAttached, setAttached, setFrameIcon
-
-
-
-
Constructor Detail
-
CardLayoutEditor
public CardLayoutEditor(java.io.File f) throws java.io.IOExceptionCreates a new card layout editor for the specified layout file. As they are part of a project, a card layout is always tied to a file (i.e., it never has anullfile value).- Parameters:
f- the file to edit- Throws:
java.io.IOException
-
-
Method Detail
-
setFile
public void setFile(java.io.File f)
Description copied from interface:StrangeEonsEditorSets the preferred file to use when saving the edited component.- Specified by:
setFilein interfaceStrangeEonsEditor- Overrides:
setFilein classAbstractStrangeEonsEditor- Parameters:
f- the file to use for Save operations- See Also:
StrangeEonsEditor.getFile()
-
fileRenamed
public void fileRenamed(Project p, Member m, java.io.File oldFile, java.io.File newFile)
Rename listener implementation. Checks for renaming of images files that are in use by a layer and updates the layer resource field automatically.- Specified by:
fileRenamedin interfaceRename.RenameListener- Parameters:
p- the project in which the command was issuedm- the new member associated with the file, if availableoldFile- the original file namenewFile- the new file name, ornullif the file was deleted
-
export
public void export()
Description copied from class:AbstractSupportEditorExports the editor content as a different file format. The base class implementation handles the details of determining the file to be written and exception handling. To use it, overrideAbstractSupportEditor.exportImpl(int, java.io.File)to write the document, andAbstractSupportEditor.getExportExtensions()andAbstractSupportEditor.getExportDescriptions()to describe the possible formats.- Specified by:
exportin interfaceStrangeEonsEditor- Overrides:
exportin classAbstractSupportEditor- See Also:
AbstractSupportEditor.canPerformCommand(ca.cgjennings.apps.arkham.commands.AbstractCommand)
-
exportImpl
protected void exportImpl(int type, java.io.File f) throws java.io.IOExceptionDescription copied from class:AbstractSupportEditorSubclasses should override this to export the edited content if EXPORT is a supported command. The value oftypeis the index of the element inAbstractSupportEditor.getExportExtensions()for the file type that was selected by the user. The value offileis the destination file to write content to.- Overrides:
exportImplin classAbstractSupportEditor- Parameters:
type- the index of the file format to exportf- the file to write content to- Throws:
java.io.IOException- if an error occurs while writing
-
createExportText
public java.lang.String createExportText(CardLayoutEditor.ExportType type, boolean isFrontFace, boolean escapeText)
-
exportPaintImpl
public void exportPaintImpl(java.lang.StringBuilder b, boolean isFrontFace)
-
saveImpl
protected void saveImpl(java.io.File f) throws java.io.IOExceptionDescription copied from class:AbstractStrangeEonsEditorSaves the editor content to the specified file. This method is called by {link #save} in response to save requests. Subclasses must override it to write an appropriate file for the document if the editor supports saving.- Overrides:
saveImplin classAbstractStrangeEonsEditor- Parameters:
f- the file to write content to- Throws:
java.io.IOException- if the save fails
-
load
protected void load(java.io.File f) throws java.io.IOException- Throws:
java.io.IOException
-
clearImpl
protected void clearImpl()
Description copied from class:AbstractStrangeEonsEditorSubclasses should override this to clear the edited document if CLEAR is a supported command.- Overrides:
clearImplin classAbstractStrangeEonsEditor
-
getFileNameExtension
public java.lang.String getFileNameExtension()
Description copied from interface:StrangeEonsEditorReturns the standard file extension for the type of content displayed in this editor.- Specified by:
getFileNameExtensionin interfaceStrangeEonsEditor- Returns:
- a file extension, such as
"txt" - See Also:
StrangeEonsEditor.getFileTypeDescription()
-
getFileTypeDescription
public java.lang.String getFileTypeDescription()
Description copied from interface:StrangeEonsEditorReturns a description of the content displayed in this editor. For English descriptions, this should be plural as it is used to describe the file type in save dialogs.- Specified by:
getFileTypeDescriptionin interfaceStrangeEonsEditor- Returns:
- a human-friendly description of the content associated with the editor, such as "Text Files"
- See Also:
StrangeEonsEditor.getFileNameExtension()
-
regionChanged
public void regionChanged(java.lang.Object source, java.awt.Rectangle r)- Specified by:
regionChangedin interfaceRegionPicker.RegionChangeListener
-
getTemplateLayer
public int getTemplateLayer()
Returns the index of the layer that will represent the card template. This is the index of the lowest visible layer with typeIMAGElocated at (0,0). If there is no suitable layer, returns -1.- Returns:
- the index of the template layer, or -1
-
canPerformCommand
public boolean canPerformCommand(AbstractCommand command)
Description copied from class:AbstractSupportEditorReturnstrueif the commandable wishes to handle the given command. This method defines the set of commands that the commandable responds to. The commandable might not be able to act on the command at the current moment. For example, a commandable that responds to "Cut" could return true from this method, but false fromAbstractStrangeEonsEditor.isCommandApplicable(ca.cgjennings.apps.arkham.commands.AbstractCommand)if there is currently no selection to cut.The base class for support editors returns true for the following standard commands: CLEAR, EXPORT, PRINT, SAVE, SAVE_AS.
- Specified by:
canPerformCommandin interfaceCommandable- Specified by:
canPerformCommandin interfaceStrangeEonsEditor- Overrides:
canPerformCommandin classAbstractSupportEditor- Parameters:
command- the command to be performed- Returns:
trueif this commandable wishes to handle the command (even if it cannot execute the command currently)- See Also:
Commands
-
getBorder
public final javax.swing.border.Border getBorder()
- Overrides:
getBorderin classjavax.swing.JComponent
-
setFrameIcon
public void setFrameIcon(javax.swing.Icon icon)
Sets the preferred icon to use for this editor window. This icon may be used to represent the window in various parts of the application interface. Possible example uses include the following: the document tab, the editor's item in the Window menu, and the frame icon of the editor's detached window. Note, however, that there is no guarantee that the icon will be used, or how. Furthermore, the icon may be used in modified form.- Overrides:
setFrameIconin classjavax.swing.JInternalFrame- Parameters:
icon- the preferred icon for the editor window- See Also:
JInternalFrame.getFrameIcon()
-
getFrameIcon
public javax.swing.Icon getFrameIcon()
Returns the editor window icon.- Overrides:
getFrameIconin classjavax.swing.JInternalFrame- Returns:
- the icon for the editor, or
nullif no icon is set
-
setAttached
public void setAttached(boolean attach)
Sets whether this editor is attached to the document tab strip. Iftrue, the editor is attached; this is the default state for new editors. Iffalse, the editor is detached from the tab strip. When detached, the editor appears in its own floating window separate from the main application window. The editor reattaches when the window is closed.- Parameters:
attach- iftrue, attaches the window to the tab strip
-
isAttached
public boolean isAttached()
Returnstrueif this editor is currently attached to the document tab strip.- Returns:
trueif the editor is attached- See Also:
setAttached(boolean)
-
-