artisynth.core.modelmenu
Class DemoMenuParser
java.lang.Object
artisynth.core.modelmenu.DemoMenuParser
public class DemoMenuParser
- extends java.lang.Object
- Author:
- antonio
Parses an XML menu that can be used to create a menu entries for "Models".
Doesn't actually build a JMenu, instead all information is constructed in a
Tree that holds "MenuEntry" objects with icon/title/type information
The XML format supports submenus, icons, dividers, reading classes from a
.demoModels file, and reading classes in a given package that are derived
from a supplied base class (e.g. RootModel). Other xml menu files can also be
imported.
Method Summary |
static void |
compactMenu(Tree<MenuEntry> menu)
If a menu entry has only a single child, it merges it with this one and
the new title becomes "title1 (title2)" |
static java.lang.String |
findFile(java.lang.String filename,
java.lang.String localPath)
Finds a file specified by "file" First checks if file is specified by an
absolute path. |
static java.lang.String |
getPrefix(java.util.ArrayList<java.lang.String> array)
Given a list of strings, finds the greatest common prefix |
static Tree<MenuEntry> |
parseXML(java.lang.String filename)
|
static void |
setFont(Node<MenuEntry> node,
java.awt.Font font)
|
static void |
sortMenu(Node<MenuEntry> root)
|
static void |
sortMenu(Node<MenuEntry> root,
java.util.Comparator<Node<MenuEntry>> comparer)
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ROOT_TAG
public static final java.lang.String ROOT_TAG
- See Also:
- Constant Field Values
MENU_TAG
public static final java.lang.String MENU_TAG
- See Also:
- Constant Field Values
MENU_TAG_TEXT
public static final java.lang.String MENU_TAG_TEXT
- See Also:
- Constant Field Values
MENU_TAG_ICON
public static final java.lang.String MENU_TAG_ICON
- See Also:
- Constant Field Values
DIVIDER_TAG
public static final java.lang.String DIVIDER_TAG
- See Also:
- Constant Field Values
LABEL_TAG
public static final java.lang.String LABEL_TAG
- See Also:
- Constant Field Values
LABEL_TAG_ICON
public static final java.lang.String LABEL_TAG_ICON
- See Also:
- Constant Field Values
LABEL_TAG_TEXT
public static final java.lang.String LABEL_TAG_TEXT
- See Also:
- Constant Field Values
DEMO_TAG
public static final java.lang.String DEMO_TAG
- See Also:
- Constant Field Values
DEMO_TAG_TEXT
public static final java.lang.String DEMO_TAG_TEXT
- See Also:
- Constant Field Values
DEMO_TAG_CLASS
public static final java.lang.String DEMO_TAG_CLASS
- See Also:
- Constant Field Values
DEMO_TAG_ICON
public static final java.lang.String DEMO_TAG_ICON
- See Also:
- Constant Field Values
DEMOFILE_TAG
public static final java.lang.String DEMOFILE_TAG
- See Also:
- Constant Field Values
DEMOFILE_TAG_FILENAME
public static final java.lang.String DEMOFILE_TAG_FILENAME
- See Also:
- Constant Field Values
DEMOPACKAGE_TAG
public static final java.lang.String DEMOPACKAGE_TAG
- See Also:
- Constant Field Values
DEMOPACKAGE_TAG_SRC
public static final java.lang.String DEMOPACKAGE_TAG_SRC
- See Also:
- Constant Field Values
DEMOPACKAGE_TAG_VIEW
public static final java.lang.String DEMOPACKAGE_TAG_VIEW
- See Also:
- Constant Field Values
DEMOPACKAGE_TAG_VIEW_FLAT
public static final java.lang.String DEMOPACKAGE_TAG_VIEW_FLAT
- See Also:
- Constant Field Values
DEMOPACKAGE_TAG_VIEW_HIERARCHICAL
public static final java.lang.String DEMOPACKAGE_TAG_VIEW_HIERARCHICAL
- See Also:
- Constant Field Values
DEMOPACKAGE_TAG_BASECLASS
public static final java.lang.String DEMOPACKAGE_TAG_BASECLASS
- See Also:
- Constant Field Values
DEMOPACKAGE_TAG_REGEX
public static final java.lang.String DEMOPACKAGE_TAG_REGEX
- See Also:
- Constant Field Values
DEMOPACKAGE_TAG_COMPACT
public static final java.lang.String DEMOPACKAGE_TAG_COMPACT
- See Also:
- Constant Field Values
XMLINCLUDE_TAG
public static final java.lang.String XMLINCLUDE_TAG
- See Also:
- Constant Field Values
XMLINCLUDE_TAG_FILE
public static final java.lang.String XMLINCLUDE_TAG_FILE
- See Also:
- Constant Field Values
HIDDEN_TAG
public static final java.lang.String HIDDEN_TAG
- See Also:
- Constant Field Values
ALL_TAG_FONTNAME
public static final java.lang.String ALL_TAG_FONTNAME
- See Also:
- Constant Field Values
ALL_TAG_FONTSTYLE
public static final java.lang.String ALL_TAG_FONTSTYLE
- See Also:
- Constant Field Values
ALL_TAG_FONTSTYLE_BOLD
public static final java.lang.String ALL_TAG_FONTSTYLE_BOLD
- See Also:
- Constant Field Values
ALL_TAG_FONTSTYLE_ITALIC
public static final java.lang.String ALL_TAG_FONTSTYLE_ITALIC
- See Also:
- Constant Field Values
ALL_TAG_FONTSIZE
public static final java.lang.String ALL_TAG_FONTSIZE
- See Also:
- Constant Field Values
DemoMenuParser
public DemoMenuParser()
parseXML
public static Tree<MenuEntry> parseXML(java.lang.String filename)
throws java.io.IOException,
javax.xml.parsers.ParserConfigurationException,
org.xml.sax.SAXException
- Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
findFile
public static java.lang.String findFile(java.lang.String filename,
java.lang.String localPath)
- Finds a file specified by "file" First checks if file is specified by an
absolute path. If not found, checks if it's relative to the supplied
localPath. As a last resort, it searches ARTISYNTH_PATH
- Returns:
- The absolute path of the file, null if not found
compactMenu
public static void compactMenu(Tree<MenuEntry> menu)
- If a menu entry has only a single child, it merges it with this one and
the new title becomes "title1 (title2)"
setFont
public static void setFont(Node<MenuEntry> node,
java.awt.Font font)
sortMenu
public static void sortMenu(Node<MenuEntry> root,
java.util.Comparator<Node<MenuEntry>> comparer)
sortMenu
public static void sortMenu(Node<MenuEntry> root)
getPrefix
public static java.lang.String getPrefix(java.util.ArrayList<java.lang.String> array)
- Given a list of strings, finds the greatest common prefix
- Parameters:
array
- input array of strings
- Returns:
- the greatest common prefix