org.openbp.cockpit.modeler.figures.process
Class SocketFigure

java.lang.Object
  extended by CH.ifa.draw.standard.AbstractFigure
      extended by CH.ifa.draw.standard.CompositeFigure
          extended by org.openbp.cockpit.modeler.figures.tag.AbstractTagFigure
              extended by org.openbp.cockpit.modeler.figures.tag.HorizontalRotatingTagFigure
                  extended by org.openbp.cockpit.modeler.figures.process.SocketFigure
All Implemented Interfaces:
CH.ifa.draw.framework.Figure, CH.ifa.draw.framework.FigureChangeListener, CH.ifa.draw.standard.TextHolder, CH.ifa.draw.util.Storable, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, ChildFigure, Colorizable, Expandable, ShadowDropper, UpdatableFigure, LayoutableTag, ProcessElementContainer, VisualElement, InteractionClient

public class SocketFigure
extends HorizontalRotatingTagFigure
implements ProcessElementContainer, CH.ifa.draw.standard.TextHolder, Colorizable

Socket figure.

Author:
Stephan Moritz
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.openbp.cockpit.modeler.figures.tag.AbstractTagFigure
AbstractTagFigure.TagContent
 
Field Summary
static java.lang.String REGION_COLOR
          Drop region id for color region
static java.lang.String REGION_PARAM_BY_TYPE
          Drop region id for param by type region
static java.lang.String REGION_PARAM_BY_VARIABLE
          Drop region id for param by other param region
protected  NodeSocket socket
          Socket represented by this tag
 
Fields inherited from class org.openbp.cockpit.modeler.figures.tag.AbstractTagFigure
angle, content, CONTENT_DATA, CONTENT_FLOW, CONTENT_ICON, CONTENT_INTERACTION, CONTENT_STATIC, CONTENT_TEXT, CONTENT_USER1, CONTENT_USER2, contentState, currentContentState, DECO_TAGCONTENTTYPE, layouter, origin, parent, presentationFigure, shadowFigure, visualStatus
 
Fields inherited from class CH.ifa.draw.standard.CompositeFigure
_nHighestZ, _nLowestZ, fFigures
 
Fields inherited from interface org.openbp.cockpit.modeler.figures.VisualElement
VISUAL_DISPLAY_ALL, VISUAL_DND_PARTICIPANT, VISUAL_VISIBLE
 
Fields inherited from interface CH.ifa.draw.framework.Figure
POPUP_MENU
 
Constructor Summary
SocketFigure(NodeFigure parent, NodeSocket socket)
          Default constructor.
 
Method Summary
 boolean acceptsTyping()
           
 void addFlowConnection(FlowConnection connection)
          Adds a flow connection.
 ParamFigure addParam(NodeParam param, int pos)
          Adds a figure for the given param to the socket figure.
 void applyContentState()
          Override that applies for hiding standard in/out names.
 void basicSetAngle(double angle)
          Sets the angle to the given one.
 boolean canConnect()
           
 void connect(CH.ifa.draw.framework.Figure connectedFigure)
           
 CH.ifa.draw.framework.Connector connectorAt(int x, int y)
           
 boolean containsPoint(int x, int y)
           
 void decodeGeometry()
           
protected  void decodeParameter(java.lang.String parameter)
           
 void disconnect(CH.ifa.draw.framework.Figure disconnectFigure)
           
 void dragEnded(java.awt.datatransfer.Transferable transferable)
          called when a dragging has ended.
 void dragStarted(java.awt.datatransfer.Transferable transferable)
          Called when a dragging has been started.
 void encodeGeometry()
          Stores geometric information in the socket object.
 ProcessElementContainer findProcessElementContainer(int x, int y)
          Gets the direct child element at the given coordinates.
 ProcessElementContainer findProcessElementContainerInside(int x, int y)
          Gets the innermost child at the given coordinates.
 java.awt.Color getDefaultFillColor()
          Gets the default fill color.
 java.util.List getDropRegions(java.util.List flavors, java.awt.datatransfer.Transferable data, java.awt.event.MouseEvent mouseEvent)
          Returns a list of drop regions of this client that are compatible with the provided data flavors.
 java.util.List getFlowConnections()
          Gets the list of all flow connections to / from this point.
 java.awt.Font getFont()
           
 java.util.List getImportersAt(java.awt.Point p)
          Returns all importers which will be accepted at the given point by this client.
 NodeSocket getNodeSocket()
          Gets the socket represented by this tag.
 java.util.List getParamList()
          Gets the list of all param figures contained in this tag.
 java.awt.Rectangle[] getParamRegions()
          Returns an array of Rectangles containing the coordinates of the regions between the parameters.
 ProcessObject getProcessElement()
          Returns the contained process element.
 ProcessObject getReferredProcessElement()
          Returns the process element this figure refers to.
 java.lang.String getText()
           
 boolean handleEvent(VisualElementEvent event)
          Handler method that is called for handling events.
 boolean importData(java.lang.Object regionId, java.awt.datatransfer.Transferable data, java.awt.Point p)
          Imports the given transferable into the given region.
