chemaxon.marvin.space
Class GraphicScene

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by chemaxon.marvin.space.GraphicScene
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.media.opengl.GLEventListener

public class GraphicScene
extends javax.swing.JPanel
implements javax.media.opengl.GLEventListener

GraphicScene is the main "entry point" to MarvinSpace. It is the top level class of the visualization class hierarchy. It extends JPanel to be able to use it as a swing component, and represents a hardware accelerated OpenGL2 context called canvas.
GraphicScene (scene) consits of cells, represented by the GraphicCell class. By default the entire scene is one cell. Cells visualize GraphicComponents (components) associtated to them. Visualization settings are primarily passed to the scene namely camera view, projection, rotation, zooming, etc. Component specific settings are passed to each individual component by the cells.
Breif overview of main functions:

Example of typical usage:
 GraphicScene graphicScene = new GraphicScene( rowCount, columnCount );
 graphicScene.setSize(600, 600);
 this.getContentPane().add(graphicScene);
 this.show();

 graphicScene.getEventHandler().readMolecule(moleculeFile.pdb);
 graphicScene.processEvent("Protein.DrawType", "Stick");
 graphicScene.processEvent( "Ligand.DrawType", "Spacefill");
 graphicScene.processEvent( "Quality", "High");
 

Since:
Marvin 4.0.2
Version:
MarvinSpace 1.0
Author:
Judit Papp, Miklos Vargyas
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
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
 
Field Summary
static int CELL_RANGE
           
static int COMPONENT_RANGE
           
static java.lang.String GLInfo
           
static int MODE_MOVING
           
static int MODE_STANDING
           
static int SCENE_RANGE
           
static int VERBOSE_LEVEL_BASIC
           
static int VERBOSE_LEVEL_DEVEL
           
static int VERBOSE_LEVEL_NONE
           
 
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
GraphicScene()
          Creates a hardware accelerated and double buffered GraphicScene.
GraphicScene(int rowCount, int columnCount)
          Creates a hardware accelerated and double buffered GraphicScene.
 
