public class DefaultLabelStyleRenderer extends Object implements ILabelStyleRenderer, IBoundsProvider, IVisibilityTestable, IMarqueeTestable, IHitTestable, ILookup, IVisualCreator
ILabelStyleRenderer implementation that can handle DefaultLabelStyle instances.
This implementation will just draw the label's Text using the properties provided by DefaultLabelStyle
into the label's layout area.
EMPTY, UNBOUNDEDALWAYS, NEVERALWAYS, NEVERALWAYS, NEVER| Constructor and Description |
|---|
DefaultLabelStyleRenderer()
Creates a new default instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
configure()
Prepares this instance for subsequent calls after the style and label have been initialized.
|
Node |
createVisual(IRenderContext context)
This method is called by the framework to create a
Node that will be included into the IRenderContext. |
RectD |
getBounds(ICanvasContext context)
Returns a tight rectangular area where the whole rendering would fit into.
|
IBoundsProvider |
getBoundsProvider(ILabel label,
ILabelStyle style)
|
ILookup |
getContext(ILabel label,
ILabelStyle style)
|
IHitTestable |
getHitTestable(ILabel label,
ILabelStyle style)
|
protected ILabel |
getLabel()
Gets the currently configured label.
|
protected IOrientedRectangle |
getLayout()
Retrieves the current
layout. |
IMarqueeTestable |
getMarqueeTestable(ILabel label,
ILabelStyle style)
|
protected SizeD |
getPreferredSize()
Calculates the preferred size given the current state of the renderer.
|
SizeD |
getPreferredSize(ILabel label,
ILabelStyle style)
Calculates the
preferred size of a given label using the associated style. |
protected DefaultLabelStyle |
getStyle()
Gets the currently configured style.
|
protected VPos |
getVerticalAlignment()
Determines how the text should be aligned vertically within the assigned label bounds.
|
IVisibilityTestable |
getVisibilityTestable(ILabel label,
ILabelStyle style)
|
IVisualCreator |
getVisualCreator(ILabel label,
ILabelStyle style)
|
protected boolean |
isAutoFlippingEnabled()
Delegates to
AutoFlippingEnabled. |
protected boolean |
isClippingTextEnabled()
Determines whether text should be forced to be clipped inside the rectangle.
|
boolean |
isHit(IInputModeContext context,
PointD location)
Determines if something has been hit at the given coordinates in the world coordinate system.
|
boolean |
isInBox(IInputModeContext context,
RectD rectangle)
This callback returns
true if the corresponding item is considered to intersect the given rectangular box. |
protected boolean |
isTextMirrored(IRenderContext context)
Determines whether the text should be horizontally mirrored.
|
boolean |
isVisible(ICanvasContext context,
RectD rectangle)
Uses the
ILabel.getLayout() to determine whether the clip intersects. |
<TLookup> TLookup |
lookup(Class<TLookup> type)
Implements the
ILookup interface. |
protected void |
setLabel(ILabel value)
Sets the currently configured label.
|
protected void |
setLayout(IOrientedRectangle value)
Retrieves the current
layout. |
protected void |
setStyle(DefaultLabelStyle value)
Sets the currently configured style.
|
Node |
updateVisual(IRenderContext context,
Node oldVisual)
This method updates or replaces a previously created
Node for inclusion in the IRenderContext. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitfromRectanglecreatecreateDictionaryLookup, createDynamic, createSingle, createSingle, createWrapped, lookup, lookup, safeLookuppublic DefaultLabelStyleRenderer()
protected void configure()
Upon invocation the Style and Label properties have been populated by the
getVisualCreator(ILabel, ILabelStyle), getBoundsProvider(ILabel, ILabelStyle),
getHitTestable(ILabel, ILabelStyle), or getMarqueeTestable(ILabel, ILabelStyle) methods.
Stores the layout into
Layout. Subclasses which to override this method should call the base implementation.
public Node createVisual(IRenderContext context)
IVisualCreatorNode that will be included into the IRenderContext.
CanvasControl uses this interface through the ICanvasObjectDescriptor
to populate the visual canvas object tree.
createVisual in interface IVisualCreatorcontext - The context that describes where the visual will be used.null.IVisualCreator.updateVisual(IRenderContext, Node)public RectD getBounds(ICanvasContext context)
IBoundsProvider
If calculating the bounds is too expensive or the rendering is not bound to a certain area, this method may return
RectD.INFINITE. If nothing is rendered, this method should return an empty rectangle, where either or both
the width and height is non-positive or RectD.EMPTY.
getBounds in interface IBoundsProvidercontext - the context to calculate the bounds forRectD.EMPTY to indicate an unbound areapublic IBoundsProvider getBoundsProvider(ILabel label, ILabelStyle style)
getBoundsProvider in interface ILabelStyleRendererlabel - The label to retrieve the bounds provider for. The value will be stored in the Label property.style - The style to associate with the label. The value will be stored in the Style property.thisgetBounds(ICanvasContext)public ILookup getContext(ILabel label, ILabelStyle style)
style and label parameters, does not call configure() and returns
this.
As this method may be called often it will not automatically call configure(), instead subclasses should ensure
that in the lookup(Class) method call they should call configure() only if needed, i.e. if they decide
to return this or an instance that depends on a correctly configured this.
getContext in interface ILabelStyleRendererlabel - The label to query the context for. The value will be stored in the Label property.style - The style to associate with the label. The value will be stored in the Style property.thislookup(Class)public IHitTestable getHitTestable(ILabel label, ILabelStyle style)
getHitTestable in interface ILabelStyleRendererlabel - The label to query hit test with. The value will be stored in the Label property.style - The style to associate with the label. The value will be stored in the Style property.thisisHit(IInputModeContext, PointD)protected final ILabel getLabel()
setLabel(ILabel)protected final IOrientedRectangle getLayout()
layout.setLayout(IOrientedRectangle)public IMarqueeTestable getMarqueeTestable(ILabel label, ILabelStyle style)
getMarqueeTestable in interface ILabelStyleRendererlabel - The label to query marquee intersection tests. The value will be stored in the Label property.style - The style to associate with the label. The value will be stored in the Style property.thisisInBox(IInputModeContext, RectD)protected SizeD getPreferredSize()
public final SizeD getPreferredSize(ILabel label, ILabelStyle style)
ILabelStyleRendererpreferred size of a given label using the associated style.getPreferredSize in interface ILabelStyleRendererlabel - The label to determine the preferred size forstyle - The style instance that uses this instance as its RendererPreferredSize if this renderer renders the label using
the associated style.protected final DefaultLabelStyle getStyle()
setStyle(DefaultLabelStyle)protected VPos getVerticalAlignment()
public IVisibilityTestable getVisibilityTestable(ILabel label, ILabelStyle style)
style and label parameters, does not call configure() and returns
this.
Unlike most of the other methods this implementation does not call configure(). If the subclass
implementation depends on this instance to be configured, it needs to call Configure in
isVisible(ICanvasContext, RectD).
getVisibilityTestable in interface ILabelStyleRendererlabel - The label to query visibility tests. The value will be stored in the Label property.style - The style to associate with the label. The value will be stored in the Style property.thisisVisible(ICanvasContext, RectD)public IVisualCreator getVisualCreator(ILabel label, ILabelStyle style)
getVisualCreator in interface ILabelStyleRendererlabel - The label to retrieve the IVisualCreator for. The value will be stored in the Label
property.style - The style to associate with the label. The value will be stored in the Style property.thiscreateVisual(IRenderContext),
updateVisual(IRenderContext, Node)protected boolean isAutoFlippingEnabled()
AutoFlippingEnabled.protected boolean isClippingTextEnabled()
public boolean isHit(IInputModeContext context, PointD location)
IHitTestable
Implementations should inspect the HitTestRadius and
take the value into account when performing hit tests. This allows the user to hit elements even if the zoom level is
very small and allows for accurate hit tests at greater zoom levels.
isHit in interface IHitTestablecontext - the context the hit test is performed inlocation - the coordinates in world coordinate systempublic boolean isInBox(IInputModeContext context, RectD rectangle)
IMarqueeTestabletrue if the corresponding item is considered to intersect the given rectangular box.
This method may return false if the item cannot be selected using a selection marquee or optionally if the item
is only partially contained within the box.
Implementations should respect the HitTestRadius if
marquee selections should behave differently on different zoom levels.
isInBox in interface IMarqueeTestablecontext - the current input mode contextrectangle - the box describing the marquee's boundstrue if the item is considered to be captured by the marqueeprotected boolean isTextMirrored(IRenderContext context)
This can be necessary if the CanvasControl's NodeOrientation is set to NodeOrientation.RIGHT_TO_LEFT
because this will apply a mirroring transform onto the canvas contents, making text unreadable otherwise. This
implementation tests whether the flow direction property on the canvas is set to NodeOrientation.RIGHT_TO_LEFT.
context - The context for which the rendering is performed.public boolean isVisible(ICanvasContext context, RectD rectangle)
ILabel.getLayout() to determine whether the clip intersects.isVisible in interface IVisibilityTestablecontext - The context to determine the visibility for.rectangle - The visible region clip.false if and only if it is safe not to paint the element because it would not affect the given clipping region.public <TLookup> TLookup lookup(Class<TLookup> type)
ILookup interface.
This method will be used by default if getContext(ILabel, ILabelStyle) has been queried for a lookup
implementation. Note that it cannot be assumed that configure() has already been invoked. However, normally Label
and Style will be correctly configured if invoked directly after GetContext. Subclass
implementations should make sure to configure this instance before they return this as a result of a successful
lookup. This implementation will check if type.IsInstanceOfType(this) and will call configure() on
success and return this.
protected final void setLabel(ILabel value)
value - The Label to set.getLabel()protected final void setLayout(IOrientedRectangle value)
layout.value - The Layout to set.getLayout()protected final void setStyle(DefaultLabelStyle value)
value - The Style to set.getStyle()public Node updateVisual(IRenderContext context, Node oldVisual)
IVisualCreatorNode for inclusion in the IRenderContext.
The CanvasControl uses this method to give implementations a chance to update an existing
Visual that has previously been created by the same instance during a call to IVisualCreator.createVisual(IRenderContext).
Implementation may update the oldVisual and return that same reference, or create a new visual and return the
new instance or null.
updateVisual in interface IVisualCreatorcontext - The context that describes where the visual will be used in.oldVisual - The visual instance that had been returned the last time the IVisualCreator.createVisual(IRenderContext) method was called on
this instance.oldVisual, if this instance modified the visual, or a new visual that should replace the existing one in the
canvas object visual tree.IVisualCreator.createVisual(IRenderContext),
ICanvasObjectDescriptor,
CanvasControl