Class Renderer
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
Renderer.Renderer$Impl
PangoRenderer is a base class for objects that can render text
provided as PangoGlyphString or PangoLayout.
By subclassing PangoRenderer and overriding operations such as
drawGlyphs and drawRectangle, renderers for particular font
backends and destinations can be created.
- Since:
- 1.8
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRenderer.Builder<B extends Renderer.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classThe Renderer$Impl type represents a native instance of the abstract Renderer class.static classClass structure forPangoRenderer.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionRenderer()Creates a new Renderer.Renderer(MemorySegment address) Create a Renderer proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()Does initial setup before rendering operations onrenderer.protected RendererasParent()Returns this instance as if it were its parent type.protected voidbegin()Do renderer-specific initialization before drawingvoidCleans up after rendering operations onrenderer.voiddrawErrorUnderline(int x, int y, int width, int height) Draw a squiggly line that approximately covers the given rectangle in the style of an underline used to indicate a spelling error.voidDraws a single glyph with coordinates in device space.voiddrawGlyphItem(@Nullable String text, GlyphItem glyphItem, int x, int y) Draws the glyphs inglyphItemwith the specifiedPangoRenderer, embedding the text associated with the glyphs in the output if the output format supports it.voiddrawGlyphs(Font font, GlyphString glyphs, int x, int y) Draws the glyphs inglyphswith the specifiedPangoRenderer.voiddrawLayout(Layout layout, int x, int y) Drawslayoutwith the specifiedPangoRenderer.voiddrawLayoutLine(LayoutLine line, int x, int y) Drawslinewith the specifiedPangoRenderer.voiddrawRectangle(RenderPart part, int x, int y, int width, int height) Draws an axis-aligned rectangle in user space coordinates with the specifiedPangoRenderer.protected voiddraw content for a glyph shaped withPangoAttrShapex,yare the coordinates of the left edge of the baseline, in user coordinates.voiddrawTrapezoid(RenderPart part, double y1, double x11, double x21, double y2, double x12, double x22) Draws a trapezoid with the parallel sides aligned with the X axis using the givenPangoRenderer; coordinates are in device space.protected voidend()Do renderer-specific cleanup after drawingshortgetAlpha(RenderPart part) Gets the current alpha for the specified part.@Nullable ColorgetColor(RenderPart part) Gets the current rendering color for the specified part.@Nullable LayoutGets the layout currently being rendered usingrenderer.@Nullable LayoutLineGets the layout line currently being rendered usingrenderer.@Nullable MatrixGets the transformation matrix that will be applied when rendering.static MemoryLayoutThe memory layout of the native struct.static @Nullable TypegetType()Get the GType of the Renderer classvoidpartChanged(RenderPart part) Informs Pango that the way that the rendering is done forparthas changed.protected voidprepareRun(LayoutRun run) updates the renderer for a new runvoidsetAlpha(RenderPart part, short alpha) Sets the alpha for part of the rendering.voidsetColor(RenderPart part, @Nullable Color color) Sets the color for part of the rendering.voidSets the transformation matrix that will be applied when rendering.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, builder, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Renderer
Create a Renderer proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Renderer
public Renderer()Creates a new Renderer.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
activate
public void activate()Does initial setup before rendering operations onrenderer.deactivate()should be called when done drawing. Calls such asdrawLayout(org.gnome.pango.Layout, int, int)automatically activate the layout before drawing on it.Calls to
activate()anddeactivate()can be nested and the renderer will only be initialized and deinitialized once.- Since:
- 1.8
-
deactivate
public void deactivate()Cleans up after rendering operations onrenderer.See docs for
activate().- Since:
- 1.8
-
drawErrorUnderline
public void drawErrorUnderline(int x, int y, int width, int height) Draw a squiggly line that approximately covers the given rectangle in the style of an underline used to indicate a spelling error.The width of the underline is rounded to an integer number of up/down segments and the resulting rectangle is centered in the original rectangle.
This should be called while this Renderer is already active. Use
activate()to activate a renderer.- Parameters:
x- X coordinate of underline, in Pango units in user coordinate systemy- Y coordinate of underline, in Pango units in user coordinate systemwidth- width of underline, in Pango units in user coordinate systemheight- height of underline, in Pango units in user coordinate system- Since:
- 1.8
-
drawGlyph
Draws a single glyph with coordinates in device space.- Parameters:
font- aPangoFontglyph- the glyph index of a single glyphx- X coordinate of left edge of baseline of glyphy- Y coordinate of left edge of baseline of glyph- Since:
- 1.8
-
drawGlyphItem
Draws the glyphs inglyphItemwith the specifiedPangoRenderer, embedding the text associated with the glyphs in the output if the output format supports it.This is useful for rendering text in PDF.
Note that this method does not handle attributes in
glyphItem.If you want colors, shapes and lines handled automatically according to those attributes, you need to use pango_renderer_draw_layout_line() or pango_renderer_draw_layout().Note that
textis the start of the text for layout, which is then indexed byglyph_item->item->offset.If
textisnull, this simply callsdrawGlyphs(org.gnome.pango.Font, org.gnome.pango.GlyphString, int, int).The default implementation of this method simply falls back to
drawGlyphs(org.gnome.pango.Font, org.gnome.pango.GlyphString, int, int).- Parameters:
text- the UTF-8 text thatglyphItemrefers toglyphItem- aPangoGlyphItemx- X position of left edge of baseline, in user space coordinates in Pango unitsy- Y position of left edge of baseline, in user space coordinates in Pango units- Since:
- 1.22
-
drawGlyphs
Draws the glyphs inglyphswith the specifiedPangoRenderer.- Parameters:
font- aPangoFontglyphs- aPangoGlyphStringx- X position of left edge of baseline, in user space coordinates in Pango units.y- Y position of left edge of baseline, in user space coordinates in Pango units.- Since:
- 1.8
-
drawLayout
Drawslayoutwith the specifiedPangoRenderer.This is equivalent to drawing the lines of the layout, at their respective positions relative to
x,y.- Parameters:
layout- aPangoLayoutx- X position of left edge of baseline, in user space coordinates in Pango units.y- Y position of left edge of baseline, in user space coordinates in Pango units.- Since:
- 1.8
-
drawLayoutLine
Drawslinewith the specifiedPangoRenderer.This draws the glyph items that make up the line, as well as shapes, backgrounds and lines that are specified by the attributes of those items.
- Parameters:
line- aPangoLayoutLinex- X position of left edge of baseline, in user space coordinates in Pango units.y- Y position of left edge of baseline, in user space coordinates in Pango units.- Since:
- 1.8
-
drawRectangle
Draws an axis-aligned rectangle in user space coordinates with the specifiedPangoRenderer.This should be called while this Renderer is already active. Use
activate()to activate a renderer.- Parameters:
part- type of object this rectangle is part ofx- X position at which to draw rectangle, in user space coordinates in Pango unitsy- Y position at which to draw rectangle, in user space coordinates in Pango unitswidth- width of rectangle in Pango unitsheight- height of rectangle in Pango units- Since:
- 1.8
-
drawTrapezoid
public void drawTrapezoid(RenderPart part, double y1, double x11, double x21, double y2, double x12, double x22) Draws a trapezoid with the parallel sides aligned with the X axis using the givenPangoRenderer; coordinates are in device space.- Parameters:
part- type of object this trapezoid is part ofy1- Y coordinate of top of trapezoidx11- X coordinate of left end of top of trapezoidx21- X coordinate of right end of top of trapezoidy2- Y coordinate of bottom of trapezoidx12- X coordinate of left end of bottom of trapezoidx22- X coordinate of right end of bottom of trapezoid- Since:
- 1.8
-
getAlpha
Gets the current alpha for the specified part.- Parameters:
part- the part to get the alpha for- Returns:
- the alpha for the specified part, or 0 if it hasn't been set and should be inherited from the environment.
- Since:
- 1.38
-
getColor
Gets the current rendering color for the specified part.- Parameters:
part- the part to get the color for- Returns:
- the color for the
specified part, or
nullif it hasn't been set and should be inherited from the environment. - Since:
- 1.8
-
getLayout
Gets the layout currently being rendered usingrenderer.Calling this function only makes sense from inside a subclass's methods, like in its draw_shape vfunc, for example.
The returned layout should not be modified while still being rendered.
- Returns:
- the layout, or
nullif no layout is being rendered using this Renderer at this time. - Since:
- 1.20
-
getLayoutLine
Gets the layout line currently being rendered usingrenderer.Calling this function only makes sense from inside a subclass's methods, like in its draw_shape vfunc, for example.
The returned layout line should not be modified while still being rendered.
- Returns:
- the layout line, or
nullif no layout line is being rendered using this Renderer at this time. - Since:
- 1.20
-
getMatrix
Gets the transformation matrix that will be applied when rendering.- Returns:
- the matrix, or
nullif no matrix has been set (which is the same as the identity matrix). The returned matrix is owned by Pango and must not be modified or freed. - Since:
- 1.8
-
partChanged
Informs Pango that the way that the rendering is done forparthas changed.This should be called if the rendering changes in a way that would prevent multiple pieces being joined together into one drawing call. For instance, if a subclass of
PangoRendererwas to add a stipple option for drawing underlines, it needs to callpango_renderer_part_changed (render, PANGO_RENDER_PART_UNDERLINE);When the stipple changes or underlines with different stipples might be joined together. Pango automatically calls this for changes to colors. (See
setColor(org.gnome.pango.RenderPart, org.gnome.pango.Color))- Parameters:
part- the part for which rendering has changed.- Since:
- 1.8
-
setAlpha
Sets the alpha for part of the rendering.Note that the alpha may only be used if a color is specified for
partas well.- Parameters:
part- the part to set the alpha foralpha- an alpha value between 1 and 65536, or 0 to unset the alpha- Since:
- 1.38
-
setColor
Sets the color for part of the rendering.- Parameters:
part- the part to change the color ofcolor- the new color ornullto unset the current color- Since:
- 1.8
-
setMatrix
Sets the transformation matrix that will be applied when rendering.- Parameters:
matrix- aPangoMatrix, ornullto unset any existing matrix (No matrix set is the same as setting the identity matrix.)- Since:
- 1.8
-
begin
protected void begin()Do renderer-specific initialization before drawing -
drawShape
draw content for a glyph shaped withPangoAttrShapex,yare the coordinates of the left edge of the baseline, in user coordinates. -
end
protected void end()Do renderer-specific cleanup after drawing -
prepareRun
updates the renderer for a new run
-