examples.socket.plugin
Class SocketDataSourceCollection

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector
              extended by simtools.data.DataSourceCollection
                  extended by simtools.data.DynamicDataSourceCollection
                      extended by examples.socket.plugin.SocketDataSourceCollection
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.EventListener, java.util.List, java.util.RandomAccess, ContextualActionProvider

public class SocketDataSourceCollection
extends DynamicDataSourceCollection
implements java.awt.event.ActionListener, ContextualActionProvider

This class is the DynamicDataSourceCollection for data that is received over a socket

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class simtools.data.DynamicDataSourceCollection
DynamicDataSourceCollection.SourceInfo
 
Nested classes/interfaces inherited from class simtools.data.DataSourceCollection
DataSourceCollection.Container
 
Field Summary
protected  examples.socket.plugin.DynamicDataSocket socket
           
protected  java.lang.Thread thread
           
 
Fields inherited from class simtools.data.DynamicDataSourceCollection
ourInfo, sourceInfo
 
Fields inherited from class simtools.data.DataSourceCollection
buffers, endNotificationListeners, lastIndex, listeners, map, startIndex
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Fields inherited from interface jsynoptic.base.ContextualActionProvider
EDITOR_CONTEXT, MOUSE_OUT_CONTEXT, MOUSE_OVER_CONTEXT, MOUSE_PRESSED_CONTEXT, SHAPELIST_CONTEXT, SOURCELIST_CONTEXT
 
Constructor Summary
SocketDataSourceCollection()
          This constructor sets one default-source and some data sources (index of received packets = number of packets).
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          (Timer-Interface) This method is called by the timer each time it triggers; reads data from the socket
 void addSource()
          Adds a new data source to the collection
 boolean canDoAction(double x, double y, java.lang.Object o, java.lang.String action, int context)
          Returns true if, and only if, it is possible to do the action right now
 boolean doAction(double x, double y, java.lang.Object o, java.lang.String action, javax.swing.undo.CompoundEdit undoableEdit)
          Do one of the actions previously declared by getAction.
 java.lang.String[] getActions(double x, double y, java.lang.Object o, int context)
          (Part of the ContextualActionProvide interface This adds a contextual popup menu when right-clicking on the collection in the source pane) Return the list of possible actions
 DataInfo getInformation()
          Returns information about the collection itself
protected  void processInput(java.lang.String _Input)
          Analyses the String passed as "Input" and extracts the values contained in it; the values are written into the data-buffers in the order they appear in the string
 int sortedOrder(int i)
          If a source is sorted, this can lead to some optimization.
 
Methods inherited from class simtools.data.DynamicDataSourceCollection
bufferize, bufferize, bufferize, changeDataSourceInfo, changeInfo, computeLastIndex, computeMax, computeMin, computeStartIndex, createDataSource, createDataSource, getByteMax, getByteMin, getDoubleMax, getDoubleMin, getFloatMax, getFloatMin, getInformation, getIntegerMax, getIntegerMin, getKind, getLastIndex, getLongMax, getLongMin, getMax, getMin, getShortMax, getShortMin, getStartIndex, getValue, isComparable, registerNewValues, removeDataSource, removeDataSource, setByteValue, setDoubleValue, setFloatValue, setIntegerValue, setLongValue, setObjectValue, setShortValue, valueClass
 
Methods inherited from class simtools.data.DataSourceCollection
addEndNotificationListener, addListener, attachBuffer, computeLastIndex, computeStartIndex, get, getByteValue, getCollectionContainers, getDoubleValue, getFloatValue, getIntegerValue, getLastIndex, getLongValue, getShortValue, getStartIndex, hashCode, isCompound, notifyEndNotificationListeners, notifyListenersForCollectionRemoved, notifyListenersForDataSourceAdded, notifyListenersForDataSourceRemoved, notifyListenersForInfoChange, removeAllElements, removeEndNotificationListener, removeListener, setSlice
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Field Detail

socket

protected examples.socket.plugin.DynamicDataSocket socket

thread

protected java.lang.Thread thread
Constructor Detail

SocketDataSourceCollection

public SocketDataSourceCollection()
This constructor sets one default-source and some data sources (index of received packets = number of packets).

Method Detail

addSource

public void addSource()
Adds a new data source to the collection


sortedOrder

public int sortedOrder(int i)
If a source is sorted, this can lead to some optimization.

Overrides:
sortedOrder in class DataSourceCollection

getInformation

public DataInfo getInformation()
Returns information about the collection itself

Overrides:
getInformation in class DynamicDataSourceCollection

getActions

public java.lang.String[] getActions(double x,
                                     double y,
                                     java.lang.Object o,
                                     int context)
(Part of the ContextualActionProvide interface This adds a contextual popup menu when right-clicking on the collection in the source pane) Return the list of possible actions

Specified by:
getActions in interface ContextualActionProvider
Parameters:
x - Coordinate, mouse position in the same unit as contains(x,y)
y - Coordinate, mouse position in the same unit as contains(x,y)
o - Object the actions should work on. Possibly null => default or all actions
context - one of the context defined in the ContextualActionProvider class
Returns:
The list of possible actions, possibly null or an empty array

processInput

protected void processInput(java.lang.String _Input)
Analyses the String passed as "Input" and extracts the values contained in it; the values are written into the data-buffers in the order they appear in the string


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
(Timer-Interface) This method is called by the timer each time it triggers; reads data from the socket

Specified by:
actionPerformed in interface java.awt.event.ActionListener

doAction

public boolean doAction(double x,
                        double y,
                        java.lang.Object o,
                        java.lang.String action,
                        javax.swing.undo.CompoundEdit undoableEdit)
Do one of the actions previously declared by getAction.

Specified by:
doAction in interface ContextualActionProvider
Parameters:
x - Coordinate, for example mouse position
y - Coordinate, for example mouse position
o - Object the action should work on.
action - An action returned by a previous getActions call with the same x, y, o parameters It may be null, in which case the default action is requested for this x,y,o.
undoableEdit - current edit for undo/redo operation If not null, this action is undoable.
Returns:
true if the action could be performed

canDoAction

public boolean canDoAction(double x,
                           double y,
                           java.lang.Object o,
                           java.lang.String action,
                           int context)
Returns true if, and only if, it is possible to do the action right now

Specified by:
canDoAction in interface ContextualActionProvider
Parameters:
x - Coordinate, for example mouse position
y - Coordinate, for example mouse position
o - Object the action should work on.
action - An action returned by a previous getActions call with the same x, y, o parameters It may be null, in which case the default action is requested for this x,y,o.
context - one of the context defined in the ContextualActionProvider class
Returns:
true if the action can be performed