|
Copyright 2011-09-18 Werner Randelshofer | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Graphics
java.awt.Graphics2D
ch.randelshofer.awt.graphics.Pipe
ch.randelshofer.awt.graphics.AbstractPipe
ch.randelshofer.awt.graphics.OpaquePipe
ch.randelshofer.awt.graphics.OpaqueAntialiasingPipe
public class OpaqueAntialiasingPipe
A rendering pipe to render graphics primitives with antialiasing with opaque colors. This Graphics2D object only works with a BufferedImage which has the following characteristics:
int and with the RGB bit masks: 0xff0000, 0xff00, 0xff.
Usage:
// Create a raster and a buffered image using the supported characteristics.
WritableRaster ras = Raster.createWritableRaster(
new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT, gw, gh,
new int[] {0xff0000, 0xff00, 0xff}),
new Point(0,0)
);
BufferedImage bufferedImage = new BufferedImage(
new DirectColorModel(24, 0xff0000, 0xff00, 0xff),
ras, false, new Hashtable());
// Create the graphics object
OpaqueAntialiasingPipe g = new OpaqueAntialiasingPipe(bufferedImage);
// Perform the grapics operations
g.drawLine(0,0,100,100);
XXX - This is a purely experimental implementation. Eventually all code
here will be replaced by algorithms taken from the anti-grain project.
| Field Summary | |
|---|---|
protected int |
alpha
Precomputed values to speed up alpha compositing. |
protected int |
blueBits
|
protected int |
greenBits
|
protected int |
oneMinusAlpha
|
protected int |
premultipliedB
|
protected int |
premultipliedG
|
protected int |
premultipliedR
|
protected int |
previousIn
|
protected int |
previousOut
|
protected int |
redBits
|
| Fields inherited from class ch.randelshofer.awt.graphics.OpaquePipe |
|---|
color, colorBar, edges |
| Fields inherited from class ch.randelshofer.awt.graphics.AbstractPipe |
|---|
background, flatness, mis, pixels, previousClip, previousTransform, ras, tx, ty, u1, u2 |
| Fields inherited from class ch.randelshofer.awt.graphics.Pipe |
|---|
cx1, cx2, cy1, cy2, gh, gw |
| Constructor Summary | |
|---|---|
OpaqueAntialiasingPipe(java.awt.image.BufferedImage image)
Creates a new instance. |
|
| Method Summary | |
|---|---|
protected void |
blend(int xy,
int intensity)
Blends an individual pixel at the specified coordinate with the specified alpha transparency. |
void |
draw(java.awt.Shape s)
|
void |
drawLine(int x1,
int y1,
int x2,
int y2)
|
void |
fill(java.awt.Shape s)
|
void |
fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
|
protected void |
plot(int xy)
Plots a single pixel. |
protected void |
plotH(int scan,
ch.randelshofer.awt.graphics.Edge active)
Fills a scan line between pairs of edges in the active edge list. |
protected void |
plotHClipped(int scan,
ch.randelshofer.awt.graphics.Edge active)
Fills a scan line between pairs of edges in the active edge list. |
protected void |
plotLine(int x1,
int y1,
int x2,
int y2)
Wu antialised line algorithm taken from: http://www.codeproject.com/gdi/antialias.asp#dwuln |
protected void |
plotVClipped(int scan,
ch.randelshofer.awt.graphics.Edge active)
|
protected void |
scanFillHorizontal(int[] x,
int[] y,
int cnt,
int miny,
int maxy)
ScanFill algorithm for shapes which are wider than tall. |
protected void |
scanFillVertical(int[] x,
int[] y,
int cnt,
int minx,
int maxx)
ScanFill algorithm for shapes which are taller than wide. |
void |
setColor(java.awt.Color c)
|
| Methods inherited from class ch.randelshofer.awt.graphics.OpaquePipe |
|---|
buildActiveList, buildEdgeListHorizontal, buildEdgeListVertical, deleteAfter, drawDigital, drawGlyphVector, drawOval, drawPolygon, drawPolyline, drawRect, drawWithSubpixelAccuracy, fillOval, fillRect, getColor, insertEdge, makeEdgeRecHorizontal, makeEdgeRecVertical, prepareEdgeList, resortActiveList, updateActiveList, xNext, yNext |
| Methods inherited from class ch.randelshofer.awt.graphics.AbstractPipe |
|---|
arrayfill, clearRect, clipRect, clipTest, clipTest, flush, getBackground, setBackground, setClip, setClip, setComposite, setTransform, transform, translate, translate |
| Methods inherited from class ch.randelshofer.awt.graphics.Pipe |
|---|
addRenderingHints, clip, copyArea, create, dispose, drawArc, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawRenderableImage, drawRenderedImage, drawRoundRect, drawString, drawString, drawString, drawString, fillArc, fillRoundRect, getClip, getClipBounds, getComposite, getDeviceConfiguration, getFont, getFontMetrics, getFontRenderContext, getPaint, getRenderingHint, getRenderingHints, getStroke, getTransform, hit, rotate, rotate, scale, setFont, setPaint, setPaintMode, setRenderingHint, setRenderingHints, setStroke, setXORMode, shear, toString |
| Methods inherited from class java.awt.Graphics2D |
|---|
draw3DRect, fill3DRect |
| Methods inherited from class java.awt.Graphics |
|---|
create, drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected int alpha
protected int oneMinusAlpha
protected int premultipliedR
protected int premultipliedG
protected int premultipliedB
protected int previousIn
protected int previousOut
protected int redBits
protected int greenBits
protected int blueBits
| Constructor Detail |
|---|
public OpaqueAntialiasingPipe(java.awt.image.BufferedImage image)
| Method Detail |
|---|
public void drawLine(int x1,
int y1,
int x2,
int y2)
drawLine in class OpaquePipe
protected void plotLine(int x1,
int y1,
int x2,
int y2)
x1 - start point of liney1 - start point of linex2 - end point of liney2 - end point of lineprotected void plot(int xy)
protected void blend(int xy,
int intensity)
xy - coordinate of the pixelintensity - 0=fully transparent, 255=fully opaquepublic void setColor(java.awt.Color c)
setColor in class OpaquePipepublic void draw(java.awt.Shape s)
draw in class OpaquePipe
public void fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
fillPolygon in class OpaquePipepublic void fill(java.awt.Shape s)
fill in class OpaquePipe
protected void scanFillHorizontal(int[] x,
int[] y,
int cnt,
int miny,
int maxy)
scanFillHorizontal in class OpaquePipeminy - Must be = smallest y and >= cy1.maxy - Must be = biggest y and <= cy2.
protected void scanFillVertical(int[] x,
int[] y,
int cnt,
int minx,
int maxx)
scanFillVertical in class OpaquePipeminx - Must be = smallest x and >= cx1.maxx - Must be = biggest x and <= cx2.
protected void plotHClipped(int scan,
ch.randelshofer.awt.graphics.Edge active)
protected void plotH(int scan,
ch.randelshofer.awt.graphics.Edge active)
protected void plotVClipped(int scan,
ch.randelshofer.awt.graphics.Edge active)
|
Copyright 2011-09-18 Werner Randelshofer | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||