Package docking.util
Class BadgedIcon
- java.lang.Object
-
- docking.util.BadgedIcon
-
- All Implemented Interfaces:
javax.swing.Icon
public class BadgedIcon extends java.lang.Object implements javax.swing.Icon
An icon that allows sub-icons to be added at key perimeter locations. Each position can be manipulated independently, adding and removing icons as desired. Additionally, each position can be toggled enabled or disabled, or visible or invisible.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BadgedIcon.BadgePosition
-
Constructor Summary
Constructors Constructor Description BadgedIcon(javax.swing.Icon baseIcon)
BadgedIcon(javax.swing.Icon baseIcon, boolean enabled)
BadgedIcon(javax.swing.Icon baseIcon, boolean enabled, int width, int height)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BadgedIcon
addBadge(javax.swing.Icon badge, BadgedIcon.BadgePosition position)
Add an icon at the specified locationBadgedIcon
addScaledBadge(javax.swing.Icon icon, int newWidth, int newHeight, BadgedIcon.BadgePosition position)
javax.swing.Icon[]
getBadges(BadgedIcon.BadgePosition pos)
Return array of Icons that were added to this BadgedIcon.int
getIconHeight()
int
getIconWidth()
boolean
isBadgeEnabled(BadgedIcon.BadgePosition position)
Get the enablement status of the badge at the specified locationboolean
isBadgeVisible(BadgedIcon.BadgePosition position)
Get the visibility status of the badge at the specified locationboolean
isEnabled()
Determine the overall enablement appearance state.void
paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
BadgedIcon
removeBadge(BadgedIcon.BadgePosition position)
Remove the badge from the specified locationBadgedIcon
setBadge(javax.swing.Icon badge, BadgedIcon.BadgePosition position)
Replace the existing icon with the provided icon at the specified locationvoid
setBadgeEnabled(BadgedIcon.BadgePosition position, boolean enabled)
Set the enablement of the badge at the specified locationvoid
setBadgeVisisble(BadgedIcon.BadgePosition position, boolean visible)
Set the visibility status of the badge at the specified locationvoid
setEnabled(boolean enabled)
Set the 'enabled' appearance of the entire icon.java.lang.String
toString()
-
-
-
Method Detail
-
addBadge
public BadgedIcon addBadge(javax.swing.Icon badge, BadgedIcon.BadgePosition position)
Add an icon at the specified location- Parameters:
badge
- The iconposition
- Where to place the image- Returns:
- a reference to this object
-
addScaledBadge
public BadgedIcon addScaledBadge(javax.swing.Icon icon, int newWidth, int newHeight, BadgedIcon.BadgePosition position)
-
setBadge
public BadgedIcon setBadge(javax.swing.Icon badge, BadgedIcon.BadgePosition position)
Replace the existing icon with the provided icon at the specified location- Parameters:
badge
- The iconposition
- Where to place the image- Returns:
- a reference to this object
-
removeBadge
public BadgedIcon removeBadge(BadgedIcon.BadgePosition position)
Remove the badge from the specified location- Parameters:
position
- Where to place the image- Returns:
- a reference to this object
-
setBadgeEnabled
public void setBadgeEnabled(BadgedIcon.BadgePosition position, boolean enabled)
Set the enablement of the badge at the specified location- Parameters:
position
- Which icon to modifyenabled
- True if the image should be shown 'enabled', false otherwise- See Also:
isBadgeEnabled(BadgePosition)
-
isBadgeEnabled
public boolean isBadgeEnabled(BadgedIcon.BadgePosition position)
Get the enablement status of the badge at the specified location- Parameters:
position
- Which icon to enquire about- Returns:
- True if the badge is enabled, false otherwise
- See Also:
setBadgeEnabled(BadgePosition, boolean)
-
setBadgeVisisble
public void setBadgeVisisble(BadgedIcon.BadgePosition position, boolean visible)
Set the visibility status of the badge at the specified location- Parameters:
position
- Which icon to modifyvisible
- True if the badge should be visible, false otherwise- See Also:
isBadgeVisible(BadgePosition)
-
isBadgeVisible
public boolean isBadgeVisible(BadgedIcon.BadgePosition position)
Get the visibility status of the badge at the specified location- Parameters:
position
- Which icon to enquire about- Returns:
- True if the badge is visible, false otherwise
- See Also:
setBadgeVisisble(BadgePosition, boolean)
-
getIconHeight
public int getIconHeight()
- Specified by:
getIconHeight
in interfacejavax.swing.Icon
- See Also:
Icon.getIconHeight()
-
getIconWidth
public int getIconWidth()
- Specified by:
getIconWidth
in interfacejavax.swing.Icon
- See Also:
Icon.getIconWidth()
-
isEnabled
public boolean isEnabled()
Determine the overall enablement appearance state.- Returns:
- true if the if the entire icon is rendered as 'enabled'; false otherwise.
-
setEnabled
public void setEnabled(boolean enabled)
Set the 'enabled' appearance of the entire icon. Preserves the underlying enablement state of badges, though the entire icon looks disabled ifsetEnabled(true)
is called.- Parameters:
enabled
-
-
getBadges
public javax.swing.Icon[] getBadges(BadgedIcon.BadgePosition pos)
Return array of Icons that were added to this BadgedIcon.
-
paintIcon
public void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
- Specified by:
paintIcon
in interfacejavax.swing.Icon
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-