|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectchemaxon.marvin.space.GraphicComponent
public abstract class GraphicComponent
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:
GraphicScene
, and must handle those
that are releated to itself. For example if draw quality (one of the draw properties) is changed by the user to High
,
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.BoundingBox
.GraphicComponent
class provides basic mechanisms for its
derived classes to implement picking. By default, a GraphicComponent
can
indicate whether it was picked or not.
Field Summary | |
---|---|
protected boolean |
active
Is this component selected or not. |
protected java.util.ArrayList |
associatedComponents
Strores components that depend on this component. |
protected BoundingBox |
boundingBox
The smallest box containing the graphic component. |
protected java.awt.Color |
color
|
protected static int |
COMPONENT_TYPE_ENTIRE
Indicates if the entire component is selected by picking. |
protected java.util.Properties |
drawProperties
Common drawing related properties that affect all three quality modes . |
protected int |
drawType
The actual drawing type of the component. |
protected javax.media.opengl.GL2 |
gl
must be accessible in derived classes |
protected javax.media.opengl.glu.GLU |
glu
|
protected GraphicCell |
graphicCell
which cell of the scene is this component displayed in |
protected 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 java.lang.String |
name
|
protected ComponentElement |
pickedItem
Identifies the most recently selected element |
static 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 component |
protected boolean |
visible
Indicates if component is visible or hidden. |
Constructor Summary | |
---|---|
protected |
GraphicComponent()
Creates an empty object. |
Method Summary | |
---|---|
void |
addDrawProperties(java.util.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 |
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 center |
protected 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. |
java.util.Iterator |
getAssociatedComponents()
Returns an Iterator 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. |
java.awt.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(ComponentElement element,
float[] c)
Gets the coordinates of the given ComponentElement in the given preallocated array. |
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. |
java.lang.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. |
java.lang.String |
getDescription(ComponentElement element)
Returs the short description of the given part of the component. |
java.util.Properties |
getDrawProperties()
Returns the set draw properties of the component. |
java.lang.String |
getDrawProperty(java.lang.String propertyName)
Returns the value of a draw property. |
GraphicComponent |
getGraphicComponent()
|
chemaxon.marvin.space.UOID |
getId()
Returns the id of the component. |
ComponentElement[] |
getLabelInformation(java.lang.String labeltype)
|
ComponentElement[] |
getLabelInformation(java.lang.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. |
java.lang.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(java.lang.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)
Sets pickedItem 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(java.awt.Color c)
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 |
setDrawProperties(java.util.Properties drawProperties)
Forces the component to set all drawing property stored in drawProperties, and loose every old setting. |
void |
setDrawProperty(java.lang.String propertyName,
java.lang.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(java.lang.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(java.lang.String propertyName,
java.lang.String propertyValue)
Stores the given property. |
java.lang.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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int RENDERING_QUALITY_LOW
public static final int RENDERING_QUALITY_MEDIUM
public static final int RENDERING_QUALITY_HIGH
protected static final int COMPONENT_TYPE_ENTIRE
protected GraphicCell graphicCell
protected chemaxon.marvin.space.UOID uoid
protected java.lang.String name
protected java.awt.Color color
protected java.util.ArrayList associatedComponents
protected javax.media.opengl.GL2 gl
protected javax.media.opengl.glu.GLU glu
protected boolean visible
protected int renderingQuality
protected int drawType
GraphicComponent
.
protected java.util.Properties drawProperties
three quality modes
.
These properties are handled in a uniform way coming through the GraphicScene
API.
Properties are set by setDrawProperty(String propertyName, String propertyValue)
.
All properties are delivered to every components and it is the
responsibility of the particular GraphicComponent
to pick relevant properties to be processed.
protected boolean modifiesOrigin
monitors
and surfaces
.
protected BoundingBox boundingBox
GraphicComponent
is the center of the bounding box.
protected int rm
protected int irm
protected boolean active
protected ComponentElement pickedItem
protected int mousex
Monitor
and Label
).
protected int mousey
Monitor
and Label
).
protected int motionMode
GraphicComponent
may behave differently in the different
motion modes.
Constructor Detail |
---|
protected GraphicComponent()
Method Detail |
---|
public void onRemoveGraphicComponent()
public void setProgressBar(chemaxon.marvin.space.ProgressBarInterface progressBar)
public chemaxon.marvin.space.UOID getId()
GraphicCell
may also alter its value. Thus to preserve a component for later use,
store the component itself rather than its Id.
getId
in interface chemaxon.marvin.space.UsableObject
public boolean isGraphicComponent()
isGraphicComponent
in interface chemaxon.marvin.space.UsableObject
public GraphicComponent getGraphicComponent()
getGraphicComponent
in interface chemaxon.marvin.space.UsableObject
public java.lang.String getName()
getName
in interface chemaxon.marvin.space.UsableObject
getClass.getName()
by default.public java.lang.String toString()
toString
in interface chemaxon.marvin.space.UsableObject
toString
in class java.lang.Object
public void setName(java.lang.String n)
setName
in interface chemaxon.marvin.space.UsableObject
n
- public java.awt.Color getColor()
getColor
in interface chemaxon.marvin.space.UsableObject
public void setColor(java.awt.Color c)
setColor
in interface chemaxon.marvin.space.UsableObject
public void setColor(int r, int g, int b)
public void setColor(float r, float g, float b)
public GraphicCell getCell()
public java.util.Iterator getAssociatedComponents()
Iterator
that can enumerate the components
associated to (depending on) this component.
public void associate(GraphicComponent gc)
gc
- associated componentpublic void removeAssociation(GraphicComponent gc)
gc
- component will no longer depend of this componentpublic void receiveNotificationOnSelection(GraphicComponent gc)
gc
- selected componentpublic void receiveNotificationOnUnSelection(GraphicComponent gc)
gc
- unselected componentpublic void receiveNotificationOnVisibility(GraphicComponent gc)
gc
- visible componentpublic void receiveNotificationOnInvisibility(GraphicComponent gc)
gc
- invisible componentpublic void receiveNotificationOnCoordinateChange(GraphicComponent gc)
gc
- component changing coordinatespublic void notifySelection()
public void notifyUnSelection()
public void notifyVisibility()
public void notifyInvisibility()
public void notifyCoordinateChange()
public void setMotionMode(int mode)
mode
- either GraphicScene.MODE_STANDING
or GraphicScene.MODE_MOVING
public void setGL(javax.media.opengl.GL2 gl, javax.media.opengl.glu.GLU glu)
gl
- Interface to OpenGLglu
- Interface to OpenGLpublic void setRenderingQuality(int quality)
quality
- rendering quality, see RENDERING_*
constantsprotected void storeDrawProperty(java.lang.String propertyName, java.lang.String propertyValue)
setDrawProperty
functions.
propertyName
- identifier of the draw propertypropertyValue
- value of the draw property as a String
public void setDrawProperty(java.lang.String propertyName, java.lang.String propertyValue) throws java.lang.Exception
storeDrawProperty()
in the overriden
setDrawProperty function if it identifies the property.
setDrawProperty
in interface chemaxon.marvin.space.UsableObject
propertyName
- identifier of the draw propertypropertyValue
- value of the draw property as a String
java.lang.Exception
public java.lang.String getDrawProperty(java.lang.String propertyName)
String
public java.util.Properties getDrawProperties()
public void setDrawProperties(java.util.Properties drawProperties) throws java.lang.Exception
drawProperties
- collection of draw properties to set
java.lang.Exception
public void addDrawProperties(java.util.Properties drawProperties) throws java.lang.Exception
drawProperties
- collection of draw properties to set
java.lang.Exception
public void setRotateMatrix(float[] rotateMatrix)
rotateMatrix
- float array having 16 elements representing a 4 by 4 rotation matrixpublic void projectVector(float[] vector3)
vector3
- preallocated array containing 3 float coordinatespublic void draw()
protected void glColor()
protected void drawCoordinateAxes()
protected void drawBoundingBox()
protected void drawSelection(int mode)
mode
- GL_RENDER
or GL_SELECT
public boolean isVisible()
isVisible
in interface chemaxon.marvin.space.UsableObject
public boolean isVisible(ComponentElement element)
element
- part of the component
public void setVisible(boolean state)
setVisible
in interface chemaxon.marvin.space.UsableObject
state
- of visibilitypublic void hideSelected()
public void hideUnselected()
public void showFaded()
public void fadeSelected()
public void fadeUnselected()
public boolean hasTransparentPart()
drawTransparentPart()
will be called during draw.
Components with transparent parts should overload this function and return true,
and overload the drawTransparentPart()
method.
This is necessary because for the correct display, opaque components have to be drawn first,
and transparents after them.
public void drawTransparentPart()
public boolean has2DPart()
public void draw2DPart()
public float getZCoordinateTo2DPart()
public void translate(float[] v)
v
- The translation vector.public void rotate(float[] v, float[] center)
v
- Measurement of the rotation around the 3 axis, x, y, z.center
- Center of the rotation.public void rotate(float[] p, float[] v, float[] center)
p
- A point/vector to rotate.v
- Measurement of the rotation around the 3 axis, x, y, z.center
- Center of the rotation.public void rotate(int p, float[] v, float[] center)
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.public void resize(double x, double y, double z)
public boolean isControllable(java.lang.String type)
type
- "Shift", "Rotate", "Resize"
public BoundingBox getBoundingBox()
public double getBoundingSphereRadius()
public int getRenderingQuality()
RENDERING_QUALITY_HIGH
, RENDERING_QUALITY_MEDIUM
,
or RENDERING_QUALITY_LOW
public void getCoordinates(float[] c)
c
- allocated array where coordinates will be putpublic void getCoordinates(ComponentElement element, float[] c)
element
- specific part of the componentc
- allocated array where coordinates will be putpublic java.lang.String getDescription()
String
public java.lang.String getDescription(ComponentElement element)
element
- specific part of the component
String
public ComponentElement[] getLabelInformation(java.lang.String labeltype, boolean onlyOnHeavyAtoms)
labeltype
- onlyOnHeavyAtoms
- label info needed only for heavy atoms.
public ComponentElement[] getLabelInformation(java.lang.String labeltype)
public ComponentElement getComponentElement()
public chemaxon.marvin.space.UsableObject getUsableObject(chemaxon.marvin.space.UOID id)
id
- identifier of the component or a part of the component
public double locateObject(int x, int y)
x
- window coordinate of the mousey
- window coordinate of the mouse
protected double touchObject(int hits)
hits
- Number of hits at the previous hit.
protected void pickObject(int offset, double[] maxZ, float[] modelview)
pickedItem
to be the picked part of the component.
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.public boolean isSelected()
isSelected
in interface chemaxon.marvin.space.UsableObject
public boolean isSelected(ComponentElement element)
isSelected()
.
element
- specific part of the component
public boolean hasSelectedElements()
isSelected()
public void select()
unSelect()
.
select
in interface chemaxon.marvin.space.UsableObject
public void select(ComponentElement element)
element
- specific part of the componentpublic void selectComponentElementsInside(BoundingBox bb)
bb
- given box represented by a BoundingBox
public void unSelect()
unSelect
in interface chemaxon.marvin.space.UsableObject
public void unSelect(ComponentElement element)
element
- specific part of the componentpublic void invertSelection()
public void invertSelection(ComponentElement element)
element
- specific part of the componentpublic void extendSelection()
public void extendSelection(ComponentElement element)
element
- specific part of the componentpublic void exclusiveSelection()
public void exclusiveSelection(ComponentElement element)
select()
.
element
- specific part of the component
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |