net.hivecell.hive.agent.image
Class GenericFilterAgentImpl
java.lang.Object
|
+--java.rmi.server.RemoteObject
|
+--java.rmi.server.RemoteServer
|
+--java.rmi.server.UnicastRemoteObject
|
+--net.hivecell.hive.agent.AgentImpl
|
+--net.hivecell.hive.agent.EventReceivingAgentImpl
|
+--net.hivecell.hive.agent.EventTransceivingAgentImpl
|
+--net.hivecell.hive.agent.EventTranslatingAgentImpl
|
+--net.hivecell.hive.agent.image.ImageSourceAgentImpl
|
+--net.hivecell.hive.agent.image.GenericFilterAgentImpl
- Direct Known Subclasses:
- ContrastFilterAgentImpl, GrayscaleFilterAgentImpl, MotionColorFilterAgentImpl
- public abstract class GenericFilterAgentImpl
- extends ImageSourceAgentImpl
This abstract class is the superclass for all image
filters. Subclassers need merely to implement the abstract
filter method to have a working filter. It is very important
that filter return a NEW image, and not merely a modified copy of the
argument, or else there will be a lot of issues with multiple
agents sharing copies of the same image.
- See Also:
- Serialized Form
Field Summary |
protected net.hivecell.hive.agent.image.ImageFetchingHelper |
fetcher
This threaded class fetches any images waiting in the fetchQ and puts them into the filterQ |
protected <>Queue |
fetchQ
This Queue handles the images waiting to be fetched. |
protected <>Queue |
filterQ
This Queue handles any images waiting to be filtered. |
Fields inherited from class net.hivecell.hive.agent.AgentImpl |
AGENTKILLED,
AGENTMOVED,
agentThreadGroup,
commandList,
commands,
description,
icon,
iconName,
myAddress,
myCell,
readyFlag,
stopCode,
timeToStop |
Fields inherited from class java.rmi.server.RemoteObject |
ref |
Method Summary |
void |
doBehavior()
Waits until notified by the filterQ, grabs elements off the filterQ, filtering them and
putting them into the ringbuffer. |
void |
doLocalSetup()
Instantiates the ImageFetchingHelper and the fetchQ and filterQ queues. |
protected abstract SerializableImage |
filter(SerializableImage si)
This is where the filtering takes place. |
void |
translate(HiveEvent event)
When an event is recieved, this method ensures that it is
an ImageEvent and that the sender is a ImageSourceAgent. |
Methods inherited from class net.hivecell.hive.agent.image.ImageSourceAgentImpl |
getAlpha,
getBlue,
getBufSize,
getEarliestIndex,
getGreen,
getImage,
getImage,
getLatestIndex,
getRed,
isBusy,
isBusy,
sendUIAgent,
setAlpha,
setAlpha,
setBlue,
setBlue,
setBusy,
setGreen,
setGreen,
setRed,
setRed |
Methods inherited from class net.hivecell.hive.agent.AgentImpl |
addActionCommand,
blockUntilReady,
configure,
doLocalCleanup,
getActionCommands,
getAddress,
getCell,
getComponentManagerShadow,
getDescription,
getIcon,
getIconName,
getName,
getThreadGroup,
invokeActionCommand,
isReady,
isTimeToStop,
loadIcon,
moveTo,
onDying,
onMoving,
setCell,
setDescription,
setIconName,
setIsReady,
setThreadGroup,
setTimeToStop,
waitUntilDeath |
Methods inherited from class java.rmi.server.UnicastRemoteObject |
clone,
exportObject,
exportObject,
exportObject,
unexportObject |
Methods inherited from class java.rmi.server.RemoteServer |
getClientHost,
getLog,
setLog |
Methods inherited from class java.rmi.server.RemoteObject |
equals,
getRef,
hashCode,
toString,
toStub |
Methods inherited from class java.lang.Object |
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
fetchQ
protected <>Queue fetchQ
- This Queue handles the images waiting to be fetched.
fetcher
protected transient net.hivecell.hive.agent.image.ImageFetchingHelper fetcher
- This threaded class fetches any images waiting in the fetchQ and puts them into the filterQ
filterQ
protected <>Queue filterQ
- This Queue handles any images waiting to be filtered.
GenericFilterAgentImpl
public GenericFilterAgentImpl()
throws java.rmi.RemoteException
- Initialize the Filter. If you override this method be sure and call super();
- Throws:
- java.rmi.RemoteException -
filter
protected abstract SerializableImage filter(SerializableImage si)
- This is where the filtering takes place.
Subclassers will want to override this method.
IMPORTANT: The filter MUST return a NEW image, and not simply
modify the argument. If you do you will get wierd and unexpected
results because multiple ImageConsumers can have references to a
single image
- Parameters:
si
-
doLocalSetup
public void doLocalSetup()
throws AgentInitializationException
- Instantiates the ImageFetchingHelper and the fetchQ and filterQ queues.
- Overrides:
- doLocalSetup in class EventTransceivingAgentImpl
- Tags copied from class: AgentImpl
- Throws:
- AgentInitializationException - can be thrown by the agent if for some reason it cannot fufil its setup stuff
translate
public void translate(HiveEvent event)
- When an event is recieved, this method ensures that it is
an ImageEvent and that the sender is a ImageSourceAgent.
If the ImageEvent is a PENDING notification, that message is
rebroadcast. If it is a READY message, then if the filter is
busy, a IGNORED message is broadcast, otherwise, the image is
added to the fetchQ to be retrieved. If the fetchQ exceeds BUFSIZE
then the filter goes busy.
- Overrides:
- translate in class EventTranslatingAgentImpl
- Parameters:
event
-
doBehavior
public void doBehavior()
- Waits until notified by the filterQ, grabs elements off the filterQ, filtering them and
putting them into the ringbuffer.
- Overrides:
- doBehavior in class EventTranslatingAgentImpl
- Tags copied from class: AgentImpl
- See Also:
timeToStop
,
doLocalSetup