Package chemaxon.marvin.space.monitor
Class Label
- java.lang.Object
-
- chemaxon.marvin.space.GraphicComponent
-
- chemaxon.marvin.space.monitor.Monitor
-
- chemaxon.marvin.space.monitor.Label
-
- All Implemented Interfaces:
chemaxon.marvin.space.UsableObject
@PublicAPI public class Label extends Monitor
Label is a special monitor that watches 1 object and shows its description.- Since:
- Marvin 4.0.2
-
-
Field Summary
Fields Modifier and Type Field Description 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 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
Constructors Constructor Description Label()
Creates a new Label and sets the size of the font to medium.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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(float[] c)
Returns the coordinates of the selected item as a GeomCalc vector.void
getCoordinates(ComponentElement item, float[] c)
Returns the coordinates of the selected item as a GeomCalc vector.byte[]
getForegroundColor()
Returns the foreground color of the label.ComponentElement
getSelectedItem()
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(Color c)
Sets the background color of the label.void
setBackgroundColorMode(int mode)
Sets the coloring mode of the background.void
setBorderColor(Color c)
Sets the border color of the label.void
setBorderColorMode(int mode)
Sets the coloring mode of the border.void
setDrawProperty(String propertyName, String propertyValue)
Sets adraw property
.void
setForegroundColor(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(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(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, cleanup, 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, setColor, setDrawProperties, setGL, setMotionMode, setName, setProgressBar, setRenderingQuality, setRotateMatrix, setVisible, showFaded, storeDrawProperty, toString, touchObject, translate
-
-
-
-
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 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.
-
-
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 classMonitor
-
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 classMonitor
-
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 classGraphicComponent
- 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 classGraphicComponent
- Parameters:
item
- specific part of the componentc
- allocated array where coordinates will be put
-
getText
public 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(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 tonull
.- 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 interfacechemaxon.marvin.space.UsableObject
- Overrides:
select
in classGraphicComponent
-
unSelect
public void unSelect()
The color of the label changes by selection.
-
unSelect
public void unSelect(ComponentElement element)
The color of the label changes by selection.- Overrides:
unSelect
in classGraphicComponent
- 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 classMonitor
- 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 classGraphicComponent
-
drawTransparentPart
public void drawTransparentPart()
Renders the label in 3d as a transparent object.- Overrides:
drawTransparentPart
in classGraphicComponent
-
hasTransparentPart
public boolean hasTransparentPart()
The label is rendered as a transparent object in case of drawing in space.- Overrides:
hasTransparentPart
in classMonitor
- Returns:
- false by default
-
has2DPart
public boolean has2DPart()
Returns true when the label is drawn in plane.- Overrides:
has2DPart
in classGraphicComponent
- 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 classGraphicComponent
- Returns:
- a pseudo 'z' cordinate
-
draw2DPart
public void draw2DPart()
Draws the label when it is set to be drawn in plane.- Overrides:
draw2DPart
in classGraphicComponent
-
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 classMonitor
- 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 classGraphicComponent
- Parameters:
x
- window coordinate of the mousey
- window coordinate of the mouse- Returns:
- z coordinate of the nearest picked object
-
setLabelSize
protected void setLabelSize(String size)
Sets the size of the label font. Warning: sizes are named constants, not explicit values, see alsoLARGE_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 actualGraphicCell
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 actualGraphicCell
in pixels.
-
getForegroundColor
public byte[] getForegroundColor()
Returns the foreground color of the label.- Returns:
- rgb colors represented as byte array
-
setForegroundColor
public void setForegroundColor(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(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(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 withsetDrawProperty("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 ofsetDrawProperty(String, String)
.- Parameters:
b
-
-
setDrawProperty
public void setDrawProperty(String propertyName, String propertyValue) throws Exception
Sets adraw property
.
Accepts:- "Label.Size" -- "Small", "Medium", "Large"
- "Label.ForegroundColor" -- java.awt.Color value as
String
- "Label.BackgroundColor" -- java.awt.Color value as
String
- "Label.Draw2D" -- Boolean value as
String
- "Label.DrawRelation" -- Boolean value as
String
: If the label is to be drawn connected to the selected element with a line.
- Specified by:
setDrawProperty
in interfacechemaxon.marvin.space.UsableObject
- Overrides:
setDrawProperty
in classGraphicComponent
- Parameters:
propertyName
- identifier of the draw propertypropertyValue
- value of the draw property as aString
- Throws:
Exception
-
-