com.flagstone.transform.shape
Class Line

java.lang.Object
  extended by com.flagstone.transform.shape.Line
All Implemented Interfaces:
Copyable<ShapeRecord>, SWFEncodeable, ShapeRecord

public final class Line
extends Object
implements ShapeRecord

Line defines a straight line. The line is drawn from the current drawing point to the end point specified in the Line object which is specified relative to the current drawing point. Once the line is drawn, the end of the line is now the current drawing point.


Constructor Summary
Line(int coordX, int coordY)
          Creates a Line with the specified relative coordinates.
Line(Line object)
          Creates and initialises a Line object using the values copied from another Line object.
Line(SWFDecoder coder)
          Creates and initialises a Line object using values encoded in the Flash binary format.
 
Method Summary
 Line copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 int getX()
          Get the relative x-coordinate of the end-point of the line.
 int getY()
          Get the relative y-coordinate of the end-point of the line.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setPoint(int coordX, int coordY)
          Sets the relative x and y coordinates.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Line

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

Parameters:
coder - an SWFDecoder object that contains the encoded Flash data.
Throws:
IOException - if an error occurs while decoding the data.

Line

public Line(int coordX,
            int coordY)
Creates a Line with the specified relative coordinates.

Parameters:
coordX - the x-coordinate of the end point, specified relative to the current drawing point. Must be in the range -65536..65535.
coordY - the y-coordinate of the end point, specified relative to the current drawing point. Must be in the range -65536..65535.

Line

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

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

getX

public int getX()
Get the relative x-coordinate of the end-point of the line.

Returns:
the x-coordinate of the line end.

getY

public int getY()
Get the relative y-coordinate of the end-point of the line.

Returns:
the y-coordinate of the line end.

setPoint

public void setPoint(int coordX,
                     int coordY)
Sets the relative x and y coordinates.

Parameters:
coordX - the x-coordinate of the end point. Must be in the range -65536..65535.
coordY - the y-coordinate of the end point. Must be in the range -65536..65535.

copy

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

Specified by:
copy in interface Copyable<ShapeRecord>
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.