edu.neu.ccs.gui
Class PlotMark

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

public class PlotMark
extends Object

Class PlotMark is a class for drawing a geometric shape or mark at a specified point in a graphics context or for painting a Paintable at such a point.

In 2.4.0, the class was completely refactored to use the class PlotMarkAlgorithm so that it is possible for the user to define a new plot mark.

In 2.4.0, the alternative to use a Paintable as a mark was also introduced.

When a plot mark is defined via a plot mark algorithm then the paint used for drawing is that determined by the graphics context. When a plot mark is defined by a paintable, then the paintable controls the entire drawing process.

In 2.4.0, it was decided to remove options that would permit a PlotMark to be modified after construction. In other words, a PlotMark is immutable. Instead, there are now constructors available that permit a PlotMark to be fully or partially cloned.

This class provides several static instances of itself. The constant names are chosen to promote compatibility with earlier versions of the class although the actual objects referenced by these constants are quite different.

In 2.6.0, the mark method was changed to always stroke the boundary of a plot mark defined by a plot mark algorithm whether or not the internal fill is set to true. This was done since a pure fill may draw an asymmetric boundary. As a consequence of this decision, a mark has the same boundary whether filled or unfilled. Also, anti-aliasing is turned off when using a plot mark algorithm because that will destroy the desired symmetry.

Also, in 2.6.0, we cache the Shape that corresponds to the internal PlotMarkAlgorithm, the size, and the standard location (0,0). This makes painting a bit faster.

Finally, in 2.6.0, we allow the plot mark size to be as small as 0 to enable the base case for certain plot mark shapes.

Since:
1.0
Version:
2.6.0

Field Summary
private  PlotMarkAlgorithm algorithm
          The plot mark algorithm.
static PlotMark ASTERISK
          The asterisk plot mark.
static PlotMark BLUNT_WEDGE_E
          The blunt-wedge-facing-east plot mark.
static PlotMark BLUNT_WEDGE_N
          The blunt-wedge-facing-north plot mark.
static PlotMark BLUNT_WEDGE_S
          The blunt-wedge-facing-south plot mark.
static PlotMark BLUNT_WEDGE_W
          The blunt-wedge-facing-west plot mark.
static PlotMark CIRCLE
          The circle plot mark.
static PlotMark CROSS
          The cross plot mark.
private static PlotMarkAlgorithm DEFAULT_ALGORITHM
          Default plot mark algorithm: PlotMarkAlgorithm.Square.
private static boolean DEFAULT_FILL
          Default plot mark fill: true.
private static int DEFAULT_SIZE
          Default plot mark size: 3.
static PlotMark DIAMOND
          The diamond plot mark.
private  boolean fill
          The plot mark fill.
static PlotMark FILLED_BLUNT_WEDGE_E
          The filled blunt-wedge-facing-east plot mark.
static PlotMark FILLED_BLUNT_WEDGE_N
          The filled blunt-wedge-facing-north plot mark.
static PlotMark FILLED_BLUNT_WEDGE_S
          The filled blunt-wedge-facing-south plot mark.
static PlotMark FILLED_BLUNT_WEDGE_W
          The filled blunt-wedge-facing-west plot mark.
static PlotMark FILLED_CIRCLE
          The filled circle plot mark.
static PlotMark FILLED_DIAMOND
          The filled diamond plot mark.
static PlotMark FILLED_SHARP_WEDGE_E
          The filled sharp-wedge-facing-east plot mark.
static PlotMark FILLED_SHARP_WEDGE_N
          The filled sharp-wedge-facing-north plot mark.
static PlotMark FILLED_SHARP_WEDGE_S
          The filled sharp-wedge-facing-south plot mark.
static PlotMark FILLED_SHARP_WEDGE_W
          The filled sharp-wedge-facing-west plot mark.
static PlotMark FILLED_SQUARE
          The filled square plot mark.
static PlotMark FILLED_THUMB_E
          The filled thumb-facing-east plot mark.
static PlotMark FILLED_THUMB_N
          The filled thumb-facing-north plot mark.
