jfig.gui
Class JFigViewerBean

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byjfig.gui.JFigViewerBean
All Implemented Interfaces:
javax.accessibility.Accessible, FigDrawableEnumerator, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class JFigViewerBean
extends javax.swing.JPanel
implements FigDrawableEnumerator

A FIG file viewer implemented as a Java Bean component. The FIG file is specified via an URL with any of the standard protocols (file:, http:, ftp:, resource:, ... ).

A popup-menu allows to specify several options. The viewer implements mouse-dragging and a few keyboard shortcuts. Use the setURL() method to specify the FIG file. For example, JFigViewerBean viewer = new JFigViewerBean(); viewer.setPreferredSize( new Dimension( 600, 500 ) ); viewer.setURL( "file://C:/temp/house.fig" ); JFrame frame = new JFrame( "FIG Bean Demo" ); frame.getContentPane().add( "Center", viewer ); frame.pack(); frame.show(); viewer.doZoomFit();

See Also:
Serialized Form

Nested Class Summary
 class JFigViewerBean.DefaultKeyHandler
           
 class JFigViewerBean.DefaultPopupMenu
           
 class JFigViewerBean.MouseDragHandler
           
 class JFigViewerBean.PositionAndZoomPanel
           
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  boolean antiAlias
           
protected  FigAttribs attribs
           
protected  JConsole console
           
protected  boolean debug
           
protected  boolean enableRulerDragging
           
protected  java.net.URL figURL
           
protected  int gridMode
           
protected  java.lang.String iconpath
           
protected  FigCanvas objectCanvas
           
protected  FigObjectList objectList
           
protected  FigParser parser
           
protected  boolean renderQuality
           
protected  boolean showRulers
           
protected  double zoomFactor
           
 
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.Container
 
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
JFigViewerBean()
           
 
Method Summary
 void createDefaultDragHandler()
           
 void createDefaultKeyHandler()
           
 void createDefaultPopupMenu()
           
 void createDefaultPopupMenu(boolean allowExit)
           
static javax.swing.JFrame createFrame(JFigViewerBean viewer)
           
 void createPositionAndZoomPanel()
           
static JFigViewerBean createViewer(java.lang.String urlname)
          create a JFigViewerBean with default popup-menu, default key-handler, showing the given URL.
 void doExit()
           
 void doFullRedraw()
           
 void doPanDown(java.lang.Object arg)
           
 void doPanHome(java.lang.Object arg)
           
 void doPanLeft(java.lang.Object arg)
           
 void doPanRight(java.lang.Object arg)
           
 void doPanUp(java.lang.Object arg)
           
 void doSelectURL()
          query the user to select a new URL, then try to load the specified FIG file/URL.
 void doShowAbout()
           
 void doShowHelpTopics()
           
 void doShowMessages()
           
 void doSpecifyAnchor()
           
 void doSpecifyZoomFactor()
           
 void doToggleAntiAlias()
           
 void doToggleGridMode()
           
 void doToggleRenderQuality()
           
 void doToggleShowRulers()
           
 void doToggleUnits()
           
 void doZoom11()
           
 void doZoomFactor(double factor)
           
 void doZoomFit()
           
 void doZoomFitAssumingDimension(java.awt.Dimension d)
           
 void doZoomFitWidth()
           
 java.awt.Point getAnchor()
           
 boolean getAntiAlias()
           
 boolean getDebug()
           
 java.util.Enumeration getDrawableObjects()
          ** ObjectEnumerator stuff ** ** **
 boolean getEnableRulerDragging()
           
 FigCanvas getFigCanvas()
           
 int getGridMode()
           
 javax.swing.Icon getIcon()
           
 FigObjectList getObjectList()
          get a reference to our internal object list.
 boolean getRenderQuality()
           
 boolean getShowRulers()
           
 FigDrawable getTmpObject()
          return a reference to the current 'active' (temporary) object
 int getUnits()
           
 java.net.URL getURL()
           
 double getZoomFactor()
           
static void main(java.lang.String[] args)
           
static void msg(java.lang.String s)
           
 void NOT_YET()
           
 void setAnchor(java.awt.Point anchor)
           
 void setAntiAlias(boolean b)
           
 void setDebug(boolean _debug)
           
 void setEnableRulerDragging(boolean b)
           
 void setFigCanvas(FigCanvas canvas)
          set a new canvas for this bean.
 void setGridMode(int mode)
           
 void setObjectList(FigObjectList tmp)
          set a new object list.
 void setRenderQuality(boolean b)
           
 void setShowRulers(boolean b)
           
 void setUnits(int mode)
           
 void setURL(java.net.URL url)
          set a new URL and display the URL contents as a FIG 3.2 file.
 void setZoomFactor(double factor)
          set the canvas zoom factor to the specified value; additionally we modify the anchor to maintain the drawing's translation (the fixpoint being the current screen's center point).
 void setZoomFit()
          just a slightly-more-bean-compatible name for doZoomFit()
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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

console

protected JConsole console

objectCanvas

protected FigCanvas objectCanvas

attribs

protected FigAttribs attribs

parser

protected FigParser parser

objectList

protected FigObjectList objectList

figURL

protected java.net.URL figURL

debug

protected boolean debug

antiAlias

protected boolean antiAlias

renderQuality

protected boolean renderQuality

showRulers

protected boolean showRulers

zoomFactor

protected double zoomFactor

gridMode

protected int gridMode

enableRulerDragging

protected boolean enableRulerDragging

iconpath

protected java.lang.String iconpath
Constructor Detail

JFigViewerBean

public JFigViewerBean()
Method Detail

setURL

public void setURL(java.net.URL url)
set a new URL and display the URL contents as a FIG 3.2 file.


getURL

public java.net.URL getURL()

getFigCanvas

public FigCanvas getFigCanvas()

setFigCanvas

public void setFigCanvas(FigCanvas canvas)
set a new canvas for this bean. You would only need to call this method if you plan to provide your own FigCanvas implementation instead of the default FigSwingCanvas.


getObjectList

public FigObjectList getObjectList()
get a reference to our internal object list. Direct access to the object list allows to enumerate and to change the list; for example, to delete or add objects, or to change their attributes and coordinates. (Note that you may have to call doFullRedraw() after modifying the object list).


setObjectList

public void setObjectList(FigObjectList tmp)
set a new object list. Note that you may want to call doFullRedraw() and some of the zoom and panning functions after setting a new object list, in order to acutally display the new objects...


getDebug

public boolean getDebug()

setDebug

public void setDebug(boolean _debug)

getZoomFactor

public double getZoomFactor()

getGridMode

public int getGridMode()

setGridMode

public void setGridMode(int mode)

setShowRulers

public void setShowRulers(boolean b)

getShowRulers

public boolean getShowRulers()

setEnableRulerDragging

public void setEnableRulerDragging(boolean b)

getEnableRulerDragging

public boolean getEnableRulerDragging()

setUnits

public void setUnits(int mode)

getUnits

public int getUnits()

setAnchor

public void setAnchor(java.awt.Point anchor)

getAnchor

public java.awt.Point getAnchor()

setZoomFactor

public void setZoomFactor(double factor)
set the canvas zoom factor to the specified value; additionally we modify the anchor to maintain the drawing's translation (the fixpoint being the current screen's center point). Use an additional call to setAnchor() if you want to also explicitly set the translation.


doZoomFit

public void doZoomFit()

setZoomFit

public void setZoomFit()
just a slightly-more-bean-compatible name for doZoomFit()


doZoomFitAssumingDimension

public void doZoomFitAssumingDimension(java.awt.Dimension d)

setRenderQuality

public void setRenderQuality(boolean b)

getRenderQuality

public boolean getRenderQuality()

setAntiAlias

public void setAntiAlias(boolean b)

getAntiAlias

public boolean getAntiAlias()

createDefaultKeyHandler

public void createDefaultKeyHandler()

createDefaultPopupMenu

public void createDefaultPopupMenu()

createDefaultPopupMenu

public void createDefaultPopupMenu(boolean allowExit)

createDefaultDragHandler

public void createDefaultDragHandler()

createPositionAndZoomPanel

public void createPositionAndZoomPanel()

msg

public static void msg(java.lang.String s)

NOT_YET

public void NOT_YET()

getIcon

public javax.swing.Icon getIcon()

doShowAbout

public void doShowAbout()

doShowMessages

public void doShowMessages()

doShowHelpTopics

public void doShowHelpTopics()

doSelectURL

public void doSelectURL()
query the user to select a new URL, then try to load the specified FIG file/URL.


doExit

public void doExit()

doZoomFactor

public void doZoomFactor(double factor)

doZoom11

public void doZoom11()

doZoomFitWidth

public void doZoomFitWidth()

doSpecifyZoomFactor

public void doSpecifyZoomFactor()

doPanHome

public void doPanHome(java.lang.Object arg)

doPanLeft

public void doPanLeft(java.lang.Object arg)

doPanRight

public void doPanRight(java.lang.Object arg)

doPanUp

public void doPanUp(java.lang.Object arg)

doPanDown

public void doPanDown(java.lang.Object arg)

doSpecifyAnchor

public void doSpecifyAnchor()

doToggleAntiAlias

public void doToggleAntiAlias()

doToggleRenderQuality

public void doToggleRenderQuality()

doToggleShowRulers

public void doToggleShowRulers()

doToggleUnits

public void doToggleUnits()

doToggleGridMode

public void doToggleGridMode()

doFullRedraw

public void doFullRedraw()

getDrawableObjects

public java.util.Enumeration getDrawableObjects()
** ObjectEnumerator stuff ** ** **

Specified by:
getDrawableObjects in interface FigDrawableEnumerator

getTmpObject

public FigDrawable getTmpObject()
Description copied from interface: FigDrawableEnumerator
return a reference to the current 'active' (temporary) object

Specified by:
getTmpObject in interface FigDrawableEnumerator

createViewer

public static JFigViewerBean createViewer(java.lang.String urlname)
create a JFigViewerBean with default popup-menu, default key-handler, showing the given URL. Just pack this into a JFrame and you have a simple FIG-file viewer.


createFrame

public static javax.swing.JFrame createFrame(JFigViewerBean viewer)

main

public static void main(java.lang.String[] args)