edu.mssm.crover.domain2d
Class DrawingSurface

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--edu.mssm.crover.domain2d.PrintablePanel
                                |
                                +--edu.mssm.crover.domain2d.DrawingSurface
All Implemented Interfaces:
javax.accessibility.Accessible, CoolPrint, CoolPrintRescale, java.awt.image.ImageObserver, java.awt.MenuContainer, java.util.Observer, java.awt.print.Printable, java.io.Serializable

public class DrawingSurface
extends PrintablePanel
implements java.util.Observer, java.awt.print.Printable, CoolPrintRescale

Where the drawings are rendered.

See Also:
Serialized Form

Field Summary
protected  java.awt.Color bgColor
           
protected  java.util.Vector lastMinuteDrawings
           
 
Fields inherited from class edu.mssm.crover.domain2d.PrintablePanel
SVG_ANCHOR_HREF_PROPERTY
 
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.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DrawingSurface()
           
 
Method Summary
 java.awt.Component add(java.awt.Component c)
          Do not use add, use addDomain instead.
 void addDomain(Domain2D d2d)
           
 void addDrawing(Drawing d)
          Add a drawing to be rendered when all the residues have been rendered (last-minute drawing).
 void addDrawings(Drawing[] drawings)
          Adds several drawings to this surface.
 void coolPrint(java.awt.Graphics g)
          Paint the children and the last minute drawings.
 void dispose()
          Dispose of this DrawingSurface.
 java.util.Enumeration enumerateDomains()
          Returns domains contained in the surface.
 Domain2D getDomainById(java.lang.String id)
          Return the Domain which has this id.
 java.awt.image.BufferedImage getImage()
          Returns the drawing as an image.
 boolean isOptimizedDrawingEnabled()
           
 void lastMinutePaint(java.awt.Graphics g)
          Paint last minute drawings.
 void pack()
          Pack the SSE.
 void paintChildren(java.awt.Graphics g)
          Paint the children and the last minute drawings.
 void paintComponent(java.awt.Graphics g)
           
 int print(java.awt.Graphics g, java.awt.print.PageFormat pf, int pi)
           
 void removeAllDrawings()
          Remove all the last-minute drawings.
 void removeDrawing(Drawing d)
          Removes all the references to the specified drawing.
 void setBackgroundColor(java.awt.Color bg)
           
 void setPostScriptHeight(float height)
          Sets the height of the diagram when rendered on the page as a PostScript file.
 void setPostScriptResolution(int resolution)
          Sets the resolution of the PostScript output driver.
 void setPostScriptWidth(float width)
          Sets the width of the diagram when rendered on the page as a PostScript file.
 void setPreferredSize(java.awt.Dimension d)
           
 void startDragging(Drawing d)
          Notify the surface that a drawing will be dragged now.
 void stopDragging(Drawing d)
          Notify the surface that a drawing is not dragged anymore.
 void suggestPosition(Drawing d, java.awt.Point dest)
           
 ConstrainedPoint surfacePosition(ConstrainedPoint relativePosition, Drawing comp)
          Returns the position on the drawing surface.
 java.awt.geom.Point2D surfacePosition(double x, double y, java.awt.Component comp)
          Returns the position on the drawing surface.
 java.awt.geom.Point2D surfacePosition(java.awt.geom.Point2D relativePosition, java.awt.Component comp)
          Returns the position on the drawing surface.
 void update(java.awt.Graphics g)
           
 void update(java.util.Observable o, java.lang.Object arg)
           
 
Methods inherited from class edu.mssm.crover.domain2d.PrintablePanel
recurseSVGPrint, svgPrint
 
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, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, 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, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction
 
Methods inherited from class java.awt.Container
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

bgColor

protected java.awt.Color bgColor

lastMinuteDrawings

protected java.util.Vector lastMinuteDrawings
Constructor Detail

DrawingSurface

public DrawingSurface()
Method Detail

getDomainById

public Domain2D getDomainById(java.lang.String id)
Return the Domain which has this id.

Returns:
the Domain2D instance which has this ID, or null if none has been found in this DS.

dispose

public void dispose()
Dispose of this DrawingSurface. Dispatch the call to the Domain2D children, release all the direct references, release the observed objects.


setPreferredSize

public void setPreferredSize(java.awt.Dimension d)
Overrides:
setPreferredSize in class javax.swing.JComponent

addDomain

public void addDomain(Domain2D d2d)

add

public java.awt.Component add(java.awt.Component c)
Do not use add, use addDomain instead.

