jview
Class JViewportButton.ViewportIcon

java.lang.Object
  extended by jview.JViewportButton.ViewportIcon
All Implemented Interfaces:
PropertyChangeListener, EventListener, Icon
Enclosing class:
JViewportButton

private class JViewportButton.ViewportIcon
extends Object
implements Icon, PropertyChangeListener

The icon to be displayed on the button. It shows a rectangular area as big as its size and inlayed the size of the currently active viewport. If the viewport size changes, we are notified via a property change.


Field Summary
private  Rectangle2D curview
          The current viewport clipping.
 
Constructor Summary
private JViewportButton.ViewportIcon(JViewportCanvas canvas)
          Creates a viewport icon with the desired viewport.
 
Method Summary
 int getIconHeight()
          The height of the icon.
 int getIconWidth()
          The width of the icon equals the width of the button.
 void paintIcon(Component button, Graphics g, int x, int y)
          Paints the icon onto the graphics.
 void propertyChange(PropertyChangeEvent e)
          Notified when a viewport has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

curview

private Rectangle2D curview
The current viewport clipping.

Constructor Detail

JViewportButton.ViewportIcon

private JViewportButton.ViewportIcon(JViewportCanvas canvas)
Creates a viewport icon with the desired viewport. We register as a property change listener to the viewport.

Method Detail

getIconWidth

public int getIconWidth()
The width of the icon equals the width of the button.

Specified by:
getIconWidth in interface Icon

getIconHeight

public int getIconHeight()
The height of the icon.

Specified by:
getIconHeight in interface Icon

paintIcon

public void paintIcon(Component button,
                      Graphics g,
                      int x,
                      int y)
Paints the icon onto the graphics. We draw a rectangle using the default color and spanning the size of the component. Then, the current viewport is painted inside this rectangle.

Specified by:
paintIcon in interface Icon

propertyChange

public void propertyChange(PropertyChangeEvent e)
Notified when a viewport has changed.

Specified by:
propertyChange in interface PropertyChangeListener