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 void
beginEditing()
static void
cancelActiveEditor()
void
clearCachedImages()
Clear any cached image data held by this object.PageItem
clone()
Returns a new page item, using this item as a template.protected MarkupRenderer
createMarkupRenderer(double resolution)
void
customizePopupMenu(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 customDragHandle
s for this item.java.awt.Color
getFillColor()
Returns the fill colour used when painting the item.java.lang.String
getName()
Return the user-friendly short name of this item.LineCap
getOutlineCap()
Returns the line cap style used on outline ends.java.awt.Color
getOutlineColor()
Returns the color used to draw the outline.DashPattern
getOutlineDashPattern()
Returns the dash pattern used to draw the outline.LineJoin
getOutlineJoin()
Returns the method used to join the line segments that make up the outline.float
getOutlineWidth()
Returns the width, in points, of the outline.boolean
getShrink()
java.lang.String
getText()
javax.swing.Icon
getThumbnailIcon()
Returns a small representative icon for this item.protected double
getUprightHeight()
Return the height of this item in its standard, upright orientation.protected double
getUprightWidth()
Return the width of this item in its standard, upright orientation.boolean
isTextJustified()
void
paint(java.awt.Graphics2D g, RenderTarget target, double renderResolutionHint)
Paint this item at its current location.protected void
readImpl(java.io.ObjectInputStream in)
protected java.awt.image.BufferedImage
renderImage(RenderTarget target, double resolution)
Render an image based on the target and resolution hints.void
setFillColor(java.awt.Color color)
Sets the fill colour used when painting the item.void
setOutlineCap(LineCap cap)
Sets the line cap style used on outline ends.void
setOutlineColor(java.awt.Color borderColor)
Sets the color used to draw the outline.void
setOutlineDashPattern(DashPattern pat)
Sets the dash pattern used to draw the outline.void
setOutlineJoin(LineJoin join)
Sets the method used to join the line segments that make up the outline.void
setOutlineWidth(float borderWidth)
Sets the width, in points, of the outline.void
setShrink(boolean shrink)
void
setSize(double width, double height)
Set the new size of this item, in points.void
setText(java.lang.String text)
void
setTextJustified(boolean justifyText)
void
setX(double x)
Set the x-location of this item.void
setY(double y)
Set the y-location of this item.protected void
writeImpl(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:AbstractRenderedItem
Return the width of this item in its standard, upright orientation.- Specified by:
getUprightWidth
in classAbstractRenderedItem
- Returns:
- the width of the unoriented item
-
getUprightHeight
protected double getUprightHeight()
Description copied from class:AbstractRenderedItem
Return the height of this item in its standard, upright orientation.- Specified by:
getUprightHeight
in classAbstractRenderedItem
- Returns:
- the height of the unoriented item
-
getFillColor
public java.awt.Color getFillColor()
Description copied from interface:ShapeStyle
Returns the fill colour used when painting the item.- Specified by:
getFillColor
in interfaceShapeStyle
- Returns:
- the background colour
-
setFillColor
public void setFillColor(java.awt.Color color)
Description copied from interface:ShapeStyle
Sets the fill colour used when painting the item.- Specified by:
setFillColor
in 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:PageItem
Returns a small representative icon for this item. The icon should beICON_SIZE
pixels wide and high.- Specified by:
getThumbnailIcon
in interfacePageItem
- Overrides:
getThumbnailIcon
in classAbstractRenderedItem
-
getDragHandles
public DragHandle[] getDragHandles()
Description copied from class:AbstractItem
Returns an array of the customDragHandle
s 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
dragHandles
field 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:
getDragHandles
in interfacePageItem
- Overrides:
getDragHandles
in 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:PageItem
Returns 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:
clone
in interfacePageItem
- Overrides:
clone
in 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:PageItem
Paint 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:
paint
in interfacePageItem
- Overrides:
paint
in 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:AbstractRenderedItem
Render 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 thesuper
implementation.- Specified by:
renderImage
in 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:AbstractRenderedItem
Clear 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:
clearCachedImages
in classAbstractRenderedItem
-
createMarkupRenderer
protected MarkupRenderer createMarkupRenderer(double resolution)
-
getName
public java.lang.String getName()
Description copied from interface:PageItem
Return the user-friendly short name of this item.
-
setSize
public void setSize(double width, double height)
Description copied from interface:SizablePageItem
Set the new size of this item, in points.- Specified by:
setSize
in 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:PageItem
Set the x-location of this item.- Specified by:
setX
in interfacePageItem
- Overrides:
setX
in classAbstractItem
- Parameters:
x
- the new x-location
-
setY
public void setY(double y)
Description copied from interface:PageItem
Set the y-location of this item.- Specified by:
setY
in interfacePageItem
- Overrides:
setY
in classAbstractItem
- Parameters:
y
- the new y-location
-
getOutlineColor
public java.awt.Color getOutlineColor()
Description copied from interface:OutlineStyle
Returns the color used to draw the outline.- Specified by:
getOutlineColor
in interfaceOutlineStyle
- Returns:
- the outline color
-
setOutlineColor
public void setOutlineColor(java.awt.Color borderColor)
Description copied from interface:OutlineStyle
Sets the color used to draw the outline.- Specified by:
setOutlineColor
in interfaceOutlineStyle
- Parameters:
borderColor
- the outline color
-
getOutlineWidth
public float getOutlineWidth()
Description copied from interface:OutlineStyle
Returns the width, in points, of the outline.- Specified by:
getOutlineWidth
in interfaceOutlineStyle
- Returns:
- the outline line width
-
setOutlineWidth
public void setOutlineWidth(float borderWidth)
Description copied from interface:OutlineStyle
Sets the width, in points, of the outline.- Specified by:
setOutlineWidth
in interfaceOutlineStyle
- Parameters:
borderWidth
- the outline width
-
getOutlineDashPattern
public DashPattern getOutlineDashPattern()
Description copied from interface:OutlineStyle
Returns the dash pattern used to draw the outline.- Specified by:
getOutlineDashPattern
in interfaceOutlineStyle
- Returns:
- the dash pattern for the outline
-
setOutlineDashPattern
public void setOutlineDashPattern(DashPattern pat)
Description copied from interface:OutlineStyle
Sets the dash pattern used to draw the outline.- Specified by:
setOutlineDashPattern
in interfaceOutlineStyle
- Parameters:
pat
- the dash pattern type
-
getOutlineJoin
public LineJoin getOutlineJoin()
Description copied from interface:OutlineStyle
Returns the method used to join the line segments that make up the outline.- Specified by:
getOutlineJoin
in interfaceOutlineStyle
- Returns:
- the line joining method
-
setOutlineJoin
public void setOutlineJoin(LineJoin join)
Description copied from interface:OutlineStyle
Sets the method used to join the line segments that make up the outline.- Specified by:
setOutlineJoin
in interfaceOutlineStyle
- Parameters:
join
- the line joining method
-
setOutlineCap
public void setOutlineCap(LineCap cap)
Description copied from interface:OutlineStyle
Sets the line cap style used on outline ends.- Specified by:
setOutlineCap
in interfaceOutlineStyle
- Parameters:
cap
- the line cap type
-
getOutlineCap
public LineCap getOutlineCap()
Description copied from interface:OutlineStyle
Returns the line cap style used on outline ends.- Specified by:
getOutlineCap
in interfaceOutlineStyle
- Returns:
- the line cap style
-
cancelActiveEditor
public static void cancelActiveEditor()
-
beginEditing
public void beginEditing()
- Specified by:
beginEditing
in interfaceEditablePageItem
-
customizePopupMenu
public void customizePopupMenu(javax.swing.JPopupMenu menu, PageItem[] selection, boolean isSelectionFocus)
Description copied from interface:PageItem
Allows 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:
customizePopupMenu
in interfacePageItem
- Overrides:
customizePopupMenu
in 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:
writeImpl
in classAbstractRenderedItem
- Throws:
java.io.IOException
-
readImpl
protected void readImpl(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
- Overrides:
readImpl
in classAbstractRenderedItem
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
isTextJustified
public boolean isTextJustified()
-
setTextJustified
public void setTextJustified(boolean justifyText)
-
-