DESY ACOP Beans Home

de.desy.acop.video
Class ScaleHelper

java.lang.Object
  extended by de.desy.acop.video.ScaleHelper

public class ScaleHelper
extends java.lang.Object

ScaleHelper provides methods for converting rectangles from image coordinates to component (display) coordinates. It also keeps track of the image rectangle inside the component (which can be different than the component's rectangle if aspect ratio should be kept).

Author:
Tilen Kusterle, Cosylab

Field Summary
static java.lang.String PROPERTY_ACTIVE_RECTANGLE
           
static java.lang.String PROPERTY_AOI_ZOOM
           
static java.lang.String PROPERTY_COMPONENT_DIMENSION
           
static java.lang.String PROPERTY_IMAGE_AOI
           
static java.lang.String PROPERTY_IMAGE_DIMENSION
           
static java.lang.String PROPERTY_IMAGE_ZOOM
           
static java.lang.String PROPERTY_KEEP_ASPECT_RATIO
           
 
Constructor Summary
ScaleHelper(boolean keepAspectRatio, boolean aoiZoom, ImageZoom imageZoom)
          Constructs this ScaleHelper.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a PropertyChangeListener.
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Adds a PropertyChangeListener for the specified propertyName.
 java.awt.Rectangle componentToImage(java.awt.geom.Rectangle2D componentRect)
          Transforms a rectangle contained within the component from display coordinates to image coordinates.
 java.awt.geom.Rectangle2D getActiveRectangle()
          Gets the active rectangle (the part of the component occupied by the displayed image).
 java.awt.Dimension getComponentDimension()
          Gets the dimension of the component.
 java.awt.Rectangle getImageAoi()
          Gets the image AOI rectangle.
 java.awt.Dimension getImageDimension()
          Gets the dimension of the image.
 ImageZoom getImageZoom()
          Gets the ImageZoom property.
 java.awt.geom.Rectangle2D imageToComponent(java.awt.geom.Rectangle2D rectangle)
          Transforms a rectangle contained within the image from image coordinates to display coordinates within the component.
 boolean isAoiZoom()
          Gets the AOI zoom property.
 boolean isKeepAspectRatio()
          Gets the keep aspect ratio property.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes a PropertyChangeListener.
 void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Removes a PropertyChangeListener for the specified propertyName.
 void setAoiZoom(boolean aoiZoom)
          Sets the AOI zoom property.
 void setComponentDimesnion(java.awt.Dimension componentDimension)
          Sets the dimension of the component.
 void setImageData(java.awt.Dimension imageDimension, java.awt.Rectangle imageAoi)
          Sets the image image data (dimension and AOI).
 void setImageZoom(ImageZoom imageZoom)
          Sets the ImageZoom property.
 void setKeepAspectRatio(boolean keepAspectRatio)
          Sets the keep aspect ratio property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_IMAGE_AOI

public static final java.lang.String PROPERTY_IMAGE_AOI
See Also:
Constant Field Values

PROPERTY_IMAGE_DIMENSION

public static final java.lang.String PROPERTY_IMAGE_DIMENSION
See Also:
Constant Field Values

PROPERTY_COMPONENT_DIMENSION

public static final java.lang.String PROPERTY_COMPONENT_DIMENSION
See Also:
Constant Field Values

PROPERTY_ACTIVE_RECTANGLE

public static final java.lang.String PROPERTY_ACTIVE_RECTANGLE
See Also:
Constant Field Values

PROPERTY_KEEP_ASPECT_RATIO

public static final java.lang.String PROPERTY_KEEP_ASPECT_RATIO
See Also:
Constant Field Values

PROPERTY_AOI_ZOOM

public static final java.lang.String PROPERTY_AOI_ZOOM
See Also:
Constant Field Values

PROPERTY_IMAGE_ZOOM

public static final java.lang.String PROPERTY_IMAGE_ZOOM
See Also:
Constant Field Values
Constructor Detail

ScaleHelper

public ScaleHelper(boolean keepAspectRatio,
                   boolean aoiZoom,
                   ImageZoom imageZoom)
Constructs this ScaleHelper.

Parameters:
keepAspectRatio - is aspect ratio kept or not
Method Detail

componentToImage

public java.awt.Rectangle componentToImage(java.awt.geom.Rectangle2D componentRect)
Transforms a rectangle contained within the component from display coordinates to image coordinates.

Parameters:
componentRect - the rectangle in display coordinates to transform
Returns:
the transformed rectangle in image coordinates

imageToComponent

public java.awt.geom.Rectangle2D imageToComponent(java.awt.geom.Rectangle2D rectangle)
Transforms a rectangle contained within the image from image coordinates to display coordinates within the component.

Parameters:
rectangle - the rectangle in image coordinates to transform
Returns:
the transformed rectangle in display coordinates

getImageDimension

public java.awt.Dimension getImageDimension()
Gets the dimension of the image.

Returns:
the imageDimension

getImageAoi

public java.awt.Rectangle getImageAoi()
Gets the image AOI rectangle.

Returns:
the imageAoi

setImageData

public void setImageData(java.awt.Dimension imageDimension,
                         java.awt.Rectangle imageAoi)
Sets the image image data (dimension and AOI).

Parameters:
imageDimension - the imageDimension to set
imageAoi - the imageAoi to set

getComponentDimension

public java.awt.Dimension getComponentDimension()
Gets the dimension of the component.

Returns:
the componentDimension

setComponentDimesnion

public void setComponentDimesnion(java.awt.Dimension componentDimension)
Sets the dimension of the component.

Parameters:
componentDimension - the componentDimension to set

getActiveRectangle

public java.awt.geom.Rectangle2D getActiveRectangle()
Gets the active rectangle (the part of the component occupied by the displayed image).

Returns:
the activeRectangle

isKeepAspectRatio

public boolean isKeepAspectRatio()
Gets the keep aspect ratio property.

Returns:
the keepAspectRatio

setKeepAspectRatio

public void setKeepAspectRatio(boolean keepAspectRatio)
Sets the keep aspect ratio property.

Parameters:
keepAspectRatio - the keepAspectRatio to set

isAoiZoom

public boolean isAoiZoom()
Gets the AOI zoom property.

Returns:
the aoiZoom

setAoiZoom

public void setAoiZoom(boolean aoiZoom)
Sets the AOI zoom property.

Parameters:
aoiZoom - the aoiZoom to set

getImageZoom

public ImageZoom getImageZoom()
Gets the ImageZoom property.

Returns:
the imageZoom

setImageZoom

public void setImageZoom(ImageZoom imageZoom)
Sets the ImageZoom property.

Parameters:
imageZoom - the imageZoom to set

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener for the specified propertyName.

Parameters:
propertyName - the name of the property
listener - the PropertyChangeListener to add

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propertyName,
                                         java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener for the specified propertyName.

Parameters:
propertyName - the name of the property
listener - the PropertyChangeListener to remove

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener.

Parameters:
listener - the PropertyChangeListener to add

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener.

Parameters:
listener - the PropertyChangeListener to remove


Copyright © 2010. All Rights Reserved.