Zooming Out and Zooming In (Visual J++)

Take the following steps to add code that can reduce and enlarge the displayed size of the image. This demonstrates the scaling properties that are normally used for zooming in and zooming out. It emphasizes the relationship of the displayed rectangle to the LEAD control.

1. Start with the project that you created in Loading and Displaying an Image.

2. image\btncmd.gif Add two command buttons to your form and name them as follows:

Name

Text

ZoomIn

Zoom In

ZoomOut

Zoom Out

3. Code the ZoomIn button's click event as follows:

private void ZoomIn_click(Object source, Event e)
{
   LEAD1.setAutoSetRects( true );
   LEAD1.setPaintSizeMode( (short) LTOCXU.PaintSizeModeConstants.PAINTSIZEMODE_ZOOM );
   LEAD1.setPaintZoomFactor( LEAD1.getPaintZoomFactor() + 10 );
}

4. Code the ZoomOut button's click procedure as follows:

private void ZoomOut_click(Object source, Event e)
{
   LEAD1.setAutoSetRects( true );
   LEAD1.setPaintSizeMode( (short) LTOCXU.PaintSizeModeConstants.PAINTSIZEMODE_ZOOM );
   if( LEAD1.getPaintZoomFactor() > 10 )
      LEAD1.setPaintZoomFactor( LEAD1.getPaintZoomFactor() - 10 );
}

5. Run your program to test it.