Skip to Main Content
Class Plane

Class Plane

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----Plane

public class Plane
extends Canvas
A class that represents a basic graphical picture of a portion of some plane, with axes and tickmarks, if so desired.


Variable Index

 o corner
The abstract coordinates of the upper-left corner of the visible window.
 o draw_axes
Should we draw the axes on this plane.
 o LOGOFTEN
Log of ten, used in making tickmarks.
 o prefsize
The width and height, in pixels, of the visible window.
 o reset
The original corner coordinates, width and height, in abstract units, of the visible window, to be used when we wish to reset.
 o show_xticks
Should we draw tickmarks on the x-border of the visible window.
 o size
The width and height, in abstract coordinates, of the visible window.

Constructor Index

 o Plane(double, double, double, double, int, int)
Constructor for Planes.

Method Index

 o abstractToPixels(double, double)
Convert abstract coordinates to pixels in this Plane's window.
 o drawTickmarks(Graphics)
Draws tickmarks on the lower and left edges of this's visible window; lower edge tickmarks only drawn if show_xticks is true.
 o paint(Graphics)
Paint this Plane.
 o pixelsToAbstract(int, int)
Convert pixel coordinates to abstract in this Plane's window.
 o preferredSize()
Gives the preferred size, at which this Plane was created.
 o reset()
Resets the UL corner of this plane and its width and height to be as when first created (in abstract units), then repaints.
 o toString()
Makes a string containing the ranges of coordinates, in abstract units, that are currently visible in this Plane; only shows the y range if show_xticks is false.

Variables

 o corner
 public double corner[]
The abstract coordinates of the upper-left corner of the visible window.

 o size
 public double size[]
The width and height, in abstract coordinates, of the visible window.

 o prefsize
 public int prefsize[]
The width and height, in pixels, of the visible window.

 o reset
 protected double reset[]
The original corner coordinates, width and height, in abstract units, of the visible window, to be used when we wish to reset.

 o draw_axes
 public boolean draw_axes
Should we draw the axes on this plane.

 o show_xticks
 public boolean show_xticks
Should we draw tickmarks on the x-border of the visible window.

 o LOGOFTEN
 public static final double LOGOFTEN
Log of ten, used in making tickmarks.

Constructors

 o Plane
 public Plane(double cx,
              double cy,
              double sx,
              double sy,
              int x,
              int y)
Constructor for Planes.

Parameters:
cx - the abstract coordinates of the left side of the visble window
cy - the abstract coordinates of the top edge of the visble window
sx - the width of the visible window, in abstract units
sy - the height of the visible window, in abstract units
x - the width of the window in pixels
y - the height of the window in pixels

Methods

 o drawTickmarks
 public void drawTickmarks(Graphics g)
Draws tickmarks on the lower and left edges of this's visible window; lower edge tickmarks only drawn if show_xticks is true.

Parameters:
g - the graphics object upon which to draw
 o paint
 public void paint(Graphics g)
Paint this Plane.

Parameters:
g - the graphics object upon which to paint
Overrides:
paint in class Canvas
 o preferredSize
 public Dimension preferredSize()
Gives the preferred size, at which this Plane was created.

Returns:
a Dimension of the Plane's original size, in pixels.
Overrides:
preferredSize in class Component
 o reset
 public void reset()
Resets the UL corner of this plane and its width and height to be as when first created (in abstract units), then repaints.

 o toString
 public String toString()
Makes a string containing the ranges of coordinates, in abstract units, that are currently visible in this Plane; only shows the y range if show_xticks is false.

Returns:
the String showing this Plane's abstract dimensions
Overrides:
toString in class Component
 o pixelsToAbstract
 public double[] pixelsToAbstract(int x,
                                  int y)
Convert pixel coordinates to abstract in this Plane's window.

Parameters:
x - an input x coordinate, in pixels
y - an input y coordinate, in pixels
Returns:
an array of two doubles telling the corresponding x and y abstract coordinates
 o abstractToPixels
 public int[] abstractToPixels(double x,
                               double y)
Convert abstract coordinates to pixels in this Plane's window.

Parameters:
x - an input x coordinate, in abstract units
y - an input y coordinate, in abstract units
Returns:
an array of two ints telling the corresponding x and y pixel coordinates