y.io
Class ViewPortConfigurator

java.lang.Object
  |
  +--y.io.ViewPortConfigurator

public class ViewPortConfigurator
extends 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 cofigure 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 cofigure the viewport.
 void setClipType(byte clipType)
          Sets the clip type used to cofigure 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 ViewPortConfigurator.CLIP_GRAPH is active.
 void setGraph2DView(Graph2DView view)
          Sets the reference view used to configure the viewport when clip type ViewPortConfigurator.CLIP_VIEW is active.
 void setMargin(int margin)
          When clip type ViewPortConfigurator.CLIP_GRAPH is being used, then an additionaly 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 cofigure 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:
ViewPortConfigurator.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:
ViewPortConfigurator.setClipType(byte)

SIZE_USE_ORIGINAL

public static byte SIZE_USE_ORIGINAL
Size policy specifier. If the clip type is ViewPortConfigurator.CLIP_GRAPH, then the viewport will have the size of the diagram as it is given in world coordinates. If the clip type is ViewPortConfigurator.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 ViewPortConfigurator.setCustomWidth(int) as the width of the viewport. The height will be scaled accordingly to avoid distortions. Invoking this method effectivly invalidates the value set by method ViewPortConfigurator.setCustomHeight(int).


SIZE_USE_CUSTOM_HEIGHT

public static byte SIZE_USE_CUSTOM_HEIGHT
Size policy specifier. Uses the value set by method ViewPortConfigurator.setCustomHeight(int) as the height of the viewport. The width will be scaled accordingly to avoid distortions. Invoking this method effectivly invalidates the value set by method ViewPortConfigurator.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.


getScalingFactor

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

See Also:
ViewPortConfigurator.setScalingFactor(double)

setMargin

public void setMargin(int margin)
When clip type ViewPortConfigurator.CLIP_GRAPH is being used, then an additionaly 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:
ViewPortConfigurator.setMargin(int).

setClipType

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

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

getClipType

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


setSizeType

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

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

getSizeType

public byte getSizeType()
Returns the size type used to cofigure 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 ViewPortConfigurator.SIZE_USE_CUSTOM_WIDTH is set. By default a value of 500 is set.


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 ViewPortConfigurator.SIZE_USE_CUSTOM_HEIGHT is set. By default a value of 500 is set.


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 ViewPortConfigurator.CLIP_VIEW is active.


setGraph2D

public void setGraph2D(Graph2D graph)
Sets the reference graph used to configure the viewport when clip type ViewPortConfigurator.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-2003,
yWorks GmbH.
All rights reserved.

2003