public class ShapeNodeStyleRenderer extends Object implements INodeStyleRenderer, IShapeGeometry, IBoundsProvider, IVisibilityTestable, IMarqueeTestable, IHitTestable, ILookup, IVisualCreator
ShapeNodeStyle
instances.Modifier and Type | Field and Description |
---|---|
static ShapeNodeStyleRenderer |
INSTANCE
A shared immutable instance of this class.
|
EMPTY, UNBOUNDED
ALWAYS, NEVER
ALWAYS, NEVER
ALWAYS, NEVER
Constructor and Description |
---|
ShapeNodeStyleRenderer() |
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)
This method is called by the framework to create a
Node that will be included into the IRenderContext . |
RectD |
getBounds(ICanvasContext context)
Returns the layout bounds as an upper bound for the painting bound.
|
IBoundsProvider |
getBoundsProvider(INode node,
INodeStyle style)
|
ILookup |
getContext(INode node,
INodeStyle style)
|
IHitTestable |
getHitTestable(INode node,
INodeStyle style)
|
PointD |
getIntersection(PointD inner,
PointD outer)
Returns the intersection for the given line with this shape's geometry.
|
IRectangle |
getLayout()
Returns the
Layout of the node this renderer is currently configured for. |
IMarqueeTestable |
getMarqueeTestable(INode node,
INodeStyle style)
|
protected INode |
getNode()
Gets the currently configured node.
|
GeneralPath |
getOutline()
Returns the outline of the shape or
null . |
protected Paint |
getPaint()
Get the brush that is currently used by this renderer.
|
protected Pen |
getPen()
Get the pen that is currently used by this renderer.
|
double |
getRoundRectArcRadius()
Gets the radius that is used to draw rounded edges.
|
protected ShapeNodeShape |
getShape()
Get the shape that is currently used by this renderer.
|
IShapeGeometry |
getShapeGeometry(INode node,
INodeStyle style)
|
protected ShapeNodeStyle |
getStyle()
Gets the currently configured style.
|
IVisibilityTestable |
getVisibilityTestable(INode node,
INodeStyle style)
|
IVisualCreator |
getVisualCreator(INode node,
INodeStyle 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)
|
boolean |
isInside(PointD location)
Checks whether the given coordinate is deemed to lie within the shape's geometric bounds.
|
boolean |
isVisible(ICanvasContext context,
RectD rectangle)
Determines visibility by checking for an intersection with the
Layout . |
<TLookup> TLookup |
lookup(Class<TLookup> type)
Implements the
ILookup interface. |
protected void |
setNode(INode value)
Sets the currently configured node.
|
void |
setRoundRectArcRadius(double value)
Sets the radius that is used to draw rounded edges.
|
protected void |
setStyle(ShapeNodeStyle 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, wait
fromRectangle
create
createDictionaryLookup, createDynamic, createSingle, createSingle, createWrapped, lookup, lookup, safeLookup
public static final ShapeNodeStyleRenderer INSTANCE
Trying to modify the properties of this instance will trigger exceptions. Note that instances of this class are not thread safe.
protected void configure()
Upon invocation the Style
and Node
properies 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)
IVisualCreator
Node
that will be included into the IRenderContext
.
CanvasControl
uses this interface through the ICanvasObjectDescriptor
to populate the visual canvas object tree.
createVisual
in interface IVisualCreator
context
- The context that describes where the visual will be used.null
.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 IBoundsProvider
context
- the context to calculate the bounds fornull
to indicate an unbound areapublic IBoundsProvider getBoundsProvider(INode node, INodeStyle style)
getBoundsProvider
in interface INodeStyleRenderer
node
- The node to retrieve the bounds provider 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.this
getBounds(ICanvasContext)
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 INodeStyleRenderer
node
- 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.this
lookup(Class)
public IHitTestable getHitTestable(INode node, INodeStyle style)
getHitTestable
in interface INodeStyleRenderer
node
- The node to query hit test with. 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.this
isHit(IInputModeContext, PointD)
public PointD getIntersection(PointD inner, PointD outer)
IShapeGeometry
getIntersection
in interface IShapeGeometry
inner
- 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)
getMarqueeTestable
in interface INodeStyleRenderer
node
- The node to query marquee intersection 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.this
isInBox(IInputModeContext, RectD)
protected final INode getNode()
setNode(INode)
public GeneralPath getOutline()
IShapeGeometry
null
.getOutline
in interface IShapeGeometry
null
if no outline can be provided.protected Paint getPaint()
This implementation retrieves the brush from the owning style
protected Pen getPen()
This implementation retrieves the pen from the owning style
public double getRoundRectArcRadius()
setRoundRectArcRadius(double)
protected final ShapeNodeShape getShape()
This implementation retrieves the shape from the owning style
public IShapeGeometry getShapeGeometry(INode node, INodeStyle style)
getShapeGeometry
in interface INodeStyleRenderer
node
- The node to retrieve the shape geometry 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.this
isInside(PointD)
,
getIntersection(PointD, PointD)
protected final ShapeNodeStyle getStyle()
setStyle(ShapeNodeStyle)
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 INodeStyleRenderer
node
- 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.this
isVisible(ICanvasContext, RectD)
public IVisualCreator getVisualCreator(INode node, INodeStyle style)
getVisualCreator
in interface INodeStyleRenderer
node
- 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.this
createVisual(IRenderContext)
,
updateVisual(IRenderContext, Node)
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)
node
using the current Style
for an intersection with the given box.
This implementation uses the Layout
to determine whether the node is in the box.
isInBox
in interface IMarqueeTestable
context
- the current input mode contextrectangle
- the box describing the marquee's boundstrue
if the node is considered to be captured by the marqueepublic boolean isInside(PointD location)
IShapeGeometry
isInside
in interface IShapeGeometry
location
- The point to test.public boolean isVisible(ICanvasContext context, RectD rectangle)
Layout
.isVisible
in interface IVisibilityTestable
context
- The context.rectangle
- The current clipLayout
is visible in the clip.public <TLookup> TLookup lookup(Class<TLookup> type)
ILookup
interface.
This method will be used by default if getContext(INode, INodeStyle)
has been queried for a lookup
implementation. Note that it cannot be assumed that configure()
has already been invoked. However, normally Node
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 setNode(INode value)
value
- The Node to set.getNode()
public void setRoundRectArcRadius(double value)
value
- The RoundRectArcRadius to set.getRoundRectArcRadius()
protected final void setStyle(ShapeNodeStyle value)
value
- The Style to set.getStyle()
public Node updateVisual(IRenderContext context, Node oldVisual)
IVisualCreator
Node
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 IVisualCreator
context
- 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