001: /*--
002: Copyright (C) 2003-2007 Wolf Paulus.
003: All rights reserved.
004:
005: Redistribution and use in source and binary forms, with or without
006: modification, are permitted provided that the following conditions
007: are met:
008:
009: 1. Redistributions of source code must retain the above copyright
010: notice, this list of conditions, and the following disclaimer.
011:
012: 2. Redistributions in binary form must reproduce the above copyright
013: notice, this list of conditions, and the disclaimer that follows
014: these conditions in the documentation and/or other materials provided
015: with the distribution.
016:
017: 3. The end-user documentation included with the redistribution,
018: if any, must include the following acknowledgment:
019: "This product includes software developed by the
020: SWIXML Project (http://www.swixml.org/)."
021: Alternately, this acknowledgment may appear in the software itself,
022: if and wherever such third-party acknowledgments normally appear.
023:
024: 4. The name "Swixml" must not be used to endorse or promote products
025: derived from this software without prior written permission. For
026: written permission, please contact <info_AT_swixml_DOT_org>
027:
028: 5. Products derived from this software may not be called "Swixml",
029: nor may "Swixml" appear in their name, without prior written
030: permission from the Swixml Project Management.
031:
032: THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
033: WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
034: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
035: DISCLAIMED. IN NO EVENT SHALL THE SWIXML PROJECT OR ITS
036: CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
037: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
038: LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
039: USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
040: ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
041: OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
042: OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
043: SUCH DAMAGE.
044: ====================================================================
045:
046: This software consists of voluntary contributions made by many
047: individuals on behalf of the Swixml Project and was originally
048: created by Wolf Paulus <wolf_AT_swixml_DOT_org>. For more information
049: on the Swixml Project, please see <http://www.swixml.org/>.
050: */
051:
052: package org.swixml;
053:
054: import java.awt.LayoutManager;
055:
056: import org.jdom.Attribute;
057: import org.jdom.Element;
058:
059: /**
060: * <p>The <code>LayoutConverter</code> interface defines a layout converter that
061: * creates LayoutManager objects and constraints objects based on a provided
062: * XML attributes or elements.</p>
063: *
064: * @author Karl Tauber
065: * @see LayoutConverterLibrary
066: */
067: public interface LayoutConverter {
068:
069: /**
070: * Returns the unique identifier of the layout converter. E.g. "flowlayout".
071: * This identifier is used in "layout" attributes and elements to specify the
072: * layout manager.
073: */
074: public String getID();
075:
076: /**
077: * <p>Converts the given "layout" attribute to a <code>LayoutManager</code>
078: * instance. The attribute value always starts with the layout identifier
079: * (see {@link #getID()}) followed by optional parameters.</p>
080: *
081: * <p>If the layout converter does not use the "layout" attribute, this method
082: * should return <code>null</code>, but then {@link #convertLayoutElement}
083: * must return a <code>LayoutManager</code> instance.</p>
084: *
085: * <p><b>XML notation:</b></p>
086: * <pre>
087: * <panel layout="mylayout"/>
088: * </pre>
089: */
090: public LayoutManager convertLayoutAttribute(final Attribute attr);
091:
092: /**
093: * <p>Converts the given "layout" element to a <code>LayoutManager</code>
094: * instance. The element may have any layout manager specific attributes
095: * or child elements. The "type" attribute is used to choose the layout converter.</p>
096: *
097: * <p>If the layout converter does not use the "layout" element, this method
098: * should return <code>null</code>, but then {@link #convertLayoutAttribute}
099: * must return a <code>LayoutManager</code> instance.</p>
100: *
101: * <p><b>XML notation:</b></p>
102: * <pre>
103: * <panel>
104: * <layout type="mylayout" attr1="value1"/>
105: * </panel>
106: * </pre>
107: */
108: public LayoutManager convertLayoutElement(final Element element);
109:
110: /**
111: * <p>Converts the given "constraints" attribute to a layout manager specific
112: * constraints instance.</p>
113: *
114: * <p>If the layout converter does not use the "constraints" attribute, this method
115: * should return <code>null</code>.</p>
116: *
117: * <p><b>XML notation:</b></p>
118: * <pre>
119: * <label constraints="value" />
120: * </pre>
121: */
122: public Object convertConstraintsAttribute(final Attribute attr);
123:
124: /**
125: * <p>Converts the given "constraints" element to a layout manager specific
126: * constraints instance. The element may have any layout manager specific attributes
127: * or child elements.</p>
128: *
129: * <p>If the layout converter does not use the "constraints" element, this method
130: * should return <code>null</code>.</p>
131: *
132: * <p><b>XML notation:</b></p>
133: * <pre>
134: * <label>
135: * <constraints attr1="value1" />
136: * </label>
137: * </pre>
138: */
139: public Object convertConstraintsElement(final Element element);
140: }
|