|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectEnvironment2D.Shape2D
public class Shape2D
Represents a single shape to the plane. Shapes can be moved and their properties changed during execution. They are transformed from the theoretical plane through the viewport and onto the graphics plane provided when rendering.
Extend this class in order to add new shapes or features such as collision detection code
| Field Summary | |
|---|---|
java.awt.Color |
colour
Holds the colour of this shape. |
double |
h
Holds the height on the plane of this shape. |
double |
w
Holds the width on the plane of this shape. |
double |
x
Holds the x co-ordinate on the plane of this shape. |
double |
y
Holds the y co-ordinate on the plane of this shape. |
| Constructor Summary | |
|---|---|
Shape2D(double p_x,
double p_y,
double p_w,
double p_h,
java.awt.Color p_colour)
Creates a new shape at a given position and of given dimensions. |
|
| Method Summary | |
|---|---|
protected double |
getAdjustedScalar(double x,
double p_viewMin,
double p_viewMax,
double p_graphcsWidth)
Returns a scalar distance transformed to match a set output distance. |
protected Shape2D |
getAdjustedShape(Shape2D p_shape,
Viewport2D p_view,
java.awt.Dimension p_graphicsSize)
Returns a new shape with dimensions that have been adjusted to fit a set viewport and dimension. |
void |
paintAdjusted(java.awt.Graphics g,
java.awt.Dimension p_graphicsSize,
Viewport2D p_view)
Paints a shape onto a graphics plane, adjusting for the viewport and final output size. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public double x
public double y
public double w
public double h
public java.awt.Color colour
| Constructor Detail |
|---|
public Shape2D(double p_x,
double p_y,
double p_w,
double p_h,
java.awt.Color p_colour)
p_x - The x co-ordinate to draw the top-left from.p_y - The y co-ordinate to draw the top-left from.p_w - The width of the shapep_h - The height of the shapep_colour - The colour of this shape| Method Detail |
|---|
protected Shape2D getAdjustedShape(Shape2D p_shape,
Viewport2D p_view,
java.awt.Dimension p_graphicsSize)
p_shape - The shape to transform.p_view - The viewport to 'see' the plane through.p_graphicsSize - The dimensions of the final output.
protected double getAdjustedScalar(double x,
double p_viewMin,
double p_viewMax,
double p_graphcsWidth)
The ratio of sizes is clearly (p_viewMax - p_viewMin):p_graphcsWidth
x - The value to transformp_viewMin - The min. bound of the viewportp_viewMax - The max. bound of the viewportp_graphcsWidth - The width of the final output
public void paintAdjusted(java.awt.Graphics g,
java.awt.Dimension p_graphicsSize,
Viewport2D p_view)
g - The graphics plane on which to draw.p_graphicsSize - The size of the graphics plane (or portion to output onto)p_view - The viewport, defining what portions of the plane to output
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||