Class GraphicCell


  • @PublicAPI
    public class GraphicCell
    extends Object
    GraphicCell is a rectangular part of the OpenGL2 canvas containing GraphicComponents. 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
    • Constructor Summary

      Constructors 
      Constructor Description
      GraphicCell()
      Creates a new instance of GraphicCell.
      GraphicCell​(javax.media.opengl.GL2 gl, javax.media.opengl.glu.GLU glu)
      Creates a new instance of GraphicCell.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int addComponent​(GraphicComponent component)
      Adds a new component to this cell.
      void clearSelections()
      Sets all components and parts of components to be unselected.
      boolean componentBecameSelected()
      Returns true if a component became selected previously.
      boolean componentBecameUnselected()
      Returns true if a component became unselected previously.
      boolean containsComponent​(GraphicComponent gc)
      Tells whether the component is in the cell.
      void draw()
      Makes the vieport draw this cell.
      void drawBorders()
      Draw borders of the cell.
      void drawCell()
      Draws all components of the cell.
      void drawSmoothBackground()  
      void drawSphere()
      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 fadeSelectedComponents()
      Sets all selected components to faded.
      void fadeUnselectedComponents()
      Sets all selected components to faded.
      int getBottom()
      Returns the y coordinate of the bottom of the cell in pixels.
      BoundingBox getBoundingBoxAndSetSphereRadius()
      Computes the radius of the bounding sphere in order to set the z coordinate of the camera properly.
      double getCameraZ()
      Returns the z coordinate of the camera.
      String getCellDrawProperty​(String propertyName)
      Returns the value of the cell-range drawing property with the given name.
      GraphicComponent getComponent​(int componentIndex)
      Returns the component having the given index.
      int getComponentCount()
      Returns the number of components of the cell including monitors, surfaces and so on.
      Iterator getComponentIterator()
      Returns the iterator of the GraphicComponents of the cell.
      GraphicComponent getControllableObject​(String type)
      Returns a component if there is any which allows itself to be controlled.
      float getFarClip()
      Returns the z coordinate of the farther clipping plane which is computed considering all components.
      float getFovY()
      Returns the field of view.
      int getHeight()
      Returns the height of the cell.
      chemaxon.marvin.space.UOID getId()
      Returns the cell id as a UOID.
      int getIndex()
      Returns the internal index of the cell.
      int getLeft()
      Returns the x coordinate of the left edge of the active cell.
      float getNearClip()
      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[] getRotateMatrix()
      Returns the matrix of rotation.
      double getShiftX()
      Returns the shifting value of the x direction.
      double getShiftY()
      Returns the shifting value of the y direction.
      int getTop()
      Returns the y coordinate of the top of the cell.
      float[] getTransformationCenter()
      Returns the transformation center.
      int getVerboseLevel()
      Gets the verbose level.
      int getWidth()
      Returns the width of the cell.
      boolean hasSelectedComponent()
      Returns true if there is at least 1 selected component.
      boolean hasSelectedComponentElement()
      Returns true if there is at least 1 component with a selected part.
      void hideAllComponents​(Class c)
      Sets all components of the given class to invisible.
      void hideAllMonitors()
      Sets all monitor type components (labels as well) to invisible.
      void hideSelectedComponents()
      Sets all selected components to invisible.
      void hideUnselectedComponents()
      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 isVerbose()
      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 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.
      void removeAllComponents()
      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 removeSelectedComponents()
      Removes all selected components and all associated components from the cell.
      void removeUnselectedComponents()
      Removes all unselected components and all associated components from the cell.
      void removeUnselectedMonitors()
      Removes all unsselected monitor components from the cell.
      void resetView()  
      void resetZoom()  
      void rotate​(double angleX, double angleY, double angleZ)  
      void selectComponentElementsInside​(BoundingBox bb)
      Sets all components lying inside the given box to be selected.
      void setActive()
      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 setInactive()
      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 setPickMatrix()  
      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 showAllComponents()
      Sets all components to visible.
      void showAllComponents​(Class c)
      Sets all components of the given class to visible.
      void showAllMonitors()
      Sets all monitor type components (labels as well) to visible.
      void showFaded()
      Sets all faded components to visible.
      void updateRotationMatrix()  
      void zoom​(double factor)  
    • Constructor Detail

      • GraphicCell

        public GraphicCell()
        Creates a new instance of GraphicCell.
      • GraphicCell

        public GraphicCell​(javax.media.opengl.GL2 gl,
                           javax.media.opengl.glu.GLU glu)
        Creates a new instance of GraphicCell.
        Parameters:
        gl - Interface to OpenGL
    • Method Detail

      • 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
        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 also setVerbose(int level).
        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 a UOID.
        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 pixels
        height - 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

        public int addComponent​(GraphicComponent component)
                         throws Exception
        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

        public boolean removeComponent​(GraphicComponent component)
        Removes the component and all associated components from the cell.
        Parameters:
        component - to remove
        Returns:
        succeeded or not
      • removeComponent

        public void removeComponent​(Class componentClass)
      • 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

        public boolean containsComponent​(GraphicComponent gc)
        Tells whether the component is in the cell.
        Parameters:
        gc - component
        Returns:
        is in the cell or not
      • getComponent

        public GraphicComponent getComponent​(int componentIndex)
        Returns the component having the given index.
        Parameters:
        componentIndex - internal index of the component
        Returns:
        component with given index
      • getComponentIterator

        public Iterator getComponentIterator()
        Returns the iterator of the GraphicComponents 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

        public void showAllComponents​(Class c)
        Sets all components of the given class to visible.
      • hideAllComponents

        public void hideAllComponents​(Class c)
        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 scene
        bottom - 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 in
        inColumn - 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 in
        inColumn - which column of the scene is this cell in
        index - internal index of the cell
        left - lowest x coordinate in the scene
        bottom - lowest y coordinate in the scene
        gl - interface to OpenGL
      • getCellDrawProperty

        public String getCellDrawProperty​(String propertyName)
        Returns the value of the cell-range drawing property with the given name.
      • setCellDrawProperties

        public void setCellDrawProperties​(Properties drawProperties)
                                   throws Exception
        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

        public void setDrawProperty​(String propertyName,
                                    String propertyValue)
                             throws Exception
        Sets the drawing properties of all components of the cell.
        Parameters:
        propertyName - name of the drawing property identified by GraphicComponents
        propertyValue - value of the property as a String
        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
      • 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 coordinate
        y - vertical mouse location in absolute window coordinate
      • locateObject

        public 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.
        Parameters:
        x - horizontal mouse location in absolute window coordinate
        y - vertical mouse location in absolute window coordinate
        componentClass - 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 coordinate
        y - 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 coordinate
        y - 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

        public void selectComponentElementsInside​(BoundingBox bb)
        Sets all components lying inside the given box to be selected.
        Parameters:
        bb - box given as BoundingBox
      • 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 by GraphicComponent.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 space
        y - coordinate in the model space
        z - coordinate in the model space
      • getControllableObject

        public GraphicComponent getControllableObject​(String type)
        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

        public void setBackgroundColor​(Color newColor)
        Sets the background color of the cell used by drawing smooth background.
        Parameters:
        newColor - color as java.awt.Color
      • setBackgroundColor

        public void setBackgroundColor​(float[] newColor)
        Sets the background color of the cell used by drawing smooth background.
        Parameters:
        newColor - color as float[]
      • 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

        public BoundingBox getBoundingBoxAndSetSphereRadius()
        Computes the radius of the bounding sphere in order to set the z coordinate of the camera properly.
      • setPickMatrix

        public boolean setPickMatrix()