Package chemaxon.marvin.space
Class GraphicScene
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- chemaxon.marvin.space.GraphicScene
-
- All Implemented Interfaces:
chemaxon.marvin.util.CallbackIface
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,javax.media.opengl.GLEventListener
@PublicAPI public class GraphicScene extends JPanel implements javax.media.opengl.GLEventListener, chemaxon.marvin.util.CallbackIface
GraphicScene
is the main "entry point" to MarvinSpace. It is the top level class of the visualization class hierarchy. It extendsJPanel
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 theGraphicCell
class. By default the entire scene is one cell. Cells visualizeGraphicComponents
(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:
- content & layout: The size of the OpenGL2 canvas; size, number and orientaion of cells.
- component management: Adding new components, removing existing components.
- event handling: Delivering events to graphics objects by group: scene events, cell events and component events are distinguished.
- active cell, selected components: Restricting settings to specific parts of the scene.
- location & selection of components
- viewing transformations
- remdering: Drawing visible components
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
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description static int
CELL_RANGE
static int
COMPONENT_RANGE
static String
GLInfo
static int
MODE_MOVING
static int
MODE_STANDING
static String
MSPACE_CONFIG_DEFAULT_PATH
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
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
accessibleContext, 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
Constructors Constructor Description GraphicScene()
Creates a hardware accelerated and double bufferedGraphicScene
.GraphicScene(int rowCount, int columnCount)
Creates a hardware accelerated and double buffered GraphicScene.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
addListToDelete(int list)
Adds a gl list id to the deletion listObject
callback(String eventID, Object value)
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(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, userefresh()
orredraw()
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.ArrayList
getAllComponents(Class c)
Color
getBackgroundColor()
Returns the background color of the scene.float[]
getBackgroundColorF()
BufferedImage
getBufferedImage()
Returns the Canvas as a BufferedImage with the same size in pixels.GraphicCell
getCell(int cellIndex)
Returns theGraphicCell
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.String
getCellDrawProperty(int cellIdx, String name)
Returns the draw property from the given cell or null if not defined.String
getCellDrawProperty(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(String type)
Returns a selected component from the active cell what can be controlled by the given tye controller.String
getDrawProperty(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.Component
getGLCanvas()
Returns the GL2 canvas.String
getGLInfo(boolean extended)
Returns the OpenGL2 Renderer, Version, and Vendor and Extensions in VERBOSE_LEVEL_DEVEL mode.GraphicComponent
getGraphicComponent(int componentIndex)
Returns theGraphicComponent
having the given index in the active cell.GraphicComponent
getGraphicComponent(int cellIndex, int componentIndex)
Returns theGraphicComponent
of the given cell.GraphicComponent
getGraphicComponent(chemaxon.marvin.space.UOID id)
Returns theGraphicComponent
with the given id.int
getGraphicComponentCount()
Returns the total number ofGraphicComponent
s 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 selectedComponentElement
in the active cell.void
hideAllComponents(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 havingcellIndex
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, 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(Graphics g)
static void
printProperties()
void
processAwtEvent(AWTEvent evt, String evtID, String evtValue)
The given awt event will go to the queue of events, and will be performed during the next draw.void
processCellEvent(String evtID, String evtValue)
The given event will go to the queue of events, and will be performed during the next draw.void
processComponentEvent(Object component, String evtID, String evtValue)
The given event will go to the queue of events, and will be performed during the next draw.void
processEvent(String evtID, 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(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.PharmacophorePoint
removePharmacophorePoint(ComponentElement ce)
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(float[] newColor)
void
setBackgroundColor(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, String propertyName, String propertyValue)
Sets the given draw property to the given cell.void
setDrawProperty(String propertyName, String propertyValue)
Sets the draw property for all cells.void
setDrawProperty(String propertyName, String propertyValue, int range)
Sets the draw property either to the entire scene or to the active cell.void
setDrawProperty(Properties properties)
Sets the given draw properties to the entire scene.void
setDropTarget(DropTargetListener dl)
Sets theDropTarget
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(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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, 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, 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, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
MSPACE_CONFIG_DEFAULT_PATH
public static final String MSPACE_CONFIG_DEFAULT_PATH
- See Also:
- Constant Field Values
-
GLInfo
public static 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 Exception
Creates a hardware accelerated and double bufferedGraphicScene
. It has one cell.- Throws:
Exception
-
GraphicScene
public GraphicScene(int rowCount, int columnCount) throws Exception
Creates a hardware accelerated and double buffered GraphicScene. It will have the given number of rows and columns, that isrowCount * columnCount
cells.- Parameters:
rowCount
- number of rows of cellscolumnCount
- number of columns of cells- Throws:
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 alsogetVerboseLevel()
.- Returns:
- verbose is enabled or not
-
getVerboseLevel
public int getVerboseLevel()
- Returns:
- level of verboseness
-
setVerbose
public void setVerbose(boolean flag)
Sets the verbose level on/off. The level of verboseness will be basic. See alsosetVerbose(int level)
.
-
setVerbose
public void setVerbose(int level)
Sets the verbose level to the given level. SeeVERBOSE_LEVEL_NONE
,VERBOSE_LEVEL_BASIC
,VERBOSE_LEVEL_DEVEL
.- Parameters:
level
- level of verboseness
-
setDropTarget
public void setDropTarget(DropTargetListener dl)
Sets theDropTarget
of the graphic canvas.- Parameters:
dl
-
-
processAwtEvent
public void processAwtEvent(AWTEvent evt, String evtID, 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 processevtID
- identifier of the eventevtValue
- value of the event or emptyString
-
processEvent
public void processEvent(String evtID, 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 eventevtValue
- value of the event
-
processCellEvent
public void processCellEvent(String evtID, 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 eventevtValue
- value of the event
-
processComponentEvent
public void processComponentEvent(Object component, String evtID, 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 eventevtID
- identifier of the eventevtValue
- 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
- seeMODE_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 Exception
Sets the number of rows and columns.- Parameters:
rowCount
- number of rows, must be greater than 0columnCount
- number of columns, must be greater than 0- Throws:
Exception
- on initialization failure
-
createNewCell
public void createNewCell() throws Exception
Sets an empty cell to be the active cell. Adds new row or column if necessary.- Throws:
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 byx
andy
, and the new size is specified bywidth
andheight
.
-
setSize
public void setSize(int sizex, int sizey)
Sets the physical size of the scene.
-
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 ofGraphicComponent
s in the cells.- Returns:
- summary of components in all cells
-
removePharmacophorePoint
public PharmacophorePoint removePharmacophorePoint(ComponentElement ce)
-
addComponent
public boolean addComponent(GraphicComponent component) throws 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:
Exception
-
addComponentToEmptyCell
public boolean addComponentToEmptyCell(GraphicComponent gc) throws 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:
Exception
-
addComponent
public boolean addComponent(GraphicComponent component, int cellIndex) throws Exception
Adds a component to the cell having the given index. Has the component process the global drawing properties.- Parameters:
component
- to addcellIndex
- internal index of the cell- Returns:
- adding component succeeded or not
- Throws:
Exception
-
addCoordinateSystem
public chemaxon.marvin.space.CoordinateComponent addCoordinateSystem(int cellIndex) throws Exception
Adds a dummy graphic component that represents the coordinate system.- Parameters:
cellIndex
- internal index of the cell- Throws:
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(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 theGraphicCell
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 havingcellIndex
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 selectedComponentElement
in the active cell.- Returns:
- is there any selected elements
-
getGraphicComponent
public GraphicComponent getGraphicComponent(int componentIndex)
Returns theGraphicComponent
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 theGraphicComponent
of the given cell.- Parameters:
componentIndex
- internal index of the componentcellIndex
- internal index of the cell- Returns:
- component having given index or null
-
getGraphicComponent
public GraphicComponent getGraphicComponent(chemaxon.marvin.space.UOID id)
Returns theGraphicComponent
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 ofGraphicComponent
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 ofGraphicComponent
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 ofGraphicComponent
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(Class c)
Sets all components of the given class in the active cell to be visible.
-
hideAllComponents
public void hideAllComponents(Class c)
Sets all components of the given class in the active cell to be invisible.
-
getDrawProperty
public String getDrawProperty(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 String getCellDrawProperty(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 String getCellDrawProperty(int cellIdx, 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, String propertyName, String propertyValue) throws Exception
Sets the given draw property to the given cell.- Parameters:
cellIndex
- internal index of the cell.propertyName
- the name of the draw propertypropertyValue
- the value of the property- Throws:
Exception
-
setDrawProperty
public void setDrawProperty(Properties properties) throws Exception
Sets the given draw properties to the entire scene.- Parameters:
properties
- set of draw properties- Throws:
Exception
-
setDrawProperty
public void setDrawProperty(String propertyName, String propertyValue) throws 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:
Exception
-
setDrawProperty
public void setDrawProperty(String propertyName, String propertyValue, int range) throws Exception
Sets the draw property either to the entire scene or to the active cell.- Parameters:
propertyName
- the name of the draw propertypropertyValue
- the value of the propertyrange
-SCENE_RANGE
,CELL_RANGE
- Throws:
Exception
-
resetSettings
public void resetSettings() throws Exception
Sets all draw properties to the default value and resets view.- Throws:
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 Color getBackgroundColor()
Returns the background color of the scene.- Returns:
- color as
java.awt.Color
-
getBackgroundColorF
public float[] getBackgroundColorF()
-
setBackgroundColor
public void setBackgroundColor(Color newColor)
Sets the background color of the scene and an alpha value of 0 (transparent background).- Parameters:
newColor
- color asjava.awt.Color
-
setBackgroundColor
public void setBackgroundColor(float[] newColor)
-
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 toGL2.glViewport(int, int, int, int);
. Note that for convenience the component has already calledGL2.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 interfacejavax.media.opengl.GLEventListener
- Parameters:
glAutoDrawable
- The GLDrawable object.x
- The X Coordinate of the viewport rectangle.y
- The Y coordinate of the viewport rectangle.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) throws Exception
Called by the system.- Throws:
Exception
-
isGLInitialized
public boolean isGLInitialized()
Returns true if the OpenGL2 canvas is already initialized. It is to prevent too early gl-related calls such assetSceneSize
in applets.
-
getGL
public javax.media.opengl.GL2 getGL()
Returns the OpenGL2 interface.
-
getGLAutoDrawable
public javax.media.opengl.GLAutoDrawable getGLAutoDrawable()
Returns the GLAutoDrawable object.
-
getGLCanvas
public Component getGLCanvas()
Returns the GL2 canvas.
-
getGLInfo
public 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
-
addListToDelete
public void addListToDelete(int list)
Adds a gl list id to the deletion list- Parameters:
list
- gl list id
-
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 interfacejavax.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, userefresh()
orredraw()
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 interfacejavax.media.opengl.GLEventListener
- Parameters:
glAutoDrawable
- The GLAutoDrawable object.
-
refresh
public void refresh()
-
redraw
public void redraw()
Redraws the entire scene.
-
paint
public void paint(Graphics g)
- Overrides:
paint
in classJComponent
-
getBufferedImage
public BufferedImage getBufferedImage()
Returns the Canvas as a BufferedImage with the same size in pixels. Can be saved as a picture.
-
createImage
public int createImage(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 pixelsy
- coordinate in pixels
-
locateObject
public chemaxon.marvin.space.UOID locateObject(int x, int y, 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 pixelsy
- coordinate in pixelscomponentClass
- 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 pixelsy
- 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 coordinatey
- window coordinate
-
getControllableObject
public GraphicComponent getControllableObject(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 coordinatey
- 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 coordinatey
- 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 coordinatey
- 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 occurred 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 occurred 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 theGraphicComponent.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 arefresh()
event.- Parameters:
f
- zoom factorn
- 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 axisry
- rotation angle around the y axisrz
- 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 coordinatesshifty
- 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 arefresh()
event.- Parameters:
shiftx
- translation along x axis in window coordinatesshifty
- translation along y axis in window coordinatesn
- number of shift effects and refreshes
-
dispose
public void dispose(javax.media.opengl.GLAutoDrawable glad)
- Specified by:
dispose
in interfacejavax.media.opengl.GLEventListener
-
-