Class Line
- java.lang.Object
-
- ca.cgjennings.apps.arkham.deck.item.AbstractItem
-
- ca.cgjennings.apps.arkham.deck.item.Line
-
- All Implemented Interfaces:
LineStyle
,PageItem
,ShadowStyle
,SizablePageItem
,Style
,java.io.Serializable
,java.lang.Cloneable
- Direct Known Subclasses:
Curve
public class Line extends AbstractItem implements SizablePageItem, LineStyle, ShadowStyle
An page item representing a straight line segment.- 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 Modifier and Type Field Description protected javax.swing.ImageIcon
cachedIcon
static DashPattern
DEFAULT_DASH_PATTERN
static int
DEFAULT_LINE_CAP
static java.awt.Color
DEFAULT_LINE_COLOR
static int
DEFAULT_LINE_JOIN
static float
DEFAULT_LINE_WIDTH
protected ca.cgjennings.apps.arkham.deck.item.DropShadowLineCache
dsc
-
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
-
-
Constructor Summary
Constructors Constructor Description Line()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.awt.Stroke
applyStrokeAndPaint(java.awt.Graphics2D g)
PageItem
clone()
Returns a new page item, using this item as a template.DragHandle[]
getDragHandles()
Returns an array of the customDragHandle
s for this item.java.awt.geom.Point2D.Double
getEndPoint()
double
getHeight()
Return the height of this item, in points.LineCap
getLineCap()
Returns the line cap style used on line ends.java.awt.Color
getLineColor()
Returns the color used to draw the border.DashPattern
getLineDashPattern()
Returns the dash pattern used to draw the line.LineJoin
getLineJoin()
float
getLineWidth()
Returns the width, in points, of the line.java.lang.String
getName()
Return the user-friendly short name of this item.java.awt.Shape
getOutline()
Return aShape
that corresponds to the outline of this item.java.awt.geom.Rectangle2D.Double
getRectangle()
Return a rectangle of the bounds of this item.java.awt.geom.Point2D.Double
getStartPoint()
javax.swing.ImageIcon
getThumbnailIcon()
Returns a small representative icon for this item.double
getWidth()
Return the width of this item, in points.double
getX2()
double
getY2()
boolean
hasExteriorHandles()
Returnstrue
if this item has one or more drag handles that may lie outside of the item's bounding box.boolean
isShadowed()
Returnstrue
if a drop shadow is enabled.void
paint(java.awt.Graphics2D g, RenderTarget target, double renderResolutionHint)
Paint this item at its current location.void
paintFast(java.awt.Graphics2D g, java.awt.geom.Line2D.Double line, RenderTarget target, double renderResolutionHint)
protected void
readImpl(java.io.ObjectInputStream in)
void
setEndPoint(java.awt.geom.Point2D p)
void
setLineCap(LineCap lineCap)
Sets the line cap style used on line ends.void
setLineColor(java.awt.Color lineColour)
Sets the color used to draw the line.void
setLineDashPattern(DashPattern pat)
Sets the dash pattern used to draw the line.void
setLineJoin(LineJoin join)
Sets the line join style used for paths containing multiple line or curve segments.void
setLineWidth(float lineWidth)
Sets the width, in points, of the line.void
setName(java.lang.String name)
void
setShadowed(boolean enable)
Sets whether the drop shadow are enabled.void
setSize(double width, double height)
Set the new size of this item, in points.void
setStartPoint(java.awt.geom.Point2D p)
protected void
writeImpl(java.io.ObjectOutputStream out)
-
Methods inherited from class ca.cgjennings.apps.arkham.deck.item.AbstractItem
customizePopupMenu, getBleedMargin, getClassesSnappedTo, getClientProperty, getFoldMarks, getGroup, getLocation, getOrientation, getPage, getSnapClass, getSnapTarget, getX, getY, hitTest, isBleedMarginMarked, isHorizontal, isMirrored, isSelectionLocked, isTurned0DegreesFrom, isTurned180DegreesFrom, isTurned90DegreesFrom, isVertical, itemChanged, itemChanging, prepareToPaint, putClientProperty, setClassesSnappedTo, setGroup, setLocation, setLocation, setPage, setSelectionLocked, setSnapClass, setSnapTarget, setX, setY, 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
customizePopupMenu, getBleedMargin, getClassesSnappedTo, getClientProperty, getFoldMarks, getGroup, getLocation, getOrientation, getPage, getSnapClass, getSnapTarget, getX, getY, hitTest, isBleedMarginMarked, isHorizontal, isMirrored, isSelectionLocked, isTurned0DegreesFrom, isTurned180DegreesFrom, isTurned90DegreesFrom, isVertical, prepareToPaint, putClientProperty, setClassesSnappedTo, setGroup, setLocation, setLocation, setPage, setSelectionLocked, setSnapClass, setSnapTarget, setX, setY
-
-
-
-
Field Detail
-
DEFAULT_LINE_WIDTH
public static final float DEFAULT_LINE_WIDTH
- See Also:
- Constant Field Values
-
DEFAULT_LINE_COLOR
public static final java.awt.Color DEFAULT_LINE_COLOR
-
DEFAULT_LINE_CAP
public static final int DEFAULT_LINE_CAP
- See Also:
- Constant Field Values
-
DEFAULT_LINE_JOIN
public static final int DEFAULT_LINE_JOIN
- See Also:
- Constant Field Values
-
DEFAULT_DASH_PATTERN
public static final DashPattern DEFAULT_DASH_PATTERN
-
cachedIcon
protected transient javax.swing.ImageIcon cachedIcon
-
dsc
protected transient ca.cgjennings.apps.arkham.deck.item.DropShadowLineCache dsc
-
-
Method Detail
-
getThumbnailIcon
public javax.swing.ImageIcon 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
- Specified by:
getThumbnailIcon
in classAbstractItem
-
setName
public void setName(java.lang.String name)
-
getName
public java.lang.String getName()
Description copied from interface:PageItem
Return the user-friendly short name of this item.
-
getLineColor
public java.awt.Color getLineColor()
Description copied from interface:LineStyle
Returns the color used to draw the border.- Specified by:
getLineColor
in interfaceLineStyle
- Returns:
- the border color
-
setLineColor
public void setLineColor(java.awt.Color lineColour)
Description copied from interface:LineStyle
Sets the color used to draw the line.- Specified by:
setLineColor
in interfaceLineStyle
-
getLineCap
public LineCap getLineCap()
Description copied from interface:LineStyle
Returns the line cap style used on line ends.- Specified by:
getLineCap
in interfaceLineStyle
- Returns:
- the line cap style
-
setLineCap
public void setLineCap(LineCap lineCap)
Description copied from interface:LineStyle
Sets the line cap style used on line ends.- Specified by:
setLineCap
in interfaceLineStyle
- Parameters:
lineCap
- the line cap type
-
getLineJoin
public LineJoin getLineJoin()
- Specified by:
getLineJoin
in interfaceLineStyle
-
setLineJoin
public void setLineJoin(LineJoin join)
Description copied from interface:LineStyle
Sets the line join style used for paths containing multiple line or curve segments.- Specified by:
setLineJoin
in interfaceLineStyle
- Parameters:
join
- the new line join style
-
setLineWidth
public void setLineWidth(float lineWidth)
Description copied from interface:LineStyle
Sets the width, in points, of the line.- Specified by:
setLineWidth
in interfaceLineStyle
-
getLineDashPattern
public DashPattern getLineDashPattern()
Description copied from interface:LineStyle
Returns the dash pattern used to draw the line.- Specified by:
getLineDashPattern
in interfaceLineStyle
- Returns:
- the dash pattern for the border
-
setLineDashPattern
public void setLineDashPattern(DashPattern pat)
Description copied from interface:LineStyle
Sets the dash pattern used to draw the line.- Specified by:
setLineDashPattern
in interfaceLineStyle
- Parameters:
pat
- the dash pattern type
-
isShadowed
public boolean isShadowed()
Description copied from interface:ShadowStyle
Returnstrue
if a drop shadow is enabled.- Specified by:
isShadowed
in interfaceShadowStyle
- Returns:
true
if a shadow is enabled
-
setShadowed
public void setShadowed(boolean enable)
Description copied from interface:ShadowStyle
Sets whether the drop shadow are enabled.- Specified by:
setShadowed
in interfaceShadowStyle
- Parameters:
enable
- iftrue
, the object will have a drop shadow
-
getX2
public double getX2()
-
getY2
public double getY2()
-
getRectangle
public java.awt.geom.Rectangle2D.Double getRectangle()
Description copied from interface:PageItem
Return a rectangle of the bounds of this item.- Specified by:
getRectangle
in interfacePageItem
- Overrides:
getRectangle
in classAbstractItem
- Returns:
- a bounding rectangle for the 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
-
getWidth
public double getWidth()
Description copied from interface:PageItem
Return the width of this item, in points.- Specified by:
getWidth
in interfacePageItem
- Specified by:
getWidth
in classAbstractItem
- Returns:
- the item's width
-
getHeight
public double getHeight()
Description copied from interface:PageItem
Return the height of this item, in points.- Specified by:
getHeight
in interfacePageItem
- Specified by:
getHeight
in classAbstractItem
- Returns:
- the item's height
-
getStartPoint
public java.awt.geom.Point2D.Double getStartPoint()
-
getEndPoint
public java.awt.geom.Point2D.Double getEndPoint()
-
setStartPoint
public void setStartPoint(java.awt.geom.Point2D p)
-
setEndPoint
public void setEndPoint(java.awt.geom.Point2D p)
-
getLineWidth
public float getLineWidth()
Description copied from interface:LineStyle
Returns the width, in points, of the line.- Specified by:
getLineWidth
in interfaceLineStyle
- Returns:
- the border line width
-
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
-
getOutline
public java.awt.Shape getOutline()
Description copied from interface:PageItem
Return aShape
that corresponds to the outline of this item. In the simplest case, this can return the same result asPageItem.getRectangle()
. If precise geometry is available for the item, then this should return a more accurate bounding shape.- Specified by:
getOutline
in interfacePageItem
- Overrides:
getOutline
in classAbstractItem
- Returns:
- the outline of this object
-
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
- Specified by:
paint
in classAbstractItem
- Parameters:
g
- the graphics context to paint totarget
- the type of destination being drawn torenderResolutionHint
- a source resolution hint
-
paintFast
public void paintFast(java.awt.Graphics2D g, java.awt.geom.Line2D.Double line, RenderTarget target, double renderResolutionHint)
-
applyStrokeAndPaint
protected java.awt.Stroke applyStrokeAndPaint(java.awt.Graphics2D g)
-
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 classAbstractItem
- Returns:
- a new copy of this page item
-
hasExteriorHandles
public boolean hasExteriorHandles()
Description copied from interface:PageItem
Returnstrue
if this item has one or more drag handles that may lie outside of the item's bounding box. The editor normally only tests handles that lie within the bounding box to see if the user has pointed at them; if this method returnstrue
then the item's handles are always tested.- Specified by:
hasExteriorHandles
in interfacePageItem
- Overrides:
hasExteriorHandles
in classAbstractItem
- Returns:
true
if some handles may be outside the bounding box
-
writeImpl
protected void writeImpl(java.io.ObjectOutputStream out) throws java.io.IOException
- Overrides:
writeImpl
in classAbstractItem
- Throws:
java.io.IOException
-
readImpl
protected void readImpl(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
- Overrides:
readImpl
in classAbstractItem
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
-