public class TemplateNodeStyle extends AbstractTemplateStyle<INode> implements INodeStyle
INodeStyle
implementation that can render complex FXML controls for the visualization of INode
s using
a TemplateNodeStyleRenderer
.
The StyleResourceKey
is used to determine the URL
of the FXML file that will be applied to the
Node
. The URL
will be looked-up from the Resources
of the
CanvasControl
the style is used
in.
Constructor and Description |
---|
TemplateNodeStyle()
Creates a new instance with no style resource key and
TemplateNodeStyleRenderer as renderer. |
TemplateNodeStyle(String styleResourceKey)
Creates a new instance using the given resource key and
TemplateNodeStyleRenderer as renderer. |
TemplateNodeStyle(String styleResourceKey,
TemplateNodeStyleRenderer renderer)
Creates a new instance using the given resource key and a custom renderer instance.
|
Modifier and Type | Method and Description |
---|---|
Node |
createControl(IRenderContext context,
INode node)
Factory method that is called by the
TemplateNodeStyleRenderer to create the control that will be used for the
display of the node. |
InsetsD |
getInsets()
Gets the insets the
INodeInsetsProvider implementation for INode should
yield for this instance. |
SizeD |
getMinimumSize()
Gets the minimum size an
INodeSizeConstraintProvider implementation for INode
should yield. |
GeneralPath |
getNormalizedOutline()
Gets the normalized outline of a node that will be displayed using the
created control . |
SizeD |
getPreferredSize(IRenderContext context,
INode node)
Convenience method that determines the preferred size of the node if this style was applied.
|
TemplateNodeStyleRenderer |
getRenderer()
Gets the renderer implementation that can be queried for implementations that provide details about the visual
appearance and visual behavior for a given node and this style instance.
|
protected URL |
getStyle(IRenderContext context,
IModelItem node)
|
String |
getStyleResourceKey()
|
void |
setInsets(InsetsD value)
Sets the insets the
INodeInsetsProvider implementation for INode should
yield for this instance. |
void |
setMinimumSize(SizeD value)
Sets the minimum size an
INodeSizeConstraintProvider implementation for INode
should yield. |
void |
setNormalizedOutline(GeneralPath value)
Sets the normalized outline of a node that will be displayed using the
created control . |
void |
setStyleResourceKey(String value)
|
addPropertyChangedListener, clone, getCanvasPropertyKey, getClassLoader, getContentPropertyKey, getContextLookup, getFXMLLoader, getItemPropertyKey, getStyleTag, onPropertyChanged, removePropertyChangedListener, setCanvasPropertyKey, setClassLoader, setContentPropertyKey, setContextLookup, setItemPropertyKey, setStyleTag
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clone
public TemplateNodeStyle()
TemplateNodeStyleRenderer
as renderer.public TemplateNodeStyle(String styleResourceKey)
TemplateNodeStyleRenderer
as renderer.styleResourceKey
- The key of the style resource that will be used for the Node
.public TemplateNodeStyle(String styleResourceKey, TemplateNodeStyleRenderer renderer)
styleResourceKey
- The key of the style resource that will be used for the Node
.renderer
- The custom renderer for this instance.public Node createControl(IRenderContext context, INode node)
TemplateNodeStyleRenderer
to create the control that will be used for the
display of the node.context
- The context for which the control should be created.node
- The node that will be rendered.public final InsetsD getInsets()
INodeInsetsProvider
implementation for INode
should
yield for this instance.
This is especially useful if this style is used for
group nodes
,
as they require insets for the calculation of the bounds. The insets can be used to make sure that child nodes do not
cover visual elements of the style inside the insets. The default value is an InsetsD
insets with 5
for
all insets.
INodeInsetsProvider
,
INodeStyleRenderer.getContext(INode, INodeStyle)
,
setInsets(InsetsD)
public final SizeD getMinimumSize()
INodeSizeConstraintProvider
implementation for INode
should yield.
The default value is SizeD.EMPTY
.
INodeSizeConstraintProvider
,
setMinimumSize(SizeD)
public final GeneralPath getNormalizedOutline()
created control
.
This shape will be used to satisfy requests to
IMarqueeTestable.isInBox(com.yworks.yfiles.view.input.IInputModeContext, com.yworks.yfiles.geometry.RectD)
,
IHitTestable.isHit(com.yworks.yfiles.view.input.IInputModeContext, com.yworks.yfiles.geometry.PointD)
,
as well as for IShapeGeometry
methods (which affect edge cropping at the node
outline).
This property may be left at or set to null
to indicate default (rectangular) behavior.
The default value is null
.
setNormalizedOutline(GeneralPath)
public SizeD getPreferredSize(IRenderContext context, INode node)
context
- The context for which the size should be calculated. Can be obtained through
CanvasControl.createRenderContext()
.node
- The node to determine the preferred size of. Can be a live node or an SimpleNode
.CanvasControl.createRenderContext()
public final TemplateNodeStyleRenderer getRenderer()
INodeStyle
The idiom for retrieving, e.g. an IVisualCreator
implementation for a given style is:
getRenderer
in interface INodeStyle
protected URL getStyle(IRenderContext context, IModelItem node)
context
- The context for which the style is needed.node
- The node that will be rendered.null
.public final String getStyleResourceKey()
String
that will be used to look up
the URL
to the FXML file which encodes
the Control
.
The default value is null
.
null
in which case the default template will be used.setStyleResourceKey(java.lang.String)
public final void setInsets(InsetsD value)
INodeInsetsProvider
implementation for INode
should
yield for this instance.
This is especially useful if this style is used for
group nodes
,
as they require insets for the calculation of the bounds. The insets can be used to make sure that child nodes do not
cover visual elements of the style inside the insets. The default value is an InsetsD
insets with 5
for
all insets.
value
- The Insets to set.INodeInsetsProvider
,
INodeStyleRenderer.getContext(INode, INodeStyle)
,
getInsets()
public final void setMinimumSize(SizeD value)
INodeSizeConstraintProvider
implementation for INode
should yield.
The default value is SizeD.EMPTY
.
value
- The MinimumSize to set.INodeSizeConstraintProvider
,
getMinimumSize()
public final void setNormalizedOutline(GeneralPath value)
created control
.
This shape will be used to satisfy requests to
IMarqueeTestable.isInBox(com.yworks.yfiles.view.input.IInputModeContext, com.yworks.yfiles.geometry.RectD)
,
IHitTestable.isHit(com.yworks.yfiles.view.input.IInputModeContext, com.yworks.yfiles.geometry.PointD)
,
as well as for IShapeGeometry
methods (which affect edge cropping at the node
outline).
This property may be left at or set to null
to indicate default (rectangular) behavior.
The default value is null
.
value
- The NormalizedOutline to set.getNormalizedOutline()
public final void setStyleResourceKey(String value)
String
that will be used to look up
the URL
to the FXML file which encodes
the Control
.
The default value is null
.
value
- The resource key for the style or null
in which case the default template will be used.getStyleResourceKey()