01: /*
02: * $Id: JGraphpadSVGPlugin.java,v 1.1.1.1 2005/08/04 11:21:58 gaudenz Exp $
03: * Copyright (c) 2001-2005, Gaudenz Alder
04: *
05: * All rights reserved.
06: *
07: * See LICENSE file for license details. If you are unable to locate
08: * this file please contact info (at) jgraph (dot) com.
09: */
10: package com.jgraph.svgplugin;
11:
12: import java.io.IOException;
13:
14: import javax.xml.parsers.ParserConfigurationException;
15:
16: import org.w3c.dom.Node;
17: import org.xml.sax.SAXException;
18:
19: import com.jgraph.JGraphEditor;
20: import com.jgraph.JGraphpad;
21: import com.jgraph.editor.JGraphEditorKit;
22: import com.jgraph.editor.JGraphEditorPlugin;
23: import com.jgraph.editor.JGraphEditorResources;
24: import com.jgraph.editor.JGraphEditorSettings;
25:
26: /**
27: * Plugin for using Batik in JGraphpad Pro. Adds an export SVG and SVG server
28: * action. The latter contains a simple built-in webserver for streaming SVG,
29: * JPG and PNG to clients.
30: */
31: public class JGraphpadSVGPlugin implements JGraphEditorPlugin {
32:
33: /**
34: * Defines the path to the UI configuration to be merged into the existing
35: * UI configuration.
36: */
37: public static String PATH_UICONFIG = "/com/jgraph/svgplugin/resources/ui.xml";
38:
39: /**
40: * Adds resource bundles.
41: */
42: static {
43: JGraphEditorResources
44: .addBundles(new String[] { "com.jgraph.svgplugin.resources.strings" });
45: }
46:
47: /**
48: * Initializes the plugin by registering all action bundles and merging the
49: * UI configuration into the main configuration.
50: *
51: * @param editor
52: * The enclosing editor for the plugin.
53: * @param configuration
54: * The object to configure the plugin with.
55: */
56: public void initialize(JGraphEditor editor, Node configuration)
57: throws ParserConfigurationException, SAXException,
58: IOException {
59: JGraphEditorKit kit = editor.getKit();
60: kit.addBundle(new JGraphpadSVGAction.AllActions(editor));
61: editor.getSettings().add(
62: JGraphpad.NAME_UICONFIG,
63: JGraphEditorSettings.parse(JGraphEditorResources
64: .getInputStream(PATH_UICONFIG)));
65: }
66:
67: }
|