com.abstractics.xmlpanel.swing.componentcreator
Class ComponentFactory

java.lang.Object
  extended bycom.abstractics.xmlpanel.swing.componentcreator.ComponentFactory

public class ComponentFactory
extends java.lang.Object

Singleton factory that can create Swing components from XML. The factory is loaded with XmlPanelComponentCreator objects that handle the details of how the XML is converted into a component.
XmlPanelComponentCreator objects can be added to the factory at runtime via the addXmlPanelComponentCreator method.

The factory is preloaded with the following creators:

Version:
$Id: ComponentFactory.java,v 1.2 2006/03/15 05:37:40 andyman99 Exp $
Author:
Andrew Lawrence, Copyright 2006 Abstractics, L.L.C., Licensed under the Apache License, Version 2.0
See Also:
com.abstractics.xmlpanel.swing.xmlpanel.XmlPanelComponentCreator, GenericClassComponentCreator

Constructor Summary
protected ComponentFactory()
          Constructor left as protected for testing purposes, but in general, this class is a singleton and should be used via the getInstance() method.
 
Method Summary
 void addXmlPanelComponentCreator(ComponentCreator creator)
           
 java.awt.Component createComponent(org.w3c.dom.Element element)
          Calls the other createComponent method with a null XmlPanel parameter
 java.awt.Component createComponent(org.w3c.dom.Element element, XmlPanel panel)
          Gets the XmlPanelComponentCreator according to the "type" attribute specified in the element, then calls the createComponent method on the creator to generate the Component.
static ComponentFactory getInstance()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentFactory

protected ComponentFactory()
Constructor left as protected for testing purposes, but in general, this class is a singleton and should be used via the getInstance() method.

See Also:
getInstance()
Method Detail

getInstance

public static ComponentFactory getInstance()
Returns:
Returns the singleton instance of the ComponentFactory

addXmlPanelComponentCreator

public void addXmlPanelComponentCreator(ComponentCreator creator)

createComponent

public java.awt.Component createComponent(org.w3c.dom.Element element,
                                          XmlPanel panel)
Gets the XmlPanelComponentCreator according to the "type" attribute specified in the element, then calls the createComponent method on the creator to generate the Component.

Parameters:
element - XML element that is to represent the component
panel - The XmlPanel that this component is being placed into - for reference only.
Returns:
See Also:
ComponentCreator#createComponent(Element)

createComponent

public java.awt.Component createComponent(org.w3c.dom.Element element)
Calls the other createComponent method with a null XmlPanel parameter

Parameters:
element - XML element that is to represent the component
Returns:
See Also:
createComponent(Element, XmlPanel)