fr.esrf.tangoatk.widget.util.interlock
Class NetObject

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

public class NetObject
extends java.lang.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.

    Here are the possible bubble shapes:

    The NetEditor shapes


    Field Summary
    static int JUSTIFY_CENTER
              Center label justification
    static int JUSTIFY_LEFT
              Left label justification
    static int JUSTIFY_RIGHT
              Right label justification
    static int OBJECT_BUBBLE
              Bubble pbject
    static int OBJECT_TEXT
              Free label object
     
    Constructor Summary
    NetObject(int type, int userType, int maxInput, int maxOutput, int x, int y)
              Construct a NetObject.
     
    Method Summary
     void addChild(NetObject o)
              Add the given object to the children list.
     void clearChildren()
              Clear the children list
     NetObject getChildAt(int idx)
              Returns child at the specified index.
     int getChildrenNumber()
              Returns the number of children.
     java.awt.Color getColor()
              Gets the background (fill color) of this object (when parent NetEditor is not editable)
     java.lang.String getExtendedParam(int extIdx)
              Returns the value of the specified extended param, an empty string if not found.
     java.lang.String getExtendedParam(java.lang.String name)
              Returns the value of the specified extended param, an empty string if not found.
     int getExtendedParamIndex(java.lang.String name)
              Returns the index of the specified extended param , -1 when not found
     int getExtendedParamNumber()
              Returns the number of extensions
     int getJustify()
              Returns current justification
     java.lang.String getLabel()
              Returns the label
     int getMaxInput()
              Returns maximum number of incoming link
     int getMaxOutput()
              Returns maximum number of outgoing link
     java.lang.String getName()
              Get object name.
     NetObject getParentAt(int idx)
              Returns the parent object at the specified index.
     int getParentNumber()
              Returns the number of parent
     boolean getSelected()
               
     int getShape()
              Returns shape of this object
     int getSize()
              Gets the object size
     java.awt.Font getTextFont()
              Get the font of this object
     int getType()
              Return the type of this NetObject.
     int getUserType()
              Returns the user defined type.
     java.lang.Object getUserValue()
              Returns the user value
     int getXOrigin()
              Returns X pixel coordinates.Returns a valid value only if this object has been inserted in a NetEditor.
     int getYOrigin()
              Returns Y pixel coordinates.Returns a valid value only if this object has been inserted in a NetEditor.
     boolean isChildOf(NetObject o)
              Returns true if this object is child of o
     boolean isParentOf(NetObject o)
              Returns true if this object is parent of o
     void paint(java.awt.Graphics2D g)
              Paint this NetObject.
     void paintLink(java.awt.Graphics2D g, NetObject child, boolean drawArrow)
              Paint the link beetween this object and child.
     void removeChild(int i)
              Remove the specified child from the children list.
     void removeChild(NetObject o)
              Remove the specified child from the children list.
     void setBottomLabel(java.lang.String s)
              Sets the label displayed at the bottom left of this object.
     void setCenterLabel(java.lang.String s)
              Sets the label displayed at the center of this object.
     void setColor(java.awt.Color c)
              Sets the background (fill color) of this object (when parent NetEditor is not editable)
     void setEditableShape(boolean b)
              Set the editable shape properties.
     void setExtendedParam(int extIdx, java.lang.String value)
              Sets the extended param value.
     void setExtendedParam(java.lang.String name, java.lang.String value)
              Sets the extended param value.
     void setExtensionList(java.lang.String[] names)
              Sets the list of extended parameter name for this bubble object.
     void setJustify(int i)
              Sets the label justification of this object.
     void setLabel(java.lang.String value)
              Sets the free label of this object.
     void setLabel(java.lang.String[] value)
              Sets the free lablel
     void setSelected(boolean s)
              Select or not this NetObject within the editor.
     void setShape(int s)
              Sets the shape of this object
     void setSize(int size)
              Sets the object size
     void setTextFont(java.awt.Font f)
              Set the font of this object.
     void setUserValue(java.lang.Object v)
              Sets the user value for external usage
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    OBJECT_BUBBLE

    public static final int OBJECT_BUBBLE
    Bubble pbject

    See Also:
    Constant Field Values

    OBJECT_TEXT

    public static final int OBJECT_TEXT
    Free label object

    See Also:
    Constant Field Values

    JUSTIFY_LEFT

    public static final int JUSTIFY_LEFT
    Left label justification

    See Also:
    Constant Field Values

    JUSTIFY_RIGHT

    public static final int JUSTIFY_RIGHT
    Right label justification

    See Also:
    Constant Field Values

    JUSTIFY_CENTER

    public static final int JUSTIFY_CENTER
    Center label justification

    See Also:
    Constant Field Values
    Constructor Detail

    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:
    OBJECT_BUBBLE, OBJECT_TEXT
    Method Detail

    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)
    Returns true if this object is parent of o


    isChildOf

    public boolean isChildOf(NetObject o)
    Returns true if this object is child of o


    getLabel

    public java.lang.String getLabel()
    Returns the label


    setLabel

    public void setLabel(java.lang.String value)
    Sets the free label of this object.

    Parameters:
    value - Label

    setLabel

    public void setLabel(java.lang.String[] value)
    Sets the free lablel


    getName

    public java.lang.String getName()
    Get object name.

    Returns:
    'Bubble' or 'Text'

    getType

    public int getType()
    Return the type of this NetObject.

    See Also:
    OBJECT_BUBBLE, OBJECT_TEXT

    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:
    NetShape

    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.

    See Also:
    JUSTIFY_LEFT, JUSTIFY_RIGHT, JUSTIFY_CENTER

    getJustify

    public int getJustify()
    Returns current justification

    See Also:
    setJustify(int)

    getMaxInput

    public int getMaxInput()
    Returns maximum number of incoming link


    getMaxOutput

    public int getMaxOutput()
    Returns maximum number of outgoing link


    setCenterLabel

    public void setCenterLabel(java.lang.String s)
    Sets the label displayed at the center of this object. It uses the NetEditor small font.


    setBottomLabel

    public void setBottomLabel(java.lang.String s)
    Sets the label displayed at the bottom left of this object. It uses the NetEditor small font.


    setColor

    public void setColor(java.awt.Color c)
    Sets the background (fill color) of this object (when parent NetEditor is not editable)


    getColor

    public java.awt.Color getColor()
    Gets the background (fill color) of this object (when parent NetEditor is not editable)


    setSize

    public void setSize(int size)
    Sets the object size


    getSize

    public int getSize()
    Gets the object size


    setUserValue

    public void setUserValue(java.lang.Object v)
    Sets the user value for external usage


    getUserValue

    public java.lang.Object getUserValue()
    Returns the user value


    setExtensionList

    public void setExtensionList(java.lang.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(java.lang.String name,
                                 java.lang.String value)
    Sets the extended param value.

    Parameters:
    name - Param name
    value - Param value
    See Also:
    setExtensionList(java.lang.String[])

    setExtendedParam

    public void setExtendedParam(int extIdx,
                                 java.lang.String value)
    Sets the extended param value.

    Parameters:
    extIdx - Index of the extensions.
    value - param value
    See Also:
    setExtensionList(java.lang.String[])

    getExtendedParam

    public java.lang.String getExtendedParam(java.lang.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:
    setExtensionList(java.lang.String[])

    getExtendedParam

    public java.lang.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:
    setExtensionList(java.lang.String[])

    getExtendedParamNumber

    public int getExtendedParamNumber()
    Returns the number of extensions


    getExtendedParamIndex

    public int getExtendedParamIndex(java.lang.String name)
    Returns the index of the specified extended param , -1 when not found


    setTextFont

    public void setTextFont(java.awt.Font f)
    Set the font of this object. Only TEXT object accept font

    Parameters:
    f - Font

    getTextFont

    public java.awt.Font getTextFont()
    Get 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(java.awt.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(java.awt.Graphics2D g)
    Paint this NetObject.

    Parameters:
    g - Graphics object