All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class graph.Markers

java.lang.Object
   |
   +----graph.Markers

public class Markers
extends Object
This class installs, manipulates and draws markers. Markers are stroked using the line drawing method of the class Graph. This means that any stroked figure can become a marker.

Version:
$Revision: 1.8 $, $Date: 1996/09/20 00:02:57 $
Author:
Leigh Brookshaw

Variable Index

 o last
index of the last marker loaded
 o max
maximum number of markers allowed
 o vert
An array of vectors.

Constructor Index

 o Markers()
The class contructor
 o Markers(URL)
Instantiate the Marker class and load marker definitions from the parsed URL.

Method Index

 o AddMarker(int, boolean[], int[], int[])
Add the definition of a new marker.
 o AddMarker(int, int, boolean[], int[], int[])
Add the definition of a new marker.
 o ClearMarkers()
Clear All markers.
 o DeleteMarker(int)
Delete the marker with the given index.
 o draw(Graphics, int, double, int, int)
draw the marker
 o LoadMarkers(URL)
This method reads the marker file and loads the marker definitions.

Variables

 o last
 protected int last
index of the last marker loaded

 o max
 protected int max
maximum number of markers allowed

 o vert
 protected Vector vert[]
An array of vectors. Each element in the array contains the vertex vectors for a marker. Marker 1 is at element vert[0].

Constructors

 o Markers
 public Markers()
The class contructor

 o Markers
 public Markers(URL file) throws IOException
Instantiate the Marker class and load marker definitions from the parsed URL. The format of the file is easily worked out from the default marker file marker.txt.

Parameters:
file - The URL of the data file to read
Throws: IOException
if there is an error with the IO stream.

Methods

 o AddMarker
 public void AddMarker(int m,
                       int n,
                       boolean draw[],
                       int x[],
                       int y[])
Add the definition of a new marker. The arrays contain the vertex points of the marker. The boolean array is used to define a relative draw or move to the vertex. The first vertex should always be a move (The boolean array is "true" for a relative draw.

Parameters:
m - The index of the marker. The first marker has index 1.
n - The number of vertices required to stroke the marker.
draw - Boolean array containing relative move/draw instructions. "true" is a draw.
x - Integer array containing the pixel x position of the vertices. All positions are relative to the center of the marker.
y - Integer array containing the pixel y postions of the vertices.
 o AddMarker
 public void AddMarker(int n,
                       boolean draw[],
                       int x[],
                       int y[])
Add the definition of a new marker. The new marker is appended onto the marker list. The center of the marker is assumed to be at (0,0).

Parameters:
n - number of move/draw commands
draw - true if the point is to drawn to, false if the point is to be moved to.
x - X pixel to move/draw to.
x - Y pixel to move/draw to.
 o DeleteMarker
 public void DeleteMarker(int n)
Delete the marker with the given index. the first marker has index 1.

Parameters:
n - The index of the marker to delete. Markers start at index 1.
 o ClearMarkers
 public void ClearMarkers()
Clear All markers.

 o LoadMarkers
 public void LoadMarkers(URL file) throws IOException
This method reads the marker file and loads the marker definitions. The format of the file is simple. The following are the keywords.
start
starts a new marker definition.
end
ends a marker definition.
m x y
move to position x,y
l x y
line to position x,y
All line drawing is relative to the previous position. The center of the marker is assumed to be at (0,0). As always blank lines are ignored and comments begin with a # character.

Parameters:
file - URL of file to load
Throws: IOException
If there is an IO error
 o draw
 public void draw(Graphics g,
                  int m,
                  double scale,
                  int x,
                  int y)
draw the marker

Parameters:
g - Graphics context
m - Index of the marker to draw
scale - scale factor. All coordinates are multiplied by this factor.
x - Coordinate where to draw the marker
y - Coordinate where to draw the marker

All Packages  Class Hierarchy  This Package  Previous  Next  Index