Class XYShape
java.lang.Object
uk.ac.starlink.ttools.plot2.layer.XYShape
- Direct Known Subclasses:
BasicXYShape
,FatLineXYShape
,LineXYShape
,StrokeXYShape
Abstract superclass for shapes characterised by a pair of short integer
values. These values typically represent the horizontal and vertical
extent of a shape, but they don't have to.
This object acts as a factory for Glyphs. These glyphs are lazily cached per instance of this class for small values of the X and Y coordinates (since there aren't very many of them, and they are probably used frequently); for larger values, the glyphs are created on demand.
- Since:
- 16 Jan 2015
- Author:
- Mark Taylor
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Glyph
createGlyph
(short sx, short sy) Constructs a new glyph with given coordinates.static Icon
createIcon
(XYShape shape, int width, int height, boolean useComponentColor) Returns an icon displaying a given shape.getGlyph
(short sx, short sy) Obtains a glyph characterised by a given pair of values.getName()
Returns the name of this shape.boolean
isCached
(short sx, short sy) Indicates whether a glyph of a given size will be cached.toString()
-
Field Details
-
POINT
Glyph that paints a single pixel at the origin.
-
-
Constructor Details
-
XYShape
Constructs a shape with a specified cache limit and point glyph.- Parameters:
name
- shape namemaxCacheRadius
- glyphs are cached if both input values have an absolute value lower than or equal to this limitpointGlyph
- glyph to dispense for zero-length lines; may be null for no special-case behaviour
-
XYShape
Constructs a shape with a default cache limit and single-pixel point glyph.- Parameters:
name
- shape name
-
-
Method Details
-
getName
Returns the name of this shape.- Returns:
- name
-
isCached
public boolean isCached(short sx, short sy) Indicates whether a glyph of a given size will be cached.- Parameters:
sx
- X radiussy
- Y radius- Returns:
- true iff glyph will be cached, false if it will be created on demand
-
getGlyph
Obtains a glyph characterised by a given pair of values. The glyph may be newly created or obtained from a cache.- Parameters:
sx
- X valuesy
- Y value- Returns:
- glyph
-
createGlyph
Constructs a new glyph with given coordinates.- Parameters:
sx
- X valuesy
- Y value- Returns:
- new glyph
-
toString
-
createIcon
Returns an icon displaying a given shape. The assumption is that the X and Y values are half width and half height of the shape.- Parameters:
shape
- shapewidth
- icon widthheight
- icon heightuseComponentColor
- if true, the glyph will be painted in the component's foreground colour- Returns:
- icon
-