protected  void initContent(java.lang.Object modelObject)
          Creates the content of this tag.
 boolean isEntrySocket()
          Determines if this socket figure represents an entry socket.
 void moveParameter(int oldIndex, int newIndex)
          Moves the parameter with the given index so that it assumes the new index.
 int overlayColumns()
           
 void reinitParams(boolean showAllParams)
          Reinitializes the parameter list of the socket.
 void release()
           
protected  void removeConnections()
          Removes all connections from/to this figure.
 void removeFlowConnection(FlowConnection connection)
          Removes a flow connection.
 void removeParam(ParamFigure paramFigure)
          Removes the parameter from this socket.
 CH.ifa.draw.framework.Figure selectionOnDelete()
          select node on deletion.
 void setText(java.lang.String newText)
           
 java.awt.Rectangle textDisplayBox()
           
 java.lang.String toString()
          Returns a string representation of this object.
 void updatePresentationFigure()
          Updates (reinitializes) the presentation figure.
 
Methods inherited from class org.openbp.cockpit.modeler.figures.tag.HorizontalRotatingTagFigure
initTagLayouter, positionDisplayBox
 
Methods inherited from class org.openbp.cockpit.modeler.figures.tag.AbstractTagFigure
addContent, addContentAt, basicDisplayBox, basicMoveBy, changed, checkDecoratedContentState, compactDisplayBox, createPresentationFigure, determine2WayOrientation, determineDecoratedContentState, displayBox, dragActionTriggered, draw, findFigure, findFigureInside, findVisualElement, findVisualElementInside, getAllDropRegions, getAllImportersAt, getAngle, getCenterFigure, getCenterFigureBox, getContent, getContentFigureAt, getContentState, getDrawing, getFillColor, getLayouter, getNumberOfContents, getOrigin, getParent, getParentElement, getPresentationFigure, getShadow, getSubClients, getVisualStatus, handles, initPresentationFigure, initShadow, invalidate, isVerticalOrientation, isVisible, layoutTag, moveContent, read, setAngle, setContentState, setDrawing, setFillColor, setLayouter, setOrigin, setParent, setVisible, setVisualStatus, updateFigure, write
 
Methods inherited from class CH.ifa.draw.standard.CompositeFigure
add, addAll, addAll, bringToFront, draw, figureAt, figureChanged, figureCount, figureInvalidated, figureRemoved, figureRequestRemove, figureRequestUpdate, figures, figures, figuresReverse, findFigure, findFigure, findFigureInsideWithout, findFigureWithout, getFigureFromLayer, getLayer, includes, init, orphan, orphanAll, orphanAll, remove, removeAll, removeAll, removeAll, replace, sendToBack, sendToLayer
 
Methods inherited from class CH.ifa.draw.standard.AbstractFigure
addFigureChangeListener, addToContainer, center, clone, connectedTextLocator, connectionInsets, connectorVisibility, decompose, displayBox, displayBox, getAttribute, getZValue, isEmpty, listener, moveBy, removeFigureChangeListener, removeFromContainer, setAttribute, setZValue, size, willChange
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.openbp.cockpit.modeler.figures.VisualElement
findVisualElement, findVisualElementInside, getDrawing, getParentElement, getPresentationFigure, isVisible, setDrawing, setVisible
 
