chemaxon.marvin.space.monitor
Class Label

java.lang.Object
  extended by chemaxon.marvin.space.GraphicComponent
      extended by chemaxon.marvin.space.monitor.Monitor
          extended by chemaxon.marvin.space.monitor.Label
All Implemented Interfaces:
chemaxon.marvin.space.UsableObject

public class Label
extends Monitor

Label is a special monitor that watches 1 object and shows its description.

Since:
Marvin 4.0.2
Version:
MarvinSpace 1.0
Author:
Judit Papp

Field Summary
static int BACKGROUND_MODE_NONE
           
static int BACKGROUND_MODE_OWN_COLOR
           
protected  byte[] backgroundColor
           
protected  boolean backgroundColorChanged
           
protected  int backgroundColorMode
           
static int BORDER_MODE_BRIGHTER_FOREGROUND
           
static int BORDER_MODE_FOREGROUND_COLOR
           
static int BORDER_MODE_NONE
           
static int BORDER_MODE_OWN_COLOR
           
protected  byte[] borderColor
           
protected  boolean borderColorChanged
           
protected  int borderColorMode
           
protected  boolean draw2D
           
protected  boolean drawRelation
           
protected  byte[] foregroundColor
           
protected  boolean foregroundColorChanged
           
protected  chemaxon.marvin.space.util.GLText gltext
          This is to draw labels in the viewing plane.
protected  boolean ignoreDrawProperties
           
protected static int ITEM_COUNT
           
protected  float labelScale
           
protected  int labelSize
          Size of drawn labels.
static int LARGE_FONT_SIZE
           
static int MEDIUM_FONT_SIZE
           
protected  float[] position
           
protected  boolean positionInPlane
           
protected  double relativeX
           
protected  double relativeY
           
protected  int shiftx
          Relative position of the label of the component with respect to the reference point of the labeled component.
protected  int shifty
          Relative position of the label of the component with respect to the reference point of the labeled component.
protected  int sizeX
           
protected  int sizeY
           
static int SMALL_FONT_SIZE
           
protected  java.lang.String text
           
protected  double textPositionX
           
protected  double textPositionY
           
 
Fields inherited from class chemaxon.marvin.space.monitor.Monitor
control, mode, selectedItemCoordinates, selectedItems, selectionPointer
 
Fields inherited from class chemaxon.marvin.space.GraphicComponent
active, associatedComponents, boundingBox, color, COMPONENT_TYPE_ENTIRE, drawProperties, drawType, gl, glu, graphicCell, irm, modifiesOrigin, motionMode, mousex, mousey, name, pickedItem, RENDERING_QUALITY_HIGH, RENDERING_QUALITY_LOW, RENDERING_QUALITY_MEDIUM, renderingQuality, rm, uoid, visible
 
Constructor Summary
Label()
          Creates a new Label and sets the size of the font to medium.
 
Method Summary
 void draw()
          Does nothing, because a label is drawn in plane or as a transparent component.
 void draw2DPart()
          Draws the label when it is set to be drawn in plane.
 void drawTransparentPart()
          Renders the label in 3d as a transparent object.
 byte[] getBackgroundColor()
          Returns the background color of the label.
 byte[] getBorderColor()
          Returns the border color of the label.
 GraphicComponent getComponent()
          Returns the GraphicComponent of the only selected item.
 void getCoordinates(ComponentElement item, float[] c)
          Returns the coordinates of the selected item as a GeomCalc vector.
 void getCoordinates(float[] c)
          Returns the coordinates of the selected item as a GeomCalc vector.
 byte[] getForegroundColor()
          Returns the foreground color of the label.
 ComponentElement getSelectedItem()
           
 java.lang.String getText()
          Returns the explicit text of the label, or null if there is no explicit label set.
 float getZCoordinateTo2DPart()
          Returns a third, z coordinate in order to display 2D parts in proper order.
 boolean has2DPart()
          Returns true when the label is drawn in plane.
 boolean hasInvisibleItem()
          Tells weather the label should or should not be drawn.
 boolean hasTransparentPart()
          The label is rendered as a transparent object in case of drawing in space.
 void ignoreDrawProperties(boolean b)
          Sets the label whether it accepts draw properties or not.
 double locateObject(int x, int y)
          Pickes the label in x, y position.
 int maximumItemCount()
          Returns 1, because this is the maximun number of selected elements.