Method Summary
 void activateContainerCell(GraphicComponent component)
          The containing cell of the GraphicComponent will be the active cell of the scene.
 boolean addComponent(GraphicComponent component)
          Adds a component to the active or to the first cell.
 boolean addComponent(GraphicComponent component, int cellIndex)
          Adds a component to the cell having the given index.
 boolean addComponentToEmptyCell(GraphicComponent gc)
          Adds a component to an empty cell.
 chemaxon.marvin.space.CoordinateComponent addCoordinateSystem(int cellIndex)
          Adds a dummy graphic component that represents the coordinate system.
 void clearSelection(int index)
          Sets all components and parts of components to be unselected in the given cell.
 boolean componentBecameSelected(int cellIdx)
          Returns true if a component became selected previously in the given cell.
 boolean componentBecameUnselected(int cellIdx)
          Returns true if a component became unselected previously in the given cell.
 boolean containsComponent(GraphicComponent gc)
          Returns true if the component exists in the scene.
 int createImage(java.nio.Buffer buf, int imageWidth, int imageHeight)
           
 void createNewCell()
          Sets an empty cell to be the active cell.
 void deactivateActiveCell()
          Sets the active cell to be no longer active.
 void display(javax.media.opengl.GLAutoDrawable glAutoDrawable)
          Warning: this function should not be called directly, use refresh() or redraw() instead.
 void displayChanged(javax.media.opengl.GLAutoDrawable glAutoDrawable, boolean b, boolean b1)
          Called by the system.
 void dispose(javax.media.opengl.GLAutoDrawable glad)
           
 void exclusiveSelection(chemaxon.marvin.space.UOID id)
          Exclusive selection in the given component in its container cell.
 void extendSelection(chemaxon.marvin.space.UOID id)
          Additive selection in the given component in its container cell.
 void fadeSelectedComponents()
          Sets the drawing mode of all selected elements to faded so it will be hardly visible, and prevents them from clicking.
 void fadeUnselectedComponents()
          Sets the drawing mode of all unselected elements to faded so it will be hardly visible, and prevents them from clicking.
 GraphicCell getActiveCell()
          Returns the active cell of the scene.
 int getActiveCellIndex()
          Returns the index of the active cell.
 java.util.ArrayList getAllComponents(java.lang.Class c)
           
 java.awt.Color getBackgroundColor()
          Returns the background color of the scene.
 java.awt.image.BufferedImage getBufferedImage()
          Returns the Canvas as a BufferedImage with the same size in pixels.
 GraphicCell getCell(int cellIndex)
          Returns the GraphicCell which has the given index.
 int getCellButtom()
          Returns the y coordinate of the buttom of the active cell in pixels.
 int getCellCount()
          Returns the number of cells in the scene.
 java.lang.String getCellDrawProperty(int cellIdx, java.lang.String name)
          Returns the draw property from the given cell or null if not defined.
 java.lang.String getCellDrawProperty(java.lang.String name)
          Returns the draw property from the active cell or null if there is no active cell or the property is not defined in the active cell.
 int getCellHeight()
          Returns the height of the cells.
 int getCellLeft()
          Returns the x coordinate of the left edge of the active cell.
 int getCellRight()
          Returns the x coordinate of the right edge of the active cell.
 int getCellTop()
          Returns the y coordinate of the top of the active cell.
 int getCellWidth()
          Returns the width of the cells.
 int getColumnCount()
          Returns the number of columns in the scene.
 GraphicComponent getControllableObject(java.lang.String type)
          Returns a selected component from the active cell what can be controlled by the given tye controller.
 java.lang.String getDrawProperty(java.lang.String name)
          Returns the draw property of the scene or null if the property is not defined.
 chemaxon.marvin.space.MSpaceEventHandler getEventHandler()
          Returns the event handler of the scene.
 javax.media.opengl.GL2 getGL()
          Returns the OpenGL2 interface.
 javax.media.opengl.GLAutoDrawable getGLAutoDrawable()
          Returns the GLAutoDrawable object.
 java.lang.String getGLInfo(boolean extended)
          Returns the OpenGL2 Renderer, Version, and Vendor and Extensions in VERBOSE_LEVEL_DEVEL mode.
 javax.media.opengl.awt.GLJPanel getGLJPanel()
          Returns the GL2 canvas.
 GraphicComponent getGraphicComponent(int componentIndex)
          Returns the GraphicComponent having the given index in the active cell.
 GraphicComponent getGraphicComponent(int cellIndex, int componentIndex)
          Returns the GraphicComponent of the given cell.
 GraphicComponent getGraphicComponent(chemaxon.marvin.space.UOID id)
          Returns the GraphicComponent with the given id.
 int getGraphicComponentCount()
          Returns the total number of GraphicComponents in the cells.
 int getRowCount()
          Returns the number of rows in the scene.
 double getShiftX(int cellIndex)
          Returns corrected shifting value of the given cell.
 double getShiftY(int cellIndex)
          Returns corrected shifting value of the given cell.
 float[] getTransformationCenter()
          Returns the center of transformation of the active cell or null if there is no active cell.
 int getVerboseLevel()
          Gets the verbose level.
 int getViewportHeight()
          Returns the phisical height of the viewport.
 int getViewportWidth()
          Returns the phisical width of the viewport.
 boolean hasSelectedComponent()
          Returns true if there is at least 1 selected component in the active cell.
 boolean hasSelectedComponentElement()
          Returns true if there is at least 1 selected ComponentElement in the active cell.
 void hideAllComponents(java.lang.Class c)
          Sets all components of the given class in the active cell to be invisible.
 void hideAllMonitors()
          Sets all monitor component of the active cell to invisible.
 void hideSelectedComponents()
          Hides all selected components from the active cell with all related components (connected monitors, surface of a molecule).
 void hideUnselectedComponents()
          Hides all unselected components from the active cell with all related components (connected monitors, surface of a molecule).
 void init(javax.media.opengl.GLAutoDrawable glAutoDrawable)
          Called by the drawable immediately after the OpenGL2 context is initialized for the first time.
 void invertSelection(chemaxon.marvin.space.UOID id)
          The previously picked part of the component will be selected if it was unselected and vice versa.
 boolean isActiveCell(int cellIndex)
          Returns true if the cell having cellIndex is the active cell of the scene.
 boolean isAntialiasEnabled()
          Returns true if full-screen antialias is enabled.
 boolean isGLInitialized()
          Returns true if the OpenGL2 canvas is already initialized.
 boolean isSmoothBackgroundEnabled()
          Returns true if the background is enabled to be smooth, so that it does not have a homogenous color.
 boolean isTransparentBackgroundEnabled()
          Returns true if the background is transparent.
 boolean isVerbose()
          Gets the verbose level.
 int locateCell(int x, int y)
          Returns the internal index of the cell under x,y position.
 chemaxon.marvin.space.UOID locateCellId(int x, int y)
          Returns the id of the cell under x, y position.
 chemaxon.marvin.space.UOID locateObject(int x, int y)
          Returns the identifire of the object under x,y position.
 chemaxon.marvin.space.UOID locateObject(int x, int y, java.lang.Class componentClass)
          Returns the identifire of the given class object under x,y position.
 boolean locationNearEdge(int x, int y)
          Tells whether the given location is near to any edges of any cell.
 boolean locationNearEdgeX(int x, int y)
          Tells whether the given location is near the vertical edges of any cell.
 boolean locationNearEdgeY(int x, int y)
          Tells whether the given location is near the horizontal edges of any cell.
 void measureFrameRate()
          Measures frame rate of drawing.
 void paint(java.awt.Graphics g)
           