Methods inherited from interface CH.ifa.draw.framework.Figure
addFigureChangeListener, addToContainer, basicDisplayBox, center, changed, clone, connectedTextLocator, connectionInsets, connectorVisibility, decompose, displayBox, displayBox, displayBox, draw, figures, findFigureInside, getAttribute, getZValue, handles, includes, invalidate, isEmpty, listener, moveBy, removeFigureChangeListener, removeFromContainer, setAttribute, setZValue, size, willChange
 
Methods inherited from interface CH.ifa.draw.util.Storable
read, write
 
Methods inherited from interface org.openbp.jaspira.gui.interaction.InteractionClient
dragActionTriggered, getAllDropRegions, getAllImportersAt, getSubClients
 
Methods inherited from interface org.openbp.cockpit.modeler.figures.generic.UpdatableFigure
updateFigure
 
Methods inherited from interface org.openbp.cockpit.modeler.figures.generic.Colorizable
getFillColor, setFillColor
 
Methods inherited from interface CH.ifa.draw.framework.FigureChangeListener
figureChanged, figureInvalidated, figureRemoved, figureRequestRemove, figureRequestUpdate
 

Field Detail

REGION_COLOR

public static final java.lang.String REGION_COLOR
Drop region id for color region

See Also:
Constant Field Values

REGION_PARAM_BY_TYPE

public static final java.lang.String REGION_PARAM_BY_TYPE
Drop region id for param by type region

See Also:
Constant Field Values

REGION_PARAM_BY_VARIABLE

public static final java.lang.String REGION_PARAM_BY_VARIABLE
Drop region id for param by other param region

See Also:
Constant Field Values

socket

protected NodeSocket socket
Socket represented by this tag

Constructor Detail

SocketFigure

public SocketFigure(NodeFigure parent,
                    NodeSocket socket)
Default constructor.

Parameters:
parent - Parent node figure
socket - Socket the figure refers to
Method Detail

initContent

protected void initContent(java.lang.Object modelObject)
Creates the content of this tag.

Overrides:
initContent in class AbstractTagFigure
Parameters:
modelObject - Model object this tag represents or null

reinitParams

public void reinitParams(boolean showAllParams)
Reinitializes the parameter list of the socket.

Parameters:
showAllParams - true: Show visible and hidden parameters
false: Show hidden parameters only if the socket belongs to the node editor dummy process

applyContentState

public void applyContentState()
Override that applies for hiding standard in/out names. When reinitializing the contents of the socket, the text information may be hidden if the name of the underlying process element is 'In' or 'Out' and the skin tells us to do so.

Overrides:
applyContentState in class AbstractTagFigure

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object

getNodeSocket

public NodeSocket getNodeSocket()
Gets the socket represented by this tag.


isEntrySocket

public boolean isEntrySocket()
Determines if this socket figure represents an entry socket.

Returns:
true: The figure represents an entry socket.
false: The figure represents an exit socket.

getFlowConnections

public java.util.List getFlowConnections()
Gets the list of all flow connections to / from this point.


addFlowConnection

public void addFlowConnection(FlowConnection connection)
Adds a flow connection.

Parameters:
connection - Connection to add

removeFlowConnection

public void removeFlowConnection(FlowConnection connection)
Removes a flow connection.

Parameters:
connection - Connection to remove

getParamList

public java.util.List getParamList()
Gets the list of all param figures contained in this tag.


addParam

public ParamFigure addParam(NodeParam param,
                            int pos)
Adds a figure for the given param to the socket figure.

Parameters:
param - Param to add
pos - Position to add the parameter at (starting with 1) or -1 to add it to the end of the parameter list
Returns:
The new param figure

removeParam

public void removeParam(ParamFigure paramFigure)
Removes the parameter from this socket.

Parameters:
paramFigure - Parameter to remove

moveParameter

public void moveParameter(int oldIndex,
                          int newIndex)
Moves the parameter with the given index so that it assumes the new index. Replaced parameters have their indices increased by one.


removeConnections

protected void removeConnections()
Removes all connections from/to this figure.


basicSetAngle