protected  void presetTextDraw()
           
 void receiveNotificationOnCoordinateChange(GraphicComponent gc)
          When the coordinates of the labeled object change, the label refreshes its coordinates relatively.
 void refresh()
          The monitor refreshes its coordinates from the selected item's coordinates.
 void select()
          The color of the label changes by selection.
 void selectItem(ComponentElement item)
          Parameter item will be the selected item of the monitor.
 void selectItem(GraphicComponent gc)
          The given component will be the selected item of the Label.
 void setBackgroundColor(java.awt.Color c)
          Sets the background color of the label.
 void setBackgroundColorMode(int mode)
          Sets the coloring mode of the background.
 void setBorderColor(java.awt.Color c)
          Sets the border color of the label.
 void setBorderColorMode(int mode)
          Sets the coloring mode of the border.
 void setDrawProperty(java.lang.String propertyName, java.lang.String propertyValue)
          Sets a draw property.
 void setForegroundColor(java.awt.Color c)
          Sets the color of the characters on the label.
 void setLabel2DDrawing(boolean b)
          Sets the drawing mode of the label that can be drawing in plane or in exact depth.
protected  void setLabelSize(java.lang.String size)
          Sets the size of the label font.
 void setPosition(float[] position)
          Sets the monitor's position defined by 3 coordinates.
 void setPosition(float x, float y)
          Sets the monitor's position defined by 2 coordinates.
 void setPosition(float x, float y, float z)
          Sets the monitor's position defined by 3 coordinates.
 void setRelativeXCoordinate(float x)
          Sets the coordinate considered as the x coordinate of the origin in window coordinates.
 void setRelativeYCoordinate(float y)
          Sets the coordinate considered as the y coordinate of the origin in window coordinates.
 void setText(java.lang.String text)
          Sets an explicit text to the label, that has priority to the description of the selected component.
 void shift(int x, int y)
          A label can be shifted in x,y direction.
 void unSelect()
          The color of the label changes by selection.
 void unSelect(ComponentElement element)
          The color of the label changes by selection.
 
Methods inherited from class chemaxon.marvin.space.monitor.Monitor
clear, getSelectedElements, hasControl, isFull, isVisible, onRemoveGraphicComponent, pickedIndicator, receiveNotificationOnInvisibility, receiveNotificationOnVisibility, refersTo
 
Methods inherited from class chemaxon.marvin.space.GraphicComponent
addDrawProperties, associate, drawBoundingBox, drawCoordinateAxes, drawSelection, exclusiveSelection, exclusiveSelection, extendSelection, extendSelection, fadeSelected, fadeUnselected, getAssociatedComponents, getBoundingBox, getBoundingSphereRadius, getCell, getColor, getComponentElement, getDescription, getDescription, getDrawProperties, getDrawProperty, getGraphicComponent, getId, getLabelInformation, getLabelInformation, getName, getRenderingQuality, getUsableObject, glColor, hasSelectedElements, hideSelected, hideUnselected, invertSelection, invertSelection, isControllable, isGraphicComponent, isSelected, isSelected, isVisible, notifyCoordinateChange, notifyInvisibility, notifySelection, notifyUnSelection, notifyVisibility, pickObject, projectVector, receiveNotificationOnSelection, receiveNotificationOnUnSelection, removeAssociation, resize, rotate, rotate, rotate, select, selectComponentElementsInside, setColor, setColor, setColor, setDrawProperties, setGL, setMotionMode, setName, setProgressBar, setRenderingQuality, setRotateMatrix, setVisible, showFaded, storeDrawProperty, toString, touchObject, translate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LARGE_FONT_SIZE

public static final int LARGE_FONT_SIZE
See Also:
Constant Field Values

MEDIUM_FONT_SIZE

public static final int MEDIUM_FONT_SIZE
See Also:
Constant Field Values

SMALL_FONT_SIZE

public static final int SMALL_FONT_SIZE
See Also:
Constant Field Values

BORDER_MODE_NONE

public static final int BORDER_MODE_NONE
See Also:
Constant Field Values

BORDER_MODE_OWN_COLOR

public static final int BORDER_MODE_OWN_COLOR
See Also:
Constant Field Values

BORDER_MODE_FOREGROUND_COLOR

public static final int BORDER_MODE_FOREGROUND_COLOR
See Also:
Constant Field Values

BORDER_MODE_BRIGHTER_FOREGROUND

public static final int BORDER_MODE_BRIGHTER_FOREGROUND
See Also:
Constant Field Values

BACKGROUND_MODE_NONE

public static final int BACKGROUND_MODE_NONE
See Also:
Constant Field Values

BACKGROUND_MODE_OWN_COLOR

public static final int BACKGROUND_MODE_OWN_COLOR
See Also:
Constant Field Values

borderColorMode

protected int borderColorMode

backgroundColorMode

protected int backgroundColorMode

ITEM_COUNT

protected static final int ITEM_COUNT
See Also:
Constant Field Values

