VisDraw is an interactive drawing tool written using the VisTech
Interactive Graphics Toolkit (VIGT). It is currently in beta. Download and
send your comments and bug report to larryhr2004@yahoo.com.
It is a class library consisting
of a number of graphics related packages.
The Shapes Library consists
of serializable classes that enable interactive drawing of graphical
shapes. Classes that represent shapes in Java 2D are not serializable. To
write programs using Java 2D to manipulate shapes interactively requires a lot
of effort. The VisTech shapes library is written on top of Java 2D to make
this job simpler.
Each shape is a serializable bean, which can be created programmatically or
using an authoring tool like VisDraw. Because the shapes are beans, they
can be saved once their properties are set and retrieved for later use.
Shapes currently supported include;
The shapes library has a class for each shape. You can choose to buy the shapes
you need.
Each shape provides the following functionality:
·
Draw interactive
Draws the shapes interactively on
a drawing canvas.
·
Deposit
Deposits the shape on the drawing
canvas. Once a shape is deposited, it can not be manipulated. This is quite
useful in image processing applications. For example, you can
define an ROI (Region of Interest) shapes interactively, and once you get
the exact shape, deposit it over the image.
·
Move
Moves the shape interactively, i.e.,
erases the currently drawn shape and moves it to a new location.
·
Resize
Resizes the shapes interactively.
Resizing depends on the shape. Rectangle has eight resizing points where as
line has two. In case of ploy lines, number of resizing points equal to number
of segments +1. In the case of cubic curve, each segment has four resize
points.
·
Erase
Erases the shape from the drawing
canvas. Erasing does not destroy the shape.
Here is a simple example that shows how to create a shape:
// Construct an Ellipse
// GenericShape is an
interface that specifies the functionality described above and much more.
GenericShape shape =
ShapeFactory.createShape("com.vistech.shapes.Ellipse");
// Construct a component
to draw graphics.
// GraphicsCanvas2D is a class
in the com.vistech.graphics package
GraphicsCanvas2D
grCanvas = new GraphicsCanvas2D();
// Obtain its current graphics
context
Graphics2D g =
grCanvas.getCurrentGraphicsContext();
In the
mousePressed() method
public void
mousePressed(int x,int y) {
shape.init(x,y);
}
In the mouseDragged()
method
public void
mouseDragged(int x, int y) {
shape.setCurrentPosition(x,y);
shape.drawInteractive(g);
}
This is a sub class of JComponent
and comes with two graphics contexts. Each graphics context is a graphics
layer over which shapes are drawn. The two two graphics contexts are:
1. Base Graphics Context
This is the base graphics context. In a typical imaging
example, you draw the image on this context.
2. Current Graphics Context
This is a graphics context that is typically used for
manipulating the graphics objects. Once manipulated, a graphics object
can be deposited over the base graphics context.
Both the graphics contexts can be created and cleared by the clients.
The interactive library consists
of a number of class that support interactive drawing. You need
these classes to build an interactive application.
The
architecture of the interactive library is based on the MVC philosophy.
Fundamental to this architecture is the notion of a Graphics Container,
which is an abstract layer in which a graphical objects reside. Each graphical
object is a GenericShape. The Graphics Container extracts the shapes from the
GraphicsContainerModel. The ViewController object manipulates the graphical
objects. The GraphicsView object displays them.
The Model represents data, which
in this case is made up of graphical objects. The GraphicsContainerModel
is the interface that specifies the methods of this model. The functions
provided by this interface include adding objects to and removing objects from
the graphics container
The View represents the display.
The GraphicsView interface defines the view. The GraphicsCanvas2D class
implements this interface. The controller will manipulate the
object and display the results in the View.
The Controller controls the
container, i.e., manipulates the objects in the container. The
controller recieves inputs from input events, such as mouse and key. The
ViewContoller interface specifies the methods needed to implement the
controller.
The ViewController object executes commands and operations. For example in the
case of drawing a rectangle, the command is DRAW, and operation is single
-stroke, i.e., start, drag, end.&nbssp; To execute a command, the
ViewController object extracts the data from the GraphicsContainer, manipulates
it and then displays it on the GraphicsView. It also saves the modified object
in the ContainerModel.
The
interactive class library supports single stroke and multi stroke drawing. In
the single stroke drawing, the shape darwing is completed in one stroke.
An example of single stroke drawing is the drawing of a rectangle. In this
case, you would typically click the mouse and drag. This means that the darwing
is completed in one mouse click.
In the multiple-stroke drawing , the shape drawing is completed in one or more
strokess. An example of multi-stroke drawing is the drawing of a polygon with
multiple segments. In this case, you would typically click the mouse and drag
to draw a segment. This means that you would need multiple mouse clicks to draw
a shape.
The graphics library is designed in such as way it is independent of type
of input events, i.e., mouse, key etc. Input events can be mapped to a
neutral interface called DrawingPolicy which defines the drawing policy. A
number of classes that implement the DrawingPolicy, whcih icnclude:
1. ShapeOperation
Implements the single-stroke operation
2. PolyShapeOperation
Implements the multi-stroke operation.
3. TextOperation
Implements the text drawing
4. GroupSelectOperation
Implements the operation that selects a group of
shapes.
The
Interactive Graphics Engine constructs and assembles model, view and controller
objects. The Graphics Engine class shields the programmer from complexities of
the interactive operations. It is an front end to accept the inputs from the
mouse, key and other GUI events. If you build a GUI around
interactive graphics library, you can use the Graphics Engine to communicate
with the Controller.
The VisTech Image Viewer is a Java application that lets you load, view, manipulate, and save images. It uses the latest Java 2D and the Image IO APIs. It is currently in beta. To download, click here.
The features include:
The basic Java supports JPEG, GIF and PNG formats. However, you can install plugins to load any image formats
Images can be panned, zoomed
in/out, flipped, and rotated. You can perform image manipulation operations in
any order without the image being reset to the original state. For example, pan the image to desirable position, zoom out at that point, then rotate it.
If you
are interested in these products, please send email to larryhr2004@yahoo.com
Home