static void printProperties()
           
 void processAwtEvent(java.awt.AWTEvent evt, java.lang.String evtID, java.lang.String evtValue)
          The given awt event will go to the queue of events, and will be performed during the next draw.
 void processCellEvent(java.lang.String evtID, java.lang.String evtValue)
          The given event will go to the queue of events, and will be performed during the next draw.
 void processComponentEvent(java.lang.Object component, java.lang.String evtID, java.lang.String evtValue)
          The given event will go to the queue of events, and will be performed during the next draw.
 void processEvent(java.lang.String evtID, java.lang.String evtValue)
          The given event will go to the queue of events, and will be performed during the next draw.
 void redraw()
          Redraws the entire scene.
 void refresh()
           
 void removeAllComponents()
          Removes all component from the scene and clears the selection panel.
 void removeAllComponents(java.lang.Class c)
          Removes all component from the scene and clears the selection panel.
 void removeComponent(GraphicComponent component)
          Removes a component from the scene.
 void removeComponent(chemaxon.marvin.space.UOID componentId)
          Removes a component from the scene.
 void removeSelectedComponents()
          Removes all selected components from the active cell with all related components (connected monitors, surface of a molecule).
 void removeUnselectedComponents()
          Removes all unselected components from the active cell with all related components (connected monitors, surface of a molecule).
 void removeUnselectedMonitors()
          Removes all unselected monitor component from the scene.
 void resetAll()
          Resets view settings of all cells including rotation, zoom and shifting.
 void resetSettings()
          Sets all draw properties to the default value and resets view.
 void resetView()
          Resets view settings of the active cell including rotation, zoom and shifting.
 void reshape(javax.media.opengl.GLAutoDrawable glAutoDrawable, int x, int y, int width, int height)
          Called by the drawable during the first repaint after the component has been resized.
 void rotate(double rx, double ry, double rz)
          Sets the given rotation factor in the active cell or in every cells in case of synchronous mode.
 void rotateTo(float[] rm)
          Sets the matrix of rotation explicitly in the active cell or in every cells in case of synchronous mode.
 void setActiveCell(int i)
          Sets the ith cell to be the active cell of the scene.
 void setAntialias(boolean state)
          Enables/disables full scene anti-aliasing.
 void setBackgroundColor(java.awt.Color newColor)
          Sets the background color of the scene and an alpha value of 0 (transparent background).
 void setBounds(int x, int y, int width, int height)
          Moves and resizes this component.
 void setCellDrawProperty(int cellIndex, java.lang.String propertyName, java.lang.String propertyValue)
          Sets the given draw property to the given cell.
 void setDrawProperty(java.util.Properties properties)
          Sets the given draw properties to the entire scene.
 void setDrawProperty(java.lang.String propertyName, java.lang.String propertyValue)
          Sets the draw property for all cells.
 void setDrawProperty(java.lang.String propertyName, java.lang.String propertyValue, int range)
          Sets the draw property either to the entire scene or to the active cell.
 void setDropTarget(java.awt.dnd.DropTargetListener dl)
          Sets the DropTarget of the graphic canvas.
 void setMotionMode(int mode)
          Notifies every cell of moving and standing modes.
 void setNearEdgeTolerance(int tolerance)
          Sets a border near the boundary of the cells in which mouse handling can work other way.
 void setProgressBar(chemaxon.marvin.space.gui.JMSpaceProgressBar progressBar)
           
 void setSceneSize(int rowCount, int columnCount)
          Sets the number of rows and columns.
 void setSize(int sizex, int sizey)
          Sets the physical size of the scene.
 void setSmoothBackground(boolean b)
          Enables/disables shaded background.
 void setSynchronousMode(boolean state)
          Sets handling of cells to synchronous/asynchronous.
 void setTransformationCenter(float[] c)
          Sets the transformation center explicitly to the given value.
 void setTransformationCenter(chemaxon.marvin.space.UOID id)
          Sets the center of transformation of the active cell to the coordinates of the named component.
 void setTransparentBackground(boolean b)
          Enables/disables transparent background color.
 void setVerbose(boolean flag)
          Sets the verbose level on/off.
 void setVerbose(int level)
          Sets the verbose level to the given level.
 void shift(double shiftx, double shifty)
          Sets the given shift factor in the active cell or in every cells in case of synchronous mode.
 void shiftAnimated(double shiftx, double shifty, int n)
          Sets the given shift factor dividing by n parts.
 void showAllComponents()
          Sets all invisible component of the active cell to visible.
 void showAllComponents(java.lang.Class c)
          Sets all components of the given class in the active cell to be visible.
 void showAllMonitors()
          Sets all monitor component of the active cell to visible.
 void showFaded()
          Sets the drawing mode of all faded elements back to the original drawing mode.
 void zoom(double factor)
          Sets the given zoom factor in the active cell or in every cells in case of synchronous mode.
 void zoomAnimated(double f, int n)
          Sets the given zoom factor dividing by n parts.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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
 
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, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, 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

GLInfo

public static java.lang.String GLInfo

MODE_STANDING

public static final int MODE_STANDING
See Also:
Constant Field Values

MODE_MOVING

public static final int MODE_MOVING
See Also:
Constant Field Values

VERBOSE_LEVEL_NONE

public static final int VERBOSE_LEVEL_NONE
See Also:
Constant Field Values

VERBOSE_LEVEL_BASIC

public static final int VERBOSE_LEVEL_BASIC
See Also:
Constant Field Values

VERBOSE_LEVEL_DEVEL

public static final int VERBOSE_LEVEL_DEVEL
See Also:
Constant Field Values

