gnu.java.awt.java2d

Class ScanlineCoverage


public final class ScanlineCoverage
extends Object

Stores and handles the pixel converage for a scanline. The pixel coverage is stored as sorted list of entries, each of which holds information about the coverage for the X and Y axis. This is utilized to compute the actual coverage for each pixel on the scanline and finding chunks of pixels with equal coverage quickly.

Nested Class Summary

class
ScanlineCoverage.Iterator
Iterates over the coverage list and calculates the actual coverage ranges on a scanline.
static class
ScanlineCoverage.Range
A data object that carries information about pixel coverage on a scanline.

Constructor Summary

ScanlineCoverage()
Creates a new ScanlineCoverage instance.

Method Summary

void
add(int x, int xc, int yc)
This adds the specified coverage to the pixel at the specified X position.
void
clear()
Clears the list.
int
getMaxCoverage()
Returns the maximum coverage value for the scanline.
int
getMaxX()
Returns the maximum X coordinate of the current scanline.
int
getMinX()
Returns the minimum X coordinate of the current scanline.
boolean
isEmpty()
Returns if this object has no entries for the current scanline, otherwise.
ScanlineCoverage.Iterator
iterate()
(Re-)Starts iterating the coverage values for the scanline.
void
rewind()
Indicates the the next scan of the scanline begins and that the next request will be at the beginning of this list.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

ScanlineCoverage

public ScanlineCoverage()
Creates a new ScanlineCoverage instance.

Method Details

add

public void add(int x,
                int xc,
                int yc)
This adds the specified coverage to the pixel at the specified X position.
Parameters:
x - the X position
xc - the x coverage
yc - the y coverage

clear

public void clear()
Clears the list. This does not throw away the old buckets but only resets the end-pointer of the list to the first element. All buckets are then unused and are reused when the list is filled again.

getMaxCoverage

public int getMaxCoverage()
Returns the maximum coverage value for the scanline.
Returns:
the maximum coverage value for the scanline

getMaxX

public int getMaxX()
Returns the maximum X coordinate of the current scanline.
Returns:
the maximum X coordinate of the current scanline

getMinX

public int getMinX()
Returns the minimum X coordinate of the current scanline.
Returns:
the minimum X coordinate of the current scanline

isEmpty

public boolean isEmpty()
Returns if this object has no entries for the current scanline, otherwise.
Returns:
if this object has no entries for the current scanline, otherwise

iterate

public ScanlineCoverage.Iterator iterate()
(Re-)Starts iterating the coverage values for the scanline. Use the returned iterator to get the consecutive coverage ranges.
Returns:
the iterator

rewind

public void rewind()
Indicates the the next scan of the scanline begins and that the next request will be at the beginning of this list. This makes searching and sorting of this list very quick.

ScanlineCoverage.java -- Manages coverage information for a scanline Copyright (C) 2007 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath 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 for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.