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
Label is a special monitor that watches 1 object and shows its description.
- Since:
- Marvin 4.0.2
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
protected byte[]
protected boolean
protected int
static final int
static final int
static final int
static final int
protected byte[]
protected boolean
protected int
protected boolean
protected boolean
protected byte[]
protected boolean
protected chemaxon.marvin.space.util.GLText
This is to draw labels in the viewing plane.protected boolean
protected static final int
protected float
protected int
Size of drawn labels.static final int
static final int
protected float[]
protected boolean
protected double
protected double
protected int
Relative position of the label of the component with respect to the reference point of the labeled component.protected int
Relative position of the label of the component with respect to the reference point of the labeled component.protected int
protected int
static final int
protected String
protected double
protected double
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
draw()
Does nothing, because a label is drawn in plane or as a transparent component.void
Draws the label when it is set to be drawn in plane.void
Renders the label in 3d as a transparent object.byte[]
Returns the background color of the label.byte[]
Returns the border color of the label.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[]
Returns the foreground color of the label.getText()
Returns the explicit text of the label, or null if there is no explicit label set.float
Returns a third, z coordinate in order to display 2D parts in proper order.boolean
Returns true when the label is drawn in plane.boolean
Tells weather the label should or should not be drawn.boolean
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
Returns 1, because this is the maximun number of selected elements.protected void
void
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
The given component will be the selected item of the Label.void
Sets the background color of the label.void
setBackgroundColorMode
(int mode) Sets the coloring mode of the background.void
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
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
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 Details
-
LARGE_FONT_SIZE
public static final int LARGE_FONT_SIZE- See Also:
-
MEDIUM_FONT_SIZE
public static final int MEDIUM_FONT_SIZE- See Also:
-
SMALL_FONT_SIZE
public static final int SMALL_FONT_SIZE- See Also:
-
BORDER_MODE_NONE
public static final int BORDER_MODE_NONE- See Also:
-
BORDER_MODE_OWN_COLOR
public static final int BORDER_MODE_OWN_COLOR- See Also:
-
BORDER_MODE_FOREGROUND_COLOR
public static final int BORDER_MODE_FOREGROUND_COLOR- See Also:
-
BORDER_MODE_BRIGHTER_FOREGROUND
public static final int BORDER_MODE_BRIGHTER_FOREGROUND- See Also:
-
BACKGROUND_MODE_NONE
public static final int BACKGROUND_MODE_NONE- See Also:
-
BACKGROUND_MODE_OWN_COLOR
public static final int BACKGROUND_MODE_OWN_COLOR- See Also:
-
borderColorMode
protected int borderColorMode -
backgroundColorMode
protected int backgroundColorMode -
ITEM_COUNT
protected static final int ITEM_COUNT- See Also:
-
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 shiftxRelative position of the label of the component with respect to the reference point of the labeled component. -
shifty
protected int shiftyRelative position of the label of the component with respect to the reference point of the labeled component. -
text
-
labelSize
protected int labelSizeSize 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 gltextThis is to draw labels in the viewing plane.
-
-
Constructor Details
-
Label
public Label()Creates a new Label and sets the size of the font to medium.
-
-
Method Details
-
presetTextDraw
protected void presetTextDraw() -
getSelectedItem
-
maximumItemCount
public int maximumItemCount()Returns 1, because this is the maximun number of selected elements.- Specified by:
maximumItemCount
in classMonitor
-
selectItem
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
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
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
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
Returns the explicit text of the label, or null if there is no explicit label set.- Returns:
- user defined description
-
setText
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
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
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
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
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
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} -
getBorderColor
public byte[] getBorderColor()Returns the border color of the label.- Returns:
- rgb colors represented as byte array
-
setBorderColor
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} -
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. -
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)
. -
setDrawProperty
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
-