com.flagstone.transform.linestyle
Class LineStyle1

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

public final class LineStyle1
extends Object
implements LineStyle

LineStyle1 defines the width and colour of a line that is used when drawing the outline of a shape.

All lines are drawn with rounded corners and end caps. Different join and line end styles can be created by drawing line segments as a sequence of filled shapes. With 1 twip equal to 1/20th of a pixel this technique can easily be used to draw the narrowest of visible lines. Note that specific join and cap styles can be specified with the LineStyle2 class.

Whether the alpha channel in the colour is used is determined by the class used to define the shape. Transparent colours are only supported from Flash 3 onwards. Simply specifying the level of transparency in the Color object is not sufficient.

Flash only supports contiguous lines. Dashed line styles can be created by drawing the line as a series of short line segments by interspersing ShapeStyle objects to move the current point in between the Line objects that draw the line segments.

See Also:
LineStyle2

Constructor Summary
LineStyle1(int aWidth, Color aColor)
          Creates a LineStyle, specifying the width and colour of the line.
LineStyle1(LineStyle1 object)
          Creates and initialises a LineStyle object using the values copied from another LineStyle object.
LineStyle1(SWFDecoder coder, Context context)
          Creates and initialises a LineStyle object using values encoded in the Flash binary format.
 
Method Summary
 LineStyle1 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.
 int getWidth()
          Get the width of the line.
 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 setWidth(int aNumber)
          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

LineStyle1

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

LineStyle1

public LineStyle1(int aWidth,
                  Color aColor)
Creates a LineStyle, specifying the width and colour of the line.

Parameters:
aWidth - the width of the line. Must be in the range 0..65535.
aColor - the colour of the line. Must not be null.

LineStyle1

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

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

getWidth

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

Returns:
the stroke width.

getColor

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

Returns:
the line colour.

setWidth

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

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

setColor

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

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

copy

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