Class 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 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 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.
  • 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

      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 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 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(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(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}
    • 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}
    • 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.
    • 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).
    • setDrawProperty

      public void setDrawProperty(String propertyName, String propertyValue) throws Exception
      Sets a draw 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 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:
      Exception