Class ImageScroller
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----Scroller
|
+----ImageScroller
- public class ImageScroller
- extends Scroller
A scrollable image component.
This class extends the abstract class Scroller by implementing two methods:
getScrollAreaSize which returns the image size, and
scrollTo which translates the appropriate image area to the scroller's
viewport.
Based on class ImageScroller from "Graphic Java 1.1" p. 802.
An alternative is ScrollPane.
Java 1.1 Implementation
- See Also:
- getScrollAreaSize, scrollTo, Scroller, ScrollPane, Panel
-
ImageScroller(Image)
- Construction from an image.
-
ImageScroller(ImageCanvas)
- Construction from an ImageCanvas.
-
getImage()
- Return the image.
-
getScrollAreaSize()
- Report the size of the image being scrolled.
-
scrollTo(int, int)
- Scroll to position (x,y).
-
setImage(Image)
- Set the image to be scrolled.
ImageScroller
public ImageScroller(Image image)
- Construction from an image.
The layout manager is set to BorderLayout so that a large image
will be displayed with scrollbars. If a large image is displayed
according to its preferred size then it may not activate the
scrollbars and consequently may be clipped (FlowLayout uses
preferred sizes); the image will be centered in the ImageScroller
container.
- See Also:
- BorderLayout
ImageScroller
public ImageScroller(ImageCanvas imageCanvas)
- Construction from an ImageCanvas.
Adding an EventListener to an ImageScroller object does not work well
because most of the screen area is consumed by the image.
Adding a listener to an existing ImageCanvas object and then
constructing an ImageScroller object is one solution.
Another is a constructor which has a EventListener argument.
The layout manager is set to BorderLayout so that a large image
will be displayed with scrollbars. If a large image is displayed
according to its preferred size then it may not activate the
scrollbars and consequently may be clipped (FlowLayout uses
preferred sizes); the image will be centered in the ImageScroller
container.
- See Also:
- ImageCanvas, EventListener, BorderLayout
getImage
public Image getImage()
- Return the image.
- Returns:
- the image.
getScrollAreaSize
public Dimension getScrollAreaSize()
- Report the size of the image being scrolled.
- Returns:
- the Dimension of the image being scrolled.
- Overrides:
- getScrollAreaSize in class Scroller
setImage
public void setImage(Image image)
- Set the image to be scrolled.
- Parameters:
- image - the image to be scrolled.
scrollTo
protected void scrollTo(int x,
int y)
- Scroll to position (x,y).
This method performs the work of scrolling to a particular location.
- Parameters:
- x - the value of the horizontal scrollbar.
- y - the value of the vertical scrollbar.
- Overrides:
- scrollTo in class Scroller