public class CollapsibleNodeStyleDecoratorRenderer extends Object implements INodeStyleRenderer, IShapeGeometry, IBoundsProvider, IVisibilityTestable, IMarqueeTestable, IHitTestable, ILookup, IVisualCreator
INodeStyleRenderer implementation that can be used in conjunction with CollapsibleNodeStyleDecorator
instances.EMPTY, UNBOUNDEDALWAYS, NEVERALWAYS, NEVERALWAYS, NEVER| Constructor and Description |
|---|
CollapsibleNodeStyleDecoratorRenderer()
Initializes a new instance of the
CollapsibleNodeStyleDecoratorRenderer class. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
configure()
Prepares this instance for subsequent calls after the style and node have been initialized.
|
protected Node |
createButton(IRenderContext context)
Factory method that creates the toggle button instance.
|
protected ISelectionIndicatorInstaller |
createSelectionInstaller()
Callback that provides a customized
ISelectionIndicatorInstaller. |
Node |
createVisual(IRenderContext context)
Creates the visual for the given context.
|
RectD |
getBounds(ICanvasContext context)
Delegates to the
getWrappedStyle() and takes the button into account. |
IBoundsProvider |
getBoundsProvider(INode node,
INodeStyle style)
|
protected ILabelModelParameter |
getButtonPlacement()
Yields the
ButtonPlacement for the current
Style. |
protected SizeD |
getButtonSize()
Returns the size of the collapse button.
|
ILookup |
getContext(INode node,
INodeStyle style)
|
IHitTestable |
getHitTestable(INode node,
INodeStyle style)
|
PointD |
getIntersection(PointD inner,
PointD outer)
Delegates to the
getWrappedStyle(). |
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()
Delegates to the
getWrappedStyle(). |
IShapeGeometry |
getShapeGeometry(INode node,
INodeStyle style)
|
protected CollapsibleNodeStyleDecorator |
getStyle()
Gets the currently configured style.
|
IVisibilityTestable |
getVisibilityTestable(INode node,
INodeStyle style)
|
IVisualCreator |
getVisualCreator(INode node,
INodeStyle style)
|
protected INodeStyle |
getWrappedStyle()
|
protected boolean |
isExpanded(IRenderContext context,
INode node)
Returns the folding state of the group node.
|
boolean |
isHit(IInputModeContext context,
PointD location)
Delegates to the
getWrappedStyle() and checks the button. |
boolean |
isInBox(IInputModeContext context,
RectD rectangle)
Delegates to the
getWrappedStyle(). |
boolean |
isInside(PointD location)
Delegates to the
getWrappedStyle(). |
boolean |
isVisible(ICanvasContext context,
RectD rectangle)
Delegates to the
getWrappedStyle(). |
<TLookup> TLookup |
lookup(Class<TLookup> type)
Returns an instance that implements the given type or
null. |
protected void |
setNode(INode value)
Sets the currently configured node.
|
protected void |
setStyle(CollapsibleNodeStyleDecorator value)
Sets the currently configured style.
|
protected void |
updateButton(IRenderContext context,
Node button,
boolean expanded)
Updates the toggle button depending on the folding state of the group node.
|
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 CollapsibleNodeStyleDecoratorRenderer()
CollapsibleNodeStyleDecoratorRenderer class.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.
protected Node createButton(IRenderContext context)
The button state is automatically synchronized with the folding state of the group node. In other words, it is unchecked
if the group node is expanded and vice versa.
protected ISelectionIndicatorInstaller createSelectionInstaller()
ISelectionIndicatorInstaller.RectangleIndicatorInstaller that uses
RectangleIndicatorInstaller.SELECTION_TEMPLATE_KEY.public Node createVisual(IRenderContext context)
This method uses createButton(IRenderContext) to create the togglebutton instance. It will then use the getButtonPlacement()
to determine the placement of the button and use the getWrappedStyle() to create the visual for the actual
node.
createVisual in interface IVisualCreatorcontext - The context that describes where the visual will be used.null.IVisualCreator.updateVisual(IRenderContext, Node)public RectD getBounds(ICanvasContext context)
getWrappedStyle() and takes the button into account.getBounds in interface IBoundsProvidercontext - the context to calculate the bounds forRectD.EMPTY to indicate an unbound areapublic IBoundsProvider getBoundsProvider(INode node, INodeStyle style)
getBoundsProvider in interface INodeStyleRenderernode - 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.thisgetBounds(ICanvasContext)protected ILabelModelParameter getButtonPlacement()
ButtonPlacement for the current
Style.protected SizeD getButtonSize()
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)public IHitTestable getHitTestable(INode node, INodeStyle style)
getHitTestable in interface INodeStyleRenderernode - 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.thisisHit(IInputModeContext, PointD)public PointD getIntersection(PointD inner, PointD outer)
getWrappedStyle().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)
getMarqueeTestable in interface INodeStyleRenderernode - 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.thisisInBox(IInputModeContext, RectD)protected final INode getNode()
setNode(INode)public GeneralPath getOutline()
getWrappedStyle().getOutline in interface IShapeGeometrynull if no outline can be provided.public IShapeGeometry getShapeGeometry(INode node, INodeStyle style)
getShapeGeometry in interface INodeStyleRenderernode - 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.thisisInside(PointD),
getIntersection(PointD, PointD)protected final CollapsibleNodeStyleDecorator getStyle()
setStyle(CollapsibleNodeStyleDecorator)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)protected INodeStyle getWrappedStyle()
protected boolean isExpanded(IRenderContext context, INode node)
public boolean isHit(IInputModeContext context, PointD location)
getWrappedStyle() and checks the button.isHit in interface IHitTestablecontext - the context the hit test is performed inlocation - the coordinates in world coordinate systempublic boolean isInBox(IInputModeContext context, RectD rectangle)
getWrappedStyle().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)
getWrappedStyle().isInside in interface IShapeGeometrylocation - The point to test.public boolean isVisible(ICanvasContext context, RectD rectangle)
getWrappedStyle().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)
ILookupnull.
Typically, this method will be called in order to obtain a different view or
aspect of the current instance. This is quite similar to casting or using
a super type or interface of this instance, but is not limited to inheritance or
compile time constraints. An instance implementing this method is not
required to return non-null implementations for the types, nor does it
have to return the same instance any time. Also it depends on the
type and context whether the instance returned stays up to date or needs to
be reobtained for subsequent use.protected final void setNode(INode value)
value - The Node to set.getNode()protected final void setStyle(CollapsibleNodeStyleDecorator value)
value - The Style to set.getStyle()protected void updateButton(IRenderContext context, Node button, boolean expanded)
The default implementation assumes a Labeled button instance
that was configured by createButton(IRenderContext).
expanded - true if the group node is expanded;
false if it is collapsed.IFoldingView.isExpanded(INode)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