|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.ImageIcon
jmri.jmrit.catalog.NamedIcon
public class NamedIcon
Extend an ImageIcon to remember the name from which it was created and provide rotation & scaling services.
We store both a "URL" for finding the file this was made from (so we can load this later), plus a shorter "name" for display.
These can be persisted by storing their name and rotation
PositionableLabelXml,
Serialized Form| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.ImageIcon |
|---|
ImageIcon.AccessibleImageIcon |
| Field Summary |
|---|
| Fields inherited from class javax.swing.ImageIcon |
|---|
component, tracker |
| Constructor Summary | |
|---|---|
NamedIcon(NamedIcon pOld)
Create a NamedIcon that is a complete copy of an existing NamedIcon |
|
NamedIcon(NamedIcon pOld,
Component comp)
Create a NamedIcon that is really a complete copy of an existing NamedIcon |
|
NamedIcon(String pUrl,
String pName)
Create a named icon that includes an image to be loaded from a URL. |
|
NamedIcon(URL pUrl,
String pName)
Create a named icon that includes an image to be loaded from a URL. |
|
| Method Summary | |
|---|---|
Image |
createRotatedImage(Image pImage,
Component pComponent,
int pRotation)
The following was based on a text-rotating applet from David Risner, available at http://www.risner.org/java/rotate_text.html |
int |
getDegrees()
|
static NamedIcon |
getIconByName(String pName)
Find the NamedIcon corresponding to a name. |
String |
getName()
Return the human-readable name of this icon |
int |
getRotation()
Return the 0-3 number of 90-degree rotations needed to properly display this icon |
double |
getScale()
|
String |
getURL()
Return the URL of this icon |
double |
reduceTo(int width,
int height,
double limit)
If necessary, reduce this image to within 'width' x 'height' dimensions. |
void |
rotate(int deg,
Component comp)
Rotate from anchor point (upper left corner) and shift into place |
void |
scale(double scale,
Component comp)
Scale as a percentage public void scale(int s, Component comp) { //log.info("scale= "+s+", "+getDescription()); if (s<1) { return; } scale(s/100.0, comp); } |
void |
setLoad(int d,
double s,
Component comp)
|
void |
setName(String name)
Actually it is mName that is the URL that loads the icon! |
void |
setRotation(int pRotation,
Component comp)
Set the 0-3 number of 90-degree rotations needed to properly display this icon |
void |
transformImage(int w,
int h,
AffineTransform t,
Component comp)
|
| Methods inherited from class javax.swing.ImageIcon |
|---|
getAccessibleContext, getDescription, getIconHeight, getIconWidth, getImage, getImageLoadStatus, getImageObserver, loadImage, paintIcon, setDescription, setImage, setImageObserver, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public NamedIcon(NamedIcon pOld)
pOld - Object to copy
i.e. copy of the original icon, but NOT a complete
copy of pOld (no transformations done)
public NamedIcon(NamedIcon pOld,
Component comp)
pOld - Object to copy
public NamedIcon(String pUrl,
String pName)
The default access form is "file:", so a bare pathname to an icon file will also work for the URL argument
pUrl - URL of image file to loadpName - Human-readable name for the icon
public NamedIcon(URL pUrl,
String pName)
pUrl - String-form URL of image file to loadpName - Human-readable name for the icon| Method Detail |
|---|
public static NamedIcon getIconByName(String pName)
pName - The name string, possibly starting with file: or resource:
public String getName()
public void setName(String name)
public String getURL()
public int getRotation()
public void setRotation(int pRotation,
Component comp)
public Image createRotatedImage(Image pImage,
Component pComponent,
int pRotation)
pImage - Image to transformpComponent - Component containing the image, needed to obtain
a MediaTracker to process the image consistently with displaypRotation - 0-3 number of 90-degree rotations needed
public int getDegrees()
public double getScale()
public void setLoad(int d,
double s,
Component comp)
public void transformImage(int w,
int h,
AffineTransform t,
Component comp)
public void scale(double scale,
Component comp)
public void rotate(int deg,
Component comp)
public double reduceTo(int width,
int height,
double limit)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||