public void basicSetAngle(double angle)
Description copied from class: AbstractTagFigure
Sets the angle to the given one.

Overrides:
basicSetAngle in class AbstractTagFigure

connectorAt

public CH.ifa.draw.framework.Connector connectorAt(int x,
                                                   int y)
Specified by:
connectorAt in interface CH.ifa.draw.framework.Figure
Overrides:
connectorAt in class AbstractTagFigure
See Also:
AbstractFigure.connectorAt(int x, int y)

canConnect

public boolean canConnect()
Specified by:
canConnect in interface CH.ifa.draw.framework.Figure
Overrides:
canConnect in class AbstractTagFigure
See Also:
Figure.canConnect()

containsPoint

public boolean containsPoint(int x,
                             int y)
Specified by:
containsPoint in interface CH.ifa.draw.framework.Figure
Overrides:
containsPoint in class AbstractTagFigure
See Also:
Figure.containsPoint(int, int)

release

public void release()
Specified by:
release in interface CH.ifa.draw.framework.Figure
Overrides:
release in class CH.ifa.draw.standard.CompositeFigure
See Also:
Figure.release()

decodeGeometry

public void decodeGeometry()

decodeParameter

protected void decodeParameter(java.lang.String parameter)

encodeGeometry

public void encodeGeometry()
Stores geometric information in the socket object.


getProcessElement

public ProcessObject getProcessElement()
Description copied from interface: ProcessElementContainer
Returns the contained process element.

Specified by:
getProcessElement in interface ProcessElementContainer
See Also:
ProcessElementContainer.getProcessElement()

getReferredProcessElement

public ProcessObject getReferredProcessElement()
Description copied from interface: ProcessElementContainer
Returns the process element this figure refers to. The returned element will be used for property browser and tool tip display. This is usually the same as returned by ProcessElementContainer.getProcessElement(), however this might be different also for example for sockets of initial/final nodes sockets, which will return their parent node.

Specified by:
getReferredProcessElement in interface ProcessElementContainer
See Also:
ProcessElementContainer.getReferredProcessElement()

selectionOnDelete

public CH.ifa.draw.framework.Figure selectionOnDelete()
select node on deletion.

Specified by:
selectionOnDelete in interface ProcessElementContainer
Returns:
Next figure to be selected or null
See Also:
ProcessElementContainer.selectionOnDelete()

findProcessElementContainer

public ProcessElementContainer findProcessElementContainer(int x,
                                                           int y)
Description copied from interface: ProcessElementContainer
Gets the direct child element at the given coordinates.

Specified by:
findProcessElementContainer in interface ProcessElementContainer
Parameters:
x - Document coordinate
y - Document coordinate
Returns:
The child element or null if no such child exists
See Also:
ProcessElementContainer.findProcessElementContainer(int, int)

findProcessElementContainerInside

public ProcessElementContainer findProcessElementContainerInside(int x,
                                                                 int y)
Description copied from interface: ProcessElementContainer
Gets the innermost child at the given coordinates.

Specified by:
findProcessElementContainerInside in interface ProcessElementContainer
Parameters:
x - Document coordinate
y - Document coordinate
Returns:
The child element or this if the point is in this element itself or null otherwise
See Also:
ProcessElementContainer.findProcessElementContainerInside(int, int)

textDisplayBox

public java.awt.Rectangle textDisplayBox()
Specified by:
textDisplayBox in interface CH.ifa.draw.standard.TextHolder

getText

public java.lang.String getText()
Specified by:
getText in interface CH.ifa.draw.standard.TextHolder

setText

public void setText(java.lang.String newText)
Specified by:
setText in interface CH.ifa.draw.standard.TextHolder

acceptsTyping

public boolean acceptsTyping()
Specified by:
acceptsTyping in interface CH.ifa.draw.standard.TextHolder

overlayColumns

public int overlayColumns()
Specified by:
overlayColumns in interface CH.ifa.draw.standard.TextHolder

connect

public void connect(CH.ifa.draw.framework.Figure connectedFigure)
Specified by:
connect in interface CH.ifa.draw.standard.TextHolder

disconnect

