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 String
CATEGORY_HELP
the "Help" category.static String
CATEGORY_MACHINELEARNING
the "Machine learning" category.static String
CATEGORY_MAINTENANCE
the "Maintenance" category.static String
CATEGORY_PROGRAM
the "Program" category.static String
CATEGORY_TOOLS
the "Tools" category.static String
CATEGORY_VISUALIZATION
the "Visualization" category.static String
CATEGORY_WIZARD
the "Wizard" category.protected AbstractApplicationFrame
m_Owner
the 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 int
compareTo(AbstractMenuItemDefinition o)
Uses category and title for sorting.protected ChildFrame
createChildFrame(Component c)
Creates a frame and returns it.protected ChildFrame
createChildFrame(Component c, Dimension size)
creates a frame and returns it.boolean
equals(Object obj)
Checks whether the obj is the same definition (using category/title).static AbstractMenuItemDefinition
forCommandLine(AbstractApplicationFrame owner, String cmdline)
Instantiates the menu item definition from the given commandline (i.e., classname and optional parameters).static AbstractMenuItemDefinition
forName(AbstractApplicationFrame owner, String classname, String[] params)
Returns a menu item definition based on the classname and optional parameters.String
getActualCategory()
Returns the actual category of the menu item in which it should appear, i.e., the name of the menu.abstract String
getCategory()
Returns the category of the menu item in which it should appear, i.e., the name of the menu.ImageIcon
getIcon()
Returns the icon.String
getIconName()
Returns the file name of the icon.protected Logger
getLogger()
Returns the logger.abstract JMenuItem
getMenuItem()
Returns the JMenuItem to use.AbstractApplicationFrame
getOwner()
Returns the owning application.abstract String
getTitle()
Returns the title of the window (and text of menuitem).abstract UserMode
getUserMode()
Returns the user mode, which determines visibility as well.protected void
initialize()
Initializes members.boolean
isAvailable()
Returns whether the menu item is available.abstract boolean
isSingleton()
Whether the panel can only be displayed once.boolean
requiresRestartableApplication()
Returns whether the menu item requires a restartable application.void
setOwner(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:
compareTo
in 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:
equals
in 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
-
-