jsynoptic.base
Class Plugin

java.lang.Object
  extended by jsynoptic.base.Plugin
Direct Known Subclasses:
AsyncPlugin, Builtin, Java3dPlugin, Java3DPlugin3D, JFreeChartPlugin, JSMergeCollectionPlugin, LookAndFeelPlugin, RandomDataPlugin, SocketDataPlugin, StreamingMSDataPlugin, StreamingTSDataPlugin, SvgPlugin, SynopticsExportPlugin, Xith3DPlugin3D

public class Plugin
extends java.lang.Object

This is the base class for JSynoptic plugins

Version:
1.0 2001
Author:
Nicolas Brodu

Field Summary
static int EXPORT
           
static int IMPORT
           
static int OPEN
           
static int SAVE
           
 
Constructor Summary
Plugin()
           
 
Method Summary
 java.lang.String about()
          The information returned here will be displayed in the about box.
static void addPluginHashMap(java.util.HashMap pluginHashMap)
           
 AbstractShape createShape(java.lang.String name, DiagramComponent diagram)
          The plugin is asked to create a new shape for one of the name it provided with getShapes().
 DataSource createSource(java.lang.String name, java.lang.String instanceName)
          The plugin is asked to create a new source from one of the templates it declared with getSources().
 void exit()
          Some plugins need a particular treatment during Jsynoptic closing For instance when an external process was created in a plugin, it needs to be destroyed
 java.lang.Object[][] getDataSourceIcons()
          Source factory: this plugin may bring its own data sources with its own icons to display them in the source panel
 javax.swing.filechooser.FileFilter[] getFileFilters(int action)
          Give the plugin an occasion to add its file filters.
 HelpNode getHelp()
          Help factory: this plugin may bring its own help which will be displayed into JSynoptic help contents.
 javax.swing.JComponent getOptionPanelForFilter(javax.swing.filechooser.FileFilter filter)
          Enables a plugin to show an option panel when the user selects a file using one of the plugin file filters.
static java.lang.String getShapeName(java.lang.Class c)
           
 java.lang.String[] getShapes()
          Shape factory: this plugin may bring its own shapes to put in the shape list.
 java.util.HashMap getShapesMap()
          Get a map that links the plugin shapes classes with the corresponding shapes names.
 java.lang.String[] getSources()
          Source factory: this plugin may bring its own source templates to put in the predefined sources list.
 Template[] getTemplates()
          Template factory: this plugin may bring templates to put in the template list.
static Plugin load(java.lang.String className)
           
 void newComponent(java.awt.Component c)
          Deprecated. replaced by getTemplates()
 void newDesktopComponent(DesktopCardPanel c)
          Give the plugin an occasion to work at desktop initialisation
 void newSourceComponent(javax.swing.JTabbedPane c)
          Deprecated. replaced by newSourceComponent(NamedElementContainer)
 void newSourceComponent(NamedElementContainer c)
          Give the plugin an occasion to work at source panel initialisation
 boolean processDataSourceCollection(DataSourceCollection dsc, java.lang.String actionType)
          Given the plugin the possibility to apply some changes on all loaded data sources
 boolean processFile(java.io.File f, int action)
          See getFileFilters for usage description.
 boolean processSynoptic(ShapesContainer sc, java.lang.String actionType, boolean background)
          Given the plugin the possibility to apply some changes on a given synoptic
 void setMenu(javax.swing.JMenuBar mb)
          Give the plugin an occasion to add its menus
 void setMenu(java.lang.Object mb)
          Give the plugin an occasion to add its menus
 void setToolBarItem(javax.swing.JToolBar tb)
          Give the plugin an occasion to add its toolbar items
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPEN

public static final int OPEN
See Also:
Constant Field Values

SAVE

public static final int SAVE
See Also:
Constant Field Values

IMPORT

public static final int IMPORT
See Also:
Constant Field Values

EXPORT

public static final int EXPORT
See Also:
Constant Field Values
Constructor Detail

Plugin

public Plugin()
Method Detail

load

public static Plugin load(java.lang.String className)

addPluginHashMap

public static void addPluginHashMap(java.util.HashMap pluginHashMap)

getShapeName

public static java.lang.String getShapeName(java.lang.Class c)

setMenu

public void setMenu(javax.swing.JMenuBar mb)
Give the plugin an occasion to add its menus

Parameters:
mb - The menubar in which to add menus. Typically, the plugin is expected to call tb.add on each of its menus, and should add MenuListeners on them too.

setMenu

public void setMenu(java.lang.Object mb)
Give the plugin an occasion to add its menus

Parameters:
mb - The menubar in which to add menus. Typically, the plugin is expected to call tb.add on each of its menus, and should add MenuListeners on them too.

setToolBarItem

public void setToolBarItem(javax.swing.JToolBar tb)
Give the plugin an occasion to add its toolbar items

Parameters:
tb - The toolbar in which to add items. Typically, the plugin is expected to call tb.add on each of its items, and should add ActionListeners on them too.

newComponent

public void newComponent(java.awt.Component c)
Deprecated. replaced by getTemplates()

Give the plugin an occasion to work when adding a new component

Parameters:
c - he new Component

newDesktopComponent