static PlotMark FILLED_THUMB_S
          The filled thumb-facing-south plot mark.
static PlotMark FILLED_THUMB_W
          The filled thumb-facing-west plot mark.
static PlotMark FILLED_WEDGE_E
          The filled wedge-facing-east plot mark.
static PlotMark FILLED_WEDGE_N
          The filled wedge-facing-north plot mark.
static PlotMark FILLED_WEDGE_S
          The filled wedge-facing-south plot mark.
static PlotMark FILLED_WEDGE_W
          The filled wedge-facing-west plot mark.
static PlotMark H_BAR
          The horizontal bar plot mark.
private  Paintable paintable
          The paintable if used instead of an algorithm.
static PlotMark PLUS
          The plus plot mark.
private  Shape shape
          The plot mark shape.
static PlotMark SHARP_WEDGE_E
          The sharp-wedge-facing-east plot mark.
static PlotMark SHARP_WEDGE_N
          The sharp-wedge-facing-north plot mark.
static PlotMark SHARP_WEDGE_S
          The sharp-wedge-facing-south plot mark.
static PlotMark SHARP_WEDGE_W
          The sharp-wedge-facing-west plot mark.
private  int size
          The plot mark size.
static PlotMark SQUARE
          The square plot mark.
private static Stroke standardStroke
          The standard stroke: BasicStroke(1).
static PlotMark THUMB_E
          The thumb-facing-east plot mark.
static PlotMark THUMB_N
          The thumb-facing-north plot mark.
static PlotMark THUMB_S
          The thumb-facing-south plot mark.
static PlotMark THUMB_W
          The thumb-facing-west plot mark.
static PlotMark V_BAR
          The vertical bar plot mark.
static PlotMark WEDGE_E
          The wedge-facing-east plot mark.
static PlotMark WEDGE_N
          The wedge-facing-north plot mark.
static PlotMark WEDGE_S
          The wedge-facing-south plot mark.
static PlotMark WEDGE_W
          The wedge-facing-west plot mark.
 
Constructor Summary
PlotMark()
          Constructs a plot mark using the defaults.
PlotMark(Paintable paintable)
          Constructs a plot mark using the given paintable.
PlotMark(PlotMark plotmark)
          Constructs a plot mark by cloning the given plot mark.
PlotMark(PlotMarkAlgorithm algorithm)
          Constructs a plot mark using the given algorithm and the defaults listed below.
PlotMark(PlotMarkAlgorithm algorithm, boolean fill)
          Constructs a plot mark using the given algorithm, the given fill setting, and the default listed below.
PlotMark(PlotMarkAlgorithm algorithm, int size)
          Constructs a plot mark using the given algorithm, the given size, and the default listed below.
PlotMark(PlotMarkAlgorithm algorithm, int size, boolean fill)
          Constructs a plot mark using the given algorithm, the given size, and the given fill setting.
PlotMark(PlotMark plotmark, boolean fill)
          Constructs a plot mark using the given plot mark but changing the specified setting.
PlotMark(PlotMark plotmark, int size)
          Constructs a plot mark using the given plot mark but changing the specified setting.
PlotMark(PlotMark plotmark, int size, boolean fill)
          Constructs a plot mark using the given plot mark but changing the specified settings.
 
Method Summary
 PlotMarkAlgorithm getAlgorithm()
          Returns the internal PlotMarkAlgorithm or null if an algorithm is not used.
 boolean getFill()
          Returns the fill setting.
 Paintable getPaintable()
          Returns the internal Paintable or null if a paintable is not used.
 int getSize()
          Returns the size setting.
private  void initializePlotMark(PlotMarkAlgorithm algorithm, int size, boolean fill, Paintable paintable)
          The common initialization code for a plot mark.
 void mark(Graphics g, AffineTransform T, double x, double y)
          Draws, fills, or paints a mark at the plot point which is obtained by applying the transform to the given point.
 void mark(Graphics g, AffineTransform T, Point2D p)
          Draws, fills, or paints a mark at the plot point which is obtained by applying the transform to the given point.
 void mark(Graphics g, double x, double y)
          Draws, fills, or paints a mark at the given plot point.
 void mark(Graphics g, Point2D p)
          Draws, fills, or paints a mark at the given plot point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

