edu.neu.ccs.gui
Class PlotMarkAlgorithm

java.lang.Object
  extended byedu.neu.ccs.gui.PlotMarkAlgorithm

public abstract class PlotMarkAlgorithm
extends Object

Class PlotMarkAlgorithm defines the requirements for an algorithm that will produce a scalable shape defined in the neighborhood of a given point. This class is intended to be used in constructors for the class PlotMark.

This class provides several static instances of itself.

The following changes were made in 2.6.0:

Since:
2.4.0
Version:
2.6.0

Field Summary
static PlotMarkAlgorithm Asterisk
          The asterisk algorithm.
static PlotMarkAlgorithm BetterCircle
          The better circle algorithm for creation of plot marks.
static PlotMarkAlgorithm BluntWedgeE
          The blunt-wedge-facing-east algorithm.
static PlotMarkAlgorithm BluntWedgeN
          The blunt-wedge-facing-north algorithm.
static PlotMarkAlgorithm BluntWedgeS
          The blunt-wedge-facing-south algorithm.
static PlotMarkAlgorithm BluntWedgeW
          The blunt-wedge-facing-west algorithm.
static PlotMarkAlgorithm Cross
          The cross sign algorithm.
static PlotMarkAlgorithm Diamond
          The diamond algorithm.
static PlotMarkAlgorithm HBar
          The horizontal bar algorithm.
static PlotMarkAlgorithm JavaCircle
          The Java circle algorithm.
static PlotMarkAlgorithm Plus
          The plus sign algorithm.
static PlotMarkAlgorithm SharpWedgeE
          The sharp-wedge-facing-east algorithm.
static PlotMarkAlgorithm SharpWedgeN
          The sharp-wedge-facing-north algorithm.
static PlotMarkAlgorithm SharpWedgeS
          The sharp-wedge-facing-south algorithm.
static PlotMarkAlgorithm SharpWedgeW
          The sharp-wedge-facing-west algorithm.
static PlotMarkAlgorithm Square
          The square algorithm.
static PlotMarkAlgorithm ThumbE
          The thumb-facing-east algorithm.
static PlotMarkAlgorithm ThumbN
          The thumb-facing-north algorithm.
static PlotMarkAlgorithm ThumbS
          The thumb-facing-south algorithm.
static PlotMarkAlgorithm ThumbW
          The thumb-facing-west algorithm.
static PlotMarkAlgorithm VBar
          The vertical bar algorithm.
static PlotMarkAlgorithm WedgeE
          The wedge-facing-east algorithm.
static PlotMarkAlgorithm WedgeN
          The wedge-facing-north algorithm.
static PlotMarkAlgorithm WedgeS
          The wedge-facing-south algorithm.
static PlotMarkAlgorithm WedgeW
          The wedge-facing-west algorithm.
 
Constructor Summary
PlotMarkAlgorithm()
           
 
Method Summary
static Shape BetterCirclePath(int x, int y, int radius)
          Returns a full circle path with the given center (x,y) and the given radius using the method QuarterCircleData for the computation.
abstract  Shape makeShape(double x, double y, int size)
          Returns a shape constructed in the neighborhood of the given point and scaled with the given size.
 Shape makeShape(Point2D p, int size)
          Returns a shape constructed in the neighborhood of the given point and scaled with the given size.
static int[][] QuarterCircleData(int radius)
          Returns the data for construction of a quarter circle path of the given radius.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HBar

public static final PlotMarkAlgorithm HBar

The horizontal bar algorithm.

Produces the line segment path (x-size,y) to (x+size,y).

When used in a PlotMark, the fill setting should be false.


VBar

public static final PlotMarkAlgorithm VBar

The vertical bar algorithm.

Produces the line segment path (x,y-size) to (x,y+size).

When used in a PlotMark, the fill setting should be false.


Plus

public static final PlotMarkAlgorithm Plus

The plus sign algorithm.

Produces the combined path with 2 line segments:

When used in a PlotMark, the fill setting should be false.


Cross

public static final PlotMarkAlgorithm Cross

The cross sign algorithm.

Produces the combined path with 2 line segments:

When used in a PlotMark, the fill setting should be false.


Asterisk

public static final PlotMarkAlgorithm Asterisk

The asterisk algorithm.

Produces the combined path with 4 line segments:

When used in a PlotMark, the fill setting should be false.


Square

public static final PlotMarkAlgorithm Square

The square algorithm.

Returns new XSquare(x, y, size).


Diamond

public static final PlotMarkAlgorithm Diamond

The diamond algorithm.

Produces the closed path with 4 vertices:


BetterCircle

public static PlotMarkAlgorithm BetterCircle

The better circle algorithm for creation of plot marks.

Uses the method BetterCirclePath which is in turn based on the method QuarterCircleData. The path produced has 8-fold symmetry about the horizontal, vertical, and two diagonal axes. Its appearance for small values of size is much better than that given by Java's algorithm.

On the other hand, for large values of size, this algorithm is more computationally intensive than the JavaCircle technique.

If size > 16384, this algorithm will revert to the JavaCircle algorithm.


JavaCircle

public static final PlotMarkAlgorithm JavaCircle

The Java circle algorithm.

Returns:

    new XCircle(x, y, size)

