Class MarkerStyle

java.lang.Object
uk.ac.starlink.ttools.plot2.layer.MarkerStyle
All Implemented Interfaces:
Style

public class MarkerStyle extends Object implements 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 Details

    • LEGEND_ICON_WIDTH

      public static final int LEGEND_ICON_WIDTH
      Standard width in pixels for legend icon.
      See Also:
    • LEGEND_ICON_HEIGHT

      public static final int LEGEND_ICON_HEIGHT
      Standard 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 family
      color - colour
      size - 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 family
      color - colour
      size - nominal size (non-negative integer)
      drawShape - can draw the sized shape to a graphics context
      pixer - pixel iterator giving shape
  • Method Details

    • drawShape

      public void drawShape(Graphics g)
      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

      public PixerFactory 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 the drawMarker() 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

      public void drawLegendShape(Graphics g)
      Draws this marker's shape centred at the origin suitable for display as a legend. The default implementation just invokes drawShape(java.awt.Graphics), but it may be overridden if there are special requirements, for instance if drawShape draws a miniscule graphic.
      Parameters:
      g - graphics context
    • getLegendIcon

      public Icon getLegendIcon()
      Description copied from interface: Style
      Returns an icon suitable for displaying in a legend for this style.
      Specified by:
      getLegendIcon in interface Style
    • getLegendIcon

      public Icon getLegendIcon(int width, int height)
      Returns an icon of a requested size with this marker painted in the center.
      Parameters:
      width - icon width in pixels
      height - icon height in pixels
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object