public class TLcdResizeableIcon extends Object implements ILcdResizeableIcon, ILcdAnchoredIcon
Wrapper implementation of ILcdResizeableIcon
that rescales the
wrapped icon when it is too large to fit the given size. When the wrapped icon
is smaller than the asked size, it is painted centered.
Notice that this class is not guaranteed to work correctly with non-static icons.
Constructor and Description |
---|
TLcdResizeableIcon(ILcdIcon aDelegateIcon)
Constructs a new
TLcdResizeableIcon with the height and width of the icon
aDelegateIcon . |
TLcdResizeableIcon(ILcdIcon aDelegateIcon,
int aIconWidth,
int aIconHeight)
Constructs a new
TLcdResizeableIcon where the width and/or height can be specified. |
Modifier and Type | Method and Description |
---|---|
void |
anchorPointSFCT(Point aPointSFCT)
Updates the given point to the location of the icon's anchor point, in relative coordinates with respect to the top left.
|
Object |
clone()
Makes
Object.clone() public. |
boolean |
equals(Object obj) |
ILcdIcon |
getDelegateIcon()
Returns the base icon.
|
int |
getIconHeight()
Returns the fixed height of the icon.
|
int |
getIconWidth()
Returns the fixed width of the icon.
|
int |
hashCode() |
void |
paintIcon(Component c,
Graphics g,
int x,
int y)
Draw the
ILcdIcon at the specified location. |
void |
setDelegateIcon(ILcdIcon aDelegateIcon)
Sets the base icon.
|
void |
setIconHeight(int aIconHeight)
Set the height of the icon.
|
void |
setIconWidth(int aIconWidth)
Set the width of the icon.
|
String |
toString() |
public TLcdResizeableIcon(ILcdIcon aDelegateIcon)
TLcdResizeableIcon
with the height and width of the icon
aDelegateIcon
. Notice that this class is not guaranteed to work correctly with
non-static icons.aDelegateIcon
- the base icon. Must not be null
public TLcdResizeableIcon(ILcdIcon aDelegateIcon, int aIconWidth, int aIconHeight)
TLcdResizeableIcon
where the width and/or height can be specified. Notice that this
class is not guaranteed to work correctly with non-static icons.aDelegateIcon
- the base icon. null
is allowed: nothing is painted.aIconWidth
- when set to -1, the width is scaled in a relative manner. The height must be set in this case to a value greater than zeroaIconHeight
- when set to -1, the height is scaled in a relative manner. The width must be set in this case to a value greater than zeropublic ILcdIcon getDelegateIcon()
Returns the base icon.
setDelegateIcon(ILcdIcon)
public void setDelegateIcon(ILcdIcon aDelegateIcon)
Sets the base icon.
aDelegateIcon
- the new base icongetDelegateIcon()
public void paintIcon(Component c, Graphics g, int x, int y)
ILcdIcon
ILcdIcon
at the specified location. ILcdIcon
implementations
may use the Component
argument to get properties useful for
painting, e.g. the foreground or background color.paintIcon
in interface ILcdIcon
c
- a Component to retrieve properties from.g
- the Graphics on which the icon will be painted.x
- the x position where the icon will be painted. x is the first coordinate of the top left
corner point of the icon.y
- the y position where the icon will be painted. y is the second coordinate of the top left
corner point of the icon.public int getIconWidth()
ILcdIcon
getIconWidth
in interface ILcdIcon
public void setIconWidth(int aIconWidth)
ILcdResizeableIcon
setIconWidth
in interface ILcdResizeableIcon
aIconWidth
- the new width.public int getIconHeight()
ILcdIcon
getIconHeight
in interface ILcdIcon
public void setIconHeight(int aIconHeight)
ILcdResizeableIcon
setIconHeight
in interface ILcdResizeableIcon
aIconHeight
- the new height.public Object clone()
ILcdCloneable
Makes Object.clone()
public.
java.lang.Object
, it can be implemented like this:
public Object clone() {
try {
return super.clone();
} catch ( CloneNotSupportedException e ) {
// Cannot happen: extends from Object and implements Cloneable (see also Object.clone)
throw new RuntimeException( e );
}
}
clone
in interface ILcdCloneable
clone
in class Object
Object.clone()
public void anchorPointSFCT(Point aPointSFCT)
This implementation reuses the anchor point of the delegate icon. If the delegate icon is resized, the anchor point is shifted accordingly. If the delegate icon is not anchored, the icon center is returned.
anchorPointSFCT
in interface ILcdAnchoredIcon
aPointSFCT
- the point that has to be moved to the location of the anchor point