public class TemplateNodeStyleRenderer extends Object implements INodeStyleRenderer, IShapeGeometry, IBoundsProvider, IVisibilityTestable, IMarqueeTestable, IHitTestable, ILookup, IVisualCreator
INodeStyleRenderer interface that can render TemplateNodeStyle instances.TemplateNodeStyleEMPTY, UNBOUNDEDALWAYS, NEVERALWAYS, NEVERALWAYS, NEVER| Constructor and Description |
|---|
TemplateNodeStyleRenderer() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
configure()
Prepares this instance for subsequent calls after the style and node have been initialized.
|
Node |
createVisual(IRenderContext context)
Creates the visual by delegating to
TemplateNodeStyle.createControl(IRenderContext, INode) and then initializing
the control with the context. |
RectD |
getBounds(ICanvasContext context)
Returns the layout bounds as an upper bound for the painting bound.
|
IBoundsProvider |
getBoundsProvider(INode node,
INodeStyle style)
Provides a
bounds calculation implementation for the given style and node. |
ILookup |
getContext(INode node,
INodeStyle style)
|
protected IContextLookup |
getContextLookup(TemplateNodeStyle style)
Gets the context by delegating to
ContextLookup. |
IHitTestable |
getHitTestable(INode node,
INodeStyle style)
Provides a
hit testing implementation for the given style and node. |
protected InsetsD |
getInsets(TemplateNodeStyle style)
Gets the insets by delegating to
Insets. |
PointD |
getIntersection(PointD inner,
PointD outer)
Tries to use the
outline shape to perform the intersection calculation,
otherwise reverts to default (rectangular) behavior. |
IRectangle |
getLayout()
Returns the
Layout of the node this renderer is currently configured for. |
IMarqueeTestable |
getMarqueeTestable(INode node,
INodeStyle style)
Provides a
marquee testing implementation for the given style and node. |
protected SizeD |
getMinimumSize(TemplateNodeStyle style)
Gets the minimum size by delegating to
MinimumSize. |
protected INode |
getNode()
Gets the currently configured node.
|
protected GeneralPath |
getNormalizedOutline(TemplateNodeStyle style)
Gets the normalized outline by delegating to
NormalizedOutline. |
GeneralPath |
getOutline()
Tries to use the
outline shape to create the outline shape path,
otherwise reverts to default (rectangular) behavior. |
SizeD |
getPreferredSize(INode node,
INodeStyle style)
Calculates the preferred size for the given node and style.
|
protected SizeD |
getPreferredSize(IRenderContext context)
Calculates the preferred size given the current state of the renderer for the given context.
|
SizeD |
getPreferredSize(IRenderContext context,
INode node,
INodeStyle style)
Calculates the preferred size for the given node and style in the provided context.
|
IShapeGeometry |
getShapeGeometry(INode node,
INodeStyle style)
Provides the geometry for the visual representation.
|
protected TemplateNodeStyle |
getStyle()
Gets the currently configured style.
|
IVisibilityTestable |
getVisibilityTestable(INode node,
INodeStyle style)
|
IVisualCreator |
getVisualCreator(INode node,
INodeStyle style)
|
boolean |
isHit(IInputModeContext context,
PointD location)
Tries to use the
outline shape to perform the hit test analysis,
otherwise reverts to default (rectangular) behavior. |
boolean |
isInBox(IInputModeContext context,
RectD rectangle)
Tries to use the
outline shape to perform the marquee intersection
analysis, otherwise reverts to default (rectangular) behavior. |
boolean |
isInside(PointD location)
Tries to use the
outline shape to perform the contains test, otherwise
reverts to default (rectangular) behavior. |
boolean |
isVisible(ICanvasContext context,
RectD rectangle)
Determines visibility by checking for an intersection with the
Layout. |
<TLookup> TLookup |
lookup(Class<TLookup> type)
Implementation of the
ILookup.lookup(Class) method. |
protected void |
setNode(INode value)
Sets the currently configured node.
|
protected void |
setStyle(TemplateNodeStyle 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, waitfromRectanglecreatecreateDictionaryLookup, createDynamic, createSingle, createSingle, createWrapped, lookup, lookup, safeLookupprotected void configure()
Upon invocation the Style and Node properties have been populated by the
getVisualCreator(INode, INodeStyle), getBoundsProvider(INode, INodeStyle),
getHitTestable(INode, INodeStyle), or getMarqueeTestable(INode, INodeStyle) methods.
This is an empty implementation. Subclasses might have to override this method.
public Node createVisual(IRenderContext context)
TemplateNodeStyle.createControl(IRenderContext, INode) and then initializing
the control with the context.createVisual in interface IVisualCreatorcontext - The context for the creation.IVisualCreator.updateVisual(IRenderContext, Node)public RectD getBounds(ICanvasContext context)
This implementation simply sets the Layout's bounds to the scratch variable and returns.
getBounds in interface IBoundsProvidercontext - the context to calculate the bounds fornull to indicate an unbound areapublic IBoundsProvider getBoundsProvider(INode node, INodeStyle style)
bounds calculation implementation for the given style and node.
If ContextLookup provides an
implementation of the IBoundsProvider interface than this instance will be returned, otherwise the default
(rectangular) behavior will be used.
getBoundsProvider in interface INodeStyleRenderernode - The node to query the provider for.style - The style whose provider is queried.public ILookup getContext(INode node, INodeStyle style)
style and node 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 INodeStyleRenderernode - The node to query the context for. The value will be stored in the Node property.style - The style to associate with the node. The value will be stored in the Style property.thislookup(Class)protected IContextLookup getContextLookup(TemplateNodeStyle style)
ContextLookup.public IHitTestable getHitTestable(INode node, INodeStyle style)
hit testing implementation for the given style and node.
If ContextLookup provides an
implementation of the IHitTestable interface than this instance will be returned, otherwise the outline shape
will be used to perform the hit testing.
getHitTestable in interface INodeStyleRenderernode - The node to query the tester for.style - The style whose tester is queried.isHit(IInputModeContext, PointD)protected InsetsD getInsets(TemplateNodeStyle style)
Insets.public PointD getIntersection(PointD inner, PointD outer)
outline shape to perform the intersection calculation,
otherwise reverts to default (rectangular) behavior.getIntersection in interface IShapeGeometryinner - The first point of the line that is inside the shape.outer - The second point of the line that is outside the shape.public final IRectangle getLayout()
Layout of the node this renderer is currently configured for.
Returns Node.Layout.
public IMarqueeTestable getMarqueeTestable(INode node, INodeStyle style)
marquee testing implementation for the given style and node.
If ContextLookup provides an
implementation of the IMarqueeTestable interface than this instance will be returned, otherwise the outline shape
will be used to determine the marquee intersection test with the visual representation of the node.
getMarqueeTestable in interface INodeStyleRenderernode - The node to query the tester for.style - The style whose tester is queried.isInBox(IInputModeContext, RectD)protected SizeD getMinimumSize(TemplateNodeStyle style)
MinimumSize.protected final INode getNode()
setNode(INode)protected GeneralPath getNormalizedOutline(TemplateNodeStyle style)
NormalizedOutline.public GeneralPath getOutline()
outline shape to create the outline shape path,
otherwise reverts to default (rectangular) behavior.getOutline in interface IShapeGeometrynull if no outline can be provided.public SizeD getPreferredSize(INode node, INodeStyle style)
node - The node instance.style - The style instance to apply.getPreferredSize(IRenderContext)protected SizeD getPreferredSize(IRenderContext context)
context - The render context for which the preferred size should be calculated.public SizeD getPreferredSize(IRenderContext context, INode node, INodeStyle style)
context - The context for which the preferred size should be calculated.node - The node instance.style - The style instance to apply.getPreferredSize(IRenderContext)public IShapeGeometry getShapeGeometry(INode node, INodeStyle style)
If ContextLookup provides an
implementation of the IShapeGeometry interface than this instance will be returned, otherwise the outline shape
will be used to determine the outline of the visual representation of a node.
getShapeGeometry in interface INodeStyleRenderernode - The node to query the geometry for.style - The style for which the geometry is queried.isInside(PointD),
getOutline()protected final TemplateNodeStyle getStyle()
setStyle(TemplateNodeStyle)public IVisibilityTestable getVisibilityTestable(INode node, INodeStyle style)
style and node 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 INodeStyleRenderernode - The node to query visibility tests. The value will be stored in the Node property.style - The style to associate with the node. The value will be stored in the Style property.thisisVisible(ICanvasContext, RectD)public IVisualCreator getVisualCreator(INode node, INodeStyle style)
getVisualCreator in interface INodeStyleRenderernode - The node to retrieve the IVisualCreator for. The value will be stored in the Node property.style - The style to associate with the node. The value will be stored in the Style property.thiscreateVisual(IRenderContext),
updateVisual(IRenderContext, Node)public boolean isHit(IInputModeContext context, PointD location)
outline shape to perform the hit test analysis,
otherwise reverts to default (rectangular) behavior.isHit in interface IHitTestablecontext - the context the hit test is performed inlocation - the hit point in world coordinatespublic boolean isInBox(IInputModeContext context, RectD rectangle)
outline shape to perform the marquee intersection
analysis, otherwise reverts to default (rectangular) behavior.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 isInside(PointD location)
outline shape to perform the contains test, otherwise
reverts to default (rectangular) behavior.isInside in interface IShapeGeometrylocation - The point to test.public boolean isVisible(ICanvasContext context, RectD rectangle)
Layout.isVisible in interface IVisibilityTestablecontext - The context.rectangle - The current clipLayout is visible in the clip.public <TLookup> TLookup lookup(Class<TLookup> type)
ILookup.lookup(Class) method.
Delegates to the lookup returned by getContextLookup(TemplateNodeStyle), first. Returns special INodeInsetsProvider
or INodeSizeConstraintProvider implementations if asked for. Last, it returns this class if it implements the
queried type.
protected final void setNode(INode value)
value - The Node to set.getNode()protected final void setStyle(TemplateNodeStyle value)
value - The Style to set.getStyle()public Node updateVisual(IRenderContext context, Node oldVisual)
Node correspondingly.updateVisual in interface IVisualCreatorcontext - The context for the creation.oldVisual - The currently rendered visual.IVisualCreator.createVisual(IRenderContext),
ICanvasObjectDescriptor,
CanvasControl