FreeHEP API
Version current

org.freehep.swing.graphics
Class PanelArtistUtilities

java.lang.Object
  extended byorg.freehep.swing.graphics.PanelArtistUtilities

public class PanelArtistUtilities
extends Object

This class is a collection of static methods which are useful for implementations of the PanelArtist interface. Most methods return an AffineTransform which will perform some common operation on a window.

Version:
$Id: PanelArtistUtilities.java,v 1.7 2001/02/28 05:39:42 loomis Exp $
Author:
Charles Loomis
Source Code:
PanelArtistUtilities.java

Constructor Summary
PanelArtistUtilities()
           
 
Method Summary
static AffineTransform getCCWRotateTransform(int width, int height)
          This returns an affine transform which will rotate the contents of the window by 90 degrees.
static AffineTransform getCenteringTransform(int newX, int newY, int width, int height)
          This returns an affine transform which will center the given point in the window.
static AffineTransform getCWRotateTransform(int width, int height)
          This returns an affine transform which will rotate the contents of the window by -90 degrees.
static void getFillingTransform(AffineTransform transform, RectangularShape realBounds, RectangularShape windowBounds)
          This modifies the supplied affine transform so that the rectangle given by realBounds will fit exactly inside the rectangle given by windowBounds.
static void getFittingTransform(AffineTransform transform, RectangularShape realBounds, RectangularShape windowBounds)
          This modifies the supplied affine transform so that the rectangle given by realBounds will fit inside of the rectangle given by windowBounds.
static Rectangle getLocalBounds(Rectangle bounds, Container c)
          This returns the "local" bounds of a component.
static AffineTransform getResizeTransform(int oldWidth, int oldHeight, int newWidth, int newHeight)
          This returns an affine transform which is appropriate for modifying an existing one for a change in the window size.
static AffineTransform getStretchTransform(int oldWidth, int oldHeight, int newWidth, int newHeight)
          This returns an affine transform which is appropriate for modifying an existing one for a change in the window size.
static AffineTransform getXFlipTransform(int width)
          This returns an affine transform which will flip the horizontal axis around.
static AffineTransform getYFlipTransform(int height)
          This returns an affine transform which will flip the vertical axis around.
static AffineTransform getZoomTransform(double zoomFactor, int width, int height)
          This returns an affine transform which will keep the center point in the center and scale the x- and y-directions uniformly by the factor given.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PanelArtistUtilities

public PanelArtistUtilities()
Method Detail

getResizeTransform

public static AffineTransform getResizeTransform(int oldWidth,
                                                 int oldHeight,
                                                 int newWidth,
                                                 int newHeight)
This returns an affine transform which is appropriate for modifying an existing one for a change in the window size. (NOTE: that this transform should be pre-concatenated with the existing one!) The returned transform will satisfy the following constraints: the centerpoint of the old window will map to the center point of the new window, a uniform scaling will be used in both the x and y-directions, the entire visible region of in the old window will be visible in the new window.


getStretchTransform

public static AffineTransform getStretchTransform(int oldWidth,
                                                  int oldHeight,
                                                  int newWidth,
                                                  int newHeight)
This returns an affine transform which is appropriate for modifying an existing one for a change in the window size. (NOTE: that this transform should be pre-concatenated with the existing one!) The final transform will map the four corners of the old window to the four corners of the new window. In general, the scaling in the x and y direction will be different.


getZoomTransform

public static AffineTransform getZoomTransform(double zoomFactor,
                                               int width,
                                               int height)
This returns an affine transform which will keep the center point in the center and scale the x- and y-directions uniformly by the factor given. Note that a value of 1 corresponds to the identify transform, values less than 1 will "zoom out," and values greater than 1 will "zoom in." (NOTE: that this transform should be pre-concatenated with the existing one!)


getXFlipTransform

public static AffineTransform getXFlipTransform(int width)
This returns an affine transform which will flip the horizontal axis around. (NOTE: that this transform should be pre-concatenated with the existing one!) The returned transform will maintain the centerpoint of the window and flip the direction of the x-axis.


getYFlipTransform

public static AffineTransform getYFlipTransform(int height)
This returns an affine transform which will flip the vertical axis around. (NOTE: that this transform should be pre-concatenated with the existing one!) The returned transform will maintain the centerpoint of the window and flip the direction of the y-axis.


getCenteringTransform

public static AffineTransform getCenteringTransform(int newX,
                                                    int newY,
                                                    int width,
                                                    int height)
This returns an affine transform which will center the given point in the window. (NOTE: that this transform should be pre-concatenated with the existing one!) The returned transform will move the given point to the center and maintain the x and y scales.


getCCWRotateTransform

public static AffineTransform getCCWRotateTransform(int width,
                                                    int height)
This returns an affine transform which will rotate the contents of the window by 90 degrees. (NOTE: that this transform should be pre-concatenated with the existing one!) The returned transform will rotate the contents of the window by 90 degrees while keeping the centerpoint the same. The x and y-scaling will be adjusted to keep the same area visible.


getCWRotateTransform

public static AffineTransform getCWRotateTransform(int width,
                                                   int height)
This returns an affine transform which will rotate the contents of the window by -90 degrees. (NOTE: that this transform should be pre-concatenated with the existing one!) The returned transform will rotate the contents of the window by -90 degrees while keeping the centerpoint the same. The x and y-scaling will be adjusted to keep the same area visible.


getFittingTransform

public static void getFittingTransform(AffineTransform transform,
                                       RectangularShape realBounds,
                                       RectangularShape windowBounds)
This modifies the supplied affine transform so that the rectangle given by realBounds will fit inside of the rectangle given by windowBounds. The center of the realBounds rectangle will coincide with that of the windowBounds rectangle. NOTE: THIS ONLY CORRECTLY HANDLES THE CASE WHEN THE USER SPACE RECTANGLE IS CENTERED ON THE ORIGIN.

Parameters:
transform - the transform which will be modified
realBounds - the user space rectangle
windowBounds - the window to map the user rectangle to

getFillingTransform

public static void getFillingTransform(AffineTransform transform,
                                       RectangularShape realBounds,
                                       RectangularShape windowBounds)
This modifies the supplied affine transform so that the rectangle given by realBounds will fit exactly inside the rectangle given by windowBounds. The origins of the realBounds and the windowBounds coincide; the opposite corner corresponds to (x0+dx,y0-dy) for the real coordinates.

Parameters:
transform - the transform which will be modified
realBounds - the user space rectangle
windowBounds - the window to map the user rectangle to

getLocalBounds

public static Rectangle getLocalBounds(Rectangle bounds,
                                       Container c)
This returns the "local" bounds of a component. This does the same calculation as the method of the same name in SwingUtilities, but this doesn't create a new Rectangle, but instead overwrites the one passed in.

Parameters:
bounds - rectangle to modify with the given component's bounds (will create new Rectangle if this is null)
c - component to get the bounds from
Returns:
convenience reference to the rectangle passed in (or the created rectangle)

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.