/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* The <code>RepaintArea</code> is a geometric construct created for the
* purpose of holding the geometry of several coalesced paint events.
* This geometry is accessed synchronously, although it is written such
* that painting may still be executed asynchronously.
*
* @author Eric Hawkes
* @since 1.3
*/
public class RepaintArea {
/**
* Maximum ratio of bounding rectangle to benefit for which
* both the vertical and horizontal unions are repainted.
* For smaller ratios the whole bounding rectangle is repainted.
* @see #paint
*/
/**
* Constructs a new <code>RepaintArea</code>
* @since 1.3
*/
public RepaintArea() {
}
/**
* Constructs a new <code>RepaintArea</code> initialized to match
* the values of the specified RepaintArea.
*
* @param ra the <code>RepaintArea</code> from which to copy initial
* values to a newly constructed RepaintArea
* @since 1.3
*/
// This constructor is private because it should only be called
// from the cloneAndReset method
for (int i = 0; i < RECT_COUNT; i++) {
}
}
/**
* Adds a <code>Rectangle</code> to this <code>RepaintArea</code>.
* PAINT Rectangles are divided into mostly vertical and mostly horizontal.
* Each group is unioned together.
* UPDATE Rectangles are unioned.
*
* @param r the specified <code>Rectangle</code>
* @param id possible values PaintEvent.UPDATE or PaintEvent.PAINT
* @since 1.3
*/
// Make sure this new rectangle has positive dimensions
if (r.isEmpty()) {
return;
}
}
} else {
}
}
/**
* Creates a new <code>RepaintArea</code> with the same geometry as this
* RepaintArea, then removes all of the geometry from this
* RepaintArea and restores it to an empty RepaintArea.
*
* @return ra a new <code>RepaintArea</code> having the same geometry as
* this RepaintArea.
* @since 1.3
*/
for (int i = 0; i < RECT_COUNT; i++) {
paintRects[i] = null;
}
return ra;
}
public boolean isEmpty() {
for (int i = 0; i < RECT_COUNT; i++) {
if (paintRects[i] != null) {
return false;
}
}
return true;
}
/**
* Constrains the size of the repaint area to the passed in bounds.
*/
public synchronized void constrain(int x, int y, int w, int h) {
for (int i = 0; i < RECT_COUNT; i++) {
if (rect.x < x) {
rect.x = x;
}
if (rect.y < y) {
rect.y = y;
}
if (xDelta > 0) {
}
if (yDelta > 0) {
}
paintRects[i] = null;
}
}
}
}
/**
* Marks the passed in region as not needing to be painted. It's possible
* this will do nothing.
*/
public synchronized void subtract(int x, int y, int w, int h) {
for (int i = 0; i < RECT_COUNT; i++) {
paintRects[i] = null;
}
}
}
}
/**
* Invokes paint and update on target Component with optimal
* rectangular clip region.
* If PAINT bounding rectangle is less than
* MAX_BENEFIT_RATIO times the benefit, then the vertical and horizontal unions are
* painted separately. Otherwise the entire bounding rectangle is painted.
*
* @param target Component to <code>paint</code> or <code>update</code>
* @since 1.4
*/
if (isEmpty()) {
return;
}
return;
}
}
// if benefit is comparable with bounding box
}
}
{
// Should use separate Graphics for each paint() call,
// since paint() can change Graphics state for next call.
if (g != null) {
try {
if (i == UPDATE) {
updateComponent(comp, g);
} else {
if (shouldClearRectBeforePaint) {
ra.paintRects[i].y,
}
paintComponent(comp, g);
}
} finally {
g.dispose();
}
}
}
}
}
/**
* Calls <code>Component.update(Graphics)</code> with given Graphics.
*/
}
}
/**
* Calls <code>Component.paint(Graphics)</code> with given Graphics.
*/
}
}
/**
* Subtracts subtr from rect. If the result is rectangle
* changes rect and returns true. Otherwise false.
*/
return true;
}
return true;
}
return true;
} else
return true;
}
} else
{
return true;
} else
return true;
}
}
return false;
}
}
}