H_BAR

public static final PlotMark H_BAR
The horizontal bar plot mark.


V_BAR

public static final PlotMark V_BAR
The vertical bar plot mark.


PLUS

public static final PlotMark PLUS
The plus plot mark.


CROSS

public static final PlotMark CROSS
The cross plot mark.


ASTERISK

public static final PlotMark ASTERISK
The asterisk plot mark.


SQUARE

public static final PlotMark SQUARE
The square plot mark.


DIAMOND

public static final PlotMark DIAMOND
The diamond plot mark.


CIRCLE

public static final PlotMark CIRCLE

The circle plot mark.

See comments in PlotMarkAlgorithm.BetterCircle.


WEDGE_N

public static final PlotMark WEDGE_N
The wedge-facing-north plot mark.


WEDGE_E

public static final PlotMark WEDGE_E
The wedge-facing-east plot mark.


WEDGE_S

public static final PlotMark WEDGE_S
The wedge-facing-south plot mark.


WEDGE_W

public static final PlotMark WEDGE_W
The wedge-facing-west plot mark.


BLUNT_WEDGE_N

public static final PlotMark BLUNT_WEDGE_N
The blunt-wedge-facing-north plot mark.


BLUNT_WEDGE_E

public static final PlotMark BLUNT_WEDGE_E
The blunt-wedge-facing-east plot mark.


BLUNT_WEDGE_S

public static final PlotMark BLUNT_WEDGE_S
The blunt-wedge-facing-south plot mark.


BLUNT_WEDGE_W

public static final PlotMark BLUNT_WEDGE_W
The blunt-wedge-facing-west plot mark.


SHARP_WEDGE_N

public static final PlotMark SHARP_WEDGE_N
The sharp-wedge-facing-north plot mark.


SHARP_WEDGE_E

public static final PlotMark SHARP_WEDGE_E
The sharp-wedge-facing-east plot mark.


SHARP_WEDGE_S

public static final PlotMark SHARP_WEDGE_S
The sharp-wedge-facing-south plot mark.


SHARP_WEDGE_W

public static final PlotMark SHARP_WEDGE_W
The sharp-wedge-facing-west plot mark.


THUMB_N

public static final PlotMark THUMB_N
The thumb-facing-north plot mark.


THUMB_E

public static final PlotMark THUMB_E
The thumb-facing-east plot mark.


THUMB_S

public static final PlotMark THUMB_S
The thumb-facing-south plot mark.


THUMB_W

public static final PlotMark THUMB_W
The thumb-facing-west plot mark.


FILLED_SQUARE

public static final PlotMark FILLED_SQUARE
The filled square plot mark.


FILLED_DIAMOND

public static final PlotMark FILLED_DIAMOND
The filled diamond plot mark.


FILLED_CIRCLE

public static final PlotMark FILLED_CIRCLE

The filled circle plot mark.

See comments in PlotMarkAlgorithm.BetterCircle.


FILLED_WEDGE_N

public static final PlotMark FILLED_WEDGE_N
The filled wedge-facing-north plot mark.


FILLED_WEDGE_E

public static final PlotMark FILLED_WEDGE_E
The filled wedge-facing-east plot mark.


FILLED_WEDGE_S

public static final PlotMark FILLED_WEDGE_S
The filled wedge-facing-south plot mark.


FILLED_WEDGE_W

public static final PlotMark FILLED_WEDGE_W
The filled wedge-facing-west plot mark.


FILLED_BLUNT_WEDGE_N

public static final PlotMark FILLED_BLUNT_WEDGE_N
The filled blunt-wedge-facing-north plot mark.


FILLED_BLUNT_WEDGE_E

public static final PlotMark FILLED_BLUNT_WEDGE_E
The filled blunt-wedge-facing-east plot mark.


FILLED_BLUNT_WEDGE_S

public static final PlotMark FILLED_BLUNT_WEDGE_S
The filled blunt-wedge-facing-south plot mark.


