com.flagstone.transform.linestyle
Class LineStyle2

java.lang.Object
  extended by com.flagstone.transform.linestyle.LineStyle2
All Implemented Interfaces:
Copyable<LineStyle>, SWFEncodeable, LineStyle

public final class LineStyle2
extends Object
implements LineStyle

LineStyle2 extends LineStyle1 by supporting different styles for line joins and line ends, a fill style for the stroke and whether the stroke thickness is scaled if an object is resized.


Constructor Summary
LineStyle2(int lineWidth, Color lineColor)
          Create a new LineStyle2 object with the stroke thickness and color.
LineStyle2(int lineWidth, FillStyle style)
          Create a new LineStyle2 object with the stroke thickness and fill style.
LineStyle2(LineStyle2 object)
          Creates and initialises a LineStyle2 object using the values copied from another LineStyle2 object.
LineStyle2(SWFDecoder coder, Context context)
          Creates and initialises a LineStyle2 object using values encoded in the Flash binary format.
 
Method Summary
 LineStyle2 copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 Color getColor()
          Get the colour of the line.
 CapStyle getEndCap()
          Get the CapStyle used for the end of the line.
 FillStyle getFillStyle()
          Get the FillStyle used for the line stroke.
 JoinStyle getJoinStyle()
          Get the JoinStyle used when joining with another line or curve.
 int getMiterLimit()
          Get the limit for drawing miter joins.
 CapStyle getStartCap()
          Get the CapStyle used for the start of the line.
 int getWidth()
          Get the width of the line.
 boolean isHorizontal()
          Is the stroke scaled horizontally if the shape is redrawn.
 boolean isLineClosed()
          Is the path closed if the end point matches the starting point.
 boolean isPixelAligned()
          Are the end points of the line aligned to pixel boundaries.
 boolean isVertical()
          Is the stroke scaled vertically if the shape is redrawn.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setColor(Color aColor)
          Sets the colour of the line.
 void setEndCap(CapStyle style)
          Set the CapStyle used for the end of the line.
 void setFillStyle(FillStyle style)
          Set the FillStyle used for the line stroke.
 void setHorizontal(boolean scale)
          Indicates whether the stroke is scaled horizontally if the shape is redrawn.
 void setJoinStyle(JoinStyle style)
          Set the JoinStyle used when joining with another line or curve.
 void setLineClosed(boolean close)
          Indicates whether the path closed if the end point matches the starting point.
 void setMiterLimit(int limit)
          Set the limit for drawing miter joins.
 void setPixelAligned(boolean align)
          Indicates whether the end points of the line aligned to pixel boundaries.
 void setStartCap(CapStyle style)
          Set the CapStyle used for the start of the line.
 void setVertical(boolean scale)
          Indicates whether the stroke is scaled vertically if the shape is redrawn.
 void setWidth(int thickness)
          Sets the width of the line.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LineStyle2

public LineStyle2(SWFDecoder coder,
                  Context context)
           throws IOException
Creates and initialises a LineStyle2 object using values encoded in the Flash binary format.

Parameters:
coder - an SWFDecoder object that contains the encoded Flash data.
context - a Context object used to manage the decoders for different type of object and to pass information on how objects are decoded.
Throws:
IOException - if an error occurs while decoding the data.

LineStyle2

public LineStyle2(int lineWidth,
                  Color lineColor)
Create a new LineStyle2 object with the stroke thickness and color.

Parameters:
lineWidth - the width of the line.
lineColor - the colour used to draw the line.

LineStyle2

public LineStyle2(int lineWidth,
                  FillStyle style)
Create a new LineStyle2 object with the stroke thickness and fill style.

Parameters:
lineWidth - the width of the line.
style - the fill style used to draw the line.

LineStyle2

public LineStyle2(LineStyle2 object)
Creates and initialises a LineStyle2 object using the values copied from another LineStyle2 object.

Parameters:
object - a LineStyle2 object from which the values will be copied.
Method Detail

getWidth

public int getWidth()
Get the width of the line.

Returns:
the stroke width.

setWidth

public void setWidth(int thickness)
Sets the width of the line.

Parameters:
thickness - the width of the line. Must be in the range 0..65535.

getColor

public Color getColor()
Get the colour of the line.

Returns:
the line colour.

setColor

public void setColor(Color aColor)
Sets the colour of the line.

Parameters:
aColor - the colour of the line. Must be not be null.

