Package adams.gui.core
Class TitleGenerator
- java.lang.Object
-
- adams.gui.core.TitleGenerator
-
- All Implemented Interfaces:
Serializable
public class TitleGenerator extends Object implements Serializable
A simple helper class for generating titles for frames and dialogs.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX_CHARS
the default max chars.protected boolean
m_Enabled
whether the generator is enabled.protected int
m_MaxChars
the maximum chars for shortening.protected ShorteningType
m_Shortening
whether to shorten the file (or parent).protected boolean
m_Split
whether to split the full filename into path and filename.protected String
m_Title
the base title.
-
Constructor Summary
Constructors Constructor Description TitleGenerator(String title, boolean split)
Initializes the generator.TitleGenerator(String title, boolean split, ShorteningType shortening)
Initializes the generator.TitleGenerator(String title, boolean split, ShorteningType shortening, int maxChars)
Initializes the generator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
generate()
Generates the default title.String
generate(boolean modified)
Generates the default title.String
generate(File file)
Generates a title for the given file.String
generate(File file, boolean modified)
Generates a title for the given file.String
generate(String filename)
Generates a title for the given file.String
generate(String filename, boolean modified)
Generates a title for the given file.String
generateAny(String subtitle)
Generates a title for the given sub-title.String
generateAny(String subtitle, boolean modified)
Generates a title for the given sub-title.int
getMaxChars()
Returns the maximum number of characters used for shortening the filename.ShorteningType
getShortening()
Returns how the file is being shortened.boolean
getSplit()
Returns whether the filename is split into path and name part.String
getTitle()
Returns the base title.boolean
isEnabled()
Returns whether the generator is enabled.void
setEnabled(boolean value)
Sets whether the generator is enabled.void
setTitle(String value)
Sets the base title.protected String
shorten(String s)
Shortens the string.
-
-
-
Field Detail
-
DEFAULT_MAX_CHARS
public static final int DEFAULT_MAX_CHARS
the default max chars.- See Also:
- Constant Field Values
-
m_Title
protected String m_Title
the base title.
-
m_Split
protected boolean m_Split
whether to split the full filename into path and filename.
-
m_Shortening
protected ShorteningType m_Shortening
whether to shorten the file (or parent).
-
m_MaxChars
protected int m_MaxChars
the maximum chars for shortening.
-
m_Enabled
protected boolean m_Enabled
whether the generator is enabled.
-
-
Constructor Detail
-
TitleGenerator
public TitleGenerator(String title, boolean split)
Initializes the generator. Uses no shortening.- Parameters:
title
- the base title.split
- whether to split the filename into path/name
-
TitleGenerator
public TitleGenerator(String title, boolean split, ShorteningType shortening)
Initializes the generator. Uses the specified shortening withDEFAULT_MAX_CHARS
.- Parameters:
title
- the base title.split
- whether to split the filename into path/nameshortening
- how to shorten the filename (if at all)
-
TitleGenerator
public TitleGenerator(String title, boolean split, ShorteningType shortening, int maxChars)
Initializes the generator.- Parameters:
title
- the base title.split
- whether to split the filename into path/nameshortening
- how to shorten the filename (if at all)maxChars
- the maximum number of characters for the shortened filename
-
-
Method Detail
-
setTitle
public void setTitle(String value)
Sets the base title.- Parameters:
value
- the title
-
getTitle
public String getTitle()
Returns the base title.- Returns:
- the title
-
getSplit
public boolean getSplit()
Returns whether the filename is split into path and name part.- Returns:
- true if split
-
getShortening
public ShorteningType getShortening()
Returns how the file is being shortened.- Returns:
- the shortening type
-
getMaxChars
public int getMaxChars()
Returns the maximum number of characters used for shortening the filename.- Returns:
- the max chars
- See Also:
getShortening()
-
setEnabled
public void setEnabled(boolean value)
Sets whether the generator is enabled.- Parameters:
value
- true if enabled
-
isEnabled
public boolean isEnabled()
Returns whether the generator is enabled.- Returns:
- true if enabled
-
generate
public String generate()
Generates the default title.- Returns:
- the generated title
-
generate
public String generate(boolean modified)
Generates the default title.- Parameters:
modified
- whether the data is modified- Returns:
- the generated title
-
generate
public String generate(String filename)
Generates a title for the given file.- Parameters:
filename
- the file to generate the title for, can be null- Returns:
- the generated title
-
generate
public String generate(String filename, boolean modified)
Generates a title for the given file.- Parameters:
filename
- the file to generate the title for, can be nullmodified
- whether the file is modified- Returns:
- the generated title
-
generate
public String generate(File file)
Generates a title for the given file.- Parameters:
file
- the file to generate the title for, can be null- Returns:
- the generated title
-
shorten
protected String shorten(String s)
Shortens the string.- Parameters:
s
- the string to shorten- Returns:
- the processed string
- See Also:
getShortening()
,getMaxChars()
-
generate
public String generate(File file, boolean modified)
Generates a title for the given file.- Parameters:
file
- the file to generate the title for, can be nullmodified
- whether the file is modified- Returns:
- the generated title
-
generateAny
public String generateAny(String subtitle)
Generates a title for the given sub-title. Does not apply a split.- Parameters:
subtitle
- the sub-title to generate the title for, can be null- Returns:
- the generated title
-
-