Search this API

y.io
Class ViewPortConfigurator

java.lang.Object
  extended by y.io.ViewPortConfigurator

public class ViewPortConfigurator
extends java.lang.Object

Convenience class that helps configuring the viewport as it is used by ImageOutputHandler and other classes.

 

Field Summary
static byte CLIP_GRAPH
          Clip type specifier constant.
static byte CLIP_VIEW
          Clip type specifier constant.
static byte SIZE_USE_CUSTOM_HEIGHT
          Size policy specifier.
static byte SIZE_USE_CUSTOM_WIDTH
          Size policy specifier.
static byte SIZE_USE_ORIGINAL
          Size policy specifier.
 
Constructor Summary
ViewPortConfigurator()
          Creates a new instance of ViewPortConfigurator
 
Method Summary
 void configure(Graph2DView viewPort)
          Setup the viewport of the given view according to the current configuration.
 byte getClipType()
          Returns the clip type used to configure the viewport.
 int getCustomHeight()
          Returns the custom height of the viewport.
 int getCustomWidth()
          Returns the custom width of the viewport.
 Graph2D getGraph2D()
          Returns the reference graph used to configure the viewport.
 Graph2DView getGraph2DView()
          Returns the reference view used to configure the viewport.
 int getMargin()
           
 double getScalingFactor()
          Returns the scaling factor that will be applied to the size of the viewport.
 byte getSizeType()
          Returns the size type used to configure the viewport.
 void setClipType(byte clipType)
          Sets the clip type used to configure the viewport.
 void setCustomHeight(int customHeight)
          Sets the height of the viewport.
 void setCustomWidth(int customWidth)
          Sets the width of the viewport.
 void setGraph2D(Graph2D graph)
          Sets the reference graph used to configure the viewport when clip type CLIP_GRAPH is active.
 void setGraph2DView(Graph2DView view)
          Sets the reference view used to configure the viewport when clip type CLIP_VIEW is active.
 void setMargin(int margin)
          When clip type CLIP_GRAPH is being used, then an additional margin of the given size will be added to the size of the viewport.
 void setScalingFactor(double scale)
          Sets the scaling factor that will be applied to the size of the viewport.
 void setSizeType(byte sizeType)
          Sets the size type used to configure the viewport.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLIP_GRAPH

public static byte CLIP_GRAPH
Clip type specifier constant. Adjusts the size of the viewport in a way that the whole diagram nicely fits the output area.

See Also:
setClipType(byte)

CLIP_VIEW

public static byte CLIP_VIEW
Clip type specifier constant. Adjusts the size of the viewport in a way that it displays exactly the same portion of the diagram that another reference view also exposes.

See Also:
setClipType(byte)

SIZE_USE_ORIGINAL

public static byte SIZE_USE_ORIGINAL
Size policy specifier. If the clip type is CLIP_GRAPH, then the viewport will have the size of the diagram as it is given in world coordinates. If the clip type is CLIP_VIEW, then the viewport will have the size of the reference view.


SIZE_USE_CUSTOM_WIDTH

public static byte SIZE_USE_CUSTOM_WIDTH
Size policy specifier. Uses the value set by method setCustomWidth(int) as the width of the viewport. The height will be scaled accordingly to avoid distortions. Invoking this method effectively invalidates the value set by method setCustomHeight(int).


SIZE_USE_CUSTOM_HEIGHT

public static byte SIZE_USE_CUSTOM_HEIGHT
Size policy specifier. Uses the value set by method setCustomHeight(int) as the height of the viewport. The width will be scaled accordingly to avoid distortions. Invoking this method effectively invalidates the value set by method setCustomWidth(int).

Constructor Detail

ViewPortConfigurator

public ViewPortConfigurator()
Creates a new instance of ViewPortConfigurator

Method Detail

configure

public void configure(Graph2DView viewPort)
Setup the viewport of the given view according to the current configuration.


setScalingFactor

public void setScalingFactor(double scale)
Sets the scaling factor that will be applied to the size of the viewport. The original size depends on the configured clip, margin and size type. Specified margins will not be scaled. By default the scaling factor is 1.0.

Throws:
java.lang.IllegalArgumentException - if scale is not positive

getScalingFactor

public double getScalingFactor()
Returns the scaling factor that will be applied to the size of the viewport.

See Also:
setScalingFactor(double)

setMargin

public void setMargin(int margin)
When clip type CLIP_GRAPH is being used, then an additional margin of the given size will be added to the size of the viewport. By default a margin of size 15 is being used.


getMargin

public int getMargin()
See Also:
setMargin(int).

setClipType

public void setClipType(byte clipType)
Sets the clip type used to configure the viewport.

Parameters:
clipType - one of CLIP_VIEW or CLIP_GRAPH. By default CLIP_GRAPH is set.

getClipType

public byte getClipType()
Returns the clip type used to configure the viewport.


setSizeType

public void setSizeType(byte sizeType)
Sets the size type used to configure the viewport.

Parameters:
sizeType - one of SIZE_USE_ORIGINAL, SIZE_USE_CUSTOM_WIDTH or SIZE_USE_CUSTOM_HEIGHT. By default SIZE_USE_ORIGINAL is set.

getSizeType

public byte getSizeType()
Returns the size type used to configure the viewport.


setCustomWidth

public void setCustomWidth(int customWidth)
Sets the width of the viewport. The value will be ignored if a size type other than SIZE_USE_CUSTOM_WIDTH is set. By default a value of 500 is set.

Throws:
java.lang.IllegalArgumentException - if customWidth is not positive

getCustomWidth

public int getCustomWidth()
Returns the custom width of the viewport.


setCustomHeight

public void setCustomHeight(int customHeight)
Sets the height of the viewport. The value will be ignored if a size type other than SIZE_USE_CUSTOM_HEIGHT is set. By default a value of 500 is set.

Throws:
java.lang.IllegalArgumentException - if customHeight is not positive

getCustomHeight

public int getCustomHeight()
Returns the custom height of the viewport.


setGraph2DView

public void setGraph2DView(Graph2DView view)
Sets the reference view used to configure the viewport when clip type CLIP_VIEW is active.


setGraph2D

public void setGraph2D(Graph2D graph)
Sets the reference graph used to configure the viewport when clip type CLIP_GRAPH is active.


getGraph2D

public Graph2D getGraph2D()
Returns the reference graph used to configure the viewport.


getGraph2DView

public Graph2DView getGraph2DView()
Returns the reference view used to configure the viewport.


© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.