public class ContextConfigurator extends Object
IRenderContext
object for exporting the contents of a CanvasControl
(see
#setup(CanvasControl)
).
WorldBounds
.Scale
. For a given target width or height, the
apropriate scale can be calculated using calculateScaleForWidth(double)
and
calculateScaleForHeight(double)
.
Constructor and Description |
---|
ContextConfigurator(RectD worldBounds)
Creates a new
ContextConfigurator instance for the given world bounds and scale. |
ContextConfigurator(RectD worldBounds,
double scale)
Creates a new
ContextConfigurator instance for the given world bounds and scale. |
Modifier and Type | Method and Description |
---|---|
double |
calculateScaleForHeight(double height)
|
double |
calculateScaleForWidth(double width)
|
IRenderContext |
createRenderContext(CanvasControl canvas)
Returns an initialized IRenderContext and taht contains a transforms and clip such that
a part of the given CanvasControl instance can be exported.
|
InsetsD |
getMargin()
Gets the margins for the exported image.
|
double |
getScale()
Gets the scale for the export.
|
int |
getViewHeight()
|
int |
getViewWidth()
|
RectD |
getWorldBounds()
Gets the bounds of the content to export in world coordinates.
|
double |
getZoom()
Gets the
Zoom property to use during the creation of the
visualization. |
void |
setMargin(InsetsD value)
Sets the margins for the exported image.
|
void |
setScale(double value)
Sets the scale for the export.
|
void |
setWorldBounds(RectD value)
Sets the bounds of the content to export in world coordinates.
|
void |
setZoom(double value)
Sets the
Zoom property to use during the creation of the
visualization. |
public ContextConfigurator(RectD worldBounds)
ContextConfigurator
instance for the given world bounds and scale.worldBounds
- the bounds of the content to export, see WorldBounds
public ContextConfigurator(RectD worldBounds, double scale)
ContextConfigurator
instance for the given world bounds and scale.worldBounds
- the bounds of the content to export, see WorldBounds
scale
- the scale, see Scale
public final double calculateScaleForHeight(double height)
Scale
to in order to achieve the given target height (without
Margin
).height
- the height of the target imagepublic final double calculateScaleForWidth(double width)
Scale
to in order to achieve the given target width (without
Margin
).width
- the width of the target imagepublic IRenderContext createRenderContext(CanvasControl canvas)
canvas
- the CanvasControl
instance to export fromIRenderContext
to use for creating the content to exportpublic final InsetsD getMargin()
The margins are added to the content. This means that an image with non-zero margins is larger than the WorldBounds
even if the Scale
is
1.0
. The margins are not scaled. They are interpreted to be in units (pixels for bitmaps) for the resulting
image. The default is an empty margin instance.
setMargin(InsetsD)
public final double getScale()
A scale of 1
preserves the original size, a scale of 0.5
results in a target image with half the
original size and so on.
This value has to be strictly greater than 0
. Its default value is 1.0
setScale(double)
public final int getViewHeight()
public final int getViewWidth()
public RectD getWorldBounds()
setWorldBounds(RectD)
public final double getZoom()
Zoom
property to use during the creation of the
visualization.
In contrast to the Scale
property, which works on the output graphics, this property determines what
zoom value is to be assumed on the canvas when creating the visual. This can affect the rendering of zoom dependent
visuals.
This value has to be strictly greater than 0
. Its default value is 1.0
setZoom(double)
public final void setMargin(InsetsD value)
The margins are added to the content. This means that an image with non-zero margins is larger than the WorldBounds
even if the Scale
is
1.0
. The margins are not scaled. They are interpreted to be in units (pixels for bitmaps) for the resulting
image. The default is an empty margin instance.
value
- The Margin to set.getMargin()
public final void setScale(double value)
A scale of 1
preserves the original size, a scale of 0.5
results in a target image with half the
original size and so on.
This value has to be strictly greater than 0
. Its default value is 1.0
value
- The Scale to set.getScale()
public void setWorldBounds(RectD value)
value
- The WorldBounds to set.getWorldBounds()
public final void setZoom(double value)
Zoom
property to use during the creation of the
visualization.
In contrast to the Scale
property, which works on the output graphics, this property determines what
zoom value is to be assumed on the canvas when creating the visual. This can affect the rendering of zoom dependent
visuals.
This value has to be strictly greater than 0
. Its default value is 1.0
value
- The Zoom to set.getZoom()