Class JChemistryView

  • All Implemented Interfaces:
    java.awt.dnd.DragGestureListener, java.awt.dnd.DragSourceListener, java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener
    Direct Known Subclasses:
    JEditableChemistryView

    public class JChemistryView
    extends javax.swing.JComponent
    implements java.awt.event.ActionListener, java.awt.dnd.DragGestureListener, java.awt.dnd.DragSourceListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Constructor Summary

      Constructors 
      Constructor Description
      JChemistryView​(int chemistryType)
      Creates a new JChemistryView for showing a reaction or molecules.
      JChemistryView​(int chemistryType, int allowedCopyOrDragActions, int allowedPasteOrDropActions)
      Creates a new JChemistryView for showing a reaction or molecules.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent e)  
      void addStructureListener​(StructureListener l)  
      boolean canDrop()  
      void dragDropEnd​(java.awt.dnd.DragSourceDropEvent e)  
      void dragEnter​(java.awt.dnd.DragSourceDragEvent e)  
      void dragExit​(java.awt.dnd.DragSourceEvent e)  
      void dragGestureRecognized​(java.awt.dnd.DragGestureEvent e)  
      void dragOver​(java.awt.dnd.DragSourceDragEvent e)  
      void dropActionChanged​(java.awt.dnd.DragSourceDragEvent e)  
      java.awt.geom.Rectangle2D.Double getChemistryBounds()  
      int getChemistryType()  
      java.awt.geom.Rectangle2D.Double getMoleculeBounds​(int i)
      Returns the bounding rectangle of the indicated molecule, if multiple molecules are shown, e.g.
      java.awt.datatransfer.Transferable getMoleculeTransferable()  
      java.awt.datatransfer.Transferable getReactionTransferable()  
      void informListeners()  
      boolean isEditable()  
      void mouseClicked​(java.awt.event.MouseEvent e)  
      void mouseDragged​(java.awt.event.MouseEvent e)  
      void mouseEntered​(java.awt.event.MouseEvent e)  
      void mouseExited​(java.awt.event.MouseEvent e)  
      void mouseMoved​(java.awt.event.MouseEvent e)  
      void mousePressed​(java.awt.event.MouseEvent e)  
      void mouseReleased​(java.awt.event.MouseEvent e)  
      protected void onDragEnter()  
      protected void onDragExit()  
      protected void onDragOver()  
      protected void onDrop()  
      void paintComponent​(java.awt.Graphics g)  
      void removeStructureListener​(StructureListener l)  
      void setAllowDropOrPasteWhenDisabled​(boolean b)  
      void setContent​(Reaction rxn)  
      void setContent​(Reaction rxn, DrawingObjectList drawingObjectList)  
      void setContent​(StereoMolecule mol)  
      void setContent​(StereoMolecule[] mol)  
      void setContent​(StereoMolecule[] mol, DrawingObjectList drawingObjectList)  
      void setContent​(StereoMolecule mol, DrawingObjectList drawingObjectList)  
      void setDisplayMode​(int displayMode)  
      void setEditable​(boolean b)  
      void setEnabled​(boolean enable)  
      void setFragmentNoColor​(java.awt.Color c)  
      void setOpaqueBackground​(boolean b)  
      void setPasteAndDropOptions​(int options)
      fragment status change on drop is allowed then dropping a fragment (molecule) on a molecule (fragment) inverts the status of the view's chemical object.
      protected void showWarningMessage​(java.lang.String msg)  
      • Methods inherited from class javax.swing.JComponent

        addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, 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, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, 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, 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, getAccessibleContext, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • PASTE_AND_DROP_OPTION_ALLOW_FRAGMENT_STATE_CHANGE

        public static final int PASTE_AND_DROP_OPTION_ALLOW_FRAGMENT_STATE_CHANGE
        See Also:
        Constant Field Values
      • PASTE_AND_DROP_OPTION_KEEP_ATOM_COLORS

        public static final int PASTE_AND_DROP_OPTION_KEEP_ATOM_COLORS
        See Also:
        Constant Field Values
      • PASTE_AND_DROP_OPTION_KEEP_BOND_HIGHLIGHTING

        public static final int PASTE_AND_DROP_OPTION_KEEP_BOND_HIGHLIGHTING
        See Also:
        Constant Field Values
      • PASTE_AND_DROP_OPTION_REMOVE_CATALYSTS

        public static final int PASTE_AND_DROP_OPTION_REMOVE_CATALYSTS
        See Also:
        Constant Field Values
      • PASTE_AND_DROP_OPTION_REMOVE_DRAWING_OBJECTS

        public static final int PASTE_AND_DROP_OPTION_REMOVE_DRAWING_OBJECTS
        See Also:
        Constant Field Values
      • PASTE_AND_DROP_OPTION_LAYOUT_REACTION

        public static final int PASTE_AND_DROP_OPTION_LAYOUT_REACTION
        See Also:
        Constant Field Values
    • Constructor Detail

      • JChemistryView

        public JChemistryView​(int chemistryType)
        Creates a new JChemistryView for showing a reaction or molecules. A JChemistryView uses an ExtendedDepictor to handle multiple molecules or a reaction. For showing one molecule use a JStructureView. The default will support copy/paste and drag&drop from this view only, but dropping anything onto this view doesn't have an effect. Call setEditable(true) to allow changes through drag&drop and pasting.
        Parameters:
        chemistryType - one of ExtendedDepictor.TYPE_MOLECULES and ExtendedDepictor.TYPE_REACTION
      • JChemistryView

        public JChemistryView​(int chemistryType,
                              int allowedCopyOrDragActions,
                              int allowedPasteOrDropActions)
        Creates a new JChemistryView for showing a reaction or molecules. A JChemistryView uses an ExtendedDepictor to handle multiple molecules or a reaction. For showing one molecule use a JStructureView. The default will support copy/paste and drag&drop from this view only, but dropping anything onto this view doesn't have an effect. Call setEditable(true) to allow changes through drag&drop and pasting.
        Parameters:
        chemistryType - one of the ExtendedDepictor.TYPE_... options
        allowedCopyOrDragActions - DnDConstants.ACTION_xxx
        allowedPasteOrDropActions - DnDConstants.ACTION_xxx
    • Method Detail

      • getChemistryType

        public int getChemistryType()
      • setContent

        public void setContent​(Reaction rxn)
      • setOpaqueBackground

        public void setOpaqueBackground​(boolean b)
      • setPasteAndDropOptions

        public void setPasteAndDropOptions​(int options)
        fragment status change on drop is allowed then dropping a fragment (molecule) on a molecule (fragment) inverts the status of the view's chemical object. As default status changes are prohibited.
        Parameters:
        options - flag list of PASTE_AND_DROP_OPTION...
      • setAllowDropOrPasteWhenDisabled

        public void setAllowDropOrPasteWhenDisabled​(boolean b)
      • setEnabled

        public void setEnabled​(boolean enable)
        Overrides:
        setEnabled in class javax.swing.JComponent
      • isEditable

        public boolean isEditable()
      • setEditable

        public void setEditable​(boolean b)
      • setFragmentNoColor

        public void setFragmentNoColor​(java.awt.Color c)
      • setDisplayMode

        public void setDisplayMode​(int displayMode)
      • paintComponent

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

        public java.awt.geom.Rectangle2D.Double getMoleculeBounds​(int i)
        Returns the bounding rectangle of the indicated molecule, if multiple molecules are shown, e.g. of a reaction.
        Parameters:
        i -
        Returns:
        bounds or null, if i is out of range
      • getChemistryBounds

        public java.awt.geom.Rectangle2D.Double getChemistryBounds()
      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent e)
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
      • mousePressed

        public void mousePressed​(java.awt.event.MouseEvent e)
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
      • mouseReleased

        public void mouseReleased​(java.awt.event.MouseEvent e)
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
      • mouseClicked

        public void mouseClicked​(java.awt.event.MouseEvent e)
        Specified by:
        mouseClicked in interface java.awt.event.MouseListener
      • mouseEntered

        public void mouseEntered​(java.awt.event.MouseEvent e)
        Specified by:
        mouseEntered in interface java.awt.event.MouseListener
      • mouseExited

        public void mouseExited​(java.awt.event.MouseEvent e)
        Specified by:
        mouseExited in interface java.awt.event.MouseListener
      • mouseDragged

        public void mouseDragged​(java.awt.event.MouseEvent e)
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
      • mouseMoved

        public void mouseMoved​(java.awt.event.MouseEvent e)
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
      • removeStructureListener

        public void removeStructureListener​(StructureListener l)
      • informListeners

        public void informListeners()
      • canDrop

        public boolean canDrop()
      • showWarningMessage

        protected void showWarningMessage​(java.lang.String msg)
      • getMoleculeTransferable

        public java.awt.datatransfer.Transferable getMoleculeTransferable()
      • getReactionTransferable

        public java.awt.datatransfer.Transferable getReactionTransferable()
      • dragEnter

        public void dragEnter​(java.awt.dnd.DragSourceDragEvent e)
        Specified by:
        dragEnter in interface java.awt.dnd.DragSourceListener
      • dragOver

        public void dragOver​(java.awt.dnd.DragSourceDragEvent e)
        Specified by:
        dragOver in interface java.awt.dnd.DragSourceListener
      • dragExit

        public void dragExit​(java.awt.dnd.DragSourceEvent e)
        Specified by:
        dragExit in interface java.awt.dnd.DragSourceListener
      • dragDropEnd

        public void dragDropEnd​(java.awt.dnd.DragSourceDropEvent e)
        Specified by:
        dragDropEnd in interface java.awt.dnd.DragSourceListener
      • dropActionChanged

        public void dropActionChanged​(java.awt.dnd.DragSourceDragEvent e)
        Specified by:
        dropActionChanged in interface java.awt.dnd.DragSourceListener
      • dragGestureRecognized

        public void dragGestureRecognized​(java.awt.dnd.DragGestureEvent e)
        Specified by:
        dragGestureRecognized in interface java.awt.dnd.DragGestureListener
      • onDragEnter

        protected void onDragEnter()
      • onDragExit

        protected void onDragExit()
      • onDragOver

        protected void onDragOver()
      • onDrop

        protected void onDrop()