public class IconStore
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
IconStore.SizedIcon
Icon implementation which looks like an existing one, but is resized
down if necessary.
|
Modifier and Type | Field and Description |
---|---|
private javax.swing.Icon |
defaultIcon_ |
private static java.util.logging.Logger |
logger_ |
private static java.util.Map |
urlIconMap_ |
Constructor and Description |
---|
IconStore(javax.swing.Icon defaultIcon)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static javax.swing.Icon |
createEmptyIcon(int size)
Returns an icon with no content but a given size.
|
static javax.swing.Icon |
createMinimalIcon(int size)
Returns an icon which indicates a shape but doesn't look like much.
|
(package private) static javax.swing.Icon |
createResourceIcon(java.lang.String fileName)
Constructs an icon given a file name in the images directory.
|
javax.swing.Icon |
getIcon(Client client)
Returns the icon associated with a given client.
|
javax.swing.Icon |
getIcon(java.lang.String url)
Returns the icon supplied by the graphic file at a given URL.
|
private static javax.swing.Icon |
readIcon(java.lang.String url,
int waitSecs)
Reads an icon from a URL, with a maximum wait time.
|
static javax.swing.Icon |
scaleIcon(javax.swing.Icon icon,
int fixDim,
double maxAspect,
boolean fixVertical)
Icon implementation which is rescaled to so that one dimension
(either width or height) has a fixed value.
|
static javax.swing.Icon |
sizeIcon(javax.swing.Icon icon,
int size)
Return an icon based on an existing one, but drawn to an exact size.
|
private final javax.swing.Icon defaultIcon_
private static final java.util.Map urlIconMap_
private static final java.util.logging.Logger logger_
public IconStore(javax.swing.Icon defaultIcon)
defaultIcon
- icon returned if no client icon is availablepublic javax.swing.Icon getIcon(java.lang.String url)
url
- URL of imagepublic javax.swing.Icon getIcon(Client client)
client
- client whose icon is requiredpublic static javax.swing.Icon createEmptyIcon(int size)
size
- edge size in pixelspublic static javax.swing.Icon createMinimalIcon(int size)
size
- dimension in pixelsstatic javax.swing.Icon createResourceIcon(java.lang.String fileName)
fileName
- file name omitting directorypublic static javax.swing.Icon sizeIcon(javax.swing.Icon icon, int size)
icon
- original icon, or null for blanksize
- number of horizontal and vertical pixels in outputicon
public static javax.swing.Icon scaleIcon(javax.swing.Icon icon, int fixDim, double maxAspect, boolean fixVertical)
icon
- input iconfixDim
- the fixed dimension in pixelsmaxAspect
- maximum aspect ratio (>= 1)fixVertical
- true to fix height, false to fix widthprivate static javax.swing.Icon readIcon(java.lang.String url, int waitSecs) throws java.io.IOException
url
- icon URLwaitSecs
- maximum time in seconds to waitjava.io.IOException
- if timeout has been exceeded