Class AbstractRedisTool<O,I>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.gui.visualization.segmentation.tool.AbstractTool
-
- adams.gui.visualization.segmentation.tool.AbstractToolWithParameterPanel
-
- adams.gui.visualization.segmentation.tool.AbstractRedisTool<O,I>
-
- Type Parameters:
O- the outgoing data (String or byte[])I- the incoming data (String or byte[])
- All Implemented Interfaces:
adams.core.CleanUpHandler,adams.core.GlobalInfoSupporter,adams.core.logging.LoggingLevelHandler,adams.core.logging.LoggingSupporter,adams.core.SizeOfHandler,adams.gui.visualization.segmentation.tool.CustomizableTool,adams.gui.visualization.segmentation.tool.Tool,Serializable
public abstract class AbstractRedisTool<O,I> extends adams.gui.visualization.segmentation.tool.AbstractToolWithParameterPanelAncestor for tools that exchange data via Redis.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected io.lettuce.core.RedisClientm_Clientthe client object.protected io.lettuce.core.api.StatefulRedisConnectionm_Connectionthe connection object.protected io.lettuce.core.pubsub.StatefulRedisPubSubConnectionm_PubSubConnectionthe pub/sub connection object.protected io.lettuce.core.pubsub.RedisPubSubListenerm_PubSubListenerthe pub/sub listener.protected Im_ReceivedDatathe data received via Redis.protected intm_RedisDBthe redis database.protected Stringm_RedisHostthe redis host.protected intm_RedisPortthe redis port.protected Stringm_RedisReceivethe redis receive channel.protected Stringm_RedisSendthe redis send channel.protected intm_RedisTimeoutthe timeout in milli-seconds.protected adams.gui.core.BaseObjectTextField<adams.core.base.BaseHostname>m_TextRedisHostthe redis host/port.protected adams.gui.core.BaseTextFieldm_TextRedisReceivethe redis channel for receiving.protected adams.gui.core.BaseTextFieldm_TextRedisSendthe redis channel for sending.protected adams.gui.core.NumberTextFieldm_TextRedisTimeoutthe redis timeout.-
Fields inherited from class adams.gui.visualization.segmentation.tool.AbstractToolWithParameterPanel
m_ButtonApply, m_ButtonFavorites, m_IgnoreOptionsUpdate, m_InitialOptions, m_ParameterPanel
-
-
Constructor Summary
Constructors Constructor Description AbstractRedisTool()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddOptions(adams.gui.core.ParameterPanel paramPanel)Fills the parameter panel with the options.voidannotationsChanged()Hook method for when new annotations have been set.protected abstract OassembleSendData(adams.core.MessageCollection errors)Method that assembles the data to send.protected StringcheckBeforeApply()Checks the parameters before applying them.voidcleanUp()Cleans up data structures, frees up memory.protected voiddoApply()Applies the settings.protected voidfinishedRequest()Finishes up the request.protected intgetDefaultTimeout()Returns the default timeout in msec.protected abstract StringgetReceiveChannel()The channel to receive the data on.protected abstract RedisDataTypegetReceiveType()Returns the type of data to receive.protected abstract StringgetSendChannel()The channel to send the data on.protected abstract RedisDataTypegetSendType()Returns the type of data to send.protected io.lettuce.core.pubsub.RedisPubSubListener<byte[],byte[]>newBytesListener()Returns a new pub/sub listener for byte arrays.protected io.lettuce.core.pubsub.RedisPubSubListener<String,String>newStringListener()Returns a new pub/sub listener for strings.protected abstract voidparseReceivedData(I data, adams.core.MessageCollection errors)Parses the received data and updates the GUI.protected voidretrieveParameters()Retrieves the parameters from the GUI.protected voidsendData()Communicates with DEXTR and updates the canvas.-
Methods inherited from class adams.gui.visualization.segmentation.tool.AbstractToolWithParameterPanel
apply, applyOptions, applyOptionsQuietly, createOptionPanel, getCurrentOptions, getFavoritesOptions, getOption, getOptionPanel, initialize, postProcessCurrentOptions, retrieveCurrentOptions, setFavoritesOptions, setInitialOptions, setOption, showFavoritesMenu, updateOptions
-
Methods inherited from class adams.gui.visualization.segmentation.tool.AbstractTool
activate, createApplyButton, createCursor, createKeyListener, createMouseListener, createMouseMotionListener, createPaintOperation, deactivate, getActiveColor, getActiveCombinedSubLayer, getActiveImage, getActiveOverlay, getCanvas, getCursor, getKeyListener, getLayerManager, getModifiedIcon, getMouseListener, getMouseMotionListener, getPaintOperation, getUnmodifiedIcon, getZoom, hasActiveCombinedSubLayer, hasActiveOverlay, hasAnyActive, isAutomaticUndoEnabled, setApplyButtonState, setCanvas
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel, setLoggingLevel
-
Methods inherited from interface adams.gui.visualization.segmentation.tool.Tool
activate, deactivate, getActiveColor, getActiveCombinedSubLayer, getActiveImage, getActiveOverlay, getCanvas, getCursor, getIcon, getKeyListener, getLayerManager, getMouseListener, getMouseMotionListener, getName, getPaintOperation, getZoom, hasActiveCombinedSubLayer, hasActiveOverlay, hasAnyActive, isAutomaticUndoEnabled, setCanvas
-
-
-
-
Field Detail
-
m_TextRedisHost
protected adams.gui.core.BaseObjectTextField<adams.core.base.BaseHostname> m_TextRedisHost
the redis host/port.
-
m_TextRedisSend
protected adams.gui.core.BaseTextField m_TextRedisSend
the redis channel for sending.
-
m_TextRedisReceive
protected adams.gui.core.BaseTextField m_TextRedisReceive
the redis channel for receiving.
-
m_TextRedisTimeout
protected adams.gui.core.NumberTextField m_TextRedisTimeout
the redis timeout.
-
m_RedisHost
protected String m_RedisHost
the redis host.
-
m_RedisPort
protected int m_RedisPort
the redis port.
-
m_RedisDB
protected int m_RedisDB
the redis database.
-
m_RedisSend
protected String m_RedisSend
the redis send channel.
-
m_RedisReceive
protected String m_RedisReceive
the redis receive channel.
-
m_RedisTimeout
protected int m_RedisTimeout
the timeout in milli-seconds.
-
m_ReceivedData
protected I m_ReceivedData
the data received via Redis.
-
m_Client
protected transient io.lettuce.core.RedisClient m_Client
the client object.
-
m_PubSubConnection
protected transient io.lettuce.core.pubsub.StatefulRedisPubSubConnection m_PubSubConnection
the pub/sub connection object.
-
m_Connection
protected transient io.lettuce.core.api.StatefulRedisConnection m_Connection
the connection object.
-
m_PubSubListener
protected transient io.lettuce.core.pubsub.RedisPubSubListener m_PubSubListener
the pub/sub listener.
-
-
Method Detail
-
checkBeforeApply
protected String checkBeforeApply()
Checks the parameters before applying them.- Overrides:
checkBeforeApplyin classadams.gui.visualization.segmentation.tool.AbstractTool- Returns:
- null if checks passed, otherwise error message (gets displayed in GUI)
-
retrieveParameters
protected void retrieveParameters()
Retrieves the parameters from the GUI.
-
doApply
protected void doApply()
Applies the settings.- Specified by:
doApplyin classadams.gui.visualization.segmentation.tool.AbstractTool
-
getSendChannel
protected abstract String getSendChannel()
The channel to send the data on.- Returns:
- the redis channel
-
getReceiveChannel
protected abstract String getReceiveChannel()
The channel to receive the data on.- Returns:
- the redis channel
-
getDefaultTimeout
protected int getDefaultTimeout()
Returns the default timeout in msec.- Returns:
- the timeout
-
addOptions
protected void addOptions(adams.gui.core.ParameterPanel paramPanel)
Fills the parameter panel with the options.- Specified by:
addOptionsin classadams.gui.visualization.segmentation.tool.AbstractToolWithParameterPanel- Parameters:
paramPanel- for adding the options to
-
getSendType
protected abstract RedisDataType getSendType()
Returns the type of data to send.- Returns:
- the type of data
-
getReceiveType
protected abstract RedisDataType getReceiveType()
Returns the type of data to receive.- Returns:
- the type of data
-
newStringListener
protected io.lettuce.core.pubsub.RedisPubSubListener<String,String> newStringListener()
Returns a new pub/sub listener for strings.- Returns:
- the listener
-
newBytesListener
protected io.lettuce.core.pubsub.RedisPubSubListener<byte[],byte[]> newBytesListener()
Returns a new pub/sub listener for byte arrays.- Returns:
- the listener
-
assembleSendData
protected abstract O assembleSendData(adams.core.MessageCollection errors)
Method that assembles the data to send.- Parameters:
errors- for collecting errors- Returns:
- the data to send (String or byte[])
-
parseReceivedData
protected abstract void parseReceivedData(I data, adams.core.MessageCollection errors)
Parses the received data and updates the GUI.- Parameters:
data- the data to parse (String or byte[])errors- for collecting errors
-
finishedRequest
protected void finishedRequest()
Finishes up the request.
-
sendData
protected void sendData()
Communicates with DEXTR and updates the canvas.
-
annotationsChanged
public void annotationsChanged()
Hook method for when new annotations have been set.- Specified by:
annotationsChangedin interfaceadams.gui.visualization.segmentation.tool.Tool- Overrides:
annotationsChangedin classadams.gui.visualization.segmentation.tool.AbstractTool
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUpin interfaceadams.core.CleanUpHandler- Overrides:
cleanUpin classadams.gui.visualization.segmentation.tool.AbstractTool
-
-