Package chemaxon.marvin.space
Class GraphicComponent
- java.lang.Object
-
- chemaxon.marvin.space.GraphicComponent
-
- All Implemented Interfaces:
chemaxon.marvin.space.UsableObject
- Direct Known Subclasses:
MacroMoleculeComponent
,MolecularSurfaceComponent
,MoleculeComponent
,Monitor
,PharmacophoreArrow
,PharmacophorePoint
,SurfaceComponent
@PublicAPI public abstract class GraphicComponent extends Object implements chemaxon.marvin.space.UsableObject
GraphicComponents are the basic objects what MarvinSpace can visualize and handle. A component is displayed in a GraphicCell, its view is transformed by the cell.Important concepts related to GraphicComponents:
- selection
Each component can either be in selected or in unselected state. By the selection of components various settings can be restricted, for example changing of color can be restricted to specific components. Components can also be shown/hidden/deleted separately by the use of selection. - draw property
Each component receives every properties set inGraphicScene
, and must handle those that are releated to itself. For example if draw quality (one of the draw properties) is changed by the user toHigh
, every component in the scene receives a "Quality" "H" property pair. Each component can ignore it or change its visualization settings appropriately, e.g. increasing the number of triangles displayed. - bounding box
Setting the camera position and locating components is easier if the bounding box of components is defined, seeBoundingBox
. - associated components
Association provides a strong dependency relationship between components. If a component depends on an other, e.g. a molecular surface depends on the related molecule, they can be associated with each other. This relationship can be used arbitrarily, but there is a predefined behaviour. When a component is deleted, every dependant components will also be deleted. When a component is selected/unselected, shown/hidden or its coordinates change it will notify every associated components about this action. - picking
Picking refers to the selection of a component or a part of a component with the mouse. TheGraphicComponent
class provides basic mechanisms for its derived classes to implement picking. By default, aGraphicComponent
can indicate whether it was picked or not.
- Since:
- Marvin 4.0.2
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
active
Is this component selected or not.protected ArrayList
associatedComponents
Strores components that depend on this component.protected BoundingBox
boundingBox
The smallest box containing the graphic component.protected float[]
color
protected static int
COMPONENT_TYPE_ENTIRE
Indicates if the entire component is selected by picking.protected Properties
drawProperties
Common drawing related properties that affect allthree quality modes
.protected int
drawType
The actual drawing type of the component.protected javax.media.opengl.GL2
gl
must be accessible in derived classesprotected javax.media.opengl.glu.GLU
glu
protected GraphicCell
graphicCell
which cell of the scene is this component displayed inprotected int
irm
Inverse of the Rotation matrix represented by a GeomCalc matrix.protected boolean
modifiesOrigin
Tells whether this component modifies the transformation center of the cell or not.protected int
motionMode
Indicates if the component is in standing or in moving mode.protected int
mousex
Mouse position in picking mode.protected int
mousey
Mouse position in picking mode.protected String
name
protected ComponentElement
pickedItem
Identifies the most recently selected elementstatic int
RENDERING_QUALITY_HIGH
Highest though slowest drawing quality indicator.static int
RENDERING_QUALITY_LOW
Lowest but fastest drawing quality indicator.static int
RENDERING_QUALITY_MEDIUM
Medium drawing quality indicator.protected int
renderingQuality
The actual rendering quality.protected int
rm
Rotation matrix as a GeomCalc matrix.protected chemaxon.marvin.space.UOID
uoid
internal index of the componentprotected boolean
visible
Indicates if component is visible or hidden.
-
Constructor Summary
Constructors Modifier Constructor Description protected
GraphicComponent()
Creates an empty object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDrawProperties(Properties drawProperties)
Forces the component to set all drawing property stored in drawProperties, and leaves the old settings which are not overidden.void
associate(GraphicComponent gc)
The given component will depend on this component.void
cleanup()
void
draw()
Draws the coordinate system of the component.void
draw2DPart()
A component which draws (partly) in plane should overwrite this method.protected void
drawBoundingBox()
Vizualises the bounding box.protected void
drawCoordinateAxes()
Draws the local coordinate axes, the origin is the transformation centerprotected void
drawSelection(int mode)
Draws the component in the given mode (usually in selection mode), the rendering mode is for checking.void
drawTransparentPart()
A component having transparent parts should override this method, drawing the transparent parts here.void
exclusiveSelection()
Sets the previously picked but unprocessed element to be selected, and sets every other parts not to be selected.void
exclusiveSelection(ComponentElement element)
Sets the the given part of the component to be selected, and sets every other parts not to be selected.void
extendSelection()
Sets the previously picked but unprocessed element to be selected, and leaves other parts as they are.void
extendSelection(ComponentElement element)
Sets the the given part of the component to be selected, and leaves other parts as they are.void
fadeSelected()
A descendant should overwrite this method to have its selection became faded.void
fadeUnselected()
A descendant should overwrite this method to have all but its selection became faded.Iterator
getAssociatedComponents()
Returns anIterator
that can enumerate the components associated to (depending on) this component.BoundingBox
getBoundingBox()
Returns the smallest box containing the graphic component.double
getBoundingSphereRadius()
Returns the radius of the bounding sphere of the component.GraphicCell
getCell()
Returns the container cell of the component.Color
getColor()
Returns the constant color of the component.ComponentElement
getComponentElement()
Returns the previously picked but unprocessed ComponentElement or the whole component as a ComponentElement, if no picking happened.void
getCoordinates(float[] c)
Gets the coordinates of the previously picked but not yet processed part if there is any in the given preallocated array.void
getCoordinates(ComponentElement element, float[] c)
Gets the coordinates of the given ComponentElement in the given preallocated array.String
getDescription()
Returs the short description of the component or of the previously picked but not yet processed part if there is any or the description of the whole component.String
getDescription(ComponentElement element)
Returs the short description of the given part of the component.Properties
getDrawProperties()
Returns the set draw properties of the component.String
getDrawProperty(String propertyName)
Returns the value of a draw property.GraphicComponent
getGraphicComponent()
chemaxon.marvin.space.UOID
getId()
Returns the id of the component.ComponentElement[]
getLabelInformation(String labeltype)
ComponentElement[]
getLabelInformation(String labeltype, boolean onlyOnHeavyAtoms)
Labels will be created associated to this GraphicComponent if the component supports the given labeltype, and returns arbitrary numbers of ComponentElements with correct coordinates and description to create a label.String
getName()
Returns the name of the component.int
getRenderingQuality()
Returns the actual rendering quality of the component.chemaxon.marvin.space.UsableObject
getUsableObject(chemaxon.marvin.space.UOID id)
Returns the component that the given UOID identifies.float
getZCoordinateTo2DPart()
Returns a third, z coordinate in order to display 2D parts in proper order.protected void
glColor()
Sets the default/constant color of the component for drawing.boolean
has2DPart()
Returns true, if the component resets the projection matrix in its draw method, so that the component is drawn in plane.boolean
hasSelectedElements()
Tells whether the component has some selected parts.boolean
hasTransparentPart()
Returns true if a component has transparent part to draw.void
hideSelected()
If the component is selected it will become hidden.void
hideUnselected()
If the component is unselected it will become hidden.void
invertSelection()
Sets the previously picked but unprocessed element to be selected if it was not set and vice versa.void
invertSelection(ComponentElement element)
Sets the the given part of the component to be selected if it was not set and vice versa.boolean
isControllable(String type)
A component must return true if it allows itself to be controlled by the given type controller.boolean
isGraphicComponent()
boolean
isSelected()
Tells whether the component is being selected or not.boolean
isSelected(ComponentElement element)
Tells whether a part of the component is selected.boolean
isVisible()
Returns true if this component is allowed to be drawn.boolean
isVisible(ComponentElement element)
Returns true if the specified part of the component is allowed to be drawn.double
locateObject(int x, int y)
Picking action at x, y coordinates, returns the z coordinate of the nearest picked item, or -1.void
notifyCoordinateChange()
Notifies the associated components of changing coodinates.void
notifyInvisibility()
Notifies the associated components of being invisible.void
notifySelection()
Notifies the associated components of being selected.void
notifyUnSelection()
Notifies the associated components of being unselected.void
notifyVisibility()
Notifies the associated components of being visible.void
onRemoveGraphicComponent()
protected void
pickObject(int offset, double[] maxZ, float[] modelview)
SetspickedItem
to be the picked part of the component.void
projectVector(float[] vector3)
Projects a vector from the scene to the viewport.void
receiveNotificationOnCoordinateChange(GraphicComponent gc)
Notifies the current object that the coordinates of the given component have been changed.void
receiveNotificationOnInvisibility(GraphicComponent gc)
Notifies the current object that the given component is not visible.void
receiveNotificationOnSelection(GraphicComponent gc)
Notifies the current object that the given component became selected.void
receiveNotificationOnUnSelection(GraphicComponent gc)
Notifies the current object that the given component became unselected.void
receiveNotificationOnVisibility(GraphicComponent gc)
Notifies the current object that the given component became visible.void
removeAssociation(GraphicComponent gc)
Removes the dependency of the given component from this component.void
resize(double x, double y, double z)
Resizes the component according to the given factors in each directions.void
rotate(float[] v, float[] center)
Rotates the component by changing its coordinates, and not just the view.void
rotate(float[] p, float[] v, float[] center)
Rotates the given p point by changing its coordinates.void
rotate(int p, float[] v, float[] center)
Rotates the given p point by changing its coordinates.void
select()
Sets the component to be selected.void
select(ComponentElement element)
Sets the specific part of the component to be selected.void
selectComponentElementsInside(BoundingBox bb)
The component will be selected if it is inside the given box.void
setColor(float[] color)
Sets the constant color of the component.void
setColor(float r, float g, float b)
Sets the constant color of the component.void
setColor(int r, int g, int b)
Sets the constant color of the component.void
setColor(Color color)
Sets the constant color of the component.void
setDrawProperties(Properties drawProperties)
Forces the component to set all drawing property stored in drawProperties, and loose every old setting.void
setDrawProperty(String propertyName, String propertyValue)
This is the gate of draw properties from outside to the component.void
setGL(javax.media.opengl.GL2 gl, javax.media.opengl.glu.GLU glu)
Sets the GL2 rendering environment.void
setMotionMode(int mode)
Sets the motion state of the component.void
setName(String n)
Sets the name of the component.void
setProgressBar(chemaxon.marvin.space.ProgressBarInterface progressBar)
void
setRenderingQuality(int quality)
Sets the rendering quality.void
setRotateMatrix(float[] rotateMatrix)
Sets the rotation matrix in order to get the proper mapping of a vector to the viewing plane.void
setVisible(boolean state)
Indicates whether the component will appear on the graphic scene at the next draw or not.void
showFaded()
A descendant should overwrite this method to have its faded part become visible.protected void
storeDrawProperty(String propertyName, String propertyValue)
Stores the given property.String
toString()
protected double
touchObject(int hits)
Returns the z coordinate of the nearest component.void
translate(float[] v)
Translates the component by changing its coordinates, and not just the view.void
unSelect()
Sets the component not to be selected.void
unSelect(ComponentElement element)
Sets the specific part of the component not to be selected.
-
-
-
Field Detail
-
RENDERING_QUALITY_LOW
public static final int RENDERING_QUALITY_LOW
Lowest but fastest drawing quality indicator.- See Also:
- Constant Field Values
-
RENDERING_QUALITY_MEDIUM
public static final int RENDERING_QUALITY_MEDIUM
Medium drawing quality indicator.- See Also:
- Constant Field Values
-
RENDERING_QUALITY_HIGH
public static final int RENDERING_QUALITY_HIGH
Highest though slowest drawing quality indicator.- See Also:
- Constant Field Values
-
COMPONENT_TYPE_ENTIRE
protected static final int COMPONENT_TYPE_ENTIRE
Indicates if the entire component is selected by picking. Required by subclasses which implement custom picking/selection procedures.- See Also:
- Constant Field Values
-
graphicCell
protected GraphicCell graphicCell
which cell of the scene is this component displayed in
-
uoid
protected chemaxon.marvin.space.UOID uoid
internal index of the component
-
name
protected String name
-
color
protected float[] color
-
associatedComponents
protected ArrayList associatedComponents
Strores components that depend on this component. E.g. they will be deleted when this component is deleted.
-
gl
protected javax.media.opengl.GL2 gl
must be accessible in derived classes
-
glu
protected javax.media.opengl.glu.GLU glu
-
visible
protected boolean visible
Indicates if component is visible or hidden.
-
renderingQuality
protected int renderingQuality
The actual rendering quality. It can be low, medium or high. The default is medium.
-
drawType
protected int drawType
The actual drawing type of the component. Usually various draw types are available for aGraphicComponent
.
-
drawProperties
protected Properties drawProperties
Common drawing related properties that affect allthree quality modes
. These properties are handled in a uniform way coming through theGraphicScene
API. Properties are set bysetDrawProperty(String propertyName, String propertyValue)
. All properties are delivered to every components and it is the responsibility of the particularGraphicComponent
to pick relevant properties to be processed.
-
modifiesOrigin
protected boolean modifiesOrigin
Tells whether this component modifies the transformation center of the cell or not. Most components modify the transformation center when they are added to the cell. Exceptions are for examplemonitors
andsurfaces
.
-
boundingBox
protected BoundingBox boundingBox
The smallest box containing the graphic component. In the simplest case the transformation center of the cell containing theGraphicComponent
is the center of the bounding box.
-
rm
protected int rm
Rotation matrix as a GeomCalc matrix. It is used during picking.
-
irm
protected int irm
Inverse of the Rotation matrix represented by a GeomCalc matrix. It is used during picking.
-
active
protected boolean active
Is this component selected or not.
-
pickedItem
protected ComponentElement pickedItem
Identifies the most recently selected element
-
mousex
protected int mousex
Mouse position in picking mode. Derived classes may use it (e.g.Monitor
andLabel
).
-
mousey
protected int mousey
Mouse position in picking mode. Derived classes may use it (e.g.Monitor
andLabel
).
-
motionMode
protected int motionMode
Indicates if the component is in standing or in moving mode. TheGraphicComponent
may behave differently in the different motion modes.
-
-
Method Detail
-
onRemoveGraphicComponent
public void onRemoveGraphicComponent()
-
setProgressBar
public void setProgressBar(chemaxon.marvin.space.ProgressBarInterface progressBar)
-
getId
public chemaxon.marvin.space.UOID getId()
Returns the id of the component. This id contains internal cell and component indices. The id can be changed by client and internal mechanisms inGraphicCell
may also alter its value. Thus to preserve a component for later use, store the component itself rather than its Id.- Specified by:
getId
in interfacechemaxon.marvin.space.UsableObject
- Returns:
- id of the component
-
isGraphicComponent
public boolean isGraphicComponent()
- Specified by:
isGraphicComponent
in interfacechemaxon.marvin.space.UsableObject
-
getGraphicComponent
public GraphicComponent getGraphicComponent()
- Specified by:
getGraphicComponent
in interfacechemaxon.marvin.space.UsableObject
-
getName
public String getName()
Returns the name of the component.- Specified by:
getName
in interfacechemaxon.marvin.space.UsableObject
- Returns:
- name that is
getClass.getName()
by default.
-
toString
public String toString()
-
setName
public void setName(String n)
Sets the name of the component.- Specified by:
setName
in interfacechemaxon.marvin.space.UsableObject
- Parameters:
n
-
-
getColor
public Color getColor()
Returns the constant color of the component.- Specified by:
getColor
in interfacechemaxon.marvin.space.UsableObject
-
setColor
public void setColor(Color color)
Sets the constant color of the component.- Specified by:
setColor
in interfacechemaxon.marvin.space.UsableObject
-
setColor
public void setColor(float[] color)
Sets the constant color of the component.
-
setColor
public void setColor(int r, int g, int b)
Sets the constant color of the component.
-
setColor
public void setColor(float r, float g, float b)
Sets the constant color of the component.
-
getCell
public GraphicCell getCell()
Returns the container cell of the component.- Returns:
- container cell
-
getAssociatedComponents
public Iterator getAssociatedComponents()
Returns anIterator
that can enumerate the components associated to (depending on) this component.- Returns:
- Iterator pointing to the first element
-
associate
public void associate(GraphicComponent gc)
The given component will depend on this component.- Parameters:
gc
- associated component
-
removeAssociation
public void removeAssociation(GraphicComponent gc)
Removes the dependency of the given component from this component.- Parameters:
gc
- component will no longer depend of this component
-
receiveNotificationOnSelection
public void receiveNotificationOnSelection(GraphicComponent gc)
Notifies the current object that the given component became selected.- Parameters:
gc
- selected component
-
receiveNotificationOnUnSelection
public void receiveNotificationOnUnSelection(GraphicComponent gc)
Notifies the current object that the given component became unselected.- Parameters:
gc
- unselected component
-
receiveNotificationOnVisibility
public void receiveNotificationOnVisibility(GraphicComponent gc)
Notifies the current object that the given component became visible.- Parameters:
gc
- visible component
-
receiveNotificationOnInvisibility
public void receiveNotificationOnInvisibility(GraphicComponent gc)
Notifies the current object that the given component is not visible.- Parameters:
gc
- invisible component
-
receiveNotificationOnCoordinateChange
public void receiveNotificationOnCoordinateChange(GraphicComponent gc)
Notifies the current object that the coordinates of the given component have been changed.- Parameters:
gc
- component changing coordinates
-
notifySelection
public void notifySelection()
Notifies the associated components of being selected.
-
notifyUnSelection
public void notifyUnSelection()
Notifies the associated components of being unselected.
-
notifyVisibility
public void notifyVisibility()
Notifies the associated components of being visible.
-
notifyInvisibility
public void notifyInvisibility()
Notifies the associated components of being invisible.
-
notifyCoordinateChange
public void notifyCoordinateChange()
Notifies the associated components of changing coodinates.
-
setMotionMode
public void setMotionMode(int mode)
Sets the motion state of the component.- Parameters:
mode
- eitherGraphicScene.MODE_STANDING
orGraphicScene.MODE_MOVING
-
setGL
public void setGL(javax.media.opengl.GL2 gl, javax.media.opengl.glu.GLU glu)
Sets the GL2 rendering environment. Without this being set the component cannot draw itself.- Parameters:
gl
- Interface to OpenGLglu
- Interface to OpenGL
-
setRenderingQuality
public void setRenderingQuality(int quality)
Sets the rendering quality.- Parameters:
quality
- rendering quality, seeRENDERING_*
constants
-
storeDrawProperty
protected void storeDrawProperty(String propertyName, String propertyValue)
Stores the given property. It is called from overridensetDrawProperty
functions.- Parameters:
propertyName
- identifier of the draw propertypropertyValue
- value of the draw property as aString
-
setDrawProperty
public void setDrawProperty(String propertyName, String propertyValue) throws Exception
This is the gate of draw properties from outside to the component. A component processes the draw property only if it can identify it, but every component will get it. Every subclasses must call thestoreDrawProperty()
in the overriden setDrawProperty function if it identifies the property.- Specified by:
setDrawProperty
in interfacechemaxon.marvin.space.UsableObject
- Parameters:
propertyName
- identifier of the draw propertypropertyValue
- value of the draw property as aString
- Throws:
Exception
-
getDrawProperty
public String getDrawProperty(String propertyName)
Returns the value of a draw property.- Returns:
- value of the draw property as
String
-
getDrawProperties
public Properties getDrawProperties()
Returns the set draw properties of the component.- Returns:
- collection of previously set draw properties
-
setDrawProperties
public void setDrawProperties(Properties drawProperties) throws Exception
Forces the component to set all drawing property stored in drawProperties, and loose every old setting.- Parameters:
drawProperties
- collection of draw properties to set- Throws:
Exception
-
addDrawProperties
public void addDrawProperties(Properties drawProperties) throws Exception
Forces the component to set all drawing property stored in drawProperties, and leaves the old settings which are not overidden.- Parameters:
drawProperties
- collection of draw properties to set- Throws:
Exception
-
setRotateMatrix
public void setRotateMatrix(float[] rotateMatrix)
Sets the rotation matrix in order to get the proper mapping of a vector to the viewing plane.- Parameters:
rotateMatrix
- float array having 16 elements representing a 4 by 4 rotation matrix
-
projectVector
public void projectVector(float[] vector3)
Projects a vector from the scene to the viewport.- Parameters:
vector3
- preallocated array containing 3 float coordinates
-
draw
public void draw()
Draws the coordinate system of the component. It can be called by GraphicScene when it is time for drawing, and everything is set properly. This function is not public, becaue it cannot be ensured that in the moment of calling from outside we are int the Jogl rendering thread, and everything is set properly (buffers, viewport, matrices, and so on).
-
glColor
protected void glColor()
Sets the default/constant color of the component for drawing.
-
drawCoordinateAxes
protected void drawCoordinateAxes()
Draws the local coordinate axes, the origin is the transformation center
-
drawBoundingBox
protected void drawBoundingBox()
Vizualises the bounding box.
-
drawSelection
protected void drawSelection(int mode)
Draws the component in the given mode (usually in selection mode), the rendering mode is for checking.- Parameters:
mode
-GL_RENDER
orGL_SELECT
-
isVisible
public boolean isVisible()
Returns true if this component is allowed to be drawn.- Specified by:
isVisible
in interfacechemaxon.marvin.space.UsableObject
- Returns:
- visibility of the component
-
isVisible
public boolean isVisible(ComponentElement element)
Returns true if the specified part of the component is allowed to be drawn.- Parameters:
element
- part of the component- Returns:
- visibility of the part of the component
-
setVisible
public void setVisible(boolean state)
Indicates whether the component will appear on the graphic scene at the next draw or not.- Specified by:
setVisible
in interfacechemaxon.marvin.space.UsableObject
- Parameters:
state
- of visibility
-
hideSelected
public void hideSelected()
If the component is selected it will become hidden.
-
hideUnselected
public void hideUnselected()
If the component is unselected it will become hidden.
-
showFaded
public void showFaded()
A descendant should overwrite this method to have its faded part become visible.
-
fadeSelected
public void fadeSelected()
A descendant should overwrite this method to have its selection became faded.
-
fadeUnselected
public void fadeUnselected()
A descendant should overwrite this method to have all but its selection became faded.
-
hasTransparentPart
public boolean hasTransparentPart()
Returns true if a component has transparent part to draw. If this is true,drawTransparentPart()
will be called during draw. Components with transparent parts should overload this function and return true, and overload thedrawTransparentPart()
method. This is necessary because for the correct display, opaque components have to be drawn first, and transparents after them.- Returns:
- will the component draw with transparency
-
drawTransparentPart
public void drawTransparentPart()
A component having transparent parts should override this method, drawing the transparent parts here. Antialiased lines and transparent filled polygons are considered transparent. To draw transparent objects enable GL_BLEND.
-
has2DPart
public boolean has2DPart()
Returns true, if the component resets the projection matrix in its draw method, so that the component is drawn in plane. These components are drawn after the rest.- Returns:
- will the component draw in plane
-
draw2DPart
public void draw2DPart()
A component which draws (partly) in plane should overwrite this method.
-
getZCoordinateTo2DPart
public float getZCoordinateTo2DPart()
Returns a third, z coordinate in order to display 2D parts in proper order.- Returns:
- a pseudo 'z' cordinate
-
translate
public void translate(float[] v)
Translates the component by changing its coordinates, and not just the view. This function is usually called by a translation monitor, if and only if the component returns true to the {#isControllable("Shift")} call. This funcion translates the bounding box, and notifies the associated components (e.g. the translation monitor) about the change. It does not change any coordinates of the component itself.- Parameters:
v
- The translation vector.
-
rotate
public void rotate(float[] v, float[] center)
Rotates the component by changing its coordinates, and not just the view.- Parameters:
v
- Measurement of the rotation around the 3 axis, x, y, z.center
- Center of the rotation.
-
rotate
public void rotate(float[] p, float[] v, float[] center)
Rotates the given p point by changing its coordinates.- Parameters:
p
- A point/vector to rotate.v
- Measurement of the rotation around the 3 axis, x, y, z.center
- Center of the rotation.
-
rotate
public void rotate(int p, float[] v, float[] center)
Rotates the given p point by changing its coordinates.- Parameters:
p
- A point/vector to rotate given as a GeomCalc vector.v
- Measurement of the rotation around the 3 axis, x, y, z.center
- Center of the rotation.
-
resize
public void resize(double x, double y, double z)
Resizes the component according to the given factors in each directions.
-
isControllable
public boolean isControllable(String type)
A component must return true if it allows itself to be controlled by the given type controller.- Parameters:
type
- "Shift", "Rotate", "Resize"- Returns:
- is the component aloowed to be controlled or not
-
getBoundingBox
public BoundingBox getBoundingBox()
Returns the smallest box containing the graphic component.- Returns:
- BoundingBox
-
getBoundingSphereRadius
public double getBoundingSphereRadius()
Returns the radius of the bounding sphere of the component.- Returns:
- radius in Angstroms
-
getRenderingQuality
public int getRenderingQuality()
Returns the actual rendering quality of the component.
-
getCoordinates
public void getCoordinates(float[] c)
Gets the coordinates of the previously picked but not yet processed part if there is any in the given preallocated array.- Parameters:
c
- allocated array where coordinates will be put
-
getCoordinates
public void getCoordinates(ComponentElement element, float[] c)
Gets the coordinates of the given ComponentElement in the given preallocated array.- Parameters:
element
- specific part of the componentc
- allocated array where coordinates will be put
-
getDescription
public String getDescription()
Returs the short description of the component or of the previously picked but not yet processed part if there is any or the description of the whole component.- Returns:
- short description as
String
-
getDescription
public String getDescription(ComponentElement element)
Returs the short description of the given part of the component.- Parameters:
element
- specific part of the component- Returns:
- short description as
String
-
getLabelInformation
public ComponentElement[] getLabelInformation(String labeltype, boolean onlyOnHeavyAtoms)
Labels will be created associated to this GraphicComponent if the component supports the given labeltype, and returns arbitrary numbers of ComponentElements with correct coordinates and description to create a label.- Parameters:
labeltype
-onlyOnHeavyAtoms
- label info needed only for heavy atoms.- Returns:
- array of ComponentElements to create labels to
-
getLabelInformation
public ComponentElement[] getLabelInformation(String labeltype)
-
getComponentElement
public ComponentElement getComponentElement()
Returns the previously picked but unprocessed ComponentElement or the whole component as a ComponentElement, if no picking happened.- Returns:
- picked part of the component
-
getUsableObject
public chemaxon.marvin.space.UsableObject getUsableObject(chemaxon.marvin.space.UOID id)
Returns the component that the given UOID identifies.- Parameters:
id
- identifier of the component or a part of the component- Returns:
- the component or the specific part of the component
-
locateObject
public double locateObject(int x, int y)
Picking action at x, y coordinates, returns the z coordinate of the nearest picked item, or -1.- Parameters:
x
- window coordinate of the mousey
- window coordinate of the mouse- Returns:
- z coordinate of the nearest picked object
-
touchObject
protected double touchObject(int hits)
Returns the z coordinate of the nearest component. This is exactly the component having the maximum z coordinate, because we are looking down the negative z axis.- Parameters:
hits
- Number of hits at the previous hit.- Returns:
- z coordinate of the nearest picked object
-
pickObject
protected void pickObject(int offset, double[] maxZ, float[] modelview)
SetspickedItem
to be the picked part of the component.- Parameters:
offset
- Integer used in the name stack to identify the part of the component.maxZ
- Stores the z coordinate of the part with maximum z coordinate in the actual picking. It has to be set if the part with the current offset has greater z coordinate than the stored one. Example to compute:int aIdx = GeomCalc.newVector( picked.x(), picked.y(), picked.z() );
GeomCalc.multVectorWithMatrix(aIdx, modelview);
z coordinate:maxZ[0] = GeomCalc.getZ(aIdx)
modelview
- Is to compute the proper z coordinate.
-
isSelected
public boolean isSelected()
Tells whether the component is being selected or not.- Specified by:
isSelected
in interfacechemaxon.marvin.space.UsableObject
- Returns:
- selection state of the component
-
isSelected
public boolean isSelected(ComponentElement element)
Tells whether a part of the component is selected. By default, works the same asisSelected()
.- Parameters:
element
- specific part of the component- Returns:
- selection state of the element
-
hasSelectedElements
public boolean hasSelectedElements()
Tells whether the component has some selected parts. By default, works the same asisSelected()
- Returns:
- is any part of the component selected
-
select
public void select()
Sets the component to be selected. See alsounSelect()
.- Specified by:
select
in interfacechemaxon.marvin.space.UsableObject
-
select
public void select(ComponentElement element)
Sets the specific part of the component to be selected. Note, that the whole component can also be selected with this, and this is the default behaviour as well.- Parameters:
element
- specific part of the component
-
selectComponentElementsInside
public void selectComponentElementsInside(BoundingBox bb)
The component will be selected if it is inside the given box.- Parameters:
bb
- given box represented by aBoundingBox
-
unSelect
public void unSelect()
Sets the component not to be selected.- Specified by:
unSelect
in interfacechemaxon.marvin.space.UsableObject
-
unSelect
public void unSelect(ComponentElement element)
Sets the specific part of the component not to be selected. Note, that the whole component can also be unselected with this, and this is the default behaviour as well.- Parameters:
element
- specific part of the component
-
invertSelection
public void invertSelection()
Sets the previously picked but unprocessed element to be selected if it was not set and vice versa.
-
invertSelection
public void invertSelection(ComponentElement element)
Sets the the given part of the component to be selected if it was not set and vice versa. By default it works the same as invertSelection().- Parameters:
element
- specific part of the component
-
extendSelection
public void extendSelection()
Sets the previously picked but unprocessed element to be selected, and leaves other parts as they are.
-
extendSelection
public void extendSelection(ComponentElement element)
Sets the the given part of the component to be selected, and leaves other parts as they are. By default it works the same as select().- Parameters:
element
- specific part of the component
-
exclusiveSelection
public void exclusiveSelection()
Sets the previously picked but unprocessed element to be selected, and sets every other parts not to be selected.
-
exclusiveSelection
public void exclusiveSelection(ComponentElement element)
Sets the the given part of the component to be selected, and sets every other parts not to be selected. By default it works the same asselect()
.- Parameters:
element
- specific part of the component
-
cleanup
public void cleanup()
-
-