FILLED_BLUNT_WEDGE_W

public static final PlotMark FILLED_BLUNT_WEDGE_W
The filled blunt-wedge-facing-west plot mark.


FILLED_SHARP_WEDGE_N

public static final PlotMark FILLED_SHARP_WEDGE_N
The filled sharp-wedge-facing-north plot mark.


FILLED_SHARP_WEDGE_E

public static final PlotMark FILLED_SHARP_WEDGE_E
The filled sharp-wedge-facing-east plot mark.


FILLED_SHARP_WEDGE_S

public static final PlotMark FILLED_SHARP_WEDGE_S
The filled sharp-wedge-facing-south plot mark.


FILLED_SHARP_WEDGE_W

public static final PlotMark FILLED_SHARP_WEDGE_W
The filled sharp-wedge-facing-west plot mark.


FILLED_THUMB_N

public static final PlotMark FILLED_THUMB_N
The filled thumb-facing-north plot mark.


FILLED_THUMB_E

public static final PlotMark FILLED_THUMB_E
The filled thumb-facing-east plot mark.


FILLED_THUMB_S

public static final PlotMark FILLED_THUMB_S
The filled thumb-facing-south plot mark.


FILLED_THUMB_W

public static final PlotMark FILLED_THUMB_W
The filled thumb-facing-west plot mark.


DEFAULT_ALGORITHM

private static final PlotMarkAlgorithm DEFAULT_ALGORITHM
Default plot mark algorithm: PlotMarkAlgorithm.Square.


DEFAULT_SIZE

private static final int DEFAULT_SIZE
Default plot mark size: 3.

See Also:
Constant Field Values

DEFAULT_FILL

private static final boolean DEFAULT_FILL
Default plot mark fill: true.

See Also:
Constant Field Values

standardStroke

private static final Stroke standardStroke
The standard stroke: BasicStroke(1).


algorithm

private PlotMarkAlgorithm algorithm
The plot mark algorithm.


size

private int size
The plot mark size.


fill

private boolean fill
The plot mark fill.


shape

private Shape shape
The plot mark shape.


paintable

private Paintable paintable
The paintable if used instead of an algorithm.

Constructor Detail

PlotMark

public PlotMark()

Constructs a plot mark using the defaults.

The default plot mark is a copy of the static constant plot mark FILLED_SQUARE.


PlotMark

public PlotMark(PlotMarkAlgorithm algorithm)

Constructs a plot mark using the given algorithm and the defaults listed below.

If the algorithm is null, it is set to PlotMarkAlgorithm.Square.

Parameters:
algorithm - the plot mark algorithm

PlotMark

public PlotMark(PlotMarkAlgorithm algorithm,
                int size)

Constructs a plot mark using the given algorithm, the given size, and the default listed below.

If the algorithm is null, it is set to PlotMarkAlgorithm.Square.

If the size is less than 0, it is set to 0.

Parameters:
algorithm - the plot mark algorithm
size - the plot mark size setting

PlotMark

public PlotMark(PlotMarkAlgorithm algorithm,
                boolean fill)

Constructs a plot mark using the given algorithm, the given fill setting, and the default listed below.

If the algorithm is null, it is set to PlotMarkAlgorithm.Square.

Parameters:
algorithm - the plot mark algorithm
fill - the plot mark fill setting

PlotMark

public PlotMark(PlotMarkAlgorithm algorithm,
                int size,
                boolean fill)

Constructs a plot mark using the given algorithm, the given size, and the given fill setting.

If the algorithm is null, it is set to PlotMarkAlgorithm.Square.

If the size is less than 0, it is set to 0.

Parameters:
algorithm - the plot mark algorithm
size - the plot mark size setting
fill - the plot mark fill setting

PlotMark

public PlotMark(PlotMark plotmark)

Constructs a plot mark by cloning the given plot mark.

If the plot mark is null, it is set to PlotMark.FILLED_SQUARE.

If the plot mark is set by a paintable then the new plot mark is set by the same paintable.

Parameters:
plotmark - the plot mark to clone

PlotMark