position

protected float[] position

sizeX

protected int sizeX

sizeY

protected int sizeY

textPositionX

protected double textPositionX

textPositionY

protected double textPositionY

relativeX

protected double relativeX

relativeY

protected double relativeY

draw2D

protected boolean draw2D

drawRelation

protected boolean drawRelation

positionInPlane

protected boolean positionInPlane

ignoreDrawProperties

protected boolean ignoreDrawProperties

shiftx

protected int shiftx
Relative position of the label of the component with respect to the reference point of the labeled component.


shifty

protected int shifty
Relative position of the label of the component with respect to the reference point of the labeled component.


text

protected java.lang.String text

labelSize

protected int labelSize
Size of drawn labels.


labelScale

protected float labelScale

foregroundColor

protected byte[] foregroundColor

backgroundColor

protected byte[] backgroundColor

borderColor

protected byte[] borderColor

backgroundColorChanged

protected boolean backgroundColorChanged

foregroundColorChanged

protected boolean foregroundColorChanged

borderColorChanged

protected boolean borderColorChanged

gltext

protected chemaxon.marvin.space.util.GLText gltext
This is to draw labels in the viewing plane.

Constructor Detail

Label

public Label()
Creates a new Label and sets the size of the font to medium.

Method Detail

presetTextDraw

protected void presetTextDraw()

getSelectedItem

public ComponentElement getSelectedItem()

maximumItemCount

public int maximumItemCount()
Returns 1, because this is the maximun number of selected elements.

Specified by:
maximumItemCount in class Monitor

selectItem

public void selectItem(ComponentElement item)
Parameter item will be the selected item of the monitor. A Label can have only one selected item. Also sets the monitor's position to the coordinates of the item.

Overrides:
selectItem in class Monitor

selectItem

public void selectItem(GraphicComponent gc)
The given component will be the selected item of the Label. A Label can have only one selected item. Also sets the monitor's position to the coordinates of the item.


getComponent

public GraphicComponent getComponent()
Returns the GraphicComponent of the only selected item.


refresh

public void refresh()
The monitor refreshes its coordinates from the selected item's coordinates.


getCoordinates

public void getCoordinates(float[] c)
Returns the coordinates of the selected item as a GeomCalc vector.

Overrides:
getCoordinates in class GraphicComponent
Parameters:
c - allocated array where coordinates will be put

getCoordinates

public void getCoordinates(ComponentElement item,
                           float[] c)
Returns the coordinates of the selected item as a GeomCalc vector.

Overrides:
getCoordinates in class GraphicComponent
Parameters:
item - specific part of the component
c - allocated array where coordinates will be put

getText

public java.lang.String getText()
Returns the explicit text of the label, or null if there is no explicit label set.

Returns:
user defined description

setText

public void setText(java.lang.String text)
Sets an explicit text to the label, that has priority to the description of the selected component. Note that the priority cannot be changed just if the text is set to null.

Parameters:
text - Text to display or null to reset the default text.

select

public void select()
The color of the label changes by selection.

Specified by:
select in interface chemaxon.marvin.space.UsableObject
Overrides:
select in class GraphicComponent

unSelect

public void unSelect()
The color of the label changes by selection.

Specified by:
unSelect in interface chemaxon.marvin.space.UsableObject
Overrides:
unSelect in class Monitor

unSelect

public void unSelect(ComponentElement element)
The color of the label changes by selection.

Overrides:
unSelect in class GraphicComponent
Parameters:
element - specific part of the component

setPosition

public void setPosition(float x,
                        float y,
                        float z)
Sets the monitor's position defined by 3 coordinates. The label can be drawn in plane by projection of the given coordinates to the viewing plane or in 3d rendered by the exact depth.


setPosition

public void setPosition(float[] position)
Sets the monitor's position defined by 3 coordinates. The label can be drawn in plane by projection of the given coordinates to the viewing plane or in 3d rendered by the exact depth.


setPosition

public void setPosition(float x,
                        float y)
Sets the monitor's position defined by 2 coordinates. This way the label can only be drawn in plane, the given coordinates will be considered corrdinates in the viewing plane.


shift

public void shift(int x,
                  int y)
A label can be shifted in x,y direction. It is called by location controls.


receiveNotificationOnCoordinateChange

public void receiveNotificationOnCoordinateChange(GraphicComponent gc)
When the coordinates of the labeled object change, the label refreshes its coordinates relatively.

Overrides:
receiveNotificationOnCoordinateChange in class Monitor
Parameters:
gc - component changing coordinates

draw

public void draw()
Does nothing, because a label is drawn in plane or as a transparent component.

Overrides:
draw in class GraphicComponent

