Graphics2D Actor API

g2d.swing
Class IOPComponent

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by g2d.swing.IOPComponent
All Implemented Interfaces:
KeyListener, MouseListener, MouseMotionListener, MouseWheelListener, ImageObserver, MenuContainer, Serializable, EventListener

public class IOPComponent
extends JComponent
implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener

Main component to be displayed in an IOPView.

Since:
August 2004
Author:
Ben Funnell
See Also:
IOPView, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static boolean DEBUG
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
IOPComponent()
           
 
Method Summary
 void add(Glyphish glyphs)
           
 void add(Glyphish glyphs, AffineTransform position)
           
 void addZoomListener(ZoomListener zl)
          Add given zoom listener to list of objects to be notified upon zoom change.
 void centerOn(Glyphish g)
          Deprecated. use centerOn(java.awt.geom.Rectangle2D) instead
 AffineTransform centerOn(Rectangle2D rect)
          Center component on given rectangle.
 void checkSize()
           
 double getZoomScale()
          Obtain current zoom scale in effect.
 boolean isGlyphishVisible(Glyphish g)
          Test whether given glyphish thing is currently visible.
 void keyPressed(KeyEvent e)
           
 void keyReleased(KeyEvent e)
           
 void keyTyped(KeyEvent e)
           
 void mouseClicked(MouseEvent e)
           
 void mouseDragged(MouseEvent e)
           
 void mouseEntered(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
 void mouseWheelMoved(MouseWheelEvent e)
           
 void paintComponent(Graphics g)
           
 void remove(Glyphish glyphs)
           
 void removeZoomListener(ZoomListener zl)
          Remove given zoom listener from list of objects to be notified upon zoom change.
 void setGraph(IOPGraph graph)
           
 void setKeyAction(int type, Closure fun)
           
 void setMouseAction(int type, Closure fun)
           
 void zoom(double factor)
          Apply given factor to current zoom.
 Rectangle2D zoomBound(Rectangle2D bound)
           
 Point2D zoomPoint(MouseEvent e)
           
 void zoomToFit(double width, double height)
           
 void zoomToFit(double width, double height, Rectangle2D rect)
           
 void zoomToOriginal()
          Zoom to original size of glyph list.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

public static final boolean DEBUG
See Also:
Constant Field Values
Constructor Detail

IOPComponent

public IOPComponent()
Method Detail

add

public void add(Glyphish glyphs)

remove

public void remove(Glyphish glyphs)

setGraph

public void setGraph(IOPGraph graph)

add

public void add(Glyphish glyphs,
                AffineTransform position)

isGlyphishVisible

public boolean isGlyphishVisible(Glyphish g)
Test whether given glyphish thing is currently visible. Returns false if glyphish is not entirely inside the currently visible rectangle. If given glyph is null returns false.

Parameters:
g - Glyphish thing to test visibility of
Returns:
true, if glyph is completely visible, false otherwise

setMouseAction

public void setMouseAction(int type,
                           Closure fun)

paintComponent

public void paintComponent(Graphics g)
Overrides:
paintComponent in class JComponent

checkSize

public void checkSize()

addZoomListener

public void addZoomListener(ZoomListener zl)
Add given zoom listener to list of objects to be notified upon zoom change.

Parameters:
zl - ZoomListener to be notified upon zoom change

removeZoomListener

public void removeZoomListener(ZoomListener zl)
Remove given zoom listener from list of objects to be notified upon zoom change.

Parameters:
zl - ZoomListener to be removed

getZoomScale

public double getZoomScale()
Obtain current zoom scale in effect. Uses only x-portion of scaling in the current affine transformation as this should be equal to the y-portion of scaling.

Returns:
Current scaling factor in effect for x- and y-axis

zoom

public void zoom(double factor)
Apply given factor to current zoom. A value smaller than 1.0 means zooming out (everything becomes smaller). A value greater than 1.0 means zooming in (everything becomes bigger).

Parameters:
factor - Zoom factor to apply

centerOn

public void centerOn(Glyphish g)
Deprecated. use centerOn(java.awt.geom.Rectangle2D) instead


centerOn

public AffineTransform centerOn(Rectangle2D rect)
Center component on given rectangle. Tries to move given rectangle to center but won't go across boundaries of the underleying canvas.

Parameters:
rect - Rectangle to center on
Returns:
AffineTransform describing the transformation done

zoomBound

public Rectangle2D zoomBound(Rectangle2D bound)

zoomToFit

public void zoomToFit(double width,
                      double height,
                      Rectangle2D rect)

zoomToFit

public void zoomToFit(double width,
                      double height)

zoomToOriginal

public void zoomToOriginal()
Zoom to original size of glyph list.


zoomPoint

public Point2D zoomPoint(MouseEvent e)

mouseWheelMoved

public void mouseWheelMoved(MouseWheelEvent e)
Specified by:
mouseWheelMoved in interface MouseWheelListener

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
Specified by:
mouseExited in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)
Specified by:
mouseEntered in interface MouseListener

mouseClicked

public void mouseClicked(MouseEvent e)
Specified by:
mouseClicked in interface MouseListener

mouseMoved

public void mouseMoved(MouseEvent e)
Specified by:
mouseMoved in interface MouseMotionListener

mouseDragged

public void mouseDragged(MouseEvent e)
Specified by:
mouseDragged in interface MouseMotionListener

setKeyAction

public void setKeyAction(int type,
                         Closure fun)

keyTyped

public void keyTyped(KeyEvent e)
Specified by:
keyTyped in interface KeyListener

keyReleased

public void keyReleased(KeyEvent e)
Specified by:
keyReleased in interface KeyListener

keyPressed

public void keyPressed(KeyEvent e)
Specified by:
keyPressed in interface KeyListener

Graphics2D Actor API