Class MarkerStyle

  • All Implemented Interfaces:
    Style

    public class MarkerStyle
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      static int LEGEND_ICON_HEIGHT
      Standard height in pixels for legend icon.
      static int LEGEND_ICON_WIDTH
      Standard width in pixels for legend icon.
    • Constructor Summary

      Constructors 
      Constructor Description
      MarkerStyle​(MarkerShape shapeId, java.awt.Color color, int size, int maxr, java.util.function.Consumer<java.awt.Graphics> drawShape)
      Constructs a MarkerStyle based on an object that draws to a Graphics context.
      MarkerStyle​(MarkerShape shapeId, java.awt.Color color, int size, java.util.function.Consumer<java.awt.Graphics> drawShape, Pixer pixer)
      Constructs a MarkerStyle based on an object that draws to a Graphics context and a supplied pixel iterator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void drawLegendShape​(java.awt.Graphics g)
      Draws this marker's shape centred at the origin suitable for display as a legend.
      void drawShape​(java.awt.Graphics g)
      Draws this marker's shape centered at the origin in a graphics context.
      boolean equals​(java.lang.Object o)  
      javax.swing.Icon getLegendIcon()
      Returns an icon suitable for displaying in a legend for this style.
      javax.swing.Icon getLegendIcon​(int width, int height)
      Returns an icon of a requested size with this marker painted in the center.
      PixerFactory getPixerFactory()
      Returns an iterator over pixel offsets which can be used to draw this marker onto a raster.
      int hashCode()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LEGEND_ICON_WIDTH

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

        public static final int LEGEND_ICON_HEIGHT
        Standard height in pixels for legend icon.
        See Also:
        Constant Field Values
    • Constructor Detail

      • MarkerStyle

        public MarkerStyle​(MarkerShape shapeId,
                           java.awt.Color color,
                           int size,
                           int maxr,
                           java.util.function.Consumer<java.awt.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,
                           java.awt.Color color,
                           int size,
                           java.util.function.Consumer<java.awt.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 Detail

      • drawShape

        public void drawShape​(java.awt.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​(java.awt.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 javax.swing.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 javax.swing.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 java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object