Version: 1.1.1

org.biomoby.service.dashboard.renderers
Class AbstractRenderer

java.lang.Object
  extended by org.biomoby.service.dashboard.renderers.AbstractRenderer
All Implemented Interfaces:
Renderer
Direct Known Subclasses:
AbstractMobyRenderer, CollectionRenderer, PlainText, XMLTreeRenderer

public abstract class AbstractRenderer
extends Object
implements Renderer

Abstract rendering class.

Version:
$Id: AbstractRenderer.java,v 1.4 2006/02/20 05:51:11 senger Exp $
Author:
Martin Senger (based on work by Matthew Pocock for Taverna)

Field Summary
 
Fields inherited from interface org.biomoby.service.dashboard.renderers.Renderer
CLASS, CLASS_NAME, DATA, DATA_CONTAINER, MIME_TYPE, MOBY_TYPE
 
Constructor Summary
AbstractRenderer(String name)
           
AbstractRenderer(String name, Icon icon)
           
AbstractRenderer(String name, String iconFileName)
           
 
Method Summary
abstract  boolean canHandle(String criterion, Object value)
          Return true if this SPI can handle (render) data whose type complies with given value within given criterion.
abstract  JComponent getComponent(DataContainer data)
          Return a JComponent displaying (rendering) given data.
 Icon getIcon()
          An icon for this SPI.
 String getName()
          A human-readable name for this SPI.
 boolean save2File(DataContainer data, File file)
          Default implementation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractRenderer

public AbstractRenderer(String name)

AbstractRenderer

public AbstractRenderer(String name,
                        Icon icon)

AbstractRenderer

public AbstractRenderer(String name,
                        String iconFileName)
Method Detail

getIcon

public Icon getIcon()
Description copied from interface: Renderer
An icon for this SPI. Will be used in a selection lists of available renderers.

Specified by:
getIcon in interface Renderer
Returns:
an icon, or null

getName

public final String getName()
Description copied from interface: Renderer
A human-readable name for this SPI. Will be used in a selection lists of available renderers.

Specified by:
getName in interface Renderer
Returns:
a shortish name of this viewer

save2File

public boolean save2File(DataContainer data,
                         File file)
                  throws MobyException
Default implementation.

If it gets a byte array, it saves it in the given file.

If it gets any other array, it looks at its elements and - if the elements are of type byte array, they all are stored separately, to more files (this is done with the help of the CollectionRenderer). Other types of elements are converted to strings by calling their toString() method, and all of them are store in one file.

It 'data' do not contain an array, they are treated similarly as above: they are converted to string using its toString() method and put in a file.

Specified by:
save2File in interface Renderer
Returns:
true on success, return false if you even did nt try to save data (probably because it does not make sense to store such data)
Throws:
MobyException - if saving was tried but failed

canHandle

public abstract boolean canHandle(String criterion,
                                  Object value)
Description copied from interface: Renderer
Return true if this SPI can handle (render) data whose type complies with given value within given criterion.

Any renderer should handle also a collection of objects that it can handle - see examples in Renderer.getComponent(org.biomoby.service.dashboard.data.DataContainer) and Renderer.save2File(org.biomoby.service.dashboard.data.DataContainer, java.io.File).

Specified by:
canHandle in interface Renderer
Parameters:
criterion - is a category of the value, e.g. "MIME-TYPE"
value - is a value from the category criterion, e.g. "text/xml"

getComponent

public abstract JComponent getComponent(DataContainer data)
                                 throws MobyException
Description copied from interface: Renderer
Return a JComponent displaying (rendering) given data.

If it gets an array of data, it can always delegate their accumulation to the CollectionRenderer by saying:

   if (data.getData().getClass().isArray())
      return new BoxCollectionRenderer (this).getComponent (data);

Specified by:
getComponent in interface Renderer
Parameters:
data - to be rendered
Returns:
a component for displaying data, or null if there is a problem with data
Throws:
MobyException - if called with wrong type of data

Version: 1.1.1

Submit a bug or feature
Generated: Sat May 29 04:26:35 EDT 2010