Painter¶
The actual painter composition is exposed here.
-
class
plums.plot.engine.painter.Position[source]¶ Bases:
objectSimple enum to represent the position of the confidence label.
-
LEFT= 'left'¶
-
RIGHT= 'right'¶
-
-
class
plums.plot.engine.painter.Geometry(record, zoom=1)[source]¶ Bases:
objectA class that represents a record geometry and computes meaningful properties.
- Parameters
- Raises
TypeError – When
coordinatesis not a collection or a nested.ValueError – When the record is invalid.
ValueError – When a point has not 2 coordinates
ValueError – When
coordinatescollection is empty.ValueError – When first and last coordinates differ.
ValueError – When the record has an invalid geometry type (should be either
PolygonorPoint).
-
class
plums.plot.engine.painter.Draw(size, zoom, mode, background_color)[source]¶ Bases:
objectA wrapper class arround
ImageDrawto customize drawing methods.- Parameters
-
_draw¶ An object that can be used to draw in the given image
_overlay.- Type
ImageDraw
-
circle(centroid, fill_color)[source]¶ Draw a particular ellipse with a radius depending on the zoom level.
-
line(points, fill_color)[source]¶ Draw record geometry with successive lines since PIL does not support polygon thickness.
-
polygon(points, fill_color)[source]¶ Draw a polygon, used for the confidence label.
- Parameters
points (list`) – A list of point as
(x, y)tuples.fill_color (tuple) – The color to use for the polygon.
RGBorRGBAformat.
-
class
plums.plot.engine.painter.TagPainter(descriptor, text_margin=2, text_size=11, zoom=1)[source]¶ Bases:
objectA tag artist class which draw a tag next to a given
Recordgeometry.- Parameters
descriptor (
Descriptor) –The
Descriptordescription to plot next to eachRecord.Note
The
TagPainterclass assumes that eachRecordhave already been described by the providedDescriptor.text_margin (int) – Optional. Default to 2. The margin in pixel to leave between the tag text and its border.
text_size (int) – Optional. Default to 11. The tag text font size in pixel.
zoom (int) – Optional. Defaults to
1. Zoom level to use.
New in version 0.2.0.
-
class
plums.plot.engine.painter.PainterBase(plot_centers=False, plot_tag=None, zoom=1, fill=False, alpha=64, **kwargs)[source]¶ Bases:
abc.ABCAn abstract base class that defines the basic elements a Painter needs to draw a data point.
- Parameters
plot_centers (bool) – Optional. Defaults to
False. Plot records centers (instead of full geometry).plot_tag (
Descriptor) –Optional. Defaults to
None. Besides the geometry, display aRecorddescription in a tag attached to theRecord.Note
The
PainterBaseclass assumes that eachRecordhave already been described by the providedDescriptor.zoom (int) – Optional. Defaults to
1. Zoom level to use.fill (bool) – Optional. Default to
False. A flag which represents whether to draw filled polygons.alpha (int) – Optional. Defaults to
64. A positive integer (between 0 and 255) that represents the fill transparency.
-
abstract
draw(data_point)[source]¶ Draw a data point (annotations on a given tile) and return the composed
Image.- Parameters
data_point (
DataPoint) – Data point to be drawn (tile + annotations).- Raises
ValueError – When a record has an invalid geometry type.
- Returns
The composed image (tile with annotations)
- Return type
-
class
plums.plot.engine.painter.Painter(plot_centers=False, plot_tag=None, zoom=1, fill=False, alpha=64, **kwargs)[source]¶ Bases:
plums.plot.engine.painter.PainterBaseA basic Painter that implements the
PainterBaseclass.The role of the painter is to aggregate annotations on a given tile, giving to the user a meaningful representation of the records.
- Parameters
plot_centers (bool) – Optional. Defaults to
False. Plot records centers (instead of full geometry).plot_tag (
Descriptor) –Defaults to
None. Besides the geometry, display aRecorddescription in a tag attached to theRecord.Note
The
Painterclass assumes that eachRecordhave already been described by the providedDescriptor.zoom (int) – Optional. Defaults to
1. Zoom level to use.fill (bool) – Optional. Default to
False. A flag which represents whether to draw filled polygons.alpha (int) – Optional. Defaults to
64. A positive integer (between 0 and 255) that represents the fill transparency.
-
MODE= 'RGBA'¶
-
TEXT_MARGIN= 2¶
-
TITLE_HEIGHT= 30¶
-
TITLE_SIZE= 15¶
-
TITLE_BACKGROUND_COLOR= (46, 49, 49)¶
-
TAG_TEXT_SIZE= 11¶
-
draw(data_point)[source]¶ Draw a data point (annotations on a given tile) and return the composed
Image.- Parameters
data_point (
DataPoint) – Data point to be drawn (tile + annotations).- Raises
ValueError – When a record has an invalid geometry type.
- Returns
The composed image (tile with annotations)
- Return type