public class IlvExpensiveDrawingRepaintManager extends IlvAbstractRepaintManager
The default javax.swing.RepaintManager
combines any two dirty
rectangles that apply to the same Component into a single rectangle.
This class is more careful to minimize the area to be redrawn: It combines two dirty rectangles only sometimes. For example, it does not combine two small rectangles far apart on the screen.
This class is useful when you have a view which takes some time to redraw itself, due to complex or detailed drawing.
The constructor takes a few parameters that you can use to tune the performance of repainting. The optimal parameters will usually depend on the structure of the view.
An instance of this class can be installed through
RepaintManager.setCurrentManager(javax.swing.RepaintManager)
.
Constructor and Description |
---|
IlvExpensiveDrawingRepaintManager()
Creates a repaint manager with default parameters.
|
IlvExpensiveDrawingRepaintManager(double combineAreaRatioThreshold,
int combineAreaPixelsThreshold,
boolean combineVertically,
boolean combineHorizontally)
Creates a repaint manager with given parameters.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addRectangle(LinkedList<Rectangle> list,
int x,
int y,
int w,
int h)
Adds a rectangle to a region, represented as a list of rectangles.
|
protected JComponent |
getDirtyComponentParent(JComponent comp)
Returns the parent component of the given Swing component, or
null when repainting shall be performed with the given Swing
component directly. |
protected boolean |
isTopLevelComponent(Component comp)
Returns true if the given component is considered a top-level component.
|
protected void |
paintDirtyComponent(JComponent comp,
Rectangle rect)
Paints the designated region, part of the given Swing component, in the
current thread.
|
addDirtyRegion, addInvalidComponent, getDirtyRegion, isCompletelyDirty, markCompletelyClean, paintDirtyRegions, removeInvalidComponent, validateInvalidComponents
addDirtyRegion, addDirtyRegion, currentManager, currentManager, getDoubleBufferMaximumSize, getOffscreenBuffer, getVolatileOffscreenBuffer, isDoubleBufferingEnabled, markCompletelyDirty, setCurrentManager, setDoubleBufferingEnabled, setDoubleBufferMaximumSize, toString
public IlvExpensiveDrawingRepaintManager()
public IlvExpensiveDrawingRepaintManager(double combineAreaRatioThreshold, int combineAreaPixelsThreshold, boolean combineVertically, boolean combineHorizontally)
combineAreaRatioThreshold
- When merging two dirty rectangles into a single one, this variable
limits the increase of the area of the rectangles: The merge will
only be performed if the new rectangle's area is at most the sum
of the two rectangles to be merged. multiplied with The default
value is 2.0. combineAreaRatioThreshold.combineAreaPixelsThreshold
- When merging two dirty rectangles into a single one, this variable
limits the increase of the area of the rectangles: The merge will
only be performed if the new rectangle's area is at most the sum
of the two rectangles to be merged, plus
combineAreaPixelsThreshold
. The default value is
10000, standing for a 100x100 pixels square.combineVertically
- If this flag is true
, rectangles whose x ranges
overlap will be merged. This is useful if the view contains mostly
vertical objects, and if drawing such an object entirely is faster
than drawing two pieces of it. The default value is
faslse
.combineHorizontally
- If this flag is true
, rectangles whose y ranges
overlap will be merged. This is useful if the view contains mostly
horizontal objects, and if drawing such an object entirely is
faster than drawing two pieces of it. The default value is
faslse
.protected void addRectangle(LinkedList<Rectangle> list, int x, int y, int w, int h)
addRectangle
in class IlvAbstractRepaintManager
list
- A list of rectangles, each having a width > 0 and a height > 0x
- The x coordinate of the top left point of the additional
rectangle.y
- the y coordinate of the top left point of the additional
rectangle.w
- The width of the additional rectangle. Must be > 0.h
- The height of the additional rectangle. Must be > 0.protected boolean isTopLevelComponent(Component comp)
java.awt.Window
and java.applet.Applet
.isTopLevelComponent
in class IlvAbstractRepaintManager
comp
- The component to check.java.awt.Window
or java.awt.Applet
, false
otherwise.protected JComponent getDirtyComponentParent(JComponent comp)
null
when repainting shall be performed with the given Swing
component directly.getDirtyComponentParent
in class IlvAbstractRepaintManager
comp
- The component of the parent to check.comp
is an instance
of JComponent
, null otherwise.protected void paintDirtyComponent(JComponent comp, Rectangle rect)
paintDirtyComponent
in class IlvAbstractRepaintManager
comp
- A Swing component.rect
- A rectangle, in coordinates relative to comp
.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.