This is equivalent to the pure Java call:

    new Ellipse2D.Double(x-size, y-size, 2*size, 2*size)

Warning: For small values of size, the circle constructed by Java does not have 8-fold symmetry about the horizontal, vertical, and two diagonal axes. The circle is therefore not very pleasing aesthetically.

See BetterCircle.


WedgeN

public static final PlotMarkAlgorithm WedgeN

The wedge-facing-north algorithm.

Produces the closed path with 3 vertices:


WedgeE

public static final PlotMarkAlgorithm WedgeE

The wedge-facing-east algorithm.

Produces the closed path with 3 vertices:


WedgeS

public static final PlotMarkAlgorithm WedgeS

The wedge-facing-south algorithm.

Produces the closed path with 3 vertices:


WedgeW

public static final PlotMarkAlgorithm WedgeW

The wedge-facing-west algorithm.

Produces the closed path with 3 vertices:


BluntWedgeN

public static final PlotMarkAlgorithm BluntWedgeN

The blunt-wedge-facing-north algorithm.

Produces the closed path with 3 vertices:


BluntWedgeE

public static final PlotMarkAlgorithm BluntWedgeE

The blunt-wedge-facing-east algorithm.

Produces the closed path with 3 vertices:


BluntWedgeS

public static final PlotMarkAlgorithm BluntWedgeS

The blunt-wedge-facing-south algorithm.

Produces the closed path with 3 vertices:


BluntWedgeW

public static final PlotMarkAlgorithm BluntWedgeW

The blunt-wedge-facing-west algorithm.

Produces the closed path with 3 vertices:


SharpWedgeN

public static final PlotMarkAlgorithm SharpWedgeN

The sharp-wedge-facing-north algorithm.

Produces the closed path with 3 vertices:


SharpWedgeE

public static final PlotMarkAlgorithm SharpWedgeE

The sharp-wedge-facing-east algorithm.

Produces the closed path with 3 vertices:


SharpWedgeS

public static final PlotMarkAlgorithm SharpWedgeS

The sharp-wedge-facing-south algorithm.

Produces the closed path with 3 vertices:


SharpWedgeW

public static final PlotMarkAlgorithm SharpWedgeW

The sharp-wedge-facing-west algorithm.

Produces the closed path with 3 vertices:


ThumbN

public static final PlotMarkAlgorithm ThumbN

The thumb-facing-north algorithm.

Produces the closed path with 5 vertices:


ThumbE

public static final PlotMarkAlgorithm ThumbE

The thumb-facing-east algorithm.

Produces the closed path with 5 vertices:


ThumbS

public static final PlotMarkAlgorithm ThumbS

The thumb-facing-south algorithm.

Produces the closed path with 5 vertices:


ThumbW

public static final PlotMarkAlgorithm ThumbW

The thumb-facing-west algorithm.

Produces the closed path with 5 vertices:

Constructor Detail

PlotMarkAlgorithm

public PlotMarkAlgorithm()
Method Detail

makeShape

public final Shape makeShape(Point2D p,
                             int size)

Returns a shape constructed in the neighborhood of the given point and scaled with the given size.

If the given point is null, returns an empty shape.

Otherwise calls makeShape(double, double, int).

Parameters:
p - the point defining where to place the shape
size - the scale size

makeShape

public abstract Shape makeShape(double x,
                                double y,
                                int size)

Returns a shape constructed in the neighborhood of the given point and scaled with the given size.

When defined this method may return an empty shape but should not return null.

The scale size should be forced to at least 0 before building the shape.

Parameters:
x - the x-coordinate of the point defining where to place the shape
y - the y-coordinate of the point defining where to place the shape
size - the scale size

QuarterCircleData

public static int[][] QuarterCircleData(int radius)

Returns the data for construction of a quarter circle path of the given radius.

Assume that the int[][] returned has the name data. Then data is normally of size 2. Let:

    int[] xx = data[0];
    int[] yy = data[1];

Then, the array xx contains the x-coordinates of desired data points and the array yy the corresponding y-coordinates. In particular, the arrays have the same length, say, k. The ends of the arrays are as follows:

xx[0] equals radius.

yy[0] equals 0.

xx[k-1] equals 0.

yy[k-1] equals radius.

More generally, the data is constructed to include the boundary points (x,y) whose distance from the origin is less than or equal to radius+0.5. A horizontal or vertical run of boundary points is represented by the two endpoints of the run.

The path associated with the quarter circle data is designed to be symmetrical relative to the main diagonal.

Note that:

The latter constraint is due to a desire to do all internal computations in integer arithmetic.

Parameters:
radius - the radius of the desired quarter circle

BetterCirclePath

public static Shape BetterCirclePath(int x,
                                     int y,
                                     int radius)

Returns a full circle path with the given center (x,y) and the given radius using the method QuarterCircleData for the computation. Since that method provides only a quarter of a circle, the remaining path points are generated via symmetry. In particular, 8-fold symmetry about the horizontal, vertical, and two diagonal axes is therefore guaranteed.

If radius > 16384, the method QuarterCircleData cannot be used so this method returns an XCircle-based path instead.

Parameters:
x - the circle x-center
y - the circle y-center
radius - the circle radius