public PlotMark(PlotMark plotmark,
                int size)

Constructs a plot mark using the given plot mark but changing the specified setting.

If the plot mark is null, it is set to PlotMark.FILLED_SQUARE.

If the plot mark is set by a paintable then the new plot mark is set by the same paintable.

If the size is less than 0, it is set to 0.

Parameters:
plotmark - the plot mark to partially clone
size - the plot mark size setting

PlotMark

public PlotMark(PlotMark plotmark,
                boolean fill)

Constructs a plot mark using the given plot mark but changing the specified setting.

If the plot mark is null, it is set to PlotMark.FILLED_SQUARE.

If the plot mark is set by a paintable then the new plot mark is set by the same paintable.

Parameters:
plotmark - the plot mark to partially clone
fill - the plot mark fill setting

PlotMark

public PlotMark(PlotMark plotmark,
                int size,
                boolean fill)

Constructs a plot mark using the given plot mark but changing the specified settings.

If the plot mark is null, it is set to PlotMark.FILLED_SQUARE.

If the plot mark is set by a paintable then the new plot mark is set by the same paintable.

If the size is less than 0, it is set to 0.

Parameters:
plotmark - the plot mark to partially clone
size - the plot mark size setting
fill - the plot mark fill setting

PlotMark

public PlotMark(Paintable paintable)

Constructs a plot mark using the given paintable.

Uses the default plot mark algorithm and settings if the given paintable is null.

Parameters:
paintable - the paintable to use for the plot mark
Method Detail

initializePlotMark

private void initializePlotMark(PlotMarkAlgorithm algorithm,
                                int size,
                                boolean fill,
                                Paintable paintable)

The common initialization code for a plot mark.

Parameters:
algorithm - the plot mark algorithm if used
size - the plot mark size setting
fill - the plot mark fill setting
paintable - the plot mark paintable if used

mark

public final void mark(Graphics g,
                       Point2D p)

Draws, fills, or paints a mark at the given plot point.

If this plot mark is defined by a plot mark algorithm, then proceed as follows:

Otherwise, if the plot mark is defined by a paintable, then make the call:

Does nothing if the given plot point is null.

Parameters:
g - the graphics context
p - the plot point

mark

public final void mark(Graphics g,
                       double x,
                       double y)

Draws, fills, or paints a mark at the given plot point.

If this plot mark is defined by a plot mark algorithm, then proceed as follows:

Otherwise, if the plot mark is defined by a paintable, then make the call:

Parameters:
g - the graphics context
x - the x-coordinate of the plot point
y - the y-coordinate of the plot point

mark

public final void mark(Graphics g,
                       AffineTransform T,
                       Point2D p)

Draws, fills, or paints a mark at the plot point which is obtained by applying the transform to the given point.

In all cases, find the plot point by applying the transform to the given point.

If this plot mark is defined by a plot mark algorithm, then proceed as follows:

Otherwise, if the plot mark is defined by a paintable, then make the call:

Does nothing if the original point is null.

Parameters:
g - the graphics context
T - the affine transform to apply to the original point
p - the original point

mark

public final void mark(Graphics g,
                       AffineTransform T,
                       double x,
                       double y)

Draws, fills, or paints a mark at the plot point which is obtained by applying the transform to the given point.

In all cases, find the plot point by applying the transform to the given point.

If this plot mark is defined by a plot mark algorithm, then proceed as follows:

Otherwise, if the plot mark is defined by a paintable, then make the call:

Parameters:
g - the graphics context
T - the affine transform to apply to the original point
x - the x-coordinate of the original point
y - the y-coordinate of the original point

getAlgorithm

public final PlotMarkAlgorithm getAlgorithm()
Returns the internal PlotMarkAlgorithm or null if an algorithm is not used.


getSize

public final int getSize()
Returns the size setting. This will not be used if the plot mark is defined by a paintable.


getFill

public final boolean getFill()
Returns the fill setting. This will not be used if the plot mark is defined by a paintable.


getPaintable

public final Paintable getPaintable()
Returns the internal Paintable or null if a paintable is not used.