Class MarkerStyle
java.lang.Object
uk.ac.starlink.ttools.plot2.layer.MarkerStyle
- All Implemented Interfaces:
Style
Defines a style of marker for plotting in a scatter plot.
It is defined by
MarkerShape
, colour and size.- Since:
- 9 Sep 2021
- Author:
- Mark Taylor
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Standard height in pixels for legend icon.static final int
Standard width in pixels for legend icon. -
Constructor Summary
ConstructorsConstructorDescriptionMarkerStyle
(MarkerShape shapeId, Color color, int size, int maxr, Consumer<Graphics> drawShape) Constructs a MarkerStyle based on an object that draws to a Graphics context.MarkerStyle
(MarkerShape shapeId, Color color, int size, Consumer<Graphics> drawShape, Pixer pixer) Constructs a MarkerStyle based on an object that draws to a Graphics context and a supplied pixel iterator. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Draws this marker's shape centred at the origin suitable for display as a legend.void
Draws this marker's shape centered at the origin in a graphics context.boolean
Returns an icon suitable for displaying in a legend for this style.getLegendIcon
(int width, int height) Returns an icon of a requested size with this marker painted in the center.Returns an iterator over pixel offsets which can be used to draw this marker onto a raster.int
hashCode()
-
Field Details
-
LEGEND_ICON_WIDTH
public static final int LEGEND_ICON_WIDTHStandard width in pixels for legend icon.- See Also:
-
LEGEND_ICON_HEIGHT
public static final int LEGEND_ICON_HEIGHTStandard height in pixels for legend icon.- See Also:
-
-
Constructor Details
-
MarkerStyle
public MarkerStyle(MarkerShape shapeId, Color color, int size, int maxr, Consumer<Graphics> drawShape) Constructs a MarkerStyle based on an object that draws to a Graphics context.- Parameters:
shapeId
- shape familycolor
- coloursize
- nominal size (non-negative integer)maxr
- maximum radius (furthest distance from center that the shape may plot a pixel; overestimate is OK)drawShape
- can draw the sized shape to a graphics context
-
MarkerStyle
public MarkerStyle(MarkerShape shapeId, Color color, int size, Consumer<Graphics> drawShape, Pixer pixer) Constructs a MarkerStyle based on an object that draws to a Graphics context and a supplied pixel iterator. These two representations should paint the same shape, but it allows for custom pixel patterns where drawing may not get it quite right. It's also slightly more efficient, but MarkStyle construction is not a critical part of plot generation.- Parameters:
shapeId
- shape familycolor
- coloursize
- nominal size (non-negative integer)drawShape
- can draw the sized shape to a graphics contextpixer
- pixel iterator giving shape
-
-
Method Details
-
drawShape
Draws this marker's shape centered at the origin in a graphics context. Implementing classes don't need to worry about the colour.- Parameters:
g
- graphics context
-
getPixerFactory
Returns an iterator over pixel offsets which can be used to draw this marker onto a raster. This can be used as an alternative to rendering the marker using thedrawMarker()
methods in situations where it might be more efficient. The assumption is that all the pixels are the same colour.This implementation doesn't need to be fast, the data will be cached before use.
- Returns:
- pixel offset iterator representing this style as a bitmap
-
drawLegendShape
Draws this marker's shape centred at the origin suitable for display as a legend. The default implementation just invokesdrawShape(java.awt.Graphics)
, but it may be overridden if there are special requirements, for instance ifdrawShape
draws a miniscule graphic.- Parameters:
g
- graphics context
-
getLegendIcon
Description copied from interface:Style
Returns an icon suitable for displaying in a legend for this style.- Specified by:
getLegendIcon
in interfaceStyle
-
getLegendIcon
Returns an icon of a requested size with this marker painted in the center.- Parameters:
width
- icon width in pixelsheight
- icon height in pixels
-
hashCode
public int hashCode() -
equals
-