Class NetObject

java.lang.Object
fr.esrf.tangoatk.widget.util.interlock.NetObject

public class NetObject extends Object
Class which allow to control and display an object of the network. It exists 2 types of object :

The bubble object which is the main object . A bubble accept a free label that can be moved by the user , 2 small fixed labels (one centered and one at the bottom left) and can have extensions : A list of named parameters associated to a string value. You can also specifie the maximum number of incoming/outgoing links and its shape. The coordinates of a bubble are in GRID unit.

The text object which is a free label moveable by the user. You can also specify a font for this object. The text object does not accept links , extensions , small fixed labels and shape. The coordinates for a text object a in pixel.

Important: It is not recommended to subclass this NetObject class because it would be too complex to provide a full overridable interface including file,undo and clipboard management. Nevertheless, when using the NetEditor in non editable mode, it is possible either to override NetEditor.loadFile() or NetEditor.addObject() to convert loaded NetObject into a new type. As there is no undo or clipboard operation, your objects will not be affected.

  • Field Details

    • OBJECT_BUBBLE

      public static final int OBJECT_BUBBLE
      Bubble pbject
      See Also:
    • OBJECT_TEXT

      public static final int OBJECT_TEXT
      Free label object
      See Also:
    • JUSTIFY_LEFT

      public static final int JUSTIFY_LEFT
      Left label justification
      See Also:
    • JUSTIFY_RIGHT

      public static final int JUSTIFY_RIGHT
      Right label justification
      See Also:
    • JUSTIFY_CENTER

      public static final int JUSTIFY_CENTER
      Center label justification
      See Also:
  • Constructor Details

    • NetObject

      public NetObject(int type, int userType, int maxInput, int maxOutput, int x, int y)
      Construct a NetObject.
      Parameters:
      type - Type of this NetObject
      userType - User defined type of this NetObject
      maxInput - Maximum number of incoming link for this bubble
      maxOutput - Maximum number of outgoing link for this bubble
      x - x coordinates (GRID coordinates for BUBBLE , pixel for TEXT)
      y - y coordinates ...
      See Also:
  • Method Details

    • addChild

      public void addChild(NetObject o)
      Add the given object to the children list.
      Parameters:
      o - Child object
    • removeChild

      public void removeChild(NetObject o)
      Remove the specified child from the children list.
      Parameters:
      o - Child object to remove
    • removeChild

      public void removeChild(int i)
      Remove the specified child from the children list.
      Parameters:
      i - Child index
    • getChildrenNumber

      public int getChildrenNumber()
      Returns:
      the number of children.
    • getChildAt

      public NetObject getChildAt(int idx)
      Returns child at the specified index.
      Parameters:
      idx - Child index
      Returns:
      Child NetObject
    • clearChildren

      public void clearChildren()
      Clear the children list
    • getParentNumber

      public int getParentNumber()
      Returns:
      the number of parent
    • getParentAt

      public NetObject getParentAt(int idx)
      Returns the parent object at the specified index.
      Parameters:
      idx - Parent index
      Returns:
      Parent NetObject
    • isParentOf

      public boolean isParentOf(NetObject o)
      Parameters:
      o - NetObject
      Returns:
      true if this object is parent of o
    • isChildOf

      public boolean isChildOf(NetObject o)
      Parameters:
      o - NetObject
      Returns:
      true if this object is child of o
    • getLabel

      public String getLabel()
      Returns:
      the label
    • setLabel

      public void setLabel(String value)
      Sets the free label of this object.
      Parameters:
      value - Label
    • setLabel

      public void setLabel(String[] value)
      Sets the free labels
      Parameters:
      value - Labels
    • getName

      public String getName()
      Get object name.
      Returns:
      'Bubble' or 'Text'
    • getType

      public int getType()
      Returns:
      the type of this NetObject.
      See Also:
    • getUserType

      public int getUserType()
      Returns:
      the user defined type.
    • setShape

      public void setShape(int s)
      Sets the shape of this object
      Parameters:
      s - Shape
      See Also:
    • getShape

      public int getShape()
      Returns:
      shape of this object
    • setEditableShape

      public void setEditableShape(boolean b)
      Set the editable shape properties.
      Parameters:
      b - True to make the shape editable (via the NetObjectDlg), false otherwise.
    • setJustify

      public void setJustify(int i)
      Sets the label justification of this object.
      Parameters:
      i - Justify value
      See Also:
    • getJustify

      public int getJustify()
      Returns:
      current justification
      See Also:
    • getMaxInput

      public int getMaxInput()
      Returns:
      maximum number of incoming link
    • getMaxOutput

      public int getMaxOutput()
      Returns:
      maximum number of outgoing link
    • setCenterLabel

      public void setCenterLabel(String s)
      Sets the label displayed at the center of this object. It uses the NetEditor small font.
      Parameters:
      s - Label
    • setBottomLabel

      public void setBottomLabel(String s)
      Sets the label displayed at the bottom left of this object. It uses the NetEditor small font.
      Parameters:
      s - Label
    • setColor

      public void setColor(Color c)
      Sets the background (fill color) of this object (when parent NetEditor is not editable)
      Parameters:
      c - Background color
    • getColor

      public Color getColor()
      Returns:
      the background (fill color) of this object (when parent NetEditor is not editable)
    • setSize

      public void setSize(int size)
      Sets the object size
      Parameters:
      size - Object size
    • getSize

      public int getSize()
      Returns:
      the object size
    • setUserValue

      public void setUserValue(Object v)
      Sets the user value for external usage
      Parameters:
      v - User value
    • getUserValue

      public Object getUserValue()
      Returns:
      the user value
    • setExtensionList

      public void setExtensionList(String[] names)
      Sets the list of extended parameter name for this bubble object. Text does not accept extensions.
      Parameters:
      names - List of names
    • setExtendedParam

      public void setExtendedParam(String name, String value)
      Sets the extended param value.
      Parameters:
      name - Param name
      value - Param value
      See Also:
    • setExtendedParam

      public void setExtendedParam(int extIdx, String value)
      Sets the extended param value.
      Parameters:
      extIdx - Index of the extensions.
      value - param value
      See Also:
    • getExtendedParam

      public String getExtendedParam(String name)
      Returns the value of the specified extended param, an empty string if not found.
      Parameters:
      name - Param name
      Returns:
      param value
      See Also:
    • getExtendedParam

      public String getExtendedParam(int extIdx)
      Returns the value of the specified extended param, an empty string if not found.
      Parameters:
      extIdx - Index of the extensions.
      Returns:
      param value
      See Also:
    • getExtendedParamNumber

      public int getExtendedParamNumber()
      Returns:
      the number of extensions
    • getExtendedParamIndex

      public int getExtendedParamIndex(String name)
      Parameters:
      name - Param name
      Returns:
      the index of the specified extended param , -1 when not found
    • setTextFont

      public void setTextFont(Font f)
      Set the font of this object. Only TEXT object accept font
      Parameters:
      f - Font
    • getTextFont

      public Font getTextFont()
      Returns:
      the font of this object
    • getXOrigin

      public int getXOrigin()
      Returns:
      X pixel coordinates.Returns a valid value only if this object has been inserted in a NetEditor.
    • getYOrigin

      public int getYOrigin()
      Returns:
      Y pixel coordinates.Returns a valid value only if this object has been inserted in a NetEditor.
    • setSelected

      public void setSelected(boolean s)
      Select or not this NetObject within the editor.
      Parameters:
      s - True to select, false otherwise
    • getSelected

      public boolean getSelected()
      Returns:
      True if this NetObject is selected.
    • paintLink

      public void paintLink(Graphics2D g, NetObject child, boolean drawArrow)
      Paint the link beetween this object and child.
      Parameters:
      g - Graphics object
      child - child object
      drawArrow - true to draw arrow
    • paint

      public void paint(Graphics2D g)
      Paint this NetObject.
      Parameters:
      g - Graphics object