SCENE_RANGE

public static final int SCENE_RANGE
See Also:
Constant Field Values

CELL_RANGE

public static final int CELL_RANGE
See Also:
Constant Field Values

COMPONENT_RANGE

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

GraphicScene

public GraphicScene()
             throws java.lang.Exception
Creates a hardware accelerated and double buffered GraphicScene. It has one cell.

Throws:
java.lang.Exception

GraphicScene

public GraphicScene(int rowCount,
                    int columnCount)
             throws java.lang.Exception
Creates a hardware accelerated and double buffered GraphicScene. It will have the given number of rows and columns, that is rowCount * columnCount cells.

Parameters:
rowCount - number of rows of cells
columnCount - number of columns of cells
Throws:
java.lang.Exception
Method Detail

printProperties

public static void printProperties()

setProgressBar

public void setProgressBar(chemaxon.marvin.space.gui.JMSpaceProgressBar progressBar)

isVerbose

public boolean isVerbose()
Gets the verbose level. The level of verboseness will not be returned. See also getVerboseLevel().

Returns:
verbose is enabled or not

getVerboseLevel

public int getVerboseLevel()
Gets the verbose level. See VERBOSE_LEVEL_NONE, VERBOSE_LEVEL_BASIC, VERBOSE_LEVEL_DEVEL.

Returns:
level of verboseness

setVerbose

public void setVerbose(boolean flag)
Sets the verbose level on/off. The level of verboseness will be basic. See also setVerbose(int level).


setVerbose

public void setVerbose(int level)
Sets the verbose level to the given level. See VERBOSE_LEVEL_NONE, VERBOSE_LEVEL_BASIC, VERBOSE_LEVEL_DEVEL.

Parameters:
level - level of verboseness

setDropTarget

public void setDropTarget(java.awt.dnd.DropTargetListener dl)
Sets the DropTarget of the graphic canvas.

Parameters:
dl -

processAwtEvent

public void processAwtEvent(java.awt.AWTEvent evt,
                            java.lang.String evtID,
                            java.lang.String evtValue)
The given awt event will go to the queue of events, and will be performed during the next draw.

Parameters:
evt - AWTEvent to process
evtID - identifier of the event
evtValue - value of the event or empty String

processEvent

public void processEvent(java.lang.String evtID,
                         java.lang.String evtValue)
The given event will go to the queue of events, and will be performed during the next draw. These can be specific options, or draw properties with entire scene as range.

Parameters:
evtID - identifier of the event
evtValue - value of the event

processCellEvent

public void processCellEvent(java.lang.String evtID,
                             java.lang.String evtValue)
The given event will go to the queue of events, and will be performed during the next draw. These draw properties will have effect only in the active cell.

Parameters:
evtID - identifier of the event
evtValue - value of the event

processComponentEvent

public void processComponentEvent(java.lang.Object component,
                                  java.lang.String evtID,
                                  java.lang.String evtValue)
The given event will go to the queue of events, and will be performed during the next draw. These draw properties will have effect only on the given object. These events are mainly coming from the selection panel.

Parameters:
component - range of event
evtID - identifier of the event
evtValue - value of the event

getEventHandler

public chemaxon.marvin.space.MSpaceEventHandler getEventHandler()
Returns the event handler of the scene.

Returns:
handler that processes events being in the queue

setMotionMode

public void setMotionMode(int mode)
Notifies every cell of moving and standing modes. This is useful when a component uses a time consuming computation that can be delayed to the non-interactive mode.

Parameters:
mode - see MODE_MOVING, MODE_STANDING

setSynchronousMode

public void setSynchronousMode(boolean state)
Sets handling of cells to synchronous/asynchronous. Cell events will be passed based on this, i.e in synchronous mode every cell will get the cell-range events and only the active cell will get it in asynchronous mode.

Parameters:
state - synchronous mode is enabled or not

measureFrameRate

public void measureFrameRate()
Measures frame rate of drawing. It is required for auto-scaled rendering quality. We use frame rate instead of FPS, because frame rate is linear while FPS is not.


getViewportWidth

public int getViewportWidth()
Returns the phisical width of the viewport.

Returns:
width in pixels

getViewportHeight

public int getViewportHeight()
Returns the phisical height of the viewport.

Returns:
height in pixels

setSceneSize

public void setSceneSize(int rowCount,
                         int columnCount)
                  throws java.lang.Exception
Sets the number of rows and columns.

Parameters:
rowCount - number of rows, must be greater than 0
columnCount - number of columns, must be greater than 0
Throws:
java.lang.Exception - on initialization failure

createNewCell

public void createNewCell()
                   throws java.lang.Exception
Sets an empty cell to be the active cell. Adds new row or column if necessary.

Throws:
java.lang.Exception

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Moves and resizes this component. The new location of the top-left corner is specified by x and y, and the new size is specified by width and height.

Overrides:
setBounds in class java.awt.Component
Parameters:
x - the new x-coordinate of this component
y - the new y-coordinate of this component
width - the new width of this component
height - the new height of this component

setSize

public void setSize(int sizex,
                    int sizey)
