public class IconGroup
extends java.lang.Object
RTextArea
. If the location of the icon
group is invalid in any way, any attempt to retrieve icons from an icon
group will return null
.
An icon group can logically refer to any set of icons. You will primarily fetch
icons via the getIcon(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 a fileTypes/
subpath. The icon names
should be the second "part" of the syntax constant values. For example:
getFileTypeIcon(String)
is shorthand for
getIcon("fileTypes/" + fileTypePart)
. The only added benefit to
using getFileTypeIcon()
is that method will default to the icon
named "fileTypes/default.<extension>"
if the actually-requested
icon does not exist.Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o2)
Returns whether two icon groups are equal.
|
javax.swing.Icon |
getFileTypeIcon(java.lang.String rstaSyntax)
Returns an icon that represents the file type specified.
|
javax.swing.Icon |
getIcon(java.lang.String name)
Returns the icon from this icon group with the specified name.
|
protected javax.swing.Icon |
getIconImpl(java.lang.String iconFullPath)
Does the dirty work of loading an image.
|
javax.swing.Icon |
getLargeIcon(java.lang.String name)
Returns the large icon from this icon group with the specified name.
|
java.lang.String |
getName()
Returns the name of this icon group.
|
int |
hashCode() |
boolean |
hasSeparateLargeIcons()
Returns whether a separate directory for the large icons exists.
|
public IconGroup(java.lang.String name, java.lang.String path)
name
- The name of the icon group.path
- The directory containing the icon group.public IconGroup(java.lang.String name, java.lang.String path, java.lang.String largeIconSubDir)
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 in null
.public IconGroup(java.lang.String name, java.lang.String path, java.lang.String largeIconSubDir, java.lang.String extension)
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 in null
.extension
- The extension of the icons (one of gif
,
jpg
, or png
).public IconGroup(java.lang.String name, java.lang.String path, java.lang.String largeIconSubDir, java.lang.String extension, java.lang.String jar)
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 in null
.extension
- The extension of the icons (one of gif
,
jpg
, or png
).jar
- The Jar file containing the icons, or null
if
the icons are on the local file system. If a Jar is specified,
the value of path
must 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 be
null
.public boolean equals(java.lang.Object o2)
equals
in class java.lang.Object
o2
- The object to check against.o2
represents the same icons as this icon
group.public javax.swing.Icon getFileTypeIcon(java.lang.String rstaSyntax)
rstaSyntax
- The syntax value, from SyntaxConstants
.null
if a fallback icon should be used.public javax.swing.Icon getIcon(java.lang.String name)
name
- The name of the icon. For example, if you want the icon
specified in new.gif
, this value should be
new
.null
if it could not be found or
loaded.getLargeIcon(java.lang.String)
protected javax.swing.Icon getIconImpl(java.lang.String iconFullPath)
This method is protected so applications can provide other implementations, for example, adding the ability to load SVG icons.
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.public javax.swing.Icon getLargeIcon(java.lang.String name)
null
is
returned.name
- The name of the icon. For example, if you want the icon
specified in new.gif
, this value should be
new
.null
if it could not be found or
loaded.getLargeIcon(java.lang.String)
public java.lang.String getName()
public boolean hasSeparateLargeIcons()
getLargeIcon(String)
public int hashCode()
hashCode
in class java.lang.Object