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.
- Author:
- Jonathan A. Poritz
-
corner
- The abstract coordinates of the upper-left corner of the visible window.
-
draw_axes
- Should we draw the axes on this plane.
-
LOGOFTEN
- Log of ten, used in making tickmarks.
-
prefsize
- The width and height, in pixels, of the visible window.
-
reset
- The original corner coordinates, width and height, in abstract units,
of the visible window, to be used when we wish to reset.
-
show_xticks
- Should we draw tickmarks on the x-border of the visible window.
-
size
- The width and height, in abstract coordinates, of the visible window.
-
Plane(double, double, double, double, int, int)
- Constructor for Planes.
-
abstractToPixels(double, double)
- Convert abstract coordinates to pixels in this Plane's window.
-
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.
-
getPreferredSize()
- Gives the preferred size, at which this Plane was created.
-
paint(Graphics)
- Paint this Plane.
-
pixelsToAbstract(int, int)
- Convert pixel coordinates to abstract in this Plane's window.
-
reset()
- Resets the UL corner of this plane and its width and height to be as
when first created (in abstract units), then repaints.
-
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.
corner
public double corner[]
- The abstract coordinates of the upper-left corner of the visible window.
size
public double size[]
- The width and height, in abstract coordinates, of the visible window.
prefsize
public int prefsize[]
- The width and height, in pixels, of the visible window.
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.
draw_axes
public boolean draw_axes
- Should we draw the axes on this plane.
show_xticks
public boolean show_xticks
- Should we draw tickmarks on the x-border of the visible window.
LOGOFTEN
public static final double LOGOFTEN
- Log of ten, used in making tickmarks.
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
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
paint
public void paint(Graphics g)
- Paint this Plane.
- Parameters:
- g - the graphics object upon which to paint
- Overrides:
- paint in class Canvas
getPreferredSize
public Dimension getPreferredSize()
- Gives the preferred size, at which this Plane was created.
- Returns:
- a Dimension of the Plane's original size, in pixels.
- Overrides:
- getPreferredSize in class Component
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.
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
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
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