edu.byu.phun2d
Class DrawObj

java.lang.Object
  extended by edu.byu.phun2d.DrawObj
Direct Known Subclasses:
Arc, Axes, Group, Line, Oval, Rect, Text, Triangle

public class DrawObj
extends java.lang.Object

This is the superclass of every object that can be drawn. This super class allows any of its subclasses to be added to a Win2D or to a Group. The result is that structures of drawings can be built with arbitrary complexity.

This class also manages the line color, line width and fill color for all of its subclasses.


Constructor Summary
DrawObj()
           
 
Method Summary
 Color getFillColor()
          Returns the color being used to fill this object.
 Color getLineColor()
          Returns the color being used to draw the border on this object.
 double getLineWidth()
          The width of the line/border.
 double getRotate()
          Returns the rotation angle
 double getScaleX()
          Get the X scale factor
 double getScaleY()
          Get the Y scale factor
 Point getTranslate()
          Returns the point to where the origin (0,0) has been translated
 Point insideToOutside(Point outsidePoint)
           
 Point outsideToInside(Point outsidePoint)
           
 void setFillColor(Color c)
          Changes the fill color of this object.
 void setLineColor(Color c)
          Changes the border or line color of this object.
 void setLineWidth(double width)
          Changes the width of the line or border of this object.
 void setRotate(double angle)
          This will rotate the object around the point (0,0) regardless of where the center of the object is.
 void setScale(double scaleX, double scaleY)
          This will change the size of the object.
 void setTranslate(double x, double y)
          This will move the origin (0,0) to location (x,y)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DrawObj

public DrawObj()
Method Detail

setFillColor

public void setFillColor(Color c)
Changes the fill color of this object. For solid shapes, the fill color is the color that is in the interior of the shape. If this is set to null then the shape will not be filled at all. The default fill color is black.

Parameters:
c - the new fill color.

getFillColor

public Color getFillColor()
Returns the color being used to fill this object. If this is null then the object is not being filled.

Returns:

setLineColor

public void setLineColor(Color c)
Changes the border or line color of this object. For solid shapes, the line color is the border. If this is set to null then no border is drawn. The default line color is gray.

Parameters:
c - the new line/border color.

getLineColor

public Color getLineColor()
Returns the color being used to draw the border on this object. If this is null then no border is drawn. For Line this is the color of the line itself.

Returns:

setLineWidth

public void setLineWidth(double width)
Changes the width of the line or border of this object. The default line width is 0.1 re

Parameters:
width - the new line width.

getLineWidth

public double getLineWidth()
The width of the line/border.

Returns:

setScale

public void setScale(double scaleX,
                     double scaleY)
This will change the size of the object. The size is changed by multiplying every coordinate in the object by scaleX and scaleY. If a scale factor is greater than 1 then things will get bigger. If a scale factor is between 0.0 and 1.0 then things will get smaller. If a scale factor is less than zero then the object will be resized and reflected (flipped over). Note that scale factors of zero will make the object disappear. The default is (1,1) which leaves the size unchanged.

Scaling is performed relative to the point (0,0) regardless of where center of the object is.

Parameters:
scaleX - the scale factor to be applied in the X direction.
scaleY - the scale factor to be applied in the Y direction.

getScaleX

public double getScaleX()
Get the X scale factor

Returns:
the scale factor for X

getScaleY

public double getScaleY()
Get the Y scale factor

Returns:
the scale factor for Y

setTranslate

public void setTranslate(double x,
                         double y)
This will move the origin (0,0) to location (x,y)

Parameters:
x - the X coordinate of the new location
y - the Y coordinate of the new location

getTranslate

public Point getTranslate()
Returns the point to where the origin (0,0) has been translated

Returns:
the origin translation point.

setRotate

public void setRotate(double angle)
This will rotate the object around the point (0,0) regardless of where the center of the object is.

Parameters:
angle - this is the counterclockwise angle in degrees that the object is to rotate.

getRotate

public double getRotate()
Returns the rotation angle

Returns:
the rotation angle

insideToOutside

public Point insideToOutside(Point outsidePoint)

outsideToInside

public Point outsideToInside(Point outsidePoint)