drawTransparentPart

public void drawTransparentPart()
Renders the label in 3d as a transparent object.

Overrides:
drawTransparentPart in class GraphicComponent

hasTransparentPart

public boolean hasTransparentPart()
The label is rendered as a transparent object in case of drawing in space.

Overrides:
hasTransparentPart in class Monitor
Returns:
false by default

has2DPart

public boolean has2DPart()
Returns true when the label is drawn in plane.

Overrides:
has2DPart in class GraphicComponent
Returns:
will the component draw in plane

getZCoordinateTo2DPart

public float getZCoordinateTo2DPart()
Returns a third, z coordinate in order to display 2D parts in proper order.

Overrides:
getZCoordinateTo2DPart in class GraphicComponent
Returns:
a pseudo 'z' cordinate

draw2DPart

public void draw2DPart()
Draws the label when it is set to be drawn in plane.

Overrides:
draw2DPart in class GraphicComponent

hasInvisibleItem

public boolean hasInvisibleItem()
Tells weather the label should or should not be drawn. The label will not be drawn when its selected component is not visible, and will always be drawn when the text of the label is set explicitly.

Overrides:
hasInvisibleItem in class Monitor
Returns:
true if the label is not to be drawn because of an invisible selected item

locateObject

public double locateObject(int x,
                           int y)
Pickes the label in x, y position. Returns pickedIndicator() if the label was picked, and -1 otherwise.

Overrides:
locateObject in class GraphicComponent
Parameters:
x - window coordinate of the mouse
y - window coordinate of the mouse
Returns:
z coordinate of the nearest picked object

setLabelSize

protected void setLabelSize(java.lang.String size)
Sets the size of the label font. Warning: sizes are named constants, not explicit values, see also LARGE_FONT_SIZE, MEDIUM_FONT_SIZE, SMALL_FONT_SIZE.


setRelativeXCoordinate

public void setRelativeXCoordinate(float x)
Sets the coordinate considered as the x coordinate of the origin in window coordinates. E.g. sets the left edge of the actual GraphicCell in pixels.


setRelativeYCoordinate

public void setRelativeYCoordinate(float y)
Sets the coordinate considered as the y coordinate of the origin in window coordinates. E.g. sets the bottom of the actual GraphicCell in pixels.


getForegroundColor

public byte[] getForegroundColor()
Returns the foreground color of the label.

Returns:
rgb colors represented as byte array

setForegroundColor

public void setForegroundColor(java.awt.Color c)
Sets the color of the characters on the label.


getBackgroundColor

public byte[] getBackgroundColor()
Returns the background color of the label.

Returns:
rgb colors represented as byte array

setBackgroundColor

public void setBackgroundColor(java.awt.Color c)
Sets the background color of the label.


setBackgroundColorMode

public void setBackgroundColorMode(int mode)
Sets the coloring mode of the background. See {#BACKGROUND_MODE_NONE}, {#BACKGROUND_MODE_OWN_COLOR}

Parameters:
mode -

getBorderColor

public byte[] getBorderColor()
Returns the border color of the label.

Returns:
rgb colors represented as byte array

setBorderColor

public void setBorderColor(java.awt.Color c)
Sets the border color of the label. Note the border color modes.


setBorderColorMode

public void setBorderColorMode(int mode)
Sets the coloring mode of the border. See {#BORDER_MODE_NONE}, {#BORDER_MODE_OWN_COLOR}, {#BORDER_MODE_BRIGHTER_FOREGROUND}, {#BORDER_MODE_FOREGROUND_COLOR}

Parameters:
mode -

setLabel2DDrawing

public void setLabel2DDrawing(boolean b)
Sets the drawing mode of the label that can be drawing in plane or in exact depth. This method is equivalent with setDrawProperty("Label.Draw2D", b);, but has the real sense when the label ignores the setting of global draw properties.

Parameters:
b -

ignoreDrawProperties

public void ignoreDrawProperties(boolean b)
Sets the label whether it accepts draw properties or not. This can be useful when some labels are used as notes to the viewer, not in displayable connection to any component, but independently of other labels. In this case draw properties of the label can be set directly by the corresponding api functions instead of setDrawProperty(String, String).

Parameters:
b -

setDrawProperty

public void setDrawProperty(java.lang.String propertyName,
                            java.lang.String propertyValue)
                     throws java.lang.Exception
Sets a draw property.
Accepts:

Specified by:
setDrawProperty in interface chemaxon.marvin.space.UsableObject
Overrides:
setDrawProperty in class GraphicComponent
Parameters:
propertyName - identifier of the draw property
propertyValue - value of the draw property as a String
Throws:
java.lang.Exception