Overrides:
add in class java.awt.Container

startDragging

public void startDragging(Drawing d)
Notify the surface that a drawing will be dragged now.


stopDragging

public void stopDragging(Drawing d)
Notify the surface that a drawing is not dragged anymore.


lastMinutePaint

public void lastMinutePaint(java.awt.Graphics g)
Paint last minute drawings.


paintChildren

public void paintChildren(java.awt.Graphics g)
Paint the children and the last minute drawings.

Overrides:
paintChildren in class javax.swing.JComponent

coolPrint

public void coolPrint(java.awt.Graphics g)
Paint the children and the last minute drawings.

Specified by:
coolPrint in interface CoolPrint
Overrides:
coolPrint in class PrintablePanel

paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

setBackgroundColor

public void setBackgroundColor(java.awt.Color bg)

pack

public void pack()
Pack the SSE. Always call pack() on the DrawingSurface after packing the frame that contains it. This ensure that the components which are laid out through a LayoutManager have been laid out before we calculate the deltas (relative positions of the first and last residue in the domain).


suggestPosition

public void suggestPosition(Drawing d,
                            java.awt.Point dest)

update

public void update(java.awt.Graphics g)
Overrides:
update in class javax.swing.JComponent

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer

isOptimizedDrawingEnabled

public boolean isOptimizedDrawingEnabled()
Overrides:
isOptimizedDrawingEnabled in class javax.swing.JComponent

getImage

public java.awt.image.BufferedImage getImage()
Returns the drawing as an image.


print

public int print(java.awt.Graphics g,
                 java.awt.print.PageFormat pf,
                 int pi)
          throws java.awt.print.PrinterException
Specified by:
print in interface java.awt.print.Printable
java.awt.print.PrinterException

addDrawing

public void addDrawing(Drawing d)
Add a drawing to be rendered when all the residues have been rendered (last-minute drawing). These kind of drawings are useful to display properties like disulfide bridges as lines between two residues. They require the position of the two glyphs.


addDrawings

public void addDrawings(Drawing[] drawings)
Adds several drawings to this surface.

See Also:
addDrawing(edu.mssm.crover.domain2d.Drawing)

removeDrawing

public void removeDrawing(Drawing d)
Removes all the references to the specified drawing. Multiple inclusions are correctly removed.


removeAllDrawings

public void removeAllDrawings()
Remove all the last-minute drawings. The drawing are NOT disposed.


surfacePosition

public java.awt.geom.Point2D surfacePosition(java.awt.geom.Point2D relativePosition,
                                             java.awt.Component comp)
Returns the position on the drawing surface. Returns a position relative to the top left corner of the drawing surface.

Parameters:
relativePosition - The position relative to the component comp.
comp - The component that host the coordinate system in which relativePosition is expressed.
Returns:
The position on the surface.

surfacePosition

public java.awt.geom.Point2D surfacePosition(double x,
                                             double y,
                                             java.awt.Component comp)
Returns the position on the drawing surface. Returns a position relative to the top left corner of the drawing surface.

Parameters:
x - The x co-ordinate relative to the component comp.
y - The y co-ordinate relative to the component comp.
comp - The component that host the coordinate system in which (x,y) is described.
Returns:
The position on the surface.

surfacePosition

public ConstrainedPoint surfacePosition(ConstrainedPoint relativePosition,
                                        Drawing comp)
Returns the position on the drawing surface. Returns a position relative to the top left corner of the drawing surface.

Parameters:
relativePosition - The position relative to the component comp.
comp - The component that host the coordinate system in which relativePosition is expressed.
Returns:
The position on the surface.

setPostScriptResolution

public void setPostScriptResolution(int resolution)
Sets the resolution of the PostScript output driver. Sets the number of dots per inch the driver puts on a page when rendering.


setPostScriptWidth

public void setPostScriptWidth(float width)
Sets the width of the diagram when rendered on the page as a PostScript file.

Parameters:
width - The desired width or -1 when the width has to be determined from the aspect ratio of the diagram and the dimension of the height. Units are cm.

setPostScriptHeight

public void setPostScriptHeight(float height)
Sets the height of the diagram when rendered on the page as a PostScript file.

Parameters:
height - The desired height or -1 when the height has to be determined from the aspect ratio of the diagram and the dimension of the width. Units are cm.

enumerateDomains

public java.util.Enumeration enumerateDomains()
Returns domains contained in the surface.



Copyright @ 2003 Mount Sinai School of Medicine. All Rights Reserved.