All Packages  This Package  Class Hierarchy  Class Search  Index

Class Bignose
java.lang.Object
   |
   +----Bignose

  Summary

public class  Bignose
     extends java.lang.Object
{
          // Fields 6
     private Color faceColour;
     private Color hairColour;
     private int xOrigin;
     private static final int[][] xPoints;
     private int yOrigin;
     private static final int[][] yPoints;

          // Constructors 2
     public Bignose();
     public Bignose(int, int);

          // Methods 4
     public Point getLocation();
     public Dimension getSize();
     public void paint(Graphics);
     public void setColours(Color, Color);
}

A demonstration of the use of a class.

Creates a new Class that extends the Java Object. This means that we will inherit various data and methods from this class. This class just encapsulates the data and painting attributes for a big Nose. It also has a setColours method to set the drawing colours of the upper and lower parts of the Face.

This is an addition to the fourth Java example about Colour capabilities.

This class paints an image via its paint method:

Author:
© Andrew Marriott. , Curtin University of Technology 1998




  Fields

· xPoints

Summary  |  Top

   private static final int[][] xPoints

Integer array of array of constants which are used to hold the x coordinates of the bignose image. Note that these arrays are now constants and not variables - this is possible in Java.

The final keyword makes them constants.

The static keyword makes them class constants - that is one copy for all instances of the Bignose class.

Each (x,y) array of values corresponds to a line on the screen.


· yPoints

Summary  |  Top
   private static final int[][] yPoints

Integer array of array of constants which are used to hold the y coordinates of the bignose image. Note that these arrays are now constants and not variables - this is possible in Java.

The final keyword makes them constants.

The static keyword makes them class constants - that is one copy for all instances of the Bignose class.

Each (x,y) array of values corresponds to a line on the screen.


· xOrigin

Summary  |  Top
   private int xOrigin

The default x origin used to draw the face.

Different instances of a Bignose can have different origins. Different origins may only be set via the Bignose(int x, int y) constructor.

See Also: Bignose


· yOrigin

Summary  |  Top
   private int yOrigin

The default y origin used to draw the face.

Different instances of a Bignose can have different origins. Different origins may only be set via the Bignose(int x, int y) constructor.

See Also: Bignose


· faceColour

Summary  |  Top
   private Color faceColour

The default colour used to draw the lower part of the face.

Different instances of a Bignose can have different colours. The different colours can only be set via the setColours method.

See Also: Color, setColours


· hairColour

Summary  |  Top
   private Color hairColour

The default colour used to draw the hair part of the face.

Different instances of a Bignose can have different colours. The different colours can only be set via the setColours method.

See Also: Color, setColours


  Constructors

· Bignose

Summary  |  Top

   public Bignose() 

No parameter constructor will position face at (0,0).



· Bignose

Summary  |  Top
   public Bignose(int x, 
                  int y) 

Two parameter constructor will position face at (x,y).

Parameter Description
x the x coordinate of the base of the face.
y the y coordinate of the base of the face.



  Methods

· getLocation

Summary  |  Top
   public Point getLocation() 

Returns the x and y base of the Bignose.

See Also: Point



· getSize

Summary  |  Top
   public Dimension getSize() 

Returns the width and height of the Bignose.

See Also: Dimension



· setColours

Summary  |  Top
   public void setColours(Color face, 
                          Color hair) 

Our setColours method will set appropriate drawing colours to use to draw the lower face part of the bignose and for the hair.

Parameter Description
face the colour of the lower part of the face.
hair the colour of the hair.

See Also: Color



· paint

Summary  |  Top
   public void paint(Graphics graphics) 

Our paint method will set an appropriate drawing colour to draw the lower face part of the bignose and then as appropriate set another drawing colour for the hair.

The new polyline (x,y) arrays are created on the fly from the defining points arrays and have the (xOrigin,yOrigin) added to them.

Parameter Description
graphics The graphics of the drawable surface.

See Also: Graphics, setColor, drawPolyline



All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7