com.googlecode.blaisemath.graphics.core.package.html Maven / Gradle / Ivy
Show all versions of blaise-graphics Show documentation
com.googlecode.blaisemath.graphics package
Provides components for building trees of graphics that can be rendered
on a target canvas. The graphics API includes support for several
interactive capabilities, including custom styles, tooltips, selection,
highlighting, and context menus.
This package contains the core definitions of
{@code Graphic} and {@code GraphicComposite}, along with several
implementations of graphics and supporting capabilities. The {@code swing}
package contains the logic for rendering graphic trees on a target canvas.
Overview
The Graphics Component and the Graphics Tree
{@link com.googlecode.blaisemath.graphics.swing.JGraphicComponent} is the top-level swing component,
and works primarily with two classes:
a {@link com.googlecode.blaisemath.graphics.GraphicRoot} and a {@link org.blaise.style.StyleContext}.
As might be expected, the first is responsible for storing the shapes and the
second for drawing the shapes. However, the shapes stored in the {@code GraphicRoot}
may also provide their own style information.
Shapes within the {@code GraphicRoot} are stored as
{@link com.googlecode.blaisemath.graphics.Graphic}s, comprised of:
- the graphic object and a means to draw it (in the form of a {@code contains} method and a {@code draw} method),
- a parent for that shape, and
- a tooltip for the shape (parametrized by point),
- a mouse listener for the shape (parametrized by point),
- visibility status ({@link org.blaise.style.VisibilityHint}).
The {@link com.googlecode.blaisemath.graphics.GraphicRoot} maintains the shapes that are to be drawn, including both
the shapes themselves and the order in which they are drawn. This object also listens to
mouse events from the {@link com.googlecode.blaisemath.graphics.GraphicComponent}, which it passes along as a
{@link com.googlecode.blaisemath.graphics.GraphicMouseEvent} to the top-most {@link com.googlecode.blaisemath.graphics.Graphic}
(in terms of draw order) whose parent is a {@link com.googlecode.blaisemath.graphics.GraphicMouseListener}.
Specific Graphics
Implementing {@link com.googlecode.blaisemath.graphics.Graphic} should be straightforward.
{@link com.googlecode.blaisemath.graphics.GraphicSupport} contains much of the code
required, apart from the {@code draw} and {@code contains} methods.
{@link com.googlecode.blaisemath.graphics.GraphicComposite} groups together several
{@code Graphic}s, and also has an overridable {@link org.blaise.style.StyleContext},
which can be used to set a default style for its constituents.
{@code Graphic}s are typically implemented in one of two ways: either with
concrete styles, or with styles that are chosen/generated as the
object is drawn, depending on a "source object". The first are labeled
by "{@code Basic}" and the second by "{@code Delegating}".
Within the package, a few specific {@code Graphic}s
are implemented, as described in the table below:
Class Name
Description
{@link com.googlecode.blaisemath.graphics.BasicPointGraphic}
A draggable point, rendered by a {@link org.blaise.style.PointStyle}
{@link com.googlecode.blaisemath.graphics.BasicPointSetGraphic}
Several points, rendered by a common {@link org.blaise.style.PointStyle}
{@link com.googlecode.blaisemath.graphics.BasicShapeGraphic}
An arbitrary shape or path, rendered by a common
{@link org.blaise.style.ShapeStyle} or
{@link org.blaise.style.PathStyle}
{@link com.googlecode.blaisemath.graphics.BasicStringGraphic}
A string located at a point on the graphics canvas, rendered by a
{@link org.blaise.style.StringStyle}
{@link com.googlecode.blaisemath.graphics.CustomPointSetGraphic}
Several points, with references to source objects, rendered
by a {@link org.blaise.style.PointStyle} delegate.
Interfaces
Extensible interfaces and abstract classes in the {@code com.googlecode.blaisemath.graphics} package are:
- {@link com.googlecode.blaisemath.graphics.Graphic} - core graphic object
- {@link com.googlecode.blaisemath.graphics.GraphicSupport} - partial implementation of {@code Graphic} with common functionality
- {@link com.googlecode.blaisemath.graphics.CanvasPainter} - more general object that paints on a canvas
- {@link com.googlecode.blaisemath.graphics.ContextMenuInitializer} - general way to populate a {@link javax.swing.JPopupMenu} given a "focus" object and a "selection" of objects
- {@link com.googlecode.blaisemath.graphics.AbstractPointGraphic}
- {@link com.googlecode.blaisemath.graphics.AbstractShapeGraphic}
- {@link com.googlecode.blaisemath.graphics.AbstractGraphicDragger} - make it easier to interpret drag gestures/events on graphic objects