org.mbari.siam.moos.utils.chart.graph
Class Markers

java.lang.Object
  extended by org.mbari.siam.moos.utils.chart.graph.Markers

public class Markers
extends java.lang.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.2 $, $Date: 2011/08/17 19:09:20 $
Author:
Leigh Brookshaw

Field Summary
protected  int last
          index of the last marker loaded
protected  int max
          maximum number of markers allowed
protected  java.util.Vector[] vert
          An array of vectors.
 
Constructor Summary
Markers()
          The class contructor
Markers(java.net.URL file)
          Instantiate the Marker class and load marker definitions from the parsed URL.
 
Method Summary
 void AddMarker(int n, boolean[] draw, int[] x, int[] y)
          Add the definition of a new marker.
 void AddMarker(int m, int n, boolean[] draw, int[] x, int[] y)
          Add the definition of a new marker.
 void ClearMarkers()
          Clear All markers.
 void DeleteMarker(int n)
          Delete the marker with the given index.
 void draw(java.awt.Graphics g, int m, double scale, int x, int y)
          draw the marker
 void LoadMarkers(java.net.URL file)
          This method reads the marker file and loads the marker definitions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

last

protected int last
index of the last marker loaded


max

protected int max
maximum number of markers allowed


vert

protected java.util.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].

Constructor Detail

Markers

public Markers()
The class contructor


Markers

public Markers(java.net.URL file)
        throws java.io.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 org/mbari/siam/moos/utils/chart/html/marker.txt.

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

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.
y - 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(java.net.URL file)
                 throws java.io.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:
java.io.IOException - If there is an IO error

draw

public void draw(java.awt.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


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.