Class AbstractObjectRenderer
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.gui.visualization.debug.objectrenderer.AbstractObjectRenderer
-
- All Implemented Interfaces:
LoggingSupporter
,SizeOfHandler
,ObjectRenderer
,Serializable
- Direct Known Subclasses:
FlowContainerRenderer
,ImageRenderer
,MapRenderer
,Mat5ArrayRenderer
,PlainTextRenderer
,PropertiesRenderer
,ReportRenderer
,SetRenderer
,SpreadSheetRenderer
,TimeseriesRenderer
,WekaInstancesRenderer
public abstract class AbstractObjectRenderer extends LoggingObject implements ObjectRenderer
Ancestor for classes that render objects visually.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static Hashtable<Class,List<Class>>
m_Cache
the cache for object class / renderer relation.protected static Class[]
m_RendererClasses
the renderers (classes) currently available.protected static String[]
m_Renderers
the renderers (classnames) currently available.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractObjectRenderer()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
canRenderCached(Object obj, JPanel panel)
Checks whether the renderer can use a cached setup to render an object.protected abstract String
doRender(Object obj, JPanel panel, Integer limit)
Performs the actual rendering with a new renderer setup.protected String
doRenderCached(Object obj, JPanel panel, Integer limit)
Performs the actual rendering using a cached setup.static List<ObjectRenderer>
getRenderer(Class cls)
Returns a renderer for the specified class.static List<ObjectRenderer>
getRenderer(Object obj)
Returns a renderer for the specified object.static String[]
getRenderers()
Returns a list with classnames of renderers.abstract boolean
handles(Class cls)
Checks whether the renderer can handle the specified class.protected static void
initRenderers()
Initializes the renderers.protected static List<ObjectRenderer>
instantiate(List<Class> renderers)
Instantiates the renderers.String
render(Object obj, JPanel panel, Integer limit)
Renders the object with a new renderer setup.String
renderCached(Object obj, JPanel panel, Integer limit)
Renders the object using a cached setup (if available).boolean
supportsLimit(Object obj)
Returns whether a limit is supported by the renderer.-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_Cache
protected static Hashtable<Class,List<Class>> m_Cache
the cache for object class / renderer relation.
-
m_Renderers
protected static String[] m_Renderers
the renderers (classnames) currently available.
-
m_RendererClasses
protected static Class[] m_RendererClasses
the renderers (classes) currently available.
-
-
Method Detail
-
initRenderers
protected static void initRenderers()
Initializes the renderers.
-
getRenderer
public static List<ObjectRenderer> getRenderer(Object obj)
Returns a renderer for the specified object.- Parameters:
obj
- the object to get a commandline renderer for- Returns:
- the renderer
-
instantiate
protected static List<ObjectRenderer> instantiate(List<Class> renderers)
Instantiates the renderers.- Parameters:
renderers
- the renderers to instantiate- Returns:
- the instances
-
getRenderer
public static List<ObjectRenderer> getRenderer(Class cls)
Returns a renderer for the specified class.- Parameters:
cls
- the class to get a commandline renderer for- Returns:
- the renderer
-
supportsLimit
public boolean supportsLimit(Object obj)
Returns whether a limit is supported by the renderer.
Default implementation returns false.- Specified by:
supportsLimit
in interfaceObjectRenderer
- Parameters:
obj
- the object to render- Returns:
- true if supplying a limit has an effect
-
handles
public abstract boolean handles(Class cls)
Checks whether the renderer can handle the specified class.- Specified by:
handles
in interfaceObjectRenderer
- Parameters:
cls
- the class to check- Returns:
- true if the renderer can handle this type of object
-
doRender
protected abstract String doRender(Object obj, JPanel panel, Integer limit)
Performs the actual rendering with a new renderer setup.- Parameters:
obj
- the object to renderpanel
- the panel to render intolimit
- the limit to use for the rendering (if applicable), ignored if null- Returns:
- null if successful, otherwise error message
-
render
public String render(Object obj, JPanel panel, Integer limit)
Renders the object with a new renderer setup.- Specified by:
render
in interfaceObjectRenderer
- Parameters:
obj
- the object to renderpanel
- the panel to render intolimit
- the limit to use for the rendering (if applicable), ignored if null- Returns:
- null if successful, otherwise error message
-
canRenderCached
public boolean canRenderCached(Object obj, JPanel panel)
Checks whether the renderer can use a cached setup to render an object.
Default implementation returns false.- Specified by:
canRenderCached
in interfaceObjectRenderer
- Parameters:
obj
- the object to renderpanel
- the panel to render into- Returns:
- true if possible
-
doRenderCached
protected String doRenderCached(Object obj, JPanel panel, Integer limit)
Performs the actual rendering using a cached setup.- Parameters:
obj
- the object to renderpanel
- the panel to render intolimit
- the limit to use for the rendering (if applicable), ignored if null- Returns:
- null if successful, otherwise error message
-
renderCached
public String renderCached(Object obj, JPanel panel, Integer limit)
Renders the object using a cached setup (if available).- Specified by:
renderCached
in interfaceObjectRenderer
- Parameters:
obj
- the object to renderpanel
- the panel to render intolimit
- the limit to use for the rendering (if applicable), ignored if null- Returns:
- null if successful, otherwise error message
-
getRenderers
public static String[] getRenderers()
Returns a list with classnames of renderers.- Returns:
- the renderer classnames
-
-