JGraphpad Pro
v6.0.5.0


com.jgraph.editor
Class JGraphEditorFactory

java.lang.Object
  extended bycom.jgraph.editor.JGraphEditorFactory

public class JGraphEditorFactory
extends Object

Class that creates the UI elements of a JGraph editor. It uses the actions and tools from the kit to create menu bars, toolbars, toolboxes and popup menus.


Nested Class Summary
protected  class JGraphEditorFactory.ActionChangedListener
          Updates button based on property change events.
 
Field Summary
protected  Map factoryMethods
          Holds the (name, factory method) pairs
protected static int ITEMTYPE_MENUBAR
          Constant for menubar creation.
protected static int ITEMTYPE_TOOLBAR
          Constant for toolbar creation.
protected  JGraphEditorKit kit
          References the editor kit.
static String NODENAME_GROUP
          Defines the nodename for groups.
static String NODENAME_ITEM
          Defines the nodename for items.
static String NODENAME_MENU
          Defines the nodename for menus.
static String NODENAME_SEPARATOR
          Defines the nodename for separators.
protected static Component SEPARATOR
          Shared separator instance.
static String SUFFIX_ACTION
          Defines the suffix for actionname resources.
static String SUFFIX_ICON
          Defines the suffix for icon resources, eg.
static String SUFFIX_LABEL
          Defines the suffix for label resources, eg.
static String SUFFIX_MNEMONIC
          Defines the suffix for mnemonic resources, eg.
static String SUFFIX_SHORTCUT
          Defines the suffix for shortcut resources, eg.
static String SUFFIX_TOOL
          Defines the suffix for toolname resources.
static String SUFFIX_TOOLTIP
          Defines the suffix for tooltip resources, eg.
 
Constructor Summary
JGraphEditorFactory()
          Constructs an empty factory.
JGraphEditorFactory(JGraphEditorKit kit)
          Constructs a factory for the specified kit.
 
Method Summary
 Object addMethod(JGraphEditorFactoryMethod method)
          Adds the specified factory method.
protected  void configureAbstractButton(AbstractButton button, String name)
          Hook for subclassers to configure a toolbox button for tool.
 void configureActionItem(AbstractButton button, JGraphEditorAction action)
          Hook for subclassers to configure an action item for action.
protected  void configureMenuBar(Container menu, Node configuration)
          Hook for subclassers to configure a new menu based on configuration.
protected  void configureToolBar(Container toolBar, Node configuration)
          Hook for subclassers to configure a toolbar with configuration.
protected  void configureToolbox(JGraphEditorToolbox toolbox, Node configuration)
          Hook for subclassers to configure a new toolbox based on configuration.
 PropertyChangeListener createActionChangeListener(AbstractButton button)
          Returns a new property change listener that updates button according to property change events.
 JGraphEditorDiagramPane createDiagramPane(JGraphEditorDiagram diagram)
          Returns a new diagram pane for the specified diagram by creating a new graph using the createGraph(GraphLayoutCache) method and wrapping it up in a JGraphEditorDiagramPane.
 org.jgraph.JGraph createGraph(org.jgraph.graph.GraphLayoutCache cache)
          Returns a new graph for the specified cache.
protected  Container createMenu(Node configuration)
          Hook for subclassers to create a new menu.
 JMenuBar createMenuBar(Node configuration)
          Returns a new JMenuBar configured using configureMenuBar(Container, Node).
 AbstractButton createMenuItem(Node configuration, boolean radio)
          Returns a new JCheckBoxMenuItem or JMenuItem configured using configureActionItem(AbstractButton, JGraphEditorAction).
 JPopupMenu createPopupMenu(Node configuration)
          Returns a new JPopupMenu configured using configureMenuBar(Container, Node).
 JScrollPane createScrollPane(Component component)
          Returns a new JScrollPane containing the specified component.
 JSplitPane createSplitPane(Component first, Component second, int orientation)
          Returns a new JSplitPane containing the specified component with the specified orientation.
 JTabbedPane createTabbedPane(int tabPlacement)
          Returns a new empty JTabbedPane.
 JToolBar createToolBar(Node configuration)
          Returns a new JToolBar configured using configureToolBar(Container, Node).
protected  AbstractButton createToolBarButton(Node configuration)
          Returns a new JToggleButton or JButton configured using configureActionItem(AbstractButton, JGraphEditorAction) and configureAbstractButton(AbstractButton, String) (in this order).
 JGraphEditorToolbox createToolbox(Node configuration)
          Returns a new JGraphEditorToolbox configured using configureToolbox(JGraphEditorToolbox, Node).
protected  AbstractButton createToolboxButton(JGraphEditorTool tool)
          Returns a new JToggleButton button configured for tool by calling configureAbstractButton(AbstractButton, String).
 Component executeMethod(String factoryMethod)
          Shortcut method to executeMethod(String, Node) with a null configuration.
 Component executeMethod(String factoryMethod, Node configuration)
          Executes JGraphEditorFactoryMethod.createInstance(Node) on the factory method under factoryMethod passing configuration along as an argument and returns the return value of the invoked method.
 JGraphEditorAction getAction(String key)
          Returns the action for the resource under key+SUFFIX_ACTION from the editor kit.
protected  String getKey(Node node)
          Shortcut method to JGraphEditorSettings.getKeyAttributeValue(Node).
 JGraphEditorKit getKit()
          Returns the editor kit.
 JGraphEditorFactoryMethod getMethod(String name)
          Returns the factory method for the specified name or null if no such factory method can be found.
protected  String getString(String key)
          Shortcut method to JGraphEditorResources.getString(String).
 JGraphEditorTool getTool(String key)
          Returns the tool for the resource under key+SUFFIX_TOOL from the editor kit.
 void setKit(JGraphEditorKit kit)
          Sets the editor kit to provide actions and tools.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NODENAME_SEPARATOR

public static final String NODENAME_SEPARATOR
Defines the nodename for separators.

See Also:
Constant Field Values

NODENAME_ITEM

public static final String NODENAME_ITEM
Defines the nodename for items.

See Also:
Constant Field Values

NODENAME_MENU

public static final String NODENAME_MENU
Defines the nodename for menus.

See Also:
Constant Field Values

NODENAME_GROUP

public static final String NODENAME_GROUP
Defines the nodename for groups.

See Also:
Constant Field Values

SUFFIX_ACTION

public static final String SUFFIX_ACTION
Defines the suffix for actionname resources. This is used to replace the default action name, which is its key, eg. openFile.label=Open....

See Also:
Constant Field Values

SUFFIX_TOOL

public static final String SUFFIX_TOOL
Defines the suffix for toolname resources. This is used to replace the default tool name, which is its key, eg. openFile.label=Open....

See Also:
Constant Field Values

SUFFIX_LABEL

public static final String SUFFIX_LABEL
Defines the suffix for label resources, eg. open.label=Open....

See Also:
Constant Field Values

SUFFIX_ICON

public static final String SUFFIX_ICON
Defines the suffix for icon resources, eg. open.icon=/com/jgraph/pad/images/open.gif.

See Also:
Constant Field Values

SUFFIX_MNEMONIC

public static final String SUFFIX_MNEMONIC
Defines the suffix for mnemonic resources, eg. open.mnemonic=o.

See Also:
Constant Field Values

SUFFIX_SHORTCUT

public static final String SUFFIX_SHORTCUT
Defines the suffix for shortcut resources, eg. open.shortcut=control O.

See Also:
Constant Field Values

SUFFIX_TOOLTIP

public static final String SUFFIX_TOOLTIP
Defines the suffix for tooltip resources, eg. open.tooltip=Open a file.

See Also:
Constant Field Values

ITEMTYPE_MENUBAR

protected static final int ITEMTYPE_MENUBAR
Constant for menubar creation.

See Also:
Constant Field Values

ITEMTYPE_TOOLBAR

protected static final int ITEMTYPE_TOOLBAR
Constant for toolbar creation.

See Also:
Constant Field Values

SEPARATOR

protected static final Component SEPARATOR
Shared separator instance.


factoryMethods

protected Map factoryMethods
Holds the (name, factory method) pairs


kit

protected JGraphEditorKit kit
References the editor kit.

Constructor Detail

JGraphEditorFactory

public JGraphEditorFactory()
Constructs an empty factory.


JGraphEditorFactory

public JGraphEditorFactory(JGraphEditorKit kit)
Constructs a factory for the specified kit.

Method Detail

getKit

public JGraphEditorKit getKit()
Returns the editor kit.

Returns:
Returns the kit.

setKit

public void setKit(JGraphEditorKit kit)
Sets the editor kit to provide actions and tools.

Parameters:
kit - The kit to set.

addMethod

public Object addMethod(JGraphEditorFactoryMethod method)
Adds the specified factory method.

Parameters:
method - The factory method to add.
Returns:
Returns the previous factory method for name.

getMethod

public JGraphEditorFactoryMethod getMethod(String name)
Returns the factory method for the specified name or null if no such factory method can be found.

Parameters:
name - The name that identifies the factory method.
Returns:
Returns the factory method under name or null.

executeMethod

public Component executeMethod(String factoryMethod)
Shortcut method to executeMethod(String, Node) with a null configuration.

Parameters:
factoryMethod - The name of the factory method to executed.
Returns:
Returns the return value of JGraphEditorFactoryMethod.createInstance(Node) on factoryMethod.

executeMethod

public Component executeMethod(String factoryMethod,
                               Node configuration)
Executes JGraphEditorFactoryMethod.createInstance(Node) on the factory method under factoryMethod passing configuration along as an argument and returns the return value of the invoked method.

Parameters:
factoryMethod - The name of the factory method to executed.
configuration - The configuration to pass to JGraphEditorFactoryMethod.createInstance(Node).
Returns:
Returns the return value of JGraphEditorFactoryMethod.createInstance(Node) on factoryMethod.
See Also:
getMethod(String)

getString

protected String getString(String key)
Shortcut method to JGraphEditorResources.getString(String).

Returns:
Returns the resource string for key.

getKey

protected String getKey(Node node)
Shortcut method to JGraphEditorSettings.getKeyAttributeValue(Node).


getAction

public JGraphEditorAction getAction(String key)
Returns the action for the resource under key+SUFFIX_ACTION from the editor kit. If no such resource exists then the action for key is returned or null if no action can be found.

Returns:
Returns the action for the key+SUFFIX_ACTION resource or the action for key.
See Also:
getString(String), JGraphEditorKit.getAction(String)

getTool

public JGraphEditorTool getTool(String key)
Returns the tool for the resource under key+SUFFIX_TOOL from the editor kit. If no such resource exists then the tool for key is returned or null if no tool can be found.

Returns:
Returns the tool for the key+SUFFIX_TOOL resource or the tool for key.
See Also:
getString(String), JGraphEditorKit.getTool(String)

createDiagramPane

public JGraphEditorDiagramPane createDiagramPane(JGraphEditorDiagram diagram)
Returns a new diagram pane for the specified diagram by creating a new graph using the createGraph(GraphLayoutCache) method and wrapping it up in a JGraphEditorDiagramPane.

Parameters:
diagram - The diagram that contains the graph to be used.
Returns:
Returns a new diagram pane for diagram.

createGraph

public org.jgraph.JGraph createGraph(org.jgraph.graph.GraphLayoutCache cache)
Returns a new graph for the specified cache. This implementation creates a new graph using JGraph.JGraph(GraphLayoutCache).

Parameters:
cache - The layout cache that defines the graph.
Returns:
Returns a new graph for cache.

createScrollPane

public JScrollPane createScrollPane(Component component)
Returns a new JScrollPane containing the specified component.

Returns:
Returns a new scrollpane containing the specified component.

createSplitPane

public JSplitPane createSplitPane(Component first,
                                  Component second,
                                  int orientation)
Returns a new JSplitPane containing the specified component with the specified orientation.

Returns:
Returns a new splitpane containing the the specified components.

createTabbedPane

public JTabbedPane createTabbedPane(int tabPlacement)
Returns a new empty JTabbedPane.

Returns:
Returns a new tabbed pane.

createToolbox

public JGraphEditorToolbox createToolbox(Node configuration)
Returns a new JGraphEditorToolbox configured using configureToolbox(JGraphEditorToolbox, Node).

Parameters:
configuration - The configuration to create the toolbox with.
Returns:
Returns a new toolbox.

configureToolbox

protected void configureToolbox(JGraphEditorToolbox toolbox,
                                Node configuration)
Hook for subclassers to configure a new toolbox based on configuration.

Parameters:
toolbox - The toolbox to be configured.
configuration - The configuration to configure the toolbox with.
See Also:
createToolboxButton(JGraphEditorTool)

createToolboxButton

protected AbstractButton createToolboxButton(JGraphEditorTool tool)
Returns a new JToggleButton button configured for tool by calling configureAbstractButton(AbstractButton, String).

Parameters:
tool - The tool to create the toolbox button for.
Returns:
Returns a new toolbox.

configureAbstractButton

protected void configureAbstractButton(AbstractButton button,
                                       String name)
Hook for subclassers to configure a toolbox button for tool.

Parameters:
button - The button to be configured.
name - The name of the tool or action to configure the button for.

createMenuBar

public JMenuBar createMenuBar(Node configuration)
Returns a new JMenuBar configured using configureMenuBar(Container, Node).

Parameters:
configuration - The configuration to create the menubar with.
Returns:
Returns a new toolbox.

createPopupMenu

public JPopupMenu createPopupMenu(Node configuration)
Returns a new JPopupMenu configured using configureMenuBar(Container, Node).

Parameters:
configuration - The configuration to create the popup menu with.
Returns:
Returns a new toolbox.

configureMenuBar

protected void configureMenuBar(Container menu,
                                Node configuration)
Hook for subclassers to configure a new menu based on configuration. This is used for menubars and submenus.

Parameters:
menu - The menu to be configured.
configuration - The configuration to configure the menubar with.
See Also:
createMenuItem(Node, boolean)

createMenu

protected Container createMenu(Node configuration)
Hook for subclassers to create a new menu. This implementation returns a new instance of JMenuBar.

Parameters:
configuration - The configuration to create the menu with.
Returns:
Returns a new menubar.

createMenuItem

public AbstractButton createMenuItem(Node configuration,
                                     boolean radio)
Returns a new JCheckBoxMenuItem or JMenuItem configured using configureActionItem(AbstractButton, JGraphEditorAction).

Parameters:
configuration - The configuration to create the menu item with.
radio - Whether the created item should be a JRadioButtonMenuItem.
Returns:
Returns a new menu item.

configureActionItem

public void configureActionItem(AbstractButton button,
                                JGraphEditorAction action)
Hook for subclassers to configure an action item for action. Valid action items are toolbar buttons and menu items, but not toolbox buttons.

Parameters:
button - The button to be configured.
action - The action to configure the button for.

createToolBar

public JToolBar createToolBar(Node configuration)
Returns a new JToolBar configured using configureToolBar(Container, Node).

Parameters:
configuration - The configuration to create the toolbar with.
Returns:
Returns a new toolbar.

configureToolBar

protected void configureToolBar(Container toolBar,
                                Node configuration)
Hook for subclassers to configure a toolbar with configuration.

Parameters:
toolBar - The toolBar to be configured.
configuration - The configuration to configure the toolbar with.

createToolBarButton

protected AbstractButton createToolBarButton(Node configuration)
Returns a new JToggleButton or JButton configured using configureActionItem(AbstractButton, JGraphEditorAction) and configureAbstractButton(AbstractButton, String) (in this order).

Parameters:
configuration - The configuration to create the toolbar with.
Returns:
Returns a new toolbar.

createActionChangeListener

public PropertyChangeListener createActionChangeListener(AbstractButton button)
Returns a new property change listener that updates button according to property change events.

Parameters:
button - The button to create the listener for.
Returns:
Returns a new property change listener for actions.

JGraphpad Pro
v6.0.5.0


Copyright (C) 2005 JGraph.com. All rights reserved.