Package adams.gui.application
Class AbstractMenuItemDefinition
- java.lang.Object
-
- adams.gui.application.AbstractMenuItemDefinition
-
- All Implemented Interfaces:
Serializable,Comparable<AbstractMenuItemDefinition>
- Direct Known Subclasses:
AbstractBasicMenuItemDefinition,AbstractSubMenuDefinition,AntiAliasing
public abstract class AbstractMenuItemDefinition extends Object implements Serializable, Comparable<AbstractMenuItemDefinition>
Abstract ancestor for definining menu items in the ApplicationFrame menu.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringCATEGORY_HELPthe "Help" category.static StringCATEGORY_MACHINELEARNINGthe "Machine learning" category.static StringCATEGORY_MAINTENANCEthe "Maintenance" category.static StringCATEGORY_PROGRAMthe "Program" category.static StringCATEGORY_TOOLSthe "Tools" category.static StringCATEGORY_VISUALIZATIONthe "Visualization" category.static StringCATEGORY_WIZARDthe "Wizard" category.protected AbstractApplicationFramem_Ownerthe owning application.
-
Constructor Summary
Constructors Constructor Description AbstractMenuItemDefinition()Initializes the menu item with no owner.AbstractMenuItemDefinition(AbstractApplicationFrame owner)Initializes the menu item.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intcompareTo(AbstractMenuItemDefinition o)Uses category and title for sorting.protected ChildFramecreateChildFrame(Component c)Creates a frame and returns it.protected ChildFramecreateChildFrame(Component c, Dimension size)creates a frame and returns it.booleanequals(Object obj)Checks whether the obj is the same definition (using category/title).static AbstractMenuItemDefinitionforCommandLine(AbstractApplicationFrame owner, String cmdline)Instantiates the menu item definition from the given commandline (i.e., classname and optional parameters).static AbstractMenuItemDefinitionforName(AbstractApplicationFrame owner, String classname, String[] params)Returns a menu item definition based on the classname and optional parameters.StringgetActualCategory()Returns the actual category of the menu item in which it should appear, i.e., the name of the menu.abstract StringgetCategory()Returns the category of the menu item in which it should appear, i.e., the name of the menu.ImageIcongetIcon()Returns the icon.StringgetIconName()Returns the file name of the icon.protected LoggergetLogger()Returns the logger.abstract JMenuItemgetMenuItem()Returns the JMenuItem to use.AbstractApplicationFramegetOwner()Returns the owning application.abstract StringgetTitle()Returns the title of the window (and text of menuitem).abstract UserModegetUserMode()Returns the user mode, which determines visibility as well.protected voidinitialize()Initializes members.booleanisAvailable()Returns whether the menu item is available.abstract booleanisSingleton()Whether the panel can only be displayed once.booleanrequiresRestartableApplication()Returns whether the menu item requires a restartable application.voidsetOwner(AbstractApplicationFrame value)Sets the owning application.
-
-
-
Field Detail
-
CATEGORY_PROGRAM
public static final String CATEGORY_PROGRAM
the "Program" category.- See Also:
- Constant Field Values
-
CATEGORY_VISUALIZATION
public static final String CATEGORY_VISUALIZATION
the "Visualization" category.- See Also:
- Constant Field Values
-
CATEGORY_MACHINELEARNING
public static final String CATEGORY_MACHINELEARNING
the "Machine learning" category.- See Also:
- Constant Field Values
-
CATEGORY_TOOLS
public static final String CATEGORY_TOOLS
the "Tools" category.- See Also:
- Constant Field Values
-
CATEGORY_WIZARD
public static final String CATEGORY_WIZARD
the "Wizard" category.- See Also:
- Constant Field Values
-
CATEGORY_MAINTENANCE
public static final String CATEGORY_MAINTENANCE
the "Maintenance" category.- See Also:
- Constant Field Values
-
CATEGORY_HELP
public static final String CATEGORY_HELP
the "Help" category.- See Also:
- Constant Field Values
-
m_Owner
protected AbstractApplicationFrame m_Owner
the owning application.
-
-
Constructor Detail
-
AbstractMenuItemDefinition
public AbstractMenuItemDefinition()
Initializes the menu item with no owner.
-
AbstractMenuItemDefinition
public AbstractMenuItemDefinition(AbstractApplicationFrame owner)
Initializes the menu item.- Parameters:
owner- the owning application
-
-
Method Detail
-
initialize
protected void initialize()
Initializes members.
Default implementation does nothing.
-
setOwner
public void setOwner(AbstractApplicationFrame value)
Sets the owning application.- Parameters:
value- the owner
-
getOwner
public AbstractApplicationFrame getOwner()
Returns the owning application.- Returns:
- the owner
-
isAvailable
public boolean isAvailable()
Returns whether the menu item is available.- Returns:
- true if available
-
getIconName
public String getIconName()
Returns the file name of the icon.- Returns:
- the filename or null if no icon available
-
getIcon
public ImageIcon getIcon()
Returns the icon.- Returns:
- the icon or null if no icon available
-
getMenuItem
public abstract JMenuItem getMenuItem()
Returns the JMenuItem to use.- Returns:
- the menu item
-
getTitle
public abstract String getTitle()
Returns the title of the window (and text of menuitem).- Returns:
- the title
-
compareTo
public int compareTo(AbstractMenuItemDefinition o)
Uses category and title for sorting.- Specified by:
compareToin interfaceComparable<AbstractMenuItemDefinition>- Parameters:
o- the other definition to compare with- Returns:
- less than zero, zero, or greater than zero if this menuitem is less than, equal to or greater than the other definition
- See Also:
getActualCategory(),getTitle()
-
equals
public boolean equals(Object obj)
Checks whether the obj is the same definition (using category/title).- Overrides:
equalsin classObject- Parameters:
obj- the object to compare with- Returns:
- true if the same definition
- See Also:
compareTo(AbstractMenuItemDefinition)
-
isSingleton
public abstract boolean isSingleton()
Whether the panel can only be displayed once.- Returns:
- true if the panel can only be displayed once
-
getUserMode
public abstract UserMode getUserMode()
Returns the user mode, which determines visibility as well.- Returns:
- the user mode
-
getCategory
public abstract String getCategory()
Returns the category of the menu item in which it should appear, i.e., the name of the menu.- Returns:
- the category/menu name
-
getActualCategory
public String getActualCategory()
Returns the actual category of the menu item in which it should appear, i.e., the name of the menu.- Returns:
- the category/menu name
-
requiresRestartableApplication
public boolean requiresRestartableApplication()
Returns whether the menu item requires a restartable application.- Returns:
- true if a restartable application is required
-
createChildFrame
protected ChildFrame createChildFrame(Component c)
Creates a frame and returns it. Doesn't change width or height.- Parameters:
c- the component to place, can be null- Returns:
- the generated frame
-
createChildFrame
protected ChildFrame createChildFrame(Component c, Dimension size)
creates a frame and returns it.- Parameters:
c- the component to place, can be nullsize- the size of the frame, ignored if -1 and -1- Returns:
- the generated frame
-
getLogger
protected Logger getLogger()
Returns the logger.- Returns:
- the logger
-
forCommandLine
public static AbstractMenuItemDefinition forCommandLine(AbstractApplicationFrame owner, String cmdline)
Instantiates the menu item definition from the given commandline (i.e., classname and optional parameters).- Parameters:
owner- the owning application framecmdline- the classname (and optional parameters) of the menu item definition to instantiate- Returns:
- the instantiated menu item definition or null if an error occurred
-
forName
public static AbstractMenuItemDefinition forName(AbstractApplicationFrame owner, String classname, String[] params)
Returns a menu item definition based on the classname and optional parameters.- Parameters:
owner- the owning application frameclassname- the class name of the menu itemparams- the optional parameters, can be null- Returns:
- the generated menu item definition, null in case of an error
-
-