The API consists of classes Picture, Zone, GT, Mat2D in the com.ludens.api package.
import java.applet.*; import java.awt.*; import com.ludens.api.*; public class MontageAPIDemo extends Applet { Picture picture; public void init() { picture = new Picture(this, "demo.teq"); } public void paint(Graphics g) { picture.draw(g); } }
In order to compile and run this example need to install a copy of the MONTAGE API classes in the same directory where you are placing your source code. You can get a copy of the API classes by typing GetAPI at the operating system's command prompt.
Picture(Component parent, String name)parent is the java.awt.component where the picture will be drawn.
Picture(Component parent, String name, int width, int height)parent is the java.awt.component where the picture will be drawn.
Picture(InputStream is, Component parent, String name)The picture is read from the java.io.InputStream is.
Picture(InputStream is, Component parent, String name, int width, int height)The picture is read from the java.io.InputStream is.
final static int EXACT_MATCH;Used in Zone lookups to indicate that the search pattern must be identical to the number stored in the flags instance variable for a match to occur.
final static int PROP_MATCH;Used in Zone lookups to indicate that at least one of the bits that are set in the search pattern must also be set in the flags instance variable for a match to occur.
int width;The width of the picture in pixels.
int height;The height of the picture in pixels.
Color backgroundColor;The background color for the picture.
static Picture[] getPictures(Component parent, String name)Reads a multi-picture file.
static Picture[] getPictures(Component parent, String name, int width, int height)Reads a multi-picture file.
static Picture[] getPictures(InputStream is, Component parent, String name)Reads a multi-picture file.
static Picture[] getPictures(InputStream is, Component parent, String name, int width, int height)Reads a multi-picture file.
void draw(Graphics g)Draw the picture using java.awt.Graphics g.
void draw(Graphics g, int x, int y)Draw the picture using java.awt.Graphics g.
void draw(GT gt)Draw the picture transformed by GT gt.
Zone contains(int x, int y)Returns the topmost Zone under coordinates x, y (relative to top left corner of the picture) or null if there isn't a Zone at that location.
Zone getZone(String label)Returns the topmost Zone labelled label or null if there isn't any Zone with that label.
Enumeration getAllZones()Returns a java.util.Enumeration with all the Zones in the picture.
int zoneCount()Returns the number of Zones in the picture.
Zone contains(int x, int y, int pattern, int matchType)Returns the topmost Zone under coordinates x, y (relative to top left corner of the picture) that satisfies the search criteria or null if there isn't a Zone that satisfies the search criteria at that location.
Zone getZone(String label, int pattern, int matchType)Returns the topmost Zone labelled label that satisfies the search criteria or null if there isn't any Zone with that label that satisfies the search criteria.
Zone getZone(int pattern, int matchType)Returns the topmost Zone that satisfies the search criteria or null if there isn't any Zone that satisfies the search criteria.
Enumeration getAllZones(int pattern, int matchType)Returns a java.util.Enumeration with all the Zones in the picture that satisfy the search criteria.
int zoneCount(int pattern, int matchType)Returns the number of Zones in the picture that satisfy the search criteria.
int x;The horizontal position of the upper left corner of the zone (relative to the upper left corner of the Picture that contains it).
int y;The vertical position of the upper left corner of the zone (relative to the upper left corner of the Picture that contains it).
int width;The horizontal size of the zone.
int height;The vertical size of the zone.
String label;The zone's label.
int flags;Only the 16 least significant bits of flags are used.
float tx;X coordinate of a 2D point after applying the sequence of 2D transformations.
float ty;Y coordinate of a 2D point after applying the sequence of 2D transformations.
Object clone()Returns a copy of the Mat2D instance.
void translate(float xTrans, float yTrans)Prepends a translation to the sequence of 2D transformations.
void scale(float xScale, float yScale)Prepends a change of scale, relative to (0, 0), to the sequence of 2D transformations.
void rotate(int angle)Prepends a rotation, around (0, 0), to the sequence of 2D transformations.
void transform(float x, float y)Applies the sequence of 2D transformations to a point (x, y). The coordinates for the transformed point can be fetched from tx, ty.
GT(Graphics g)g is the graphics context used to draw the lines and polygons.
Graphics g;g is the graphics context used to draw the lines and polygons.
Mat2D matrix;matrix is the current transformation matrix.
void pushMatrix()Pushes a copy of the current transformation matrix on top of the transformations stack.
void popMatrix()Pops the top of the tranformations stack and uses it to replace the current transformation matrix.
void vertexStart()Starts a new list of transformed vertices.
void fillPolygon()Uses the current list of transformed vertices to fill a polygon.
void drawPolygon()Uses the current list of transformed vertices to draw a polygon.
void drawLine()Uses the current list of transformed vertices to draw a line.
void addVertex(float x, float y)Transforms the point (x, y) and adds it to the transformed vertices list.