public class IconLabelStyleRenderer extends Object implements ILabelStyleRenderer, IBoundsProvider, IVisibilityTestable, IMarqueeTestable, IHitTestable, ILookup, IVisualCreator
ILabelStyleRenderer that can handle IconLabelStyle instances.
This implementation renders the label's inner style and an icon.
EMPTY, UNBOUNDEDALWAYS, NEVERALWAYS, NEVERALWAYS, NEVER| Constructor and Description |
|---|
IconLabelStyleRenderer()
Creates a new instance of this renderer.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
configure() |
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 Image |
getIcon()
|
protected ILabelModelParameter |
getIconPlacement()
Retrieves the
IconPlacement from the Style. |
protected SizeD |
getIconSize()
Gets the size of the icon from the
IconSize property. |
protected InsetsD |
getInnerStyleInsets()
Retrieves the
WrappedInsets from the Style. |
protected ILabel |
getLabel()
Gets the currently configured label.
|
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 IconLabelStyle |
getStyle()
Gets the currently configured style.
|
IVisibilityTestable |
getVisibilityTestable(ILabel label,
ILabelStyle style)
|
IVisualCreator |
getVisualCreator(ILabel label,
ILabelStyle style)
|
protected ILabelStyle |
getWrappedStyle()
|
protected boolean |
isAutoFlippingEnabled()
Retrieves the
AutoFlippingEnabled property from the
Style. |
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. |
boolean |
isVisible(ICanvasContext context,
RectD rectangle)
Determines whether an element might intersect the visible region for a given context.
|
<TLookup> TLookup |
lookup(Class<TLookup> type)
Implements the
ILookup interface. |
protected void |
setLabel(ILabel value)
Sets the currently configured label.
|
protected void |
setStyle(IconLabelStyle value)
Sets the currently configured style.
|
protected boolean |
shouldHitTestIcon()
Returns whether the icon bounds should be considered for hit testing.
|
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 IconLabelStyleRenderer()
protected void configure()
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 Image getIcon()
protected ILabelModelParameter getIconPlacement()
IconPlacement from the Style.protected SizeD getIconSize()
IconSize property.protected InsetsD getInnerStyleInsets()
WrappedInsets from the Style.protected final ILabel getLabel()
setLabel(ILabel)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 IconLabelStyle getStyle()
setStyle(IconLabelStyle)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 ILabelStyle getWrappedStyle()
protected boolean isAutoFlippingEnabled()
AutoFlippingEnabled property from the
Style.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 marqueepublic boolean isVisible(ICanvasContext context, RectD rectangle)
IVisibilityTestable
Conservative implementations can always return true.
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 setStyle(IconLabelStyle value)
value - The Style to set.getStyle()protected boolean shouldHitTestIcon()
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