getStartCap

public CapStyle getStartCap()
Get the CapStyle used for the start of the line.

Returns:
the CapStyle that specifies how the start of the line is drawn.

setStartCap

public void setStartCap(CapStyle style)
Set the CapStyle used for the start of the line.

Parameters:
style - the CapStyle that specifies how the start of the line is drawn.

getEndCap

public CapStyle getEndCap()
Get the CapStyle used for the end of the line.

Returns:
the CapStyle that specifies how the end of the line is drawn.

setEndCap

public void setEndCap(CapStyle style)
Set the CapStyle used for the end of the line.

Parameters:
style - the CapStyle that specifies how the end of the line is drawn.

getJoinStyle

public JoinStyle getJoinStyle()
Get the JoinStyle used when joining with another line or curve.

Returns:
the JoinStyle used to connect with another line or curve.

setJoinStyle

public void setJoinStyle(JoinStyle style)
Set the JoinStyle used when joining with another line or curve.

Parameters:
style - the JoinStyle used to connect with another line or curve.

isHorizontal

public boolean isHorizontal()
Is the stroke scaled horizontally if the shape is redrawn.

Returns:
true if the stroke is scaled horizontally, false if the stroke thickness does not change.

setHorizontal

public void setHorizontal(boolean scale)
Indicates whether the stroke is scaled horizontally if the shape is redrawn.

Parameters:
scale - true if the stroke is scaled horizontally, false if the stroke thickness does not change.

isVertical

public boolean isVertical()
Is the stroke scaled vertically if the shape is redrawn.

Returns:
true if the stroke is scaled vertically, false if the stroke thickness does not change.

setVertical

public void setVertical(boolean scale)
Indicates whether the stroke is scaled vertically if the shape is redrawn.

Parameters:
scale - true if the stroke is scaled vertically, false if the stroke thickness does not change.

isPixelAligned

public boolean isPixelAligned()
Are the end points of the line aligned to pixel boundaries.

Returns:
true if the end points are aligned to full pixels, false otherwise.

setPixelAligned

public void setPixelAligned(boolean align)
Indicates whether the end points of the line aligned to pixel boundaries.

Parameters:
align - true if the end points are aligned to full pixels, false otherwise.

isLineClosed

public boolean isLineClosed()
Is the path closed if the end point matches the starting point. If true then the line will be joined, otherwise an end cap is drawn.

Returns:
true if the line will be closed, false if the path remains open.

setLineClosed

public void setLineClosed(boolean close)
Indicates whether the path closed if the end point matches the starting point. If true then the line will be joined, otherwise an end cap is drawn.

Parameters:
close - true if the line will be closed, false if the path remains open.

getMiterLimit

public int getMiterLimit()
Get the limit for drawing miter joins.

Returns:
the value controlling how miter joins are drawn.

setMiterLimit

public void setMiterLimit(int limit)
Set the limit for drawing miter joins.

Parameters:
limit - the value controlling how miter joins are drawn.

getFillStyle

public FillStyle getFillStyle()
Get the FillStyle used for the line stroke.

Returns:
the FillStyle used to draw the line.

setFillStyle

public void setFillStyle(FillStyle style)
Set the FillStyle used for the line stroke.

Parameters:
style - the FillStyle used to draw the line.

copy

public LineStyle2 copy()
Creates a complete copy of this object.

Specified by:
copy in interface Copyable<LineStyle>
Returns:
a deep-copy of this object. New instances of mutable objects are copied and immutable instances are shared.

toString

public String toString()
Overrides:
toString in class Object

prepareToEncode

public int prepareToEncode(Context context)
Prepare an object for encoding, returning the expected size of an object when it is encoded. This method also used to initialise variables, such as offsets and flags that will be used when the object is encoded. Generally the method returns the size in bytes, however when called on objects that use bit fields such as shapes the methods will return the size in bits.

Specified by:
prepareToEncode in interface SWFEncodeable
Parameters:
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Returns:
the size of the object when it is encoded.

encode

public void encode(SWFEncoder coder,
                   Context context)
            throws IOException
Encode an object to the Flash binary format.

Specified by:
encode in interface SWFEncodeable
Parameters:
coder - an SWFEncoder object.
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Throws:
IOException - if an error occurs while encoding the object.


Copyright © 2002-2010 Flagstone Software Ltd.. All Rights Reserved.