Class Ele

java.lang.Object
  |
  +--Ele

public class Ele
extends java.lang.Object

Draws an elephant head at a user given x & y position with a user given width & height. The original aspect of the vector drawing is 5/7; height to width. The x, y, width, and height describe a rectangle just encompassing the elephant head.

Author:
Ronald Pace (ele@allelephants.com)

Constructor Summary
Ele()
          Default constructor; Creates an Ele instance with starting x & y at 0,0; width=105 and height=75.
Ele(int xp, int yp, int wd, int ht)
          Constructor; xp & yp are the starting x & y positions; wd is the width and ht is the height; These four arguments describe a rectangle just large enough to encompass the head.
 
Method Summary
 void draw(java.awt.Graphics gr, boolean fill)
          Instance method; Draws the elephant head described by this instance of Ele in the graphics area described by Graphics gr.
 void eleinit(int xp, int yp, int wd, int ht)
          Instance method; This method is called by the constuctors to create and initialize all the polygons and polylines necessary to draw the elephant head.
static int getAspHt(int width)
          Class method; Static method returning the corresponding height, for the argument width, to keep the elephant head in aspect.
static int getAspWth(int height)
          Class method; Static method returning the corresponding width, for the argument height, to keep the elephant head in aspect.
 int height()
          Instance method; returns the height.
 int startx()
          Instance method; returns the x coordinate.
 int starty()
          Instance method; returns the y coordinate.
 int width()
          Instance method; returns the width.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Ele

public Ele(int xp,
           int yp,
           int wd,
           int ht)
Constructor; xp & yp are the starting x & y positions; wd is the width and ht is the height; These four arguments describe a rectangle just large enough to encompass the head. if wd<1, a width is assigned that will keep the head in aspect to ht (height). if ht<1, a height is assigned that will keep the head in aspect to wd (width). if both wd and ht are less than one, then wd=105 and ht=75.
Parameters:
int - xp; starting x coordinate.
int - yp; starting y coordinate.
int - wd; width of elephant head.
int - ht; height of elephant head.

Ele

public Ele()
Default constructor; Creates an Ele instance with starting x & y at 0,0; width=105 and height=75.
Method Detail

startx

public int startx()
Instance method; returns the x coordinate.
Returns:
the starting x position.

starty

public int starty()
Instance method; returns the y coordinate.
Returns:
the starting y position.

width

public int width()
Instance method; returns the width.
Returns:
the width.

height

public int height()
Instance method; returns the height.
Returns:
the height.

getAspWth

public static int getAspWth(int height)
Class method; Static method returning the corresponding width, for the argument height, to keep the elephant head in aspect. Example:
int width = 0, height = 70;
Ele e;
while(width<100)
{
width = Ele.getAspWth(height);
height += 1;
}
height -= 1;
e = new Ele(0,0,width,height);
Ele.getAspWth(5); will return 7.
Parameters:
int - height; a height to test.
Returns:
int width; a width in aspect to the height.

getAspHt

public static int getAspHt(int width)
Class method; Static method returning the corresponding height, for the argument width, to keep the elephant head in aspect. Example:
int width = 200, height = 0;
Ele e;
while(height<150)
{
height = Ele.getAspWth(width);
width += 1;
}
width -= 1;
e = new Ele(0,0,width,height);
Ele.getAspHt(7); will return 5.
Parameters:
int - width; a width to test.
Returns:
int height; a height in aspect to the height.

eleinit

public void eleinit(int xp,
                    int yp,
                    int wd,
                    int ht)
Instance method; This method is called by the constuctors to create and initialize all the polygons and polylines necessary to draw the elephant head.

draw

public void draw(java.awt.Graphics gr,
                 boolean fill)
Instance method; Draws the elephant head described by this instance of Ele in the graphics area described by Graphics gr. If fill is false just the outline will be drawn, otherwise the head is drawn filled with lightGray and tusks are filled with white. In the future there may be color choices added.
Parameters:
Graphics - gr; Graphics object of area to draw the elephant head.
boolean - fill; If true a filled lightGray head is drawn; If false just the outline is drawn.