Class 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
    Direct Known Subclasses:
    DEXTR, SAM

    public abstract class AbstractRedisTool<O,​I>
    extends adams.gui.visualization.segmentation.tool.AbstractToolWithParameterPanel
    Ancestor 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.RedisClient m_Client
      the client object.
      protected io.lettuce.core.api.StatefulRedisConnection m_Connection
      the connection object.
      protected io.lettuce.core.pubsub.StatefulRedisPubSubConnection m_PubSubConnection
      the pub/sub connection object.
      protected io.lettuce.core.pubsub.RedisPubSubListener m_PubSubListener
      the pub/sub listener.
      protected I m_ReceivedData
      the data received via Redis.
      protected int m_RedisDB
      the redis database.
      protected String m_RedisHost
      the redis host.
      protected int m_RedisPort
      the redis port.
      protected String m_RedisReceive
      the redis receive channel.
      protected String m_RedisSend
      the redis send channel.
      protected int m_RedisTimeout
      the timeout in milli-seconds.
      protected adams.gui.core.BaseObjectTextField<adams.core.base.BaseHostname> m_TextRedisHost
      the redis host/port.
      protected adams.gui.core.BaseTextField m_TextRedisReceive
      the redis channel for receiving.
      protected adams.gui.core.BaseTextField m_TextRedisSend
      the redis channel for sending.
      protected adams.gui.core.NumberTextField m_TextRedisTimeout
      the redis timeout.
      • Fields inherited from class adams.gui.visualization.segmentation.tool.AbstractToolWithParameterPanel

        m_ButtonApply
      • Fields inherited from class adams.gui.visualization.segmentation.tool.AbstractTool

        m_KeyListener, m_Listener, m_MotionListener, m_PaintOperation, m_PanelCanvas, m_PanelFullOptions, m_PanelOptions
      • Fields inherited from class adams.core.logging.LoggingObject

        m_Logger, m_LoggingIsEnabled, m_LoggingLevel
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addOptions​(adams.gui.core.ParameterPanel paramPanel)
      Fills the parameter panel with the options.
      void annotationsChanged()
      Hook method for when new annotations have been set.
      protected abstract O assembleSendData​(adams.core.MessageCollection errors)
      Method that assembles the data to send.
      protected String checkBeforeApply()
      Checks the parameters before applying them.
      void cleanUp()
      Cleans up data structures, frees up memory.
      protected void doApply()
      Applies the settings.
      protected void finishedRequest()
      Finishes up the request.
      protected int getDefaultTimeout()
      Returns the default timeout in msec.
      protected abstract String getReceiveChannel()
      The channel to receive the data on.
      protected abstract RedisDataType getReceiveType()
      Returns the type of data to receive.
      protected abstract String getSendChannel()
      The channel to send the data on.
      protected abstract RedisDataType getSendType()
      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 void parseReceivedData​(I data, adams.core.MessageCollection errors)
      Parses the received data and updates the GUI.
      protected void retrieveParameters()
      Retrieves the parameters from the GUI.
      protected void sendData()
      Communicates with DEXTR and updates the canvas.
      • Methods inherited from class adams.gui.visualization.segmentation.tool.AbstractToolWithParameterPanel

        applyOptions, createOptionPanel
      • Methods inherited from class adams.gui.visualization.segmentation.tool.AbstractTool

        activate, apply, createApplyButton, createCursor, createKeyListener, createMouseListener, createMouseMotionListener, createPaintOperation, deactivate, getActiveColor, getActiveCombinedSubLayer, getActiveImage, getActiveOverlay, getCanvas, getCursor, getKeyListener, getLayerManager, getMouseListener, getMouseMotionListener, getOptionPanel, getPaintOperation, getZoom, hasActiveCombinedSubLayer, hasActiveOverlay, hasAnyActive, initialize, isAutomaticUndoEnabled, setApplyButtonState, setCanvas
      • Methods inherited from class adams.core.logging.CustomLoggingLevelObject

        setLoggingLevel
      • Methods inherited from class adams.core.logging.LoggingObject

        configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
      • Methods inherited from interface adams.core.GlobalInfoSupporter

        globalInfo
      • Methods inherited from interface adams.core.logging.LoggingLevelHandler

        getLoggingLevel, setLoggingLevel
      • Methods inherited from interface adams.core.logging.LoggingSupporter

        getLogger, isLoggingEnabled
      • Methods inherited from interface adams.gui.visualization.segmentation.tool.Tool

        activate, deactivate, getActiveColor, getActiveCombinedSubLayer, getActiveImage, getActiveOverlay, getCanvas, getCursor, getIcon, getKeyListener, getLayerManager, getMouseListener, getMouseMotionListener, getName, getOptionPanel, 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.
    • Constructor Detail

      • AbstractRedisTool

        public AbstractRedisTool()
    • Method Detail

      • checkBeforeApply

        protected String checkBeforeApply()
        Checks the parameters before applying them.
        Overrides:
        checkBeforeApply in class adams.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:
        doApply in class adams.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:
        addOptions in class adams.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:
        annotationsChanged in interface adams.gui.visualization.segmentation.tool.Tool
        Overrides:
        annotationsChanged in class adams.gui.visualization.segmentation.tool.AbstractTool
      • cleanUp

        public void cleanUp()
        Cleans up data structures, frees up memory.
        Specified by:
        cleanUp in interface adams.core.CleanUpHandler
        Overrides:
        cleanUp in class adams.gui.visualization.segmentation.tool.AbstractTool