Class TextBox
- java.lang.Object
-
- ca.cgjennings.apps.arkham.deck.item.AbstractItem
-
- ca.cgjennings.apps.arkham.deck.item.AbstractFlippableItem
-
- ca.cgjennings.apps.arkham.deck.item.AbstractRenderedItem
-
- ca.cgjennings.apps.arkham.deck.item.TextBox
-
- All Implemented Interfaces:
EditablePageItem,FlippablePageItem,OutlineStyle,PageItem,ShapeStyle,SizablePageItem,Style,java.io.Serializable,java.lang.Cloneable
public class TextBox extends AbstractRenderedItem implements SizablePageItem, EditablePageItem, ShapeStyle, OutlineStyle
A text box is a rectangular page item that displays formatted markup text.- Since:
- 2.0
- Author:
- Chris Jennings
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface ca.cgjennings.apps.arkham.deck.item.PageItem
PageItem.SnapClass, PageItem.SnapTarget
-
-
Field Summary
-
Fields inherited from class ca.cgjennings.apps.arkham.deck.item.AbstractRenderedItem
render
-
Fields inherited from class ca.cgjennings.apps.arkham.deck.item.AbstractFlippableItem
orientation
-
Fields inherited from class ca.cgjennings.apps.arkham.deck.item.AbstractItem
dragHandles, group, parent, selectionLock, snapClass, snapTarget, snapToClasses, xOff, yOff
-
Fields inherited from interface ca.cgjennings.apps.arkham.deck.item.PageItem
ICON_SIZE, ORIENT_MIRROR_TURN_LEFT, ORIENT_MIRROR_TURN_RIGHT, ORIENT_MIRROR_UPRIGHT, ORIENT_MIRROR_UPSIDEDOWN, ORIENT_TURN_LEFT, ORIENT_TURN_RIGHT, ORIENT_UPRIGHT, ORIENT_UPSIDEDOWN
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeginEditing()static voidcancelActiveEditor()voidclearCachedImages()Clear any cached image data held by this object.PageItemclone()Returns a new page item, using this item as a template.protected MarkupRenderercreateMarkupRenderer(double resolution)voidcustomizePopupMenu(javax.swing.JPopupMenu menu, PageItem[] selection, boolean isSelectionFocus)Allows a page item the opportunity to customize the popup menu before it is displayed.DragHandle[]getDragHandles()Returns an array of the customDragHandles for this item.java.awt.ColorgetFillColor()Returns the fill colour used when painting the item.java.lang.StringgetName()Return the user-friendly short name of this item.LineCapgetOutlineCap()Returns the line cap style used on outline ends.java.awt.ColorgetOutlineColor()Returns the color used to draw the outline.DashPatterngetOutlineDashPattern()Returns the dash pattern used to draw the outline.LineJoingetOutlineJoin()Returns the method used to join the line segments that make up the outline.floatgetOutlineWidth()Returns the width, in points, of the outline.booleangetShrink()java.lang.StringgetText()javax.swing.IcongetThumbnailIcon()Returns a small representative icon for this item.protected doublegetUprightHeight()Return the height of this item in its standard, upright orientation.protected doublegetUprightWidth()Return the width of this item in its standard, upright orientation.booleanisTextJustified()voidpaint(java.awt.Graphics2D g, RenderTarget target, double renderResolutionHint)Paint this item at its current location.protected voidreadImpl(java.io.ObjectInputStream in)protected java.awt.image.BufferedImagerenderImage(RenderTarget target, double resolution)Render an image based on the target and resolution hints.voidsetFillColor(java.awt.Color color)Sets the fill colour used when painting the item.voidsetOutlineCap(LineCap cap)Sets the line cap style used on outline ends.voidsetOutlineColor(java.awt.Color borderColor)Sets the color used to draw the outline.voidsetOutlineDashPattern(DashPattern pat)Sets the dash pattern used to draw the outline.voidsetOutlineJoin(LineJoin join)Sets the method used to join the line segments that make up the outline.voidsetOutlineWidth(float borderWidth)Sets the width, in points, of the outline.voidsetShrink(boolean shrink)voidsetSize(double width, double height)Set the new size of this item, in points.voidsetText(java.lang.String text)voidsetTextJustified(boolean justifyText)voidsetX(double x)Set the x-location of this item.voidsetY(double y)Set the y-location of this item.protected voidwriteImpl(java.io.ObjectOutputStream out)-
Methods inherited from class ca.cgjennings.apps.arkham.deck.item.AbstractRenderedItem
clearCachedIcon, createOrientedImage, getHeight, getOrientedImage, getWidth, isMipMapCacheEnabled, isMipMapCacheEnabledByDefault, prepareToPaint, scaleMipMapUpAtHighZoom, setMipMapCacheEnabled
-
Methods inherited from class ca.cgjennings.apps.arkham.deck.item.AbstractFlippableItem
flip, getOrientation, setOrientation, turnLeft, turnRight
-
Methods inherited from class ca.cgjennings.apps.arkham.deck.item.AbstractItem
getBleedMargin, getClassesSnappedTo, getClientProperty, getFoldMarks, getGroup, getLocation, getOutline, getPage, getRectangle, getSnapClass, getSnapTarget, getX, getY, hasExteriorHandles, hitTest, isBleedMarginMarked, isHorizontal, isMirrored, isSelectionLocked, isTurned0DegreesFrom, isTurned180DegreesFrom, isTurned90DegreesFrom, isVertical, itemChanged, itemChanging, putClientProperty, setClassesSnappedTo, setGroup, setLocation, setLocation, setPage, setSelectionLocked, setSnapClass, setSnapTarget, toString
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ca.cgjennings.apps.arkham.deck.item.PageItem
getBleedMargin, getClassesSnappedTo, getClientProperty, getFoldMarks, getGroup, getHeight, getLocation, getOrientation, getOutline, getPage, getRectangle, getSnapClass, getSnapTarget, getWidth, getX, getY, hasExteriorHandles, hitTest, isBleedMarginMarked, isHorizontal, isMirrored, isSelectionLocked, isTurned0DegreesFrom, isTurned180DegreesFrom, isTurned90DegreesFrom, isVertical, prepareToPaint, putClientProperty, setClassesSnappedTo, setGroup, setLocation, setLocation, setPage, setSelectionLocked, setSnapClass, setSnapTarget
-
-
-
-
Constructor Detail
-
TextBox
public TextBox()
Creates a new, empty text box that can be placed in a deck. The initial size of the box is 72 pt by 72 pt.
-
TextBox
public TextBox(java.lang.String text, double widthInPts, double heightInPts)Creates a new text box with the specified text and initial size (measured in points).
-
-
Method Detail
-
getUprightWidth
protected double getUprightWidth()
Description copied from class:AbstractRenderedItemReturn the width of this item in its standard, upright orientation.- Specified by:
getUprightWidthin classAbstractRenderedItem- Returns:
- the width of the unoriented item
-
getUprightHeight
protected double getUprightHeight()
Description copied from class:AbstractRenderedItemReturn the height of this item in its standard, upright orientation.- Specified by:
getUprightHeightin classAbstractRenderedItem- Returns:
- the height of the unoriented item
-
getFillColor
public java.awt.Color getFillColor()
Description copied from interface:ShapeStyleReturns the fill colour used when painting the item.- Specified by:
getFillColorin interfaceShapeStyle- Returns:
- the background colour
-
setFillColor
public void setFillColor(java.awt.Color color)
Description copied from interface:ShapeStyleSets the fill colour used when painting the item.- Specified by:
setFillColorin interfaceShapeStyle- Parameters:
color- the fill colour to use
-
getText
public java.lang.String getText()
-
setText
public void setText(java.lang.String text)
-
getThumbnailIcon
public javax.swing.Icon getThumbnailIcon()
Description copied from interface:PageItemReturns a small representative icon for this item. The icon should beICON_SIZEpixels wide and high.- Specified by:
getThumbnailIconin interfacePageItem- Overrides:
getThumbnailIconin classAbstractRenderedItem
-
getDragHandles
public DragHandle[] getDragHandles()
Description copied from class:AbstractItemReturns an array of the customDragHandles for this item. If the item has no handles, returnsnull.Concrete subclasses should create an array of handles on demand and cache them in the
dragHandlesfield in order to ensure that handles are not shared between copies of the item. Example:public DragHandle[] getDragHandles() { if( dragHandles == null ) { dragHandles = new DragHandle[] { ... }; } return dragHandles; }- Specified by:
getDragHandlesin interfacePageItem- Overrides:
getDragHandlesin classAbstractItem- Returns:
- an array of drag handles that can be used to manipulate the item,
or
null
-
clone
public PageItem clone()
Description copied from interface:PageItemReturns a new page item, using this item as a template. The new item should generally be a deep copy, not sharing any objects with the original unless those objects are immutable. The deck editor absolutely relies on this method being implemented correctly! (For example, drag-and-drop and clipboard operations use clones to create copies of existing items.)- Specified by:
clonein interfacePageItem- Overrides:
clonein classAbstractRenderedItem- Returns:
- a new copy of this page item
-
paint
public void paint(java.awt.Graphics2D g, RenderTarget target, double renderResolutionHint)Description copied from interface:PageItemPaint this item at its current location. The graphics context will be scaled so that 1 unit represents 1 point. The resolution hint is a suggestion as to the resolution the item should be rendered at if it must be converted to a bitmap before being drawn. It may or may not represent the actual resolution of the output target.- Specified by:
paintin interfacePageItem- Overrides:
paintin classAbstractRenderedItem- Parameters:
g- the graphics context to paint totarget- the type of destination being drawn torenderResolutionHint- a source resolution hint
-
renderImage
protected java.awt.image.BufferedImage renderImage(RenderTarget target, double resolution)
Description copied from class:AbstractRenderedItemRender an image based on the target and resolution hints. This is called whenever the item's image is required. The image should always be rendered in the upright, unmirrored position. An oriented image will be generated automatically as needed.It is recommended that subclasses cache results if possible, in which case
AbstractRenderedItem.clearCachedImages()should be overridden to clear the cached result before calling thesuperimplementation.- Specified by:
renderImagein classAbstractRenderedItem- Parameters:
target- the target type for renderingresolution- the resolution that the item should be rendered at- Returns:
- an image representing the item's current state
-
clearCachedImages
public void clearCachedImages()
Description copied from class:AbstractRenderedItemClear any cached image data held by this object. The base class clears any cached oriented results and the MIP map cache (if enabled). Subclasses should override this (callingsuper.clearCachedImages) if theAbstractRenderedItem.renderImage(ca.cgjennings.apps.arkham.sheet.RenderTarget, double)implementation caches results.- Overrides:
clearCachedImagesin classAbstractRenderedItem
-
createMarkupRenderer
protected MarkupRenderer createMarkupRenderer(double resolution)
-
getName
public java.lang.String getName()
Description copied from interface:PageItemReturn the user-friendly short name of this item.
-
setSize
public void setSize(double width, double height)Description copied from interface:SizablePageItemSet the new size of this item, in points.- Specified by:
setSizein interfaceSizablePageItem- Parameters:
width- the new width of the itemheight- the new height of the item
-
getShrink
public boolean getShrink()
-
setShrink
public void setShrink(boolean shrink)
-
setX
public void setX(double x)
Description copied from interface:PageItemSet the x-location of this item.- Specified by:
setXin interfacePageItem- Overrides:
setXin classAbstractItem- Parameters:
x- the new x-location
-
setY
public void setY(double y)
Description copied from interface:PageItemSet the y-location of this item.- Specified by:
setYin interfacePageItem- Overrides:
setYin classAbstractItem- Parameters:
y- the new y-location
-
getOutlineColor
public java.awt.Color getOutlineColor()
Description copied from interface:OutlineStyleReturns the color used to draw the outline.- Specified by:
getOutlineColorin interfaceOutlineStyle- Returns:
- the outline color
-
setOutlineColor
public void setOutlineColor(java.awt.Color borderColor)
Description copied from interface:OutlineStyleSets the color used to draw the outline.- Specified by:
setOutlineColorin interfaceOutlineStyle- Parameters:
borderColor- the outline color
-
getOutlineWidth
public float getOutlineWidth()
Description copied from interface:OutlineStyleReturns the width, in points, of the outline.- Specified by:
getOutlineWidthin interfaceOutlineStyle- Returns:
- the outline line width
-
setOutlineWidth
public void setOutlineWidth(float borderWidth)
Description copied from interface:OutlineStyleSets the width, in points, of the outline.- Specified by:
setOutlineWidthin interfaceOutlineStyle- Parameters:
borderWidth- the outline width
-
getOutlineDashPattern
public DashPattern getOutlineDashPattern()
Description copied from interface:OutlineStyleReturns the dash pattern used to draw the outline.- Specified by:
getOutlineDashPatternin interfaceOutlineStyle- Returns:
- the dash pattern for the outline
-
setOutlineDashPattern
public void setOutlineDashPattern(DashPattern pat)
Description copied from interface:OutlineStyleSets the dash pattern used to draw the outline.- Specified by:
setOutlineDashPatternin interfaceOutlineStyle- Parameters:
pat- the dash pattern type
-
getOutlineJoin
public LineJoin getOutlineJoin()
Description copied from interface:OutlineStyleReturns the method used to join the line segments that make up the outline.- Specified by:
getOutlineJoinin interfaceOutlineStyle- Returns:
- the line joining method
-
setOutlineJoin
public void setOutlineJoin(LineJoin join)
Description copied from interface:OutlineStyleSets the method used to join the line segments that make up the outline.- Specified by:
setOutlineJoinin interfaceOutlineStyle- Parameters:
join- the line joining method
-
setOutlineCap
public void setOutlineCap(LineCap cap)
Description copied from interface:OutlineStyleSets the line cap style used on outline ends.- Specified by:
setOutlineCapin interfaceOutlineStyle- Parameters:
cap- the line cap type
-
getOutlineCap
public LineCap getOutlineCap()
Description copied from interface:OutlineStyleReturns the line cap style used on outline ends.- Specified by:
getOutlineCapin interfaceOutlineStyle- Returns:
- the line cap style
-
cancelActiveEditor
public static void cancelActiveEditor()
-
beginEditing
public void beginEditing()
- Specified by:
beginEditingin interfaceEditablePageItem
-
customizePopupMenu
public void customizePopupMenu(javax.swing.JPopupMenu menu, PageItem[] selection, boolean isSelectionFocus)Description copied from interface:PageItemAllows a page item the opportunity to customize the popup menu before it is displayed. When a popup menu is constructed for a page view, the items in the selection will be offered the opportunity to customize the menu. Generally, only the last item (if any) makes any changes.- Specified by:
customizePopupMenuin interfacePageItem- Overrides:
customizePopupMenuin classAbstractItem- Parameters:
menu- the menu that will be displayedselection- the selected items; this should be considered read-onlyisSelectionFocus- iftrue, this is the last item in the selection
-
writeImpl
protected void writeImpl(java.io.ObjectOutputStream out) throws java.io.IOException- Overrides:
writeImplin classAbstractRenderedItem- Throws:
java.io.IOException
-
readImpl
protected void readImpl(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException- Overrides:
readImplin classAbstractRenderedItem- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
isTextJustified
public boolean isTextJustified()
-
setTextJustified
public void setTextJustified(boolean justifyText)
-
-