|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.Vector
simtools.data.DataSourceCollection
simtools.data.DynamicDataSourceCollection
examples.random.RandomDataSourceCollection
public class RandomDataSourceCollection
This example class can serves as the basis to create your own dynamic data sources. It creates data sources of random data between 0 and 100 on demand. The following optional interfaces are implemented as an example. - ContextualActionProvider : adds a contextual popup menu when right-clicking on the collection in the source pane
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 javax.swing.Timer |
timer
We use a timer to produce values periodically |
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 | |
---|---|
RandomDataSourceCollection()
This constructor sets up the timer and one time source. |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
This method is called by the timer each time it triggers (that is, every half second for us) |
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)
Return the list of possible actions The contect information may be used, or not. |
DataInfo |
getInformation()
Returns information about the collection itself |
int |
sortedOrder(int i)
If a source is sorted, this can lead to some optimization. |
void |
start()
Starts producing data automatically |
void |
step()
Produce exactly one data in each source |
void |
stop()
Stops producing data automatically |
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 |
---|
protected javax.swing.Timer timer
Constructor Detail |
---|
public RandomDataSourceCollection()
Method Detail |
---|
public void start()
public void stop()
public void step()
public void addSource()
public int sortedOrder(int i)
sortedOrder
in class DataSourceCollection
public DataInfo getInformation()
getInformation
in class DynamicDataSourceCollection
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
public java.lang.String[] getActions(double x, double y, java.lang.Object o, int context)
getActions
in interface ContextualActionProvider
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 actionscontext
- one of the context defined in the ContextualActionProvider class
public boolean doAction(double x, double y, java.lang.Object o, java.lang.String action, javax.swing.undo.CompoundEdit undoableEdit)
doAction
in interface ContextualActionProvider
x
- Coordinate, for example mouse positiony
- Coordinate, for example mouse positiono
- 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.
public boolean canDoAction(double x, double y, java.lang.Object o, java.lang.String action, int context)
canDoAction
in interface ContextualActionProvider
x
- Coordinate, for example mouse positiony
- Coordinate, for example mouse positiono
- 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
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |