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.ImageIconcachedIconstatic DashPatternDEFAULT_DASH_PATTERNstatic intDEFAULT_LINE_CAPstatic java.awt.ColorDEFAULT_LINE_COLORstatic intDEFAULT_LINE_JOINstatic floatDEFAULT_LINE_WIDTHprotected ca.cgjennings.apps.arkham.deck.item.DropShadowLineCachedsc-
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.StrokeapplyStrokeAndPaint(java.awt.Graphics2D g)PageItemclone()Returns a new page item, using this item as a template.DragHandle[]getDragHandles()Returns an array of the customDragHandles for this item.java.awt.geom.Point2D.DoublegetEndPoint()doublegetHeight()Return the height of this item, in points.LineCapgetLineCap()Returns the line cap style used on line ends.java.awt.ColorgetLineColor()Returns the color used to draw the border.DashPatterngetLineDashPattern()Returns the dash pattern used to draw the line.LineJoingetLineJoin()floatgetLineWidth()Returns the width, in points, of the line.java.lang.StringgetName()Return the user-friendly short name of this item.java.awt.ShapegetOutline()Return aShapethat corresponds to the outline of this item.java.awt.geom.Rectangle2D.DoublegetRectangle()Return a rectangle of the bounds of this item.java.awt.geom.Point2D.DoublegetStartPoint()javax.swing.ImageIcongetThumbnailIcon()Returns a small representative icon for this item.doublegetWidth()Return the width of this item, in points.doublegetX2()doublegetY2()booleanhasExteriorHandles()Returnstrueif this item has one or more drag handles that may lie outside of the item's bounding box.booleanisShadowed()Returnstrueif a drop shadow is enabled.voidpaint(java.awt.Graphics2D g, RenderTarget target, double renderResolutionHint)Paint this item at its current location.voidpaintFast(java.awt.Graphics2D g, java.awt.geom.Line2D.Double line, RenderTarget target, double renderResolutionHint)protected voidreadImpl(java.io.ObjectInputStream in)voidsetEndPoint(java.awt.geom.Point2D p)voidsetLineCap(LineCap lineCap)Sets the line cap style used on line ends.voidsetLineColor(java.awt.Color lineColour)Sets the color used to draw the line.voidsetLineDashPattern(DashPattern pat)Sets the dash pattern used to draw the line.voidsetLineJoin(LineJoin join)Sets the line join style used for paths containing multiple line or curve segments.voidsetLineWidth(float lineWidth)Sets the width, in points, of the line.voidsetName(java.lang.String name)voidsetShadowed(boolean enable)Sets whether the drop shadow are enabled.voidsetSize(double width, double height)Set the new size of this item, in points.voidsetStartPoint(java.awt.geom.Point2D p)protected voidwriteImpl(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:PageItemReturns a small representative icon for this item. The icon should beICON_SIZEpixels wide and high.- Specified by:
getThumbnailIconin interfacePageItem- Specified by:
getThumbnailIconin classAbstractItem
-
setName
public void setName(java.lang.String name)
-
getName
public java.lang.String getName()
Description copied from interface:PageItemReturn the user-friendly short name of this item.
-
getLineColor
public java.awt.Color getLineColor()
Description copied from interface:LineStyleReturns the color used to draw the border.- Specified by:
getLineColorin interfaceLineStyle- Returns:
- the border color
-
setLineColor
public void setLineColor(java.awt.Color lineColour)
Description copied from interface:LineStyleSets the color used to draw the line.- Specified by:
setLineColorin interfaceLineStyle
-
getLineCap
public LineCap getLineCap()
Description copied from interface:LineStyleReturns the line cap style used on line ends.- Specified by:
getLineCapin interfaceLineStyle- Returns:
- the line cap style
-
setLineCap
public void setLineCap(LineCap lineCap)
Description copied from interface:LineStyleSets the line cap style used on line ends.- Specified by:
setLineCapin interfaceLineStyle- Parameters:
lineCap- the line cap type
-
getLineJoin
public LineJoin getLineJoin()
- Specified by:
getLineJoinin interfaceLineStyle
-
setLineJoin
public void setLineJoin(LineJoin join)
Description copied from interface:LineStyleSets the line join style used for paths containing multiple line or curve segments.- Specified by:
setLineJoinin interfaceLineStyle- Parameters:
join- the new line join style
-
setLineWidth
public void setLineWidth(float lineWidth)
Description copied from interface:LineStyleSets the width, in points, of the line.- Specified by:
setLineWidthin interfaceLineStyle
-
getLineDashPattern
public DashPattern getLineDashPattern()
Description copied from interface:LineStyleReturns the dash pattern used to draw the line.- Specified by:
getLineDashPatternin interfaceLineStyle- Returns:
- the dash pattern for the border
-
setLineDashPattern
public void setLineDashPattern(DashPattern pat)
Description copied from interface:LineStyleSets the dash pattern used to draw the line.- Specified by:
setLineDashPatternin interfaceLineStyle- Parameters:
pat- the dash pattern type
-
isShadowed
public boolean isShadowed()
Description copied from interface:ShadowStyleReturnstrueif a drop shadow is enabled.- Specified by:
isShadowedin interfaceShadowStyle- Returns:
trueif a shadow is enabled
-
setShadowed
public void setShadowed(boolean enable)
Description copied from interface:ShadowStyleSets whether the drop shadow are enabled.- Specified by:
setShadowedin 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:PageItemReturn a rectangle of the bounds of this item.- Specified by:
getRectanglein interfacePageItem- Overrides:
getRectanglein classAbstractItem- Returns:
- a bounding rectangle for the 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
-
getWidth
public double getWidth()
Description copied from interface:PageItemReturn the width of this item, in points.- Specified by:
getWidthin interfacePageItem- Specified by:
getWidthin classAbstractItem- Returns:
- the item's width
-
getHeight
public double getHeight()
Description copied from interface:PageItemReturn the height of this item, in points.- Specified by:
getHeightin interfacePageItem- Specified by:
getHeightin 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:LineStyleReturns the width, in points, of the line.- Specified by:
getLineWidthin interfaceLineStyle- Returns:
- the border line width
-
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
-
getOutline
public java.awt.Shape getOutline()
Description copied from interface:PageItemReturn aShapethat 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:
getOutlinein interfacePageItem- Overrides:
getOutlinein classAbstractItem- Returns:
- the outline of this object
-
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- Specified by:
paintin 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: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 classAbstractItem- Returns:
- a new copy of this page item
-
hasExteriorHandles
public boolean hasExteriorHandles()
Description copied from interface:PageItemReturnstrueif 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 returnstruethen the item's handles are always tested.- Specified by:
hasExteriorHandlesin interfacePageItem- Overrides:
hasExteriorHandlesin classAbstractItem- Returns:
trueif some handles may be outside the bounding box
-
writeImpl
protected void writeImpl(java.io.ObjectOutputStream out) throws java.io.IOException- Overrides:
writeImplin classAbstractItem- Throws:
java.io.IOException
-
readImpl
protected void readImpl(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException- Overrides:
readImplin classAbstractItem- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
-