public class TemplateLabelStyleRenderer extends Object implements ILabelStyleRenderer, IVisualCreator, IBoundsProvider, IHitTestable, IMarqueeTestable, IVisibilityTestable, ILookup
ILabelStyleRenderer
interface that can render TemplateLabelStyle
instances.TemplateLabelStyle
EMPTY, UNBOUNDED
ALWAYS, NEVER
ALWAYS, NEVER
ALWAYS, NEVER
Constructor and Description |
---|
TemplateLabelStyleRenderer() |
Modifier and Type | Method and Description |
---|---|
protected void |
arrange(Node visual)
Arranges the provided element according to the current
Layout , taking into account the value of
isAutoFlippingEnabled(TemplateLabelStyle) . |
protected void |
configure()
Stores the
layout . |
Node |
createVisual(IRenderContext context)
Creates the visual by delegating to
TemplateLabelStyle.createControl(IRenderContext, ILabel) and then
initializing the control with the context. |
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()
Holds the layout of the current label.
|
IMarqueeTestable |
getMarqueeTestable(ILabel label,
ILabelStyle style)
|
protected GeneralPath |
getNormalizedOutline(TemplateLabelStyle style)
Gets the normalized outline by delegating to
NormalizedOutline . |
SizeD |
getPreferredSize(ILabel label,
ILabelStyle style)
Calculates the preferred size for the given label and style.
|
protected SizeD |
getPreferredSize(IRenderContext context)
Gets the size of the preferred for the current configuration using the provided context.
|
SizeD |
getPreferredSize(IRenderContext context,
ILabel label,
ILabelStyle style)
Calculates the preferred size for the given label and style.
|
protected TemplateLabelStyle |
getStyle()
Gets the currently configured style.
|
IVisibilityTestable |
getVisibilityTestable(ILabel label,
ILabelStyle style)
|
IVisualCreator |
getVisualCreator(ILabel label,
ILabelStyle style)
|
protected boolean |
isAutoFlippingEnabled(TemplateLabelStyle style)
Delegates to the
TemplateLabelStyle 's AutoFlippingEnabled
property. |
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)
Uses the
layout to determine whether the clip intersects. |
<TLookup> TLookup |
lookup(Class<TLookup> type)
Delegates to the
ContextLookup of the
ILabelStyle . |
protected Object |
lookupContext(TemplateLabelStyle style,
ILabel label,
Class type)
Delegates to the
TemplateLabelStyle 's
ContextLookup . |
protected void |
setLabel(ILabel value)
Sets the currently configured label.
|
protected void |
setStyle(TemplateLabelStyle value)
Sets the currently configured style.
|
Node |
updateVisual(IRenderContext context,
Node oldVisual)
Updates the
Node correspondingly. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
fromRectangle
create
createDictionaryLookup, createDynamic, createSingle, createSingle, createWrapped, lookup, lookup, safeLookup
protected void arrange(Node visual)
Layout
, taking into account the value of
isAutoFlippingEnabled(TemplateLabelStyle)
.visual
- The element to arrange to fit into the Layout
.protected void configure()
layout
.
Subclasses should override this method, call the super implementation and configure their painting entities.
public final Node createVisual(IRenderContext context)
TemplateLabelStyle.createControl(IRenderContext, ILabel)
and then
initializing the control with the context.createVisual
in interface IVisualCreator
context
- The context for the creation.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 IBoundsProvider
context
- the context to calculate the bounds forRectD.EMPTY
to indicate an unbound areapublic IBoundsProvider getBoundsProvider(ILabel label, ILabelStyle style)
getBoundsProvider
in interface ILabelStyleRenderer
label
- 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.this
getBounds(ICanvasContext)
public ILookup getContext(ILabel label, ILabelStyle style)
Style
and Label
properties, 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 ILabelStyleRenderer
label
- 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.this
lookup(Class)
public IHitTestable getHitTestable(ILabel label, ILabelStyle style)
getHitTestable
in interface ILabelStyleRenderer
label
- 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.this
isHit(IInputModeContext, PointD)
protected final ILabel getLabel()
setLabel(ILabel)
protected final IOrientedRectangle getLayout()
This value is set during configure()
to the label's layout
public IMarqueeTestable getMarqueeTestable(ILabel label, ILabelStyle style)
getMarqueeTestable
in interface ILabelStyleRenderer
label
- 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.this
isInBox(IInputModeContext, RectD)
protected GeneralPath getNormalizedOutline(TemplateLabelStyle style)
NormalizedOutline
.public SizeD getPreferredSize(ILabel label, ILabelStyle style)
getPreferredSize
in interface ILabelStyleRenderer
label
- The label instance.style
- The style instance to apply.getPreferredSize(IRenderContext)
protected SizeD getPreferredSize(IRenderContext context)
context
- The context.public SizeD getPreferredSize(IRenderContext context, ILabel label, ILabelStyle style)
label
- The label instance.style
- The style instance to apply.getPreferredSize(IRenderContext)
protected final TemplateLabelStyle getStyle()
setStyle(TemplateLabelStyle)
public IVisibilityTestable getVisibilityTestable(ILabel label, ILabelStyle style)
Style
and Label
properties, 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 ILabelStyleRenderer
label
- 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.this
isVisible(ICanvasContext, RectD)
public IVisualCreator getVisualCreator(ILabel label, ILabelStyle style)
getVisualCreator
in interface ILabelStyleRenderer
label
- 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.this
createVisual(IRenderContext)
,
updateVisual(IRenderContext, Node)
protected boolean isAutoFlippingEnabled(TemplateLabelStyle style)
TemplateLabelStyle
's AutoFlippingEnabled
property.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 IHitTestable
context
- the context the hit test is performed inlocation
- the coordinates in world coordinate systempublic boolean isInBox(IInputModeContext context, RectD rectangle)
IMarqueeTestable
true
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 IMarqueeTestable
context
- 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)
layout
to determine whether the clip intersects.isVisible
in interface IVisibilityTestable
context
- 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)
ContextLookup
of the
ILabelStyle
.protected Object lookupContext(TemplateLabelStyle style, ILabel label, Class type)
TemplateLabelStyle
's
ContextLookup
.style
- The style to look up the context for.label
- The current label.type
- The type to look up.null
.protected final void setLabel(ILabel value)
value
- The Label to set.getLabel()
protected final void setStyle(TemplateLabelStyle value)
value
- The Style to set.getStyle()
public final Node updateVisual(IRenderContext context, Node oldVisual)
Node
correspondingly.updateVisual
in interface IVisualCreator
context
- The context for the creation.oldVisual
- The currently rendered visual.IVisualCreator.createVisual(IRenderContext)
,
ICanvasObjectDescriptor
,
CanvasControl