com.flagstone.transform.linestyle
Class MorphLineStyle2

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

public final class MorphLineStyle2
extends Object
implements LineStyle

MorphLineStyle2 extends MorphLineStyle 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
MorphLineStyle2(int initialWidth, int finalWidth, Color initialColor, Color finalColor)
          Create a new MorphLineStyle2 object with the stroke thickness and color for the start and end of the morphing process.
MorphLineStyle2(int initialWidth, int finalWidth, FillStyle style)
          Create a new MorphLineStyle2 object with the stroke thickness and fill style for the start and end of the morphing process.
MorphLineStyle2(MorphLineStyle2 object)
          Creates and initialises a MorphLineStyle2 object using the values copied from another MorphLineStyle2 object.
MorphLineStyle2(SWFDecoder coder, Context context)
          Creates and initialises a MorphLineStyle2 object using values encoded in the Flash binary format.
 
Method Summary
 MorphLineStyle2 copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 CapStyle getEndCap()
          Get the CapStyle used for the end of the line.
 Color getEndColor()
          Returns the colour of the line at the end of the morphing process.
 int getEndWidth()
          Get the width of the line at the end of the morphing process.
 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.
 Color getStartColor()
          Get the colour of the line at the start of the morphing process.
 int getStartWidth()
          Get the width of the line at the start of the morphing process.
 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 setEndCap(CapStyle style)
          Set the CapStyle used for the end of the line.
 void setEndColor(Color aColor)
          Sets the colour of the line at the end of the morphing process.
 void setEndWidth(int aNumber)
          Sets the width of the line at the end of the morphing process.
 void setFillStyle(FillStyle style)
          Set the FillStyle (morphing fill styles only) 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 setStartColor(Color aColor)
          Returns the colour of the line at the start of the morphing process.
 void setStartWidth(int aNumber)
          Sets the width of the line at the start of the morphing process.
 void setVertical(boolean scale)
          Indicates whether the stroke is scaled vertically if the shape is redrawn.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MorphLineStyle2

public MorphLineStyle2(SWFDecoder coder,
                       Context context)
                throws IOException
Creates and initialises a MorphLineStyle2 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.

MorphLineStyle2

public MorphLineStyle2(int initialWidth,
                       int finalWidth,
                       Color initialColor,
                       Color finalColor)
Create a new MorphLineStyle2 object with the stroke thickness and color for the start and end of the morphing process.

Parameters:
initialWidth - the width of the line at the start of the process.
finalWidth - the width of the line at the end of the process.
initialColor - the colour used to draw the line at the start of the process.
finalColor - the colour used to draw the line at the end of the process.

MorphLineStyle2

public MorphLineStyle2(int initialWidth,
                       int finalWidth,
                       FillStyle style)
Create a new MorphLineStyle2 object with the stroke thickness and fill style for the start and end of the morphing process.

Parameters:
initialWidth - the width of the line at the start of the process.
finalWidth - the width of the line at the end of the process.
style - a FillStyle (morph fill styles only) that describes the fill used to draw the line at the start and end of the process.

MorphLineStyle2

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

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

getStartWidth

public int getStartWidth()
Get the width of the line at the start of the morphing process.

Returns:
the starting stroke width.

getEndWidth

public int getEndWidth()
Get the width of the line at the end of the morphing process.

Returns:
the final stroke width.

getStartColor

public Color getStartColor()
Get the colour of the line at the start of the morphing process.

Returns:
the starting stroke colour.

getEndColor

public Color getEndColor()
Returns the colour of the line at the end of the morphing process.

Returns:
the final stroke colour.

setStartWidth

public void setStartWidth(int aNumber)
Sets the width of the line at the start of the morphing process.

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

setEndWidth

public void setEndWidth(int aNumber)
Sets the width of the line at the end of the morphing process.

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

setStartColor

public void setStartColor(Color aColor)
Returns the colour of the line at the start of the morphing process.

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

setEndColor

public void setEndColor(Color aColor)
Sets the colour of the line at the end of the morphing process.

Parameters:
aColor - the ending colour of the line. Must 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 (morphing fill styles only) used for the line stroke.

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

copy

public MorphLineStyle2 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.