Class LineGlyph
java.lang.Object
uk.ac.starlink.ttools.plot2.layer.DrawingGlyph
uk.ac.starlink.ttools.plot2.layer.LineGlyph
- All Implemented Interfaces:
Glyph
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PixerFactory
createKernel
(MarkerShape shape, int nthick) Returns a smoothing kernel derived from a given marker shape.createPixerFactory
(Rectangle clip) Returns a PixerFactory that produces the pixels for this glyph.static PixerFactory
createThickKernel
(int nthick) Returns a (roughly circular) smoothing kernel for a thick line.static StrokeKit
createThickStrokeKit
(int nthick) Returns a stroke kit for drawing a thick line.abstract void
drawShape
(PixelDrawing drawing) Draws this shape onto a given drawing, whose bounds have been set appropriately.abstract Rectangle
Returns the boundary rectangle containing the whole of the shape that will be drawn to a PixelDrawing.void
Paints a representation of a point considered to be at the origin.abstract void
paintGlyph
(Graphics g, StrokeKit strokeKit) Paints this shape onto a graphics context with given line strokes.toThicker
(PixerFactory kernel, StrokeKit strokeKit) Returns a glyph that is the same as this one, but with thicker pen strokes.Methods inherited from class uk.ac.starlink.ttools.plot2.layer.DrawingGlyph
createPixer
-
Constructor Details
-
LineGlyph
public LineGlyph()
-
-
Method Details
-
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 bydrawShape(uk.ac.starlink.ttools.plot2.layer.PixelDrawing)
.- Returns:
- bounding box
-
drawShape
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
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 contextstrokeKit
- supplier of line drawing strokes
-
createPixerFactory
Returns a PixerFactory that produces the pixels for this glyph.- Specified by:
createPixerFactory
in classDrawingGlyph
- Parameters:
clip
- clip bounds
-
paintGlyph
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
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 kernelstrokeKit
- line strokes to use for painting- Returns:
- derived glyph
-
createThickKernel
Returns a (roughly circular) smoothing kernel for a thick line.- Parameters:
nthick
- line thickness, >=0- Returns:
- standard smoothing kernel
-
createKernel
Returns a smoothing kernel derived from a given marker shape.- Parameters:
shape
- shapenthick
- thickness index >=0- Returns:
- smoothing kernel
-
createThickStrokeKit
Returns a stroke kit for drawing a thick line.- Parameters:
nthick
- line thickness, >=0- Returns:
- thick stroke
-