Package chemaxon.marvin.space
Class GraphicCell
java.lang.Object
chemaxon.marvin.space.GraphicCell
GraphicCell
is a rectangular part of the OpenGL2 canvas containing GraphicComponent
s.
Each cell has its own camera/viewing settings, own origin, clipping planes,
and handling of viewing events such as rotation, zoom, shift, depth cue, etc.
Example of typical usage:
graphicScene.createNewCell(); GraphicCell cell = graphicScene.getActiveCell(); ArrayList molecules = graphicScene.readMolecule(moleculeFile.mol); GraphicComponent gc = molecules.get(0); cell.setTransformationCenter(gc.getId()); gc.select(); cell.hideSelectedComponents();
- Since:
- Marvin 4.0.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
protected static final int
protected static final int
protected static final int
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance ofGraphicCell
.GraphicCell
(javax.media.opengl.GL2 gl, javax.media.opengl.glu.GLU glu) Creates a new instance ofGraphicCell
. -
Method Summary
Modifier and TypeMethodDescriptionint
addComponent
(GraphicComponent component) Adds a new component to this cell.void
Sets all components and parts of components to be unselected.boolean
Returns true if a component became selected previously.boolean
Returns true if a component became unselected previously.boolean
Tells whether the component is in the cell.void
draw()
Makes the vieport draw this cell.void
Draw borders of the cell.void
drawCell()
Draws all components of the cell.void
void
Draws the rotation sphere.void
exclusiveSelection
(int itemIndex) Exclusive selection in the given component.void
extendSelection
(int itemIndex) Additive selection in the given component, so the previously picked part of the component will be selected, and all selection remains as is.void
Sets all selected components to faded.void
Sets all selected components to faded.int
Returns the y coordinate of the bottom of the cell in pixels.Computes the radius of the bounding sphere in order to set the z coordinate of the camera properly.double
Returns the z coordinate of the camera.getCellDrawProperty
(String propertyName) Returns the value of the cell-range drawing property with the given name.getComponent
(int componentIndex) Returns the component having the given index.int
Returns the number of components of the cell including monitors, surfaces and so on.Returns the iterator of theGraphicComponent
s of the cell.getControllableObject
(String type) Returns a component if there is any which allows itself to be controlled.float
Returns the z coordinate of the farther clipping plane which is computed considering all components.float
getFovY()
Returns the field of view.int
Returns the height of the cell.chemaxon.marvin.space.UOID
getId()
Returns the cell id as aUOID
.int
getIndex()
Returns the internal index of the cell.int
getLeft()
Returns the x coordinate of the left edge of the active cell.float
Returns the z coordinate of the nearer clipping plane which is computed considering all components.int
getRight()
Returns the x coordinate of the right edge of the cell.float[]
Returns the matrix of rotation.double
Returns the shifting value of the x direction.double
Returns the shifting value of the y direction.int
getTop()
Returns the y coordinate of the top of the cell.float[]
Returns the transformation center.int
Gets the verbose level.int
getWidth()
Returns the width of the cell.boolean
Returns true if there is at least 1 selected component.boolean
Returns true if there is at least 1 component with a selected part.void
Sets all components of the given class to invisible.void
Sets all monitor type components (labels as well) to invisible.void
Sets all selected components to invisible.void
Sets all selected components to invisible.void
invertSelection
(int itemIndex) The previously picked part of the component will be selected if it was unselected and vice versa.boolean
isActive()
Returns true if this cell is the active cell of the entire scene.boolean
isSelectedComponent
(int componentIndex) Tells whether the given component is selected.boolean
Gets the verbose level.chemaxon.marvin.space.UOID
locateObject
(int x, int y) Returns the internal id of the component under x, y location, or the id of the cell itself if there is no component in that location.chemaxon.marvin.space.UOID
locateObject
(int x, int y, Class componentClass) Returns the internal id of the given class component under x, y location, or the id of the cell itself if there is no component in that location.boolean
locationNearEdgeX
(int x, int y) Tells whether the given location is near the vertical edges of the cell.boolean
locationNearEdgeY
(int x, int y) Tells whether the given location is near the horizontal edges of the cell.void
Components with 2D parts should notify the container cell when their 'pseudo z' coordinate changes in order to display them in a correct order.void
Removes all components from the cell.void
removeComponent
(int componentIndex) Removes the component which has the given index, and all of its associated components from the cell.boolean
removeComponent
(GraphicComponent component) Removes the component and all associated components from the cell.void
removeComponent
(Class componentClass) void
Removes all selected components and all associated components from the cell.void
Removes all unselected components and all associated components from the cell.void
Removes all unsselected monitor components from the cell.void
void
void
rotate
(double angleX, double angleY, double angleZ) void
Sets all components lying inside the given box to be selected.void
Sets this cell to the active cell of the scene.void
setAntialias
(boolean antialias) Switches the full scene anti-aliasing on/off.void
setBackgroundColor
(float[] newColor) Sets the background color of the cell used by drawing smooth background.void
setBackgroundColor
(Color newColor) Sets the background color of the cell used by drawing smooth background.void
setCellDrawProperties
(Properties drawProperties) Sets the drawing properties of all components of the cell.void
setContexts
(int inRow, int inColumn, int index, int left, int bottom, javax.media.opengl.GL2 gl, javax.media.opengl.glu.GLU glu) Sets the indices of row and column of the scene in which this cell is in, and sets the GL2 related variables to be able to draw.void
setDrawProperty
(String propertyName, String propertyValue) Sets the drawing properties of all components of the cell.void
setDrawSphere
(boolean flag) Enables/disables drawing of the rotation sphere.void
Deactivates this cell, so it is no longer the active cell of the scene.void
setIndex
(int index) Sets the internal index of the cell.void
setIndices
(int inRow, int inColumn) Sets which row and column of the scene is this cell in.void
setMotionMode
(int mode) Notifies every component of moving and standing modes.void
setNearEdgeTolerance
(int tolerance) Sets the tolerance we consider to be near the edge of the cell.void
setOrigin
(int left, int bottom) Sets the leftmost and bottomost coordinate of the cell.boolean
void
setRotateMatrix
(float[] rm) Sets the matrix of rotation explicitly.void
setSize
(int width, int height) Sets the size of the viewport of this cell in pixels.void
setSmoothBackgroud
(boolean b) Enables/disables shaded background coloring.void
setTransformationCenter
(float x, float y, float z) Sets the transformation center and resets shifting values.void
setTransformationCenter
(chemaxon.marvin.space.UOID itemId) Sets the transformation center to the center of the component with the given id and resets shifting values.void
setTransformationCenterX
(float value) Sets the x coordinate of the transformation center.void
setTransformationCenterY
(float value) Sets the y coordinate of the transformation center.void
setTransformationCenterZ
(float value) Sets the z coordinate of the transformation center.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) void
Sets all components to visible.void
Sets all components of the given class to visible.void
Sets all monitor type components (labels as well) to visible.void
Sets all faded components to visible.void
void
zoom
(double factor)
-
Field Details
-
MAX_NUMBER_OF_COMPONENTS_PER_CELL
protected static final int MAX_NUMBER_OF_COMPONENTS_PER_CELL- See Also:
-
DEFAULT_NEAR_EDGE
protected static final int DEFAULT_NEAR_EDGE- See Also:
-
MODE_NORMAL
protected static final int MODE_NORMAL- See Also:
-
MODE_PICK
protected static final int MODE_PICK- See Also:
-
-
Constructor Details
-
GraphicCell
public GraphicCell()Creates a new instance ofGraphicCell
. -
GraphicCell
public GraphicCell(javax.media.opengl.GL2 gl, javax.media.opengl.glu.GLU glu) Creates a new instance ofGraphicCell
.- Parameters:
gl
- Interface to OpenGL
-
-
Method Details
-
isVerbose
public boolean isVerbose()Gets the verbose level. The level of verboseness will not be returned. See alsogetVerboseLevel()
.- Returns:
- verbose is enabled or not
- Since:
- Marvin 4.0.3
-
getVerboseLevel
public int getVerboseLevel()Gets the verbose level. SeeGraphicScene.VERBOSE_LEVEL_NONE
,GraphicScene.VERBOSE_LEVEL_BASIC
,GraphicScene.VERBOSE_LEVEL_DEVEL
.- Returns:
- level of verboseness
- Since:
- Marvin 4.0.3
-
setVerbose
public void setVerbose(boolean flag) Sets the verbose level on/off. The level of verboseness will be basic. See alsosetVerbose(int level)
.- Since:
- Marvin 4.0.3
-
setVerbose
public void setVerbose(int level) Sets the verbose level to the given level. SeeGraphicScene.VERBOSE_LEVEL_NONE
,GraphicScene.VERBOSE_LEVEL_BASIC
,GraphicScene.VERBOSE_LEVEL_DEVEL
.- Parameters:
level
- level of verboseness- Since:
- Marvin 4.0.3
-
getIndex
public int getIndex()Returns the internal index of the cell.- Returns:
- internal index of the cell
-
getId
public chemaxon.marvin.space.UOID getId()Returns the cell id as aUOID
.- Returns:
- id of the cell
-
setIndex
public void setIndex(int index) Sets the internal index of the cell. Called during initialization and cell-deleting.- Parameters:
index
- new index of the cell
-
setSize
public void setSize(int width, int height) Sets the size of the viewport of this cell in pixels.- Parameters:
width
- horizontal size of the cell in pixelsheight
- vertical size of the cell in pixels
-
getShiftX
public double getShiftX()Returns the shifting value of the x direction.- Returns:
- x coordinate in window coordinates
-
getShiftY
public double getShiftY()Returns the shifting value of the y direction.- Returns:
- y coordinate in window coordinates
-
getNearClip
public float getNearClip()Returns the z coordinate of the nearer clipping plane which is computed considering all components.- Returns:
- coordinate in model space
-
getFarClip
public float getFarClip()Returns the z coordinate of the farther clipping plane which is computed considering all components.- Returns:
- coordinate in model space
-
getFovY
public float getFovY()Returns the field of view.- Returns:
- field of view in degrees
-
getCameraZ
public double getCameraZ()Returns the z coordinate of the camera.- Returns:
- coordinate in model space
-
addComponent
Adds a new component to this cell.- Returns:
- internal index of the newly added component
- Throws:
Exception
- is thrown when an unlicensed draw property (e.g. partial charge coloring) is set to the newly added component For technical reasons the actual type of the exception is PluginException.
-
removeSelectedComponents
public void removeSelectedComponents()Removes all selected components and all associated components from the cell. -
removeUnselectedComponents
public void removeUnselectedComponents()Removes all unselected components and all associated components from the cell. -
removeUnselectedMonitors
public void removeUnselectedMonitors()Removes all unsselected monitor components from the cell. -
removeComponent
Removes the component and all associated components from the cell.- Parameters:
component
- to remove- Returns:
- succeeded or not
-
removeComponent
-
removeComponent
public void removeComponent(int componentIndex) Removes the component which has the given index, and all of its associated components from the cell.- Parameters:
componentIndex
- index of the component to remove
-
removeAllComponents
public void removeAllComponents()Removes all components from the cell. -
getComponentCount
public int getComponentCount()Returns the number of components of the cell including monitors, surfaces and so on.- Returns:
- number of components
-
hasSelectedComponent
public boolean hasSelectedComponent()Returns true if there is at least 1 selected component.- Returns:
- is there any selected component in the cell
-
hasSelectedComponentElement
public boolean hasSelectedComponentElement()Returns true if there is at least 1 component with a selected part.- Returns:
- is there any component with any selected part in the cell
-
containsComponent
Tells whether the component is in the cell.- Parameters:
gc
- component- Returns:
- is in the cell or not
-
getComponent
Returns the component having the given index.- Parameters:
componentIndex
- internal index of the component- Returns:
- component with given index
-
getComponentIterator
Returns the iterator of theGraphicComponent
s of the cell.- Returns:
- iterator positioning at the first component
-
isSelectedComponent
public boolean isSelectedComponent(int componentIndex) Tells whether the given component is selected.- Parameters:
componentIndex
- internal index of the component- Returns:
- the component is selected or not
-
isActive
public boolean isActive()Returns true if this cell is the active cell of the entire scene.- Returns:
- is the cell active
-
setActive
public void setActive()Sets this cell to the active cell of the scene. -
setInactive
public void setInactive()Deactivates this cell, so it is no longer the active cell of the scene. -
hideSelectedComponents
public void hideSelectedComponents()Sets all selected components to invisible. -
hideUnselectedComponents
public void hideUnselectedComponents()Sets all selected components to invisible. -
fadeSelectedComponents
public void fadeSelectedComponents()Sets all selected components to faded. -
fadeUnselectedComponents
public void fadeUnselectedComponents()Sets all selected components to faded. -
showAllComponents
public void showAllComponents()Sets all components to visible. -
showAllComponents
Sets all components of the given class to visible. -
hideAllComponents
Sets all components of the given class to invisible. -
showFaded
public void showFaded()Sets all faded components to visible. -
hideAllMonitors
public void hideAllMonitors()Sets all monitor type components (labels as well) to invisible. -
showAllMonitors
public void showAllMonitors()Sets all monitor type components (labels as well) to visible. -
setOrigin
public void setOrigin(int left, int bottom) Sets the leftmost and bottomost coordinate of the cell.- Parameters:
left
- lowest x coordinate in the scenebottom
- lowest y coordinate in the scene
-
setIndices
public void setIndices(int inRow, int inColumn) Sets which row and column of the scene is this cell in.- Parameters:
inRow
- which row of the scene is this cell ininColumn
- which column of the scene is this cell in
-
setNearEdgeTolerance
public void setNearEdgeTolerance(int tolerance) Sets the tolerance we consider to be near the edge of the cell.- Parameters:
tolerance
- width of the border in pixels
-
setContexts
public void setContexts(int inRow, int inColumn, int index, int left, int bottom, javax.media.opengl.GL2 gl, javax.media.opengl.glu.GLU glu) Sets the indices of row and column of the scene in which this cell is in, and sets the GL2 related variables to be able to draw.- Parameters:
inRow
- which row of the scene is this cell ininColumn
- which column of the scene is this cell inindex
- internal index of the cellleft
- lowest x coordinate in the scenebottom
- lowest y coordinate in the scenegl
- interface to OpenGL
-
getCellDrawProperty
Returns the value of the cell-range drawing property with the given name. -
setCellDrawProperties
Sets the drawing properties of all components of the cell.- Parameters:
drawProperties
- properties to set one by one- Throws:
Exception
- is thrown when an unlicensed draw property (e.g. partial charge coloring) is set to the newly added component For technical reasons the actual type of the exception is PluginException.
-
setDrawProperty
Sets the drawing properties of all components of the cell.- Parameters:
propertyName
- name of the drawing property identified byGraphicComponent
spropertyValue
- value of the property as aString
- Throws:
Exception
-
setAntialias
public void setAntialias(boolean antialias) Switches the full scene anti-aliasing on/off. It is here because buffers (color, depth) are handled here, and anti-aliasing is affected by buffers.- Parameters:
antialias
- state of full-screen anti-aliasing
-
setMotionMode
public void setMotionMode(int mode) Notifies every component of moving and standing modes.- Parameters:
mode
-GraphicScene.MODE_MOVING
orGraphicScene.MODE_STANDING
-
locateObject
public chemaxon.marvin.space.UOID locateObject(int x, int y) Returns the internal id of the component under x, y location, or the id of the cell itself if there is no component in that location.- Parameters:
x
- horizontal mouse location in absolute window coordinatey
- vertical mouse location in absolute window coordinate
-
locateObject
Returns the internal id of the given class component under x, y location, or the id of the cell itself if there is no component in that location.- Parameters:
x
- horizontal mouse location in absolute window coordinatey
- vertical mouse location in absolute window coordinatecomponentClass
- components of other classes will be ignored in location- Since:
- Marvin 4.0.3
-
locationNearEdgeX
public boolean locationNearEdgeX(int x, int y) Tells whether the given location is near the vertical edges of the cell.- Parameters:
x
- horizontal mouse location in absolute window coordinatey
- vertical mouse location in absolute window coordinate
-
locationNearEdgeY
public boolean locationNearEdgeY(int x, int y) Tells whether the given location is near the horizontal edges of the cell.- Parameters:
x
- horizontal mouse location in absolute window coordinatey
- vertical mouse location in absolute window coordinate
-
getWidth
public int getWidth()Returns the width of the cell.- Returns:
- width in pixels
-
getHeight
public int getHeight()Returns the height of the cell.- Returns:
- height in pixels
-
getTop
public int getTop()Returns the y coordinate of the top of the cell.- Returns:
- greatest y coordinate in pixels
-
getBottom
public int getBottom()Returns the y coordinate of the bottom of the cell in pixels.- Returns:
- lowest y coordinate in pixels
-
getLeft
public int getLeft()Returns the x coordinate of the left edge of the active cell.- Returns:
- lowest x coordinate in pixels
-
getRight
public int getRight()Returns the x coordinate of the right edge of the cell.- Returns:
- greatest x coordinate in pixels
-
clearSelections
public void clearSelections()Sets all components and parts of components to be unselected. -
selectComponentElementsInside
Sets all components lying inside the given box to be selected.- Parameters:
bb
- box given asBoundingBox
-
exclusiveSelection
public void exclusiveSelection(int itemIndex) Exclusive selection in the given component. The previously picked part of the component will be selected, and all selected components and parts of components will be unselected.- Parameters:
itemIndex
- internal index of hte component
-
extendSelection
public void extendSelection(int itemIndex) Additive selection in the given component, so the previously picked part of the component will be selected, and all selection remains as is.- Parameters:
itemIndex
- internal index of hte component
-
invertSelection
public void invertSelection(int itemIndex) The previously picked part of the component will be selected if it was unselected and vice versa. All other selection remains as is.- Parameters:
itemIndex
- internal index of hte component
-
componentBecameSelected
public boolean componentBecameSelected()Returns true if a component became selected previously. Information from a selection is kept up to this query.- Returns:
- selection occurred or not
-
componentBecameUnselected
public boolean componentBecameUnselected()Returns true if a component became unselected previously. Information from an unselection is kept up to this query.- Returns:
- unselection occurred or not
-
setTransformationCenterX
public void setTransformationCenterX(float value) Sets the x coordinate of the transformation center.- Parameters:
value
- x coordinate in the model space
-
setTransformationCenterY
public void setTransformationCenterY(float value) Sets the y coordinate of the transformation center.- Parameters:
value
- y coordinate in the model space
-
setTransformationCenterZ
public void setTransformationCenterZ(float value) Sets the z coordinate of the transformation center.- Parameters:
value
- z coordinate in the model space
-
getTransformationCenter
public float[] getTransformationCenter()Returns the transformation center.- Returns:
- coordinates in the model space
-
setTransformationCenter
public void setTransformationCenter(chemaxon.marvin.space.UOID itemId) Sets the transformation center to the center of the component with the given id and resets shifting values. The actual coordinates will be got byGraphicComponent.getCoordinates(float[])
.- Parameters:
itemId
- id of the component
-
setTransformationCenter
public void setTransformationCenter(float x, float y, float z) Sets the transformation center and resets shifting values.- Parameters:
x
- coordinate in the model spacey
- coordinate in the model spacez
- coordinate in the model space
-
getControllableObject
Returns a component if there is any which allows itself to be controlled. Usually a component allows controlling only if it is selected.- Parameters:
type
- identifier of the type of the controller, "Shift", "Rotate", "Resize"- Returns:
- controllable component or null
-
notifyZCoordinateChange
public void notifyZCoordinateChange()Components with 2D parts should notify the container cell when their 'pseudo z' coordinate changes in order to display them in a correct order. -
draw
public void draw()Makes the vieport draw this cell. -
drawCell
public void drawCell()Draws all components of the cell. -
setBackgroundColor
Sets the background color of the cell used by drawing smooth background.- Parameters:
newColor
- color asjava.awt.Color
-
setBackgroundColor
public void setBackgroundColor(float[] newColor) Sets the background color of the cell used by drawing smooth background.- Parameters:
newColor
- color asfloat[]
-
setSmoothBackgroud
public void setSmoothBackgroud(boolean b) Enables/disables shaded background coloring.- Parameters:
b
-
-
drawSmoothBackground
public void drawSmoothBackground() -
setDrawSphere
public void setDrawSphere(boolean flag) Enables/disables drawing of the rotation sphere. The rotation sphere is just a good way of learning rotation, but it does not have a real influence on anything.- Parameters:
flag
- state of drawing sphere
-
drawBorders
public void drawBorders()Draw borders of the cell. -
drawSphere
public void drawSphere()Draws the rotation sphere. -
resetZoom
public void resetZoom() -
zoom
public void zoom(double factor) -
rotate
public void rotate(double angleX, double angleY, double angleZ) -
shift
public void shift(double shiftx, double shifty) -
resetView
public void resetView() -
updateRotationMatrix
public void updateRotationMatrix() -
getRotateMatrix
public float[] getRotateMatrix()Returns the matrix of rotation.- Returns:
- 4x4 rotation matrix
-
setRotateMatrix
public void setRotateMatrix(float[] rm) Sets the matrix of rotation explicitly.- Parameters:
rm
- 4x4 rotation matrix row-by-row
-
getBoundingBoxAndSetSphereRadius
Computes the radius of the bounding sphere in order to set the z coordinate of the camera properly. -
setPickMatrix
public boolean setPickMatrix()
-