E - component typepublic class NinePatchStatePainter<E extends javax.swing.JComponent,U extends javax.swing.plaf.ComponentUI> extends AbstractPainter<E,U>
NinePatchState,
NinePatchIcon,
NinePatchIconPainter,
AbstractPainter,
Painter| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<java.lang.String,NinePatchIcon> |
stateIcons
Map containing separate 9-patch icons for different component states.
|
component, listeners, ltr, propertyChangeListener, ui| Constructor and Description |
|---|
NinePatchStatePainter()
Constructs new 9-patch state painter with empty states.
|
NinePatchStatePainter(java.util.Map<java.lang.String,NinePatchIcon> stateIcons)
Constructs new 9-patch state painter with specified state icons.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addStateIcon(java.lang.String state,
NinePatchIcon ninePatchIcon)
Adds painter state.
|
java.awt.Insets |
getBorders()
Returns borders required for visual data provided by this painter.
|
protected NinePatchIcon |
getButtonBackground(javax.swing.AbstractButton button)
Returns current state icon for the specified button.
|
protected NinePatchIcon |
getComponentBackground(E component)
Returns current state icon for the specified component.
|
NinePatchIcon |
getExactStateIcon(java.lang.String state)
Returns exact state icon or null if it is not specified.
|
java.awt.Dimension |
getPreferredSize()
Returns preferred size required for proper painting of visual data provided by this painter.
|
NinePatchIcon |
getStateIcon(java.lang.String state)
Returns state icon or possible replacement for it.
|
java.util.Map<java.lang.String,NinePatchIcon> |
getStateIcons()
Returns states map.
|
protected NinePatchIcon |
getToolBarBackground(javax.swing.JToolBar toolbar)
Returns current state icon for the specified toolbar.
|
boolean |
hasStateIcons()
Returns whether at least one state icon is available or not.
|
protected boolean |
isFocused(E component)
Returns whether component is in focused state or not.
|
void |
paint(java.awt.Graphics2D g2d,
java.awt.Rectangle bounds,
E c,
U ui)
Paints visual data using component graphics context.
|
void |
removeStateIcon(java.lang.String state)
Removes painter state.
|
void |
setStateIcons(java.util.Map<java.lang.String,NinePatchIcon> stateIcons)
Sets states map.
|
addPainterListener, b, borderChange, getCompleteBorder, i, i, i, install, installPropertyChangeListener, isOpaque, isSectionPainter, isSettingsUpdateAllowed, orientationChange, p, propertyChange, removePainterListener, repaint, repaint, repaint, revalidate, saveOrientation, uninstall, uninstallPropertyChangeListener, updateAll, updateBorder, updateOpacity, updateOrientationprotected java.util.Map<java.lang.String,NinePatchIcon> stateIcons
public NinePatchStatePainter()
public NinePatchStatePainter(java.util.Map<java.lang.String,NinePatchIcon> stateIcons)
stateIcons - state icons mappublic java.util.Map<java.lang.String,NinePatchIcon> getStateIcons()
public void setStateIcons(java.util.Map<java.lang.String,NinePatchIcon> stateIcons)
stateIcons - states mappublic void addStateIcon(java.lang.String state,
NinePatchIcon ninePatchIcon)
state - state to addninePatchIcon - 9-patch iconpublic void removeStateIcon(java.lang.String state)
state - state to removepublic boolean hasStateIcons()
protected boolean isFocused(E component)
component - component to processprotected NinePatchIcon getComponentBackground(E component)
component - component to processprotected NinePatchIcon getButtonBackground(javax.swing.AbstractButton button)
button - button to processprotected NinePatchIcon getToolBarBackground(javax.swing.JToolBar toolbar)
toolbar - toolbar to processpublic NinePatchIcon getExactStateIcon(java.lang.String state)
state - component statepublic NinePatchIcon getStateIcon(java.lang.String state)
state - component statepublic java.awt.Insets getBorders()
Painter
You may pass null in case additional borders aren't needed for this painter.
getBorders in interface Painter<E extends javax.swing.JComponent,U extends javax.swing.plaf.ComponentUI>getBorders in class AbstractPainter<E extends javax.swing.JComponent,U extends javax.swing.plaf.ComponentUI>null in case those aren't neededpublic void paint(java.awt.Graphics2D g2d,
java.awt.Rectangle bounds,
E c,
U ui)
PainterIt is highly recommended to honor provided painting bounds to avoid painting issues. These bounds might be representing full component size or contain just a small portion of the component.
g2d - graphics contextbounds - painting boundsc - painted componentui - painted component UIpublic java.awt.Dimension getPreferredSize()
PaintergetPreferredSize in interface Painter<E extends javax.swing.JComponent,U extends javax.swing.plaf.ComponentUI>getPreferredSize in class AbstractPainter<E extends javax.swing.JComponent,U extends javax.swing.plaf.ComponentUI>