public abstract class AbstractLabelStyle extends Object implements ILabelStyle, Cloneable
ILabelStyle
.
Only createVisual(IRenderContext, ILabel)
and getPreferredSize(ILabel)
need to be implemented by
subclasses, however to improve rendering performance it is highly recommended to implement at least
updateVisual(IRenderContext, Node, ILabel)
, too.
This implementation differs from the straightforward ILabelStyle
implementation in that there is no visible
separation between the style and its
ILabelStyleRenderer
. Instead the renderer used by the base class is fixed and delegates all calls back to
the style instance.
Modifier | Constructor and Description |
---|---|
protected |
AbstractLabelStyle()
Initializes a new instance of the
AbstractLabelStyle class. |
Modifier and Type | Method and Description |
---|---|
protected void |
arrangeByLayout(Node visual,
IOrientedRectangle layout,
boolean autoFlip)
Arranges the given visual for use in a
VisualGroup using the provided layout and auto
flipping rule. |
AbstractLabelStyle |
clone()
Creates a new object that is a copy of the current instance.
|
protected abstract Node |
createVisual(IRenderContext context,
ILabel label)
Callback that creates the visual.
|
protected RectD |
getBounds(ICanvasContext context,
ILabel label)
Gets the bounds of the visual for the label in the given context.
|
protected abstract SizeD |
getPreferredSize(ILabel label)
Callback that returns the preferred
size of the label. |
ILabelStyleRenderer |
getRenderer()
Gets the renderer implementation for this instance.
|
protected boolean |
isHit(IInputModeContext context,
PointD location,
ILabel label)
Determines whether the visual representation of the label has been hit at the given location.
|
protected boolean |
isInBox(IInputModeContext context,
RectD rectangle,
ILabel label)
Determines whether the visualization for the specified label is included in the marquee selection.
|
protected boolean |
isVisible(ICanvasContext context,
RectD rectangle,
ILabel label)
Determines whether the visualization for the specified label is visible in the context.
|
protected Object |
lookup(ILabel label,
Class type)
Performs the
ILookup.lookup(Class) operation for the ILabelStyleRenderer.getContext(ILabel, ILabelStyle)
that has been queried from the Renderer . |
protected Node |
updateVisual(IRenderContext context,
Node oldVisual,
ILabel label)
Callback that updates the visual previously created by
createVisual(IRenderContext, ILabel) . |
protected AbstractLabelStyle()
AbstractLabelStyle
class.protected void arrangeByLayout(Node visual, IOrientedRectangle layout, boolean autoFlip)
VisualGroup
using the provided layout and auto
flipping rule.visual
- The visual to arrange.layout
- The layout to use for arranging.autoFlip
- if set to true
auto flipping logic will be applied.public AbstractLabelStyle clone()
Immutable subclasses should consider returning this
.
clone
in interface ICloneable
clone
in class Object
Object.clone()
.Object.clone()
protected abstract Node createVisual(IRenderContext context, ILabel label)
This method is called in response to a IVisualCreator.createVisual(IRenderContext)
call to the instance that has
been queried from the Renderer
.
context
- The render context.label
- The label to which this style instance is assigned.IVisualCreator.createVisual(IRenderContext)
interface.updateVisual(IRenderContext, Node, ILabel)
protected RectD getBounds(ICanvasContext context, ILabel label)
This method is called in response to a IBoundsProvider.getBounds(ICanvasContext)
call to the instance that has
been queried from the Renderer
.
This implementation simply yields the bounds
of the layout
of the given label.
context
- The canvas context.label
- The label to which this style instance is assigned.protected abstract SizeD getPreferredSize(ILabel label)
size
of the label.label
- The label to which this style instance is assigned.public final ILabelStyleRenderer getRenderer()
The private implementation will delegate all API calls back to this instance.
getRenderer
in interface ILabelStyle
protected boolean isHit(IInputModeContext context, PointD location, ILabel label)
This method is called in response to a IHitTestable.isHit(IInputModeContext, PointD)
call to the instance that
has been queried from the Renderer
.
This implementation returns the result of the IOrientedRectangle.hits(PointD, double)
method invoked for the layout
of the label, the given point
and the hit test radius
of the
canvas context
.
context
- The input mode context.location
- The point to test.label
- The label to which this style instance is assigned.true
if the specified label representation is hit; false
otherwise.protected boolean isInBox(IInputModeContext context, RectD rectangle, ILabel label)
This method is called in response to a IMarqueeTestable.isInBox(IInputModeContext, RectD)
call to the instance
that has been queried from the Renderer
.
This implementation returns the result of the RectD.intersects(IOrientedRectangle, double)
method invoked on rectangle
for the layout
of the label and the context
.
context
- The input mode context.rectangle
- The marquee selection box.label
- The label to which this style instance is assigned.true
if the specified label is visible is selected by the marquee rectangle; false
otherwise.protected boolean isVisible(ICanvasContext context, RectD rectangle, ILabel label)
This method is called in response to a IVisibilityTestable.isVisible(ICanvasContext, RectD)
call to the instance
that has been queried from the Renderer
.
This implementation simply tests whether the bounds
intersect the clip.
context
- The canvas context.rectangle
- The clipping rectangle.label
- The label to which this style instance is assigned.true
if the specified label is visible in the clipping rectangle; false
otherwise.protected Object lookup(ILabel label, Class type)
ILookup.lookup(Class)
operation for the ILabelStyleRenderer.getContext(ILabel, ILabelStyle)
that has been queried from the Renderer
.
This implementation yields null
for everything but:
For these interfaces an implementation will be returned that delegates to the methods in this instance.
label
- The label to use for the context lookup.type
- The type to query.type
or null
.protected Node updateVisual(IRenderContext context, Node oldVisual, ILabel label)
createVisual(IRenderContext, ILabel)
.
This method is called in response to a IVisualCreator.updateVisual(IRenderContext, Node)
call to the instance
that has been queried from the Renderer
. This implementation simply delegates to createVisual(IRenderContext, ILabel)
so subclasses should override to improve rendering performance.
context
- The render context.oldVisual
- The visual that has been created in the call to createVisual(IRenderContext, ILabel)
.label
- The label to which this style instance is assigned.IVisualCreator.createVisual(IRenderContext)
interface.createVisual(IRenderContext, ILabel)