Package org.fife.ui.rtextarea
Class IconGroup
- java.lang.Object
-
- org.fife.ui.rtextarea.IconGroup
-
public class IconGroup extends java.lang.ObjectThis class encapsulates the location, properties, etc. of an icon set used for an instance ofRTextArea. If the location of the icon group is invalid in any way, any attempt to retrieve icons from an icon group will returnnull. An icon group can logically refer to any set of icons. You will primarily fetch icons via thegetIcon(String)method, which fetches an icon at the specified path from the icon group's jar.However, to support embedding RSTA in applications that are code editors, icon groups also support defining icons for file types that RSTA supports, as defined in
SyntaxConstants. To use this feature, have your icon group have icons in afileTypes/subpath. The icon names should be the second "part" of the syntax constant values. For example:- fileTypes/default.png
- fileTypes/java.png
- fileTypes/javascript.png
getFileTypeIcon(String)is shorthand forgetIcon("fileTypes/" + fileTypePart). The only added benefit to usinggetFileTypeIcon()is that method will default to the icon named"fileTypes/default.<extension>"if the actually-requested icon does not exist.- Version:
- 0.5
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringDEFAULT_EXTENSIONprivate java.lang.Stringextensionprivate java.lang.StringjarFileprivate java.lang.StringlargeIconSubDirprivate java.lang.Stringnameprivate java.lang.Stringpathprivate booleanseparateLargeIcons
-
Constructor Summary
Constructors Constructor Description IconGroup(java.lang.String name, java.lang.String path)Creates an icon set without "large versions" of the icons.IconGroup(java.lang.String name, java.lang.String path, java.lang.String largeIconSubDir)Constructor.IconGroup(java.lang.String name, java.lang.String path, java.lang.String largeIconSubDir, java.lang.String extension)Constructor.IconGroup(java.lang.String name, java.lang.String path, java.lang.String largeIconSubDir, java.lang.String extension, java.lang.String jar)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o2)Returns whether two icon groups are equal.javax.swing.IcongetFileTypeIcon(java.lang.String rstaSyntax)Returns an icon that represents the file type specified.javax.swing.IcongetIcon(java.lang.String name)Returns the icon from this icon group with the specified name.protected javax.swing.IcongetIconImpl(java.lang.String iconFullPath)Does the dirty work of loading an image.javax.swing.IcongetLargeIcon(java.lang.String name)Returns the large icon from this icon group with the specified name.java.lang.StringgetName()Returns the name of this icon group.inthashCode()booleanhasSeparateLargeIcons()Returns whether a separate directory for the large icons exists.
-
-
-
Field Detail
-
path
private java.lang.String path
-
separateLargeIcons
private boolean separateLargeIcons
-
largeIconSubDir
private java.lang.String largeIconSubDir
-
extension
private java.lang.String extension
-
name
private java.lang.String name
-
jarFile
private java.lang.String jarFile
-
DEFAULT_EXTENSION
private static final java.lang.String DEFAULT_EXTENSION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IconGroup
public IconGroup(java.lang.String name, java.lang.String path)Creates an icon set without "large versions" of the icons.- Parameters:
name- The name of the icon group.path- The directory containing the icon group.
-
IconGroup
public IconGroup(java.lang.String name, java.lang.String path, java.lang.String largeIconSubDir)Constructor.- Parameters:
name- The name of the icon group.path- The directory containing the icon group.largeIconSubDir- The subdirectory containing "large versions" of the icons. If no subdirectory exists, pass innull.
-
IconGroup
public IconGroup(java.lang.String name, java.lang.String path, java.lang.String largeIconSubDir, java.lang.String extension)Constructor.- Parameters:
name- The name of the icon group.path- The directory containing the icon group.largeIconSubDir- The subdirectory containing "large versions" of the icons. If no subdirectory exists, pass innull.extension- The extension of the icons (one ofgif,jpg, orpng).
-
IconGroup
public IconGroup(java.lang.String name, java.lang.String path, java.lang.String largeIconSubDir, java.lang.String extension, java.lang.String jar)Constructor.- Parameters:
name- The name of the icon group.path- The directory containing the icon group.largeIconSubDir- The subdirectory containing "large versions" of the icons. If no subdirectory exists, pass innull.extension- The extension of the icons (one ofgif,jpg, orpng).jar- The Jar file containing the icons, ornullif the icons are on the local file system. If a Jar is specified, the value ofpathmust be a path in the Jar file. If this is not a valid Jar file, then no Jar file will be used, meaning all icons returned from this icon group will benull.
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object o2)
Returns whether two icon groups are equal.- Overrides:
equalsin classjava.lang.Object- Parameters:
o2- The object to check against.- Returns:
- Whether
o2represents the same icons as this icon group.
-
getFileTypeIcon
public javax.swing.Icon getFileTypeIcon(java.lang.String rstaSyntax)
Returns an icon that represents the file type specified.- Parameters:
rstaSyntax- The syntax value, fromSyntaxConstants.- Returns:
- The icon, or
nullif a fallback icon should be used.
-
getIcon
public javax.swing.Icon getIcon(java.lang.String name)
Returns the icon from this icon group with the specified name.- Parameters:
name- The name of the icon. For example, if you want the icon specified innew.gif, this value should benew.- Returns:
- The icon, or
nullif it could not be found or loaded. - See Also:
getLargeIcon(java.lang.String)
-
getIconImpl
protected javax.swing.Icon getIconImpl(java.lang.String iconFullPath)
Does the dirty work of loading an image.This method is protected so applications can provide other implementations, for example, adding the ability to load SVG icons.
- Parameters:
iconFullPath- The full path to the icon, either on the local file system or in the Jar file, if this icon group represents icons in a Jar file.- Returns:
- The icon.
-
getLargeIcon
public javax.swing.Icon getLargeIcon(java.lang.String name)
Returns the large icon from this icon group with the specified name. If this icon group does not have large icons,nullis returned.- Parameters:
name- The name of the icon. For example, if you want the icon specified innew.gif, this value should benew.- Returns:
- The icon, or
nullif it could not be found or loaded. - See Also:
getLargeIcon(java.lang.String)
-
getName
public java.lang.String getName()
Returns the name of this icon group.- Returns:
- This icon group's name.
-
hasSeparateLargeIcons
public boolean hasSeparateLargeIcons()
Returns whether a separate directory for the large icons exists.- Returns:
- Whether a directory containing "large versions" of the icons exists.
- See Also:
getLargeIcon(String)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-