|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
org.jdesktop.swingx.renderer.JRendererLabel
public class JRendererLabel
A JLabel
optimized for usage in renderers and
with a minimal background painter support.
Note: the painter support will be switched to painter_work as soon it enters main. The reasoning for the performance-overrides is copied from core:
The standard JLabel
component was not
designed to be used this way and we want to avoid
triggering a revalidate
each time the
cell is drawn. This would greatly decrease performance because the
revalidate
message would be
passed up the hierarchy of the container to determine whether any other
components would be affected.
As the renderer is only parented for the lifetime of a painting operation
we similarly want to avoid the overhead associated with walking the
hierarchy for painting operations.
So this class
overrides the validate
, invalidate
,
revalidate
, repaint
, and
firePropertyChange
methods to be
no-ops and override the isOpaque
method solely to improve
performance. If you write your own renderer component,
please keep this performance consideration in mind.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JLabel |
---|
JLabel.AccessibleJLabel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected Painter |
painter
|
Fields inherited from class javax.swing.JLabel |
---|
labelFor |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.SwingConstants |
---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JRendererLabel()
|
Method Summary | |
---|---|
void |
firePropertyChange(String propertyName,
boolean oldValue,
boolean newValue)
Overridden for performance reasons. |
protected void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Overridden for performance reasons. |
Painter |
getPainter()
|
void |
invalidate()
Overridden for performance reasons. |
boolean |
isOpaque()
Overridden for performance reasons. |
protected void |
paintComponent(Graphics g)
Calls the UI delegate's paint method, if the UI delegate is non- null . |
protected void |
paintComponentWithPainter(Graphics2D g)
PRE: painter != null, isOpaque() |
void |
repaint()
Overridden for performance reasons. |
void |
repaint(long tm,
int x,
int y,
int width,
int height)
Overridden for performance reasons. |
void |
repaint(Rectangle r)
Overridden for performance reasons. |
void |
revalidate()
Overridden for performance reasons. |
void |
setPainter(Painter painter)
|
void |
setToolTipText(String text)
Registers the text to display in a tool tip. |
void |
validate()
Overridden for performance reasons. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Painter painter
Constructor Detail |
---|
public JRendererLabel()
Method Detail |
---|
public boolean isOpaque()
PENDING: Think about Painters and opaqueness?
isOpaque
in class JComponent
JComponent.setOpaque(boolean)
public void setPainter(Painter painter)
setPainter
in interface PainterAware
public Painter getPainter()
getPainter
in interface PainterAware
protected void paintComponent(Graphics g)
null
. We pass the delegate a copy of the
Graphics
object to protect the rest of the
paint code from irrevocable changes
(for example, Graphics.translate
).
If you override this in a subclass you should not make permanent
changes to the passed in Graphics
. For example, you
should not alter the clip Rectangle
or modify the
transform. If you need to do these operations you may find it
easier to create a new Graphics
from the passed in
Graphics
and manipulate it. Further, if you do not
invoker super's implementation you must honor the opaque property,
that is
if this component is opaque, you must completely fill in the background
in a non-opaque color. If you do not honor the opaque property you
will likely see visual artifacts.
The passed in Graphics
object might
have a transform other than the identify transform
installed on it. In this case, you might get
unexpected results if you cumulatively apply
another transform.
Overridden to inject Painter's painting.
TODO: cleanup logic - see JRendererCheckBox.
paintComponent
in class JComponent
g
- the Graphics
object to protectJComponent.paint(java.awt.Graphics)
,
ComponentUI
protected void paintComponentWithPainter(Graphics2D g)
g
- public void setToolTipText(String text)
See How to Use Tool Tips in The Java Tutorial for further documentation.
Overridden to not automatically de/register itself from/to the ToolTipManager. As rendering component it is not considered to be active in any way, so the manager must not listen.
setToolTipText
in class JComponent
text
- the string to display; if the text is null
,
the tool tip is turned off for this componentJComponent.TOOL_TIP_TEXT_KEY
public void invalidate()
invalidate
in class Container
Container.validate()
,
Container.layout()
,
LayoutManager
public void validate()
validate
in class Container
Container.add(java.awt.Component)
,
Component.invalidate()
,
JComponent.revalidate()
public void revalidate()
revalidate
in class JComponent
Component.invalidate()
,
Container.validate()
,
JComponent.isValidateRoot()
,
RepaintManager.addInvalidComponent(javax.swing.JComponent)
public void repaint(long tm, int x, int y, int width, int height)
repaint
in class JComponent
tm
- this parameter is not usedx
- the x value of the dirty regiony
- the y value of the dirty regionwidth
- the width of the dirty regionheight
- the height of the dirty regionComponent.isShowing()
,
RepaintManager.addDirtyRegion(javax.swing.JComponent, int, int, int, int)
public void repaint(Rectangle r)
repaint
in class JComponent
r
- a Rectangle
containing the dirty regionComponent.isShowing()
,
RepaintManager.addDirtyRegion(javax.swing.JComponent, int, int, int, int)
public void repaint()
repaint
in class Component
Component.update(Graphics)
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
firePropertyChange
in class Component
propertyName
- the property whose value has changedoldValue
- the property's previous valuenewValue
- the property's new valuepublic void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
firePropertyChange
in class JComponent
propertyName
- the property whose value has changedoldValue
- the property's previous valuenewValue
- the property's new value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |