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
-
last
- index of the last marker loaded
-
max
- maximum number of markers allowed
-
vert
- An array of vectors.
-
Markers()
- The class contructor
-
Markers(URL)
- Instantiate the Marker class and load marker definitions from the parsed URL.
-
AddMarker(int, boolean[], int[], int[])
- Add the definition of a new marker.
-
AddMarker(int, int, boolean[], int[], int[])
- Add the definition of a new marker.
-
ClearMarkers()
- Clear All markers.
-
DeleteMarker(int)
- Delete the marker with the given index.
-
draw(Graphics, int, double, int, int)
- draw the marker
-
LoadMarkers(URL)
- This method reads the marker file and loads the marker definitions.
last
protected int last
- index of the last marker loaded
max
protected int max
- maximum number of markers allowed
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].
Markers
public Markers()
- The class contructor
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.
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.
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.
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.
ClearMarkers
public void ClearMarkers()
- Clear All markers.
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
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