Sets the physical size of the scene.

Overrides:
setSize in class java.awt.Component
Parameters:
sizex - width in pixels
sizey - height in pixels

setNearEdgeTolerance

public void setNearEdgeTolerance(int tolerance)
Sets a border near the boundary of the cells in which mouse handling can work other way.

Parameters:
tolerance - in pixels

getCellTop

public int getCellTop()
Returns the y coordinate of the top of the active cell.

Returns:
greatest y coordinate in pixels

getCellButtom

public int getCellButtom()
Returns the y coordinate of the buttom of the active cell in pixels.

Returns:
lowest y coordinate in pixels

getCellLeft

public int getCellLeft()
Returns the x coordinate of the left edge of the active cell.

Returns:
lowest x coordinate in pixels

getCellRight

public int getCellRight()
Returns the x coordinate of the right edge of the active cell.

Returns:
greatest x coordinate in pixels

getCellWidth

public int getCellWidth()
Returns the width of the cells. Note that cells have uniform size.

Returns:
width of cells in pixels

getCellHeight

public int getCellHeight()
Returns the height of the cells. Note that cells have uniform size.

Returns:
heigth of cells in pixels

getRowCount

public int getRowCount()
Returns the number of rows in the scene.

Returns:
number of rows

getColumnCount

public int getColumnCount()
Returns the number of columns in the scene.

Returns:
number of columns

getCellCount

public int getCellCount()
Returns the number of cells in the scene.

Returns:
number of cells

getGraphicComponentCount

public int getGraphicComponentCount()
Returns the total number of GraphicComponents in the cells.

Returns:
summary of components in all cells

addComponent

public boolean addComponent(GraphicComponent component)
                     throws java.lang.Exception
Adds a component to the active or to the first cell. Has the component process the global drawing properties.

Parameters:
component - to add
Returns:
adding component succeeded or not // * @throws MSpaceException when scene is not properly initialized
Throws:
java.lang.Exception

addComponentToEmptyCell

public boolean addComponentToEmptyCell(GraphicComponent gc)
                                throws java.lang.Exception
Adds a component to an empty cell. Has the component process the global drawing properties.

Parameters:
gc - component to add
Returns:
adding component succeeded or not // * @throws MSpaceException when scene is not properly initialized
Throws:
java.lang.Exception

addComponent

public boolean addComponent(GraphicComponent component,
                            int cellIndex)
                     throws java.lang.Exception
Adds a component to the cell having the given index. Has the component process the global drawing properties.

Parameters:
component - to add
cellIndex - internal index of the cell
Returns:
adding component succeeded or not
Throws:
java.lang.Exception

addCoordinateSystem

public chemaxon.marvin.space.CoordinateComponent addCoordinateSystem(int cellIndex)
                                                              throws java.lang.Exception
Adds a dummy graphic component that represents the coordinate system.

Parameters:
cellIndex - internal index of the cell
Throws:
java.lang.Exception

removeSelectedComponents

public void removeSelectedComponents()
Removes all selected components from the active cell with all related components (connected monitors, surface of a molecule). If a component is partly selected, it will not be deleted.


removeUnselectedComponents

public void removeUnselectedComponents()
Removes all unselected components from the active cell with all related components (connected monitors, surface of a molecule). If a component is not entirely selected, it will not be deleted.


removeUnselectedMonitors

public void removeUnselectedMonitors()
Removes all unselected monitor component from the scene.


removeAllComponents

public void removeAllComponents()
Removes all component from the scene and clears the selection panel.


removeAllComponents

public void removeAllComponents(java.lang.Class c)
Removes all component from the scene and clears the selection panel.


removeComponent

public void removeComponent(GraphicComponent component)
Removes a component from the scene.

Parameters:
component - to remove

removeComponent

public void removeComponent(chemaxon.marvin.space.UOID componentId)
Removes a component from the scene.

Parameters:
componentId - identifier of the component to remove

containsComponent

public boolean containsComponent(GraphicComponent gc)
Returns true if the component exists in the scene.

Returns:
valid component or not

setActiveCell

public void setActiveCell(int i)
Sets the ith cell to be the active cell of the scene.

Parameters:
i - internal index of the cell

deactivateActiveCell

public void deactivateActiveCell()
Sets the active cell to be no longer active.


getCell

public GraphicCell getCell(int cellIndex)
Returns the GraphicCell which has the given index.

Parameters:
cellIndex - internal index of the cell
Returns:
the required cell

getActiveCellIndex

public int getActiveCellIndex()
Returns the index of the active cell.

Returns:
internal index

getActiveCell

public GraphicCell getActiveCell()
Returns the active cell of the scene.

Returns:
the cell

isActiveCell

public boolean isActiveCell(int cellIndex)
Returns true if the cell having cellIndex is the active cell of the scene.

Parameters:
cellIndex - internal index of the cell
Returns:
is active or not

hasSelectedComponent

public boolean hasSelectedComponent()
Returns true if there is at least 1 selected component in the active cell.

Returns:
is there any selected component

hasSelectedComponentElement

public boolean hasSelectedComponentElement()
Returns true if there is at least 1 selected ComponentElement in the active cell.

Returns:
is there any selected elements

getGraphicComponent

public GraphicComponent getGraphicComponent(int componentIndex)
Returns the GraphicComponent having the given index in the active cell.

Parameters:
componentIndex - internal index of the component
Returns:
component having given index or null

getGraphicComponent

public GraphicComponent getGraphicComponent(int cellIndex,
                                            int componentIndex)
Returns the GraphicComponent of the given cell.

Parameters:
componentIndex - internal index of the component
cellIndex - internal index of the cell
Returns:
component having given index or null

getGraphicComponent

public GraphicComponent getGraphicComponent(chemaxon.marvin.space.UOID id)
Returns the GraphicComponent with the given id.


hideSelectedComponents

public void hideSelectedComponents()
Hides all selected components from the active cell with all related components (connected monitors, surface of a molecule). If a component is partly selected, it will not be hidden.


hideUnselectedComponents

public void hideUnselectedComponents()
Hides all unselected components from the active cell with all related components (connected monitors, surface of a molecule). If a component is not entirely selected, it will not be hidden.


fadeSelectedComponents

public void fadeSelectedComponents()
Sets the drawing mode of all selected elements to faded so it will be hardly visible, and prevents them from clicking. Note that each decendants of GraphicComponent should implement this behaviour to take affect.


fadeUnselectedComponents

public void fadeUnselectedComponents()
Sets the drawing mode of all unselected elements to faded so it will be hardly visible, and prevents them from clicking. Note that each decendants of GraphicComponent should implement this behaviour to take affect.


showAllComponents

public void showAllComponents()
Sets all invisible component of the active cell to visible.


showFaded

public void showFaded()
Sets the drawing mode of all faded elements back to the original drawing mode. Note that each decendants of GraphicComponent should implement this behaviour to take affect.


hideAllMonitors

public void hideAllMonitors()
Sets all monitor component of the active cell to invisible.


showAllMonitors

public void showAllMonitors()
Sets all monitor component of the active cell to visible.


showAllComponents

public void showAllComponents(java.lang.Class c)
Sets all components of the given class in the active cell to be visible.


hideAllComponents

public void hideAllComponents(java.lang.Class c)
Sets all components of the given class in the active cell to be invisible.


getAllComponents

public java.util.ArrayList getAllComponents(java.lang.Class c)

getDrawProperty

public java.lang.String getDrawProperty(java.lang.String name)
Returns the draw property of the scene or null if the property is not defined.

Parameters:
name - identifier of the property
Returns:
value of the property as String

getCellDrawProperty

public java.lang.String getCellDrawProperty(java.lang.String name)
Returns the draw property from the active cell or null if there is no active cell or the property is not defined in the active cell.

Parameters:
name - the name of the draw property
Returns:
value of the property as String

getCellDrawProperty

public java.lang.String getCellDrawProperty(int cellIdx,
                                            java.lang.String name)
Returns the draw property from the given cell or null if not defined.

Parameters:
cellIdx - internal index of the cell.
name - the name of the draw property

setCellDrawProperty

public void setCellDrawProperty(int cellIndex,
                                java.lang.String propertyName,
                                java.lang.String propertyValue)
                         throws java.lang.Exception
Sets the given draw property to the given cell.

Parameters:
cellIndex - internal index of the cell.
propertyName - the name of the draw property
propertyValue - the value of the property
Throws:
java.lang.Exception

setDrawProperty

public void setDrawProperty(java.util.Properties properties)
                     throws java.lang.Exception
Sets the given draw properties to the entire scene.

Parameters:
properties - set of draw properties
Throws:
java.lang.Exception

setDrawProperty

public void setDrawProperty(java.lang.String propertyName,
                            java.lang.String propertyValue)
                     throws java.lang.Exception
Sets the draw property for all cells. These properties are stored in this class in order to pass them to newly created cells.

Throws:
java.lang.Exception

setDrawProperty

public void setDrawProperty(java.lang.String propertyName,
                            java.lang.String propertyValue,
                            int range)
                     throws java.lang.Exception
Sets the draw property either to the entire scene or to the active cell.

Parameters:
propertyName - the name of the draw property
propertyValue - the value of the property
range - SCENE_RANGE, CELL_RANGE
Throws:
java.lang.Exception

resetSettings

public void resetSettings()
                   throws java.lang.Exception
Sets all draw properties to the default value and resets view.

Throws:
java.lang.Exception

resetView

public void resetView()
Resets view settings of the active cell including rotation, zoom and shifting. Takes effect at the next redraw because of threading issues.


resetAll

public void resetAll()
Resets view settings of all cells including rotation, zoom and shifting. Takes effect at the next redraw because of threading issues.


setAntialias

public void setAntialias(boolean state)
Enables/disables full scene anti-aliasing.

Parameters:
state - the required state of anti-aliasing

isAntialiasEnabled

public boolean isAntialiasEnabled()
Returns true if full-screen antialias is enabled. Note, that on mouse drag event antialias is/should be automatically disabled.

Returns:
state of anti/aliasing

getBackgroundColor

public java.awt.Color getBackgroundColor()
Returns the background color of the scene.

Returns:
color as java.awt.Color

setBackgroundColor

public void setBackgroundColor(java.awt.Color newColor)
Sets the background color of the scene and an alpha value of 0 (transparent background).

Parameters:
newColor - color as java.awt.Color

isTransparentBackgroundEnabled

public boolean isTransparentBackgroundEnabled()
Returns true if the background is transparent. Note the alpha value of the background color can be 0 or 1 that means totally opaque or totally transparent.

Returns:
the background color is totally transparent or totally opaque

setTransparentBackground

public void setTransparentBackground(boolean b)
Enables/disables transparent background color. The difference cannot be seen on the canvas, but it is an important property of saving images.

Parameters:
b -

isSmoothBackgroundEnabled

public boolean isSmoothBackgroundEnabled()
Returns true if the background is enabled to be smooth, so that it does not have a homogenous color.

Returns:
the background is homogenous or shaded

setSmoothBackground

public void setSmoothBackground(boolean b)
Enables/disables shaded background.

Parameters:
b -

reshape

public void reshape(javax.media.opengl.GLAutoDrawable glAutoDrawable,
                    int x,
                    int y,
                    int width,
                    int height)
Called by the drawable during the first repaint after the component has been resized. The client can update the viewport and view volume of the window appropriately, for example by a call to GL2.glViewport(int, int, int, int);. Note that for convenience the component has already called GL2.glViewport(int, int, int, int)(x, y, width, height) when this method is called, so the client may not have to do anything in this method.

Specified by:
reshape in interface javax.media.opengl.GLEventListener
Parameters:
glAutoDrawable - The GLDrawable object.
x - The X Coordinate of the viewport rectangle.
y - The Y coordinate of the viewport rectanble.
width - The new width of the window.
height - The new height of the window.

displayChanged

public void displayChanged(javax.media.opengl.GLAutoDrawable glAutoDrawable,
                           boolean b,
                           boolean b1)
Called by the system.


isGLInitialized

public boolean isGLInitialized()
Returns true if the OpenGL2 canvas is already initialized. It is to prevent too early gl-related calls such as setSceneSize in applets.


getGL

public javax.media.opengl.GL2 getGL()
Returns the OpenGL2 interface.


getGLAutoDrawable

public javax.media.opengl.GLAutoDrawable getGLAutoDrawable()
Returns the GLAutoDrawable object.


getGLJPanel

public javax.media.opengl.awt.GLJPanel getGLJPanel()
Returns the GL2 canvas.


getGLInfo

public java.lang.String getGLInfo(boolean extended)
Returns the OpenGL2 Renderer, Version, and Vendor and Extensions in VERBOSE_LEVEL_DEVEL mode.

Parameters:
extended - the available extensions are to returned or not
Returns:
info as String

init

public void init(javax.media.opengl.GLAutoDrawable glAutoDrawable)
Called by the drawable immediately after the OpenGL2 context is initialized for the first time. Can be used to perform one-time OpenGL2 initialization such as setup of lights and display lists.

Specified by:
init in interface javax.media.opengl.GLEventListener
Parameters:
glAutoDrawable - The GLAutoDrawable object.

display

public void display(javax.media.opengl.GLAutoDrawable glAutoDrawable)
Warning: this function should not be called directly, use refresh() or redraw() instead. Draws every cell of the scene. The result depends on the cells. Called by the drawable to initiate OpenGL2 rendering by the client. After all GLEventListeners have been notified of a display event, the drawable will swap its buffers if necessary.

Specified by:
display in interface javax.media.opengl.GLEventListener
Parameters:
glAutoDrawable - The GLAutoDrawable object.

refresh

public void refresh()

redraw

public void redraw()
Redraws the entire scene.


paint

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

getBufferedImage

public java.awt.image.BufferedImage getBufferedImage()
Returns the Canvas as a BufferedImage with the same size in pixels. Can be saved as a picture.


createImage

public int createImage(java.nio.Buffer buf,
                       int imageWidth,
                       int imageHeight)

activateContainerCell

public void activateContainerCell(GraphicComponent component)
The containing cell of the GraphicComponent will be the active cell of the scene.


locateObject

public chemaxon.marvin.space.UOID locateObject(int x,
                                               int y)
Returns the identifire of the object under x,y position. Returns a cell id if location is not in the active cell.

Parameters:
x - coordinate in pixels
y - coordinate in pixels

locateObject

public chemaxon.marvin.space.UOID locateObject(int x,
                                               int y,
                                               java.lang.Class componentClass)
Returns the identifire of the given class object under x,y position. Returns a cell id if location is not in the active cell.

Parameters:
x - coordinate in pixels
y - coordinate in pixels
componentClass - components of other classes will be ignored in location
Since:
Marvin 4.0.3

locateCellId

public chemaxon.marvin.space.UOID locateCellId(int x,
                                               int y)
Returns the id of the cell under x, y position.

Parameters:
x - coordinate in pixels
y - coordinate in pixels

locateCell

public int locateCell(int x,
                      int y)
Returns the internal index of the cell under x,y position.

Parameters:
x - window coordinate
y - window coordinate

getControllableObject

public GraphicComponent getControllableObject(java.lang.String type)
Returns a selected component from the active cell what can be controlled by the given tye controller.

Parameters:
type - identifier of the type of the controller, "Shift", "Rotate", "Resize"
Returns:
controllable component or null

locationNearEdgeX

public boolean locationNearEdgeX(int x,
                                 int y)
Tells whether the given location is near the vertical edges of any cell.

Parameters:
x - horizontal mouse location in absolute window coordinate
y - vertical mouse location in absolute window coordinate
Returns:
result of location

locationNearEdgeY

public boolean locationNearEdgeY(int x,
                                 int y)
Tells whether the given location is near the horizontal edges of any cell.

Parameters:
x - horizontal mouse location in absolute window coordinate
y - vertical mouse location in absolute window coordinate
Returns:
result of location

locationNearEdge

public boolean locationNearEdge(int x,
                                int y)
Tells whether the given location is near to any edges of any cell.

Parameters:
x - horizontal mouse location in absolute window coordinate
y - vertical mouse location in absolute window coordinate
Returns:
result of location

clearSelection

public void clearSelection(int index)
Sets all components and parts of components to be unselected in the given cell.

Parameters:
index - internal index of the cell

exclusiveSelection

public void exclusiveSelection(chemaxon.marvin.space.UOID id)
Exclusive selection in the given component in its container cell. The previously picked part of the component will be selected, and all selected components and parts of components will be unselected.

Parameters:
id - identifier of the component

extendSelection

public void extendSelection(chemaxon.marvin.space.UOID id)
Additive selection in the given component in its container cell. The previously picked part of the component will be selected, and all selection remains as is.

Parameters:
id - identifier of the component

invertSelection

public void invertSelection(chemaxon.marvin.space.UOID id)
The previously picked part of the component will be selected if it was unselected and vice versa. All other selection remains as is.

Parameters:
id - identifier of the component

componentBecameSelected

public boolean componentBecameSelected(int cellIdx)
Returns true if a component became selected previously in the given cell. Information from a selection is kept up to this query.

Parameters:
cellIdx - internal index of the cell
Returns:
flag indicating if selection occured or not

componentBecameUnselected

public boolean componentBecameUnselected(int cellIdx)
Returns true if a component became unselected previously in the given cell. Information from an unselection is kept up to this query.

Parameters:
cellIdx - internal index of the cell
Returns:
flag indicating if unselection occured or not

getTransformationCenter

public float[] getTransformationCenter()
Returns the center of transformation of the active cell or null if there is no active cell.

Returns:
coordinates in the model space

getShiftX

public double getShiftX(int cellIndex)
Returns corrected shifting value of the given cell.

Parameters:
cellIndex -
Returns:
x coordinate in world coordinates

getShiftY

public double getShiftY(int cellIndex)
Returns corrected shifting value of the given cell.

Parameters:
cellIndex -
Returns:
y coordinate in world coordinates

setTransformationCenter

public void setTransformationCenter(chemaxon.marvin.space.UOID id)
Sets the center of transformation of the active cell to the coordinates of the named component. The actual coordinates are got by the GraphicComponent.getCoordinates(float[]) method

Parameters:
id - identifier of the component

setTransformationCenter

public void setTransformationCenter(float[] c)
Sets the transformation center explicitly to the given value. It will affect the active cell or all cells in case of synchronous mode.

Parameters:
c - exact coordinates to be set

zoom

public void zoom(double factor)
Sets the given zoom factor in the active cell or in every cells in case of synchronous mode.

Parameters:
factor - zooming factor, usually it is the changing of the mouse coordinates in pixels

zoomAnimated

public void zoomAnimated(double f,
                         int n)
Sets the given zoom factor dividing by n parts. Every part of zoom is followed by a refresh() event.

Parameters:
f - zoom factor
n - number of zoom effects and refreshes

rotate

public void rotate(double rx,
                   double ry,
                   double rz)
Sets the given rotation factor in the active cell or in every cells in case of synchronous mode.

Parameters:
rx - rotation angle around the x axis
ry - rotation angle around the y axis
rz - rotation angle around the z axis

rotateTo

public void rotateTo(float[] rm)
Sets the matrix of rotation explicitly in the active cell or in every cells in case of synchronous mode.

Parameters:
rm - 4x4 matrix of rotation

shift

public void shift(double shiftx,
                  double shifty)
Sets the given shift factor in the active cell or in every cells in case of synchronous mode.

Parameters:
shiftx - translation along x axis in window coordinates
shifty - translation along y axis in window coordinates

shiftAnimated

public void shiftAnimated(double shiftx,
                          double shifty,
                          int n)
Sets the given shift factor dividing by n parts. Every part of shift is followed by a refresh() event.

Parameters:
shiftx - translation along x axis in window coordinates
shifty - translation along y axis in window coordinates
n - number of shift effects and refreshes

dispose

public void dispose(javax.media.opengl.GLAutoDrawable glad)
Specified by:
dispose in interface javax.media.opengl.GLEventListener