public void disconnect(CH.ifa.draw.framework.Figure disconnectFigure)
Specified by:
disconnect in interface CH.ifa.draw.standard.TextHolder

getFont

public java.awt.Font getFont()
Specified by:
getFont in interface CH.ifa.draw.standard.TextHolder

handleEvent

public boolean handleEvent(VisualElementEvent event)
Description copied from interface: VisualElement
Handler method that is called for handling events. Events can be cursor events, selection events etc.

Specified by:
handleEvent in interface VisualElement
Overrides:
handleEvent in class AbstractTagFigure
Parameters:
event - Event that desribes the event
Returns:
true: The event was handled by the element.
false: No special handling, perform the default handling.
See Also:
VisualElement.handleEvent(VisualElementEvent event)

updatePresentationFigure

public void updatePresentationFigure()
Description copied from interface: VisualElement
Updates (reinitializes) the presentation figure.

Specified by:
updatePresentationFigure in interface VisualElement
Overrides:
updatePresentationFigure in class AbstractTagFigure
See Also:
VisualElement.updatePresentationFigure()

getDefaultFillColor

public java.awt.Color getDefaultFillColor()
Description copied from interface: Colorizable
Gets the default fill color.

Specified by:
getDefaultFillColor in interface Colorizable
Returns:
Default fill color or null for no fill color
See Also:
Colorizable.getDefaultFillColor()

dragStarted

public void dragStarted(java.awt.datatransfer.Transferable transferable)
Description copied from interface: InteractionClient
Called when a dragging has been started.

Specified by:
dragStarted in interface InteractionClient
Overrides:
dragStarted in class AbstractTagFigure
Parameters:
transferable - Transferable to be dragged
See Also:
InteractionClient.dragStarted(Transferable)

dragEnded

public void dragEnded(java.awt.datatransfer.Transferable transferable)
Description copied from interface: InteractionClient
called when a dragging has ended.

Specified by:
dragEnded in interface InteractionClient
Overrides:
dragEnded in class AbstractTagFigure
Parameters:
transferable - Transferable that has been dragged
See Also:
InteractionClient.dragEnded(Transferable)

getDropRegions

public java.util.List getDropRegions(java.util.List flavors,
                                     java.awt.datatransfer.Transferable data,
                                     java.awt.event.MouseEvent mouseEvent)
Description copied from interface: InteractionClient
Returns a list of drop regions of this client that are compatible with the provided data flavors.

Specified by:
getDropRegions in interface InteractionClient
Overrides:
getDropRegions in class AbstractTagFigure
Parameters:
flavors - List of data flavors to check
data - Transferable to be imported
mouseEvent - Mouse event that initiated the drag action
Returns:
A list of DragAwareRegion object or null if the drop client cannot satisfy at least one of the supplied data flavors.
The list will contain only regions that belong directly to this drop client.
See Also:
InteractionClient.getDropRegions(List, Transferable, MouseEvent)

getParamRegions

public java.awt.Rectangle[] getParamRegions()
Returns an array of Rectangles containing the coordinates of the regions between the parameters. The size of the returned list is (number of parameters) + 1.

Returns:
An array of Rectangles

importData

public boolean importData(java.lang.Object regionId,
                          java.awt.datatransfer.Transferable data,
                          java.awt.Point p)
Description copied from interface: InteractionClient
Imports the given transferable into the given region.

Specified by:
importData in interface InteractionClient
Overrides:
importData in class AbstractTagFigure
Parameters:
regionId - Id of the region to import into (see BasicDropRegion.getId)
data - Transferable to import
p - Drop point in glass coordinates
Returns:
true The data was successfully imported.
false An error occured while importing the data.
See Also:
InteractionClient.importData(Object, Transferable, Point)

getImportersAt

public java.util.List getImportersAt(java.awt.Point p)
Description copied from interface: InteractionClient
Returns all importers which will be accepted at the given point by this client.

Specified by:
getImportersAt in interface InteractionClient
Overrides:
getImportersAt in class AbstractTagFigure
Parameters:
p - Current mouse position in screen coordinates
Returns:
A list of Importer objects or null
See Also:
InteractionClient.getImportersAt(Point)


Copyright © 2011. All Rights Reserved.