Class LineGlyph

java.lang.Object
uk.ac.starlink.ttools.plot2.layer.DrawingGlyph
uk.ac.starlink.ttools.plot2.layer.LineGlyph
All Implemented Interfaces:
Glyph

public abstract class LineGlyph extends DrawingGlyph
Glyph partial implementation that facilitates making drawings with variable-thickness lines. The toThicker(uk.ac.starlink.ttools.plot2.layer.PixerFactory, uk.ac.starlink.ttools.plot2.layer.StrokeKit) method is supplied to generate another glyph based on this one but with thicker drawing lines.

Concrete implementations have to be able to supply bounds, and draw the shape onto a supplied PixelDrawing, or to a Graphics context with a given StrokeSet.

Since:
24 Sep 2021
Author:
Mark Taylor
  • Constructor Details

    • LineGlyph

      public LineGlyph()
  • Method Details

    • getPixelBounds

      public abstract Rectangle getPixelBounds()
      Returns the boundary rectangle containing the whole of the shape that will be drawn to a PixelDrawing. This is allowed to be an overestimate (though efficiency may suffer), but not an underestimate.

      This method is called by createPixerFactory(java.awt.Rectangle), but not by drawShape(uk.ac.starlink.ttools.plot2.layer.PixelDrawing).

      Returns:
      bounding box
    • drawShape

      public abstract void drawShape(PixelDrawing drawing)
      Draws this shape onto a given drawing, whose bounds have been set appropriately. Since a suitable clip will be in place, and PixelDrawing methods will take account of this to avoid unnecessary work, implementations do not generally have to worry concerning correctness or efficiency about graphics operations with potentially oversized coordinate values.
      Parameters:
      drawing - graphics destination
    • paintGlyph

      public abstract void paintGlyph(Graphics g, StrokeKit strokeKit)
      Paints this shape onto a graphics context with given line strokes. If any lines are drawn, they should in general be done with strokes supplied from the given StrokeKit, giving client classes a chance to customise line drawing.
      Parameters:
      g - graphics context
      strokeKit - supplier of line drawing strokes
    • createPixerFactory

      public PixelDrawing createPixerFactory(Rectangle clip)
      Returns a PixerFactory that produces the pixels for this glyph.
      Specified by:
      createPixerFactory in class DrawingGlyph
      Parameters:
      clip - clip bounds
    • paintGlyph

      public void paintGlyph(Graphics g)
      Description copied from interface: Glyph
      Paints a representation of a point considered to be at the origin. Typically this means the painting is centred at that point.
      Parameters:
      g - graphics context
    • toThicker

      public DrawingGlyph toThicker(PixerFactory kernel, StrokeKit strokeKit)
      Returns a glyph that is the same as this one, but with thicker pen strokes. The pixel drawing stroke changes are effected by convolving the output drawing with a supplied smoothing kernel, and the graphics context painting is done using a supplied StrokeKit. It is the responsibility of the calling class to ensure that these two are consistent with each other. Note the effect may not be exactly the same for painted and pixellated output even so, since only stroked lines will be thicker in the painting, while all output graphics will be smoothed in the pixels.
      Parameters:
      kernel - smoothing kernel
      strokeKit - line strokes to use for painting
      Returns:
      derived glyph
    • createThickKernel

      public static PixerFactory createThickKernel(int nthick)
      Returns a (roughly circular) smoothing kernel for a thick line.
      Parameters:
      nthick - line thickness, >=0
      Returns:
      standard smoothing kernel
    • createKernel

      public static PixerFactory createKernel(MarkerShape shape, int nthick)
      Returns a smoothing kernel derived from a given marker shape.
      Parameters:
      shape - shape
      nthick - thickness index >=0
      Returns:
      smoothing kernel
    • createThickStrokeKit

      public static StrokeKit createThickStrokeKit(int nthick)
      Returns a stroke kit for drawing a thick line.
      Parameters:
      nthick - line thickness, >=0
      Returns:
      thick stroke