E - component typeU - component UI typeD - decoration typepublic abstract class AbstractDecorationPainter<E extends javax.swing.JComponent,U extends javax.swing.plaf.ComponentUI,D extends IDecoration<E,D>> extends AbstractPainter<E,U> implements PainterShapeProvider<E>
| Modifier and Type | Field and Description |
|---|---|
protected java.awt.Container |
ancestor |
static java.lang.String |
DECORATION_STATES_PROPERTY
Decoratable states property.
|
protected java.util.Map<java.lang.String,D> |
decorationCache |
protected java.util.List<D> |
decorations
Decoration states.
|
protected boolean |
focused |
protected FocusTracker |
focusStateTracker
Listeners.
|
protected java.awt.event.HierarchyListener |
hierarchyTracker |
protected boolean |
hover |
protected AbstractHoverBehavior<E> |
hoverStateTracker |
protected java.awt.event.ContainerListener |
neighboursTracker |
protected java.util.List<java.lang.String> |
states
Runtime variables.
|
component, listeners, ltr, propertyChangeListener, ui| Constructor and Description |
|---|
AbstractDecorationPainter() |
| Modifier and Type | Method and Description |
|---|---|
protected java.awt.Rectangle |
adjustBounds(java.awt.Rectangle bounds)
Returns adjusted painting bounds.
|
protected java.util.List<SectionPainter<E,U>> |
asList(SectionPainter<E,U>... sections)
Returns section painters list in a most optimal way.
|
protected java.util.List<java.lang.String> |
collectDecorationStates()
Returns properly sorted current component decoration states.
|
java.awt.Insets |
getBorders()
Returns borders required for visual data provided by this painter.
|
protected D |
getDecoration()
Returns decoration matching current states.
|
protected java.util.List<D> |
getDecorations(java.util.List<java.lang.String> forStates)
Returns decorations for the specified states.
|
protected java.awt.Dimension |
getDecorationSize()
Returns preferred decoration size.
|
protected java.util.List<java.lang.String> |
getDecorationStates()
Returns current component decoration states.
|
java.awt.Dimension |
getPreferredSize()
Returns preferred size required for proper painting of visual data provided by this painter.
|
protected java.util.List<SectionPainter<E,U>> |
getSectionPainters()
Returns section painters used within this painter.
|
void |
install(E c,
U ui)
Called when painter is installed onto some component.
|
protected void |
installFocusListener()
Installs listener that will perform decoration updates on focus state change.
|
protected void |
installHierarchyListener()
Installs listener that will perform border updates on component hierarchy changes.
|
protected void |
installHoverListener()
Installs listener that will perform decoration updates on hover state change.
|
boolean |
isDecorated()
Returns whether or not decoration is available.
|
protected boolean |
isDecorationPaintAllowed(D decoration)
Returns whether or not painting specified decoration is allowed.
|
protected boolean |
isEnabled()
Returns whether or not component is in enabled state.
|
protected boolean |
isFocused()
Returns whether or not component has focus.
|
protected boolean |
isHover()
Returns whether or not component is in hover state.
|
java.lang.Boolean |
isOpaque()
Returns whether visual data provided by this painter is opaque or not.
|
protected java.lang.Boolean |
isOpaqueDecorated()
Returns opacity state for decorated component.
|
protected java.lang.Boolean |
isOpaqueUndecorated()
Returns opacity state for undecorated component.
|
protected boolean |
isPlainBackgroundPaintAllowed(E c)
Returns whether or not painting plain component background is allowed.
|
void |
paint(java.awt.Graphics2D g2d,
java.awt.Rectangle bounds,
E c,
U ui)
Paints visual data using component graphics context.
|
protected void |
paintContent(java.awt.Graphics2D g2d,
java.awt.Rectangle bounds,
E c,
U ui)
Paints content decorated by this painter.
|
protected void |
propertyChange(java.lang.String property,
java.lang.Object oldValue,
java.lang.Object newValue)
Performs various updates on property changes.
|
java.awt.Shape |
provideShape(E component,
java.awt.Rectangle bounds)
Returns painted component shape.
|
void |
uninstall(E c,
U ui)
Called when painter is installed into some component.
|
protected void |
uninstallFocusListener()
Uninstalls listener that performs decoration updates on focus state change.
|
protected void |
uninstallHierarchyListener()
Uninstalls listener that performs border updates on component hierarchy changes.
|
protected void |
uninstallHoverListener()
Uninstalls listener that performs decoration updates on hover state change.
|
protected void |
updateDecorationState()
Performs current decoration state update.
|
protected boolean |
usesState(java.util.List<D> decorations,
java.lang.String state)
Returns whether specified decorations are associated with specified state.
|
protected boolean |
usesState(java.lang.String state)
Returns whether component has decoration associated with specified state.
|
addPainterListener, b, borderChange, getCompleteBorder, i, i, i, installPropertyChangeListener, isSectionPainter, isSettingsUpdateAllowed, orientationChange, p, removePainterListener, repaint, repaint, repaint, revalidate, saveOrientation, uninstallPropertyChangeListener, updateAll, updateBorder, updateOpacity, updateOrientationpublic static final java.lang.String DECORATION_STATES_PROPERTY
protected java.util.List<D extends IDecoration<E,D>> decorations
protected transient FocusTracker focusStateTracker
protected transient AbstractHoverBehavior<E extends javax.swing.JComponent> hoverStateTracker
protected transient java.awt.event.HierarchyListener hierarchyTracker
protected transient java.awt.event.ContainerListener neighboursTracker
protected transient java.util.List<java.lang.String> states
protected transient java.util.Map<java.lang.String,D extends IDecoration<E,D>> decorationCache
protected transient boolean focused
protected transient boolean hover
protected transient java.awt.Container ancestor
public void install(E c, U ui)
Painterinstall in interface Painter<E extends javax.swing.JComponent,U extends javax.swing.plaf.ComponentUI>install in class AbstractPainter<E extends javax.swing.JComponent,U extends javax.swing.plaf.ComponentUI>c - component this painter is being installed ontoui - component UIpublic void uninstall(E c, U ui)
Painteruninstall in interface Painter<E extends javax.swing.JComponent,U extends javax.swing.plaf.ComponentUI>uninstall in class AbstractPainter<E extends javax.swing.JComponent,U extends javax.swing.plaf.ComponentUI>c - component this painter is being uninstalled fromui - component UIprotected void propertyChange(java.lang.String property,
java.lang.Object oldValue,
java.lang.Object newValue)
AbstractPainterpropertyChange in class AbstractPainter<E extends javax.swing.JComponent,U extends javax.swing.plaf.ComponentUI>property - modified propertyoldValue - old property valuenewValue - new property valueprotected void installFocusListener()
protected void uninstallFocusListener()
protected boolean isFocused()
protected void installHoverListener()
protected void uninstallHoverListener()
protected void installHierarchyListener()
protected void uninstallHierarchyListener()
protected boolean isHover()
protected java.util.List<SectionPainter<E,U>> getSectionPainters()
null in case no section painters are used within this one.
This method is used for various internal update mechanisms involving section painters.protected final java.util.List<SectionPainter<E,U>> asList(SectionPainter<E,U>... sections)
sections - section painters, some or all of them can be nullprotected boolean isEnabled()
protected final java.util.List<java.lang.String> collectDecorationStates()
protected java.util.List<java.lang.String> getDecorationStates()
protected boolean usesState(java.lang.String state)
state - decoration stateprotected final boolean usesState(java.util.List<D> decorations, java.lang.String state)
decorations - decorationsstate - decoration stateprotected java.util.List<D> getDecorations(java.util.List<java.lang.String> forStates)
forStates - decoration states to retrieve decoration forprotected D getDecoration()
protected void updateDecorationState()
public boolean isDecorated()
public 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 java.awt.Shape provideShape(E component, java.awt.Rectangle bounds)
PainterShapeProviderprovideShape in interface PainterShapeProvider<E extends javax.swing.JComponent>component - component to processbounds - bounds for painter visual datapublic java.lang.Boolean isOpaque()
PainterisOpaque in interface Painter<E extends javax.swing.JComponent,U extends javax.swing.plaf.ComponentUI>isOpaque in class AbstractPainter<E extends javax.swing.JComponent,U extends javax.swing.plaf.ComponentUI>protected java.lang.Boolean isOpaqueDecorated()
protected java.lang.Boolean isOpaqueUndecorated()
public 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.
protected java.awt.Rectangle adjustBounds(java.awt.Rectangle bounds)
bounds - painting bounds to adjustprotected void paintContent(java.awt.Graphics2D g2d,
java.awt.Rectangle bounds,
E c,
U ui)
g2d - graphics contextbounds - painting boundsc - painted componentui - painted component UIprotected boolean isPlainBackgroundPaintAllowed(E c)
By default this condition is limited to component being opaque. When component is opaque we must fill every single pixel in its bounds with something to avoid issues.
c - component to paint background forprotected boolean isDecorationPaintAllowed(D decoration)
By default this condition is limited to decoration existance and visibility.
decoration - decoration to be paintedpublic 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>protected java.awt.Dimension getDecorationSize()