public void newDesktopComponent(DesktopCardPanel c)
Give the plugin an occasion to work at desktop initialisation

Parameters:
c - The desktop

newSourceComponent

public void newSourceComponent(NamedElementContainer c)
Give the plugin an occasion to work at source panel initialisation

Parameters:
c - The sources container

newSourceComponent

public void newSourceComponent(javax.swing.JTabbedPane c)
Deprecated. replaced by newSourceComponent(NamedElementContainer)

Give the plugin an occasion to work at source panel initialisation

Parameters:
c - The sources container

getFileFilters

public javax.swing.filechooser.FileFilter[] getFileFilters(int action)
Give the plugin an occasion to add its file filters. If a file is selected by the user and it is accepted by one of the FileFilters returned by this function, then the processFile method will be called on that file. In graphic mode, the file filters will end up in a JFileChooser. In batch mode, the file filters will be used directly on a user-specified file. In any case, this should be transparent for the plugin.

Parameters:
action - What to do with the file. Currently OPEN or SAVE.
Returns:
An array containing all the file filters added by this plugin

processFile

public boolean processFile(java.io.File f,
                           int action)
See getFileFilters for usage description.

Parameters:
f - The file to process
action - What to do with the file. Currently OPEN or SAVE.
Returns:
true if the action could be performed successfully.

processSynoptic

public boolean processSynoptic(ShapesContainer sc,
                               java.lang.String actionType,
                               boolean background)
Given the plugin the possibility to apply some changes on a given synoptic

Parameters:
sc - The synoptic to process
actionType - Kind of action to apply to the synoptic
background - If true, run transformation in another thread
Returns:
false if actionType is not provided by Plugin or if synoptic process failed

processDataSourceCollection

public boolean processDataSourceCollection(DataSourceCollection dsc,
                                           java.lang.String actionType)
Given the plugin the possibility to apply some changes on all loaded data sources

Parameters:
dsc - The data source collection to process
actionType - Kind of action to apply to data source collection
Returns:
false if actionType is not provided by Plugin or if data process failed

getShapes

public java.lang.String[] getShapes()
Shape factory: this plugin may bring its own shapes to put in the shape list. It will then be asked to create a new shape when requested. As an example, the plot is a basic shape provided with JSynoptic.

Returns:
An array of shape names, or null if this plugin does not provide any shape.

getTemplates

public Template[] getTemplates()
Template factory: this plugin may bring templates to put in the template list.

Returns:
An array of templates, or null if this plugin does not provide any template.

getShapesMap

public java.util.HashMap getShapesMap()
Get a map that links the plugin shapes classes with the corresponding shapes names.

Returns:
the hash map if the plugin is able to create shapes, or null if this plugin does not provide any shape.

createShape

public AbstractShape createShape(java.lang.String name,
                                 DiagramComponent diagram)
The plugin is asked to create a new shape for one of the name it provided with getShapes(). Note that the newly created shape will be inserted in a diagram set up with an ActionPopup popup menu. Thus, it may implement JSynoptic ContextualActionProvider interface to interact with the user.

Parameters:
name - The name of the shape to create.
diagram - The diagram this shape will be inserted into.

getOptionPanelForFilter

public javax.swing.JComponent getOptionPanelForFilter(javax.swing.filechooser.FileFilter filter)
Enables a plugin to show an option panel when the user selects a file using one of the plugin file filters.

Parameters:
filter -
Returns:
a component to display, or null if there is no option for this filter (default)

about

public java.lang.String about()
The information returned here will be displayed in the about box. You should return an HTML 3.2 text content. This text will be included in a
  • tag. Returning null is permitted, and disables completely this plugin information. Default is to use the class name, without the package prefix.

    Returns:
    the information about this plugin, including authors, license, etc..

  • getSources

    public java.lang.String[] getSources()
    Source factory: this plugin may bring its own source templates to put in the predefined sources list. It will then be asked to create a new source when requested. How it does it is at the plugin discretion (for example, if the source template needs arguments, it's up to the plugin to open a dialog box/whatever to get them).

    Returns:
    An array of source template names, or null if this plugin does not provide any source template (default).
    See Also:
    getShapes()

    createSource

    public DataSource createSource(java.lang.String name,
                                   java.lang.String instanceName)
    The plugin is asked to create a new source from one of the templates it declared with getSources(). The newly created source will be inserted at top level in the source tree, unless the plugin already set it in a collection.

    Parameters:
    name - The name of the source template.
    instanceName - The desired name of the source created from this template.
    Returns:
    the newly created source, or null if this plugin cannot create a source of this type

    getDataSourceIcons

    public java.lang.Object[][] getDataSourceIcons()
    Source factory: this plugin may bring its own data sources with its own icons to display them in the source panel

    Returns:
    An array or null if no specific icons. Each row contains in the first column the data source class and the second column contains the icon to display it.

    exit

    public void exit()
    Some plugins need a particular treatment during Jsynoptic closing For instance when an external process was created in a plugin, it needs to be destroyed


    getHelp

    public HelpNode getHelp()
    Help factory: this plugin may bring its own help which will be displayed into JSynoptic help contents.

    Returns:
    The root HelpNode or null if this plugin cannot provide any help.