|
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.ConcurrentTranslucentPipe
public class ConcurrentTranslucentPipe
Renders non-antialiased, translucent drawing primitives with pixel accuracy. Supports translation on X- and Y-axis by full pixels.
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
ConcurrentTranslucentPipe g = new ConcurrentTranslucentPipe(bufferedImage);
// Perform the grapics operations
g.drawLine(0,0,100,100);
| Field Summary | |
|---|---|
protected int |
color
Current drawing color. |
protected Dispatcher |
dispatcher
Dispatcher for Runnable objects. |
protected ch.randelshofer.awt.graphics.Edge[] |
edges
Is filled with a list of edges for each scan line. |
protected int |
oneMinusAlpha
Precomputed values to speed up alpha compositing. |
protected int |
premultipliedB
|
protected int |
premultipliedG
|
protected int |
premultipliedR
|
protected int |
previousIn
|
protected int |
previousOut
|
| 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 | |
|---|---|
ConcurrentTranslucentPipe(java.awt.image.BufferedImage image,
Dispatcher dispatcher)
Creates a new instance. |
|
| Method Summary | |
|---|---|
protected void |
buildActiveList(int scan,
ch.randelshofer.awt.graphics.Edge active)
|
protected void |
buildEdgeListHorizontal(int[] x,
int[] y,
int cnt)
|
protected void |
buildEdgeListVertical(int[] x,
int[] y,
int cnt)
|
protected void |
deleteAfter(ch.randelshofer.awt.graphics.Edge q)
|
void |
draw(java.awt.Shape s)
|
void |
drawLine(int x1,
int y1,
int x2,
int y2)
|
void |
drawOval(int ox,
int oy,
int owidth,
int oheight)
|
void |
drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
FIXME - Must use drawLineSegment for all line segments except for the last one in order to prevent pixels at line joints from overlapping! |
void |
drawPolyline(int[] xPoints,
int[] yPoints,
int nPoints)
FIXME - Must use drawLineSegment for all line segments except for the last one in order to prevent pixels at line joints from overlapping! |
void |
drawRect(int x,
int y,
int width,
int height)
|
void |
fill(java.awt.Shape s)
|
void |
fillOval(int ox,
int oy,
int owidth,
int oheight)
|
void |
fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
|
void |
fillRect(int x,
int y,
int width,
int height)
|
void |
flush()
Flushes all pending graphics operations of the rendering pipe into its underlying image. |
java.awt.Color |
getColor()
|
protected void |
insertEdge(ch.randelshofer.awt.graphics.Edge list,
ch.randelshofer.awt.graphics.Edge edge)
Inserts edge into list in order of increasing edge.intersect |
protected void |
makeEdgeRecHorizontal(int lower,
int upper,
int yComp,
ch.randelshofer.awt.graphics.Edge edge,
int[] x,
int[] y)
|
protected void |
makeEdgeRecVertical(int lower,
int upper,
int xComp,
ch.randelshofer.awt.graphics.Edge edge,
int[] x,
int[] y)
|
protected void |
plotHClipped(int scan,
ch.randelshofer.awt.graphics.Edge active)
|
protected void |
plotVClipped(int scan,
ch.randelshofer.awt.graphics.Edge active)
|
protected void |
prepareEdgeList(int scan)
|
protected void |
resortActiveList(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 using a concurrent algorithm. |
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)
|
protected void |
updateActiveList(int scan,
ch.randelshofer.awt.graphics.Edge active)
|
protected int |
xNext(int k,
int[] x,
int[] y,
int cnt)
given an index, returns x coordinate of next nonvertical line |
protected int |
yNext(int k,
int[] x,
int[] y,
int cnt)
given an index, returns y coordinate of next nonhorizontal line |
| Methods inherited from class ch.randelshofer.awt.graphics.AbstractPipe |
|---|
arrayfill, clearRect, clipRect, clipTest, clipTest, getBackground, setBackground, setClip, setClip, setComposite, setTransform, transform, translate, translate |
| Methods inherited from class ch.randelshofer.awt.graphics.Pipe |
|---|
addRenderingHints, clip, copyArea, create, dispose, drawArc, drawGlyphVector, 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 oneMinusAlpha
protected int premultipliedR
protected int premultipliedG
protected int premultipliedB
protected int previousIn
protected int previousOut
protected int color
protected Dispatcher dispatcher
protected ch.randelshofer.awt.graphics.Edge[] edges
| Constructor Detail |
|---|
public ConcurrentTranslucentPipe(java.awt.image.BufferedImage image,
Dispatcher dispatcher)
| Method Detail |
|---|
public void flush()
Pipe
flush in class AbstractPipepublic void setColor(java.awt.Color c)
setColor in class Pipepublic java.awt.Color getColor()
getColor in class Pipe
public void drawRect(int x,
int y,
int width,
int height)
drawRect in class java.awt.Graphics
public void fillRect(int x,
int y,
int width,
int height)
fillRect in class Pipe
public void drawLine(int x1,
int y1,
int x2,
int y2)
drawLine in class java.awt.Graphics
public void drawOval(int ox,
int oy,
int owidth,
int oheight)
drawOval in class Pipe
public void fillOval(int ox,
int oy,
int owidth,
int oheight)
fillOval in class Pipe
public void drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
drawPolygon in class Pipe
public void drawPolyline(int[] xPoints,
int[] yPoints,
int nPoints)
drawPolyline in class Pipe
public void fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
fillPolygon in class Pipepublic void draw(java.awt.Shape s)
draw in class Pipepublic void fill(java.awt.Shape s)
fill in class Pipe
protected void scanFillHorizontal(int[] x,
int[] y,
int cnt,
int miny,
int maxy)
miny - 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)
minx - Must be = smallest x and >= cx1.maxx - Must be = biggest x and <= cx2.
protected void insertEdge(ch.randelshofer.awt.graphics.Edge list,
ch.randelshofer.awt.graphics.Edge edge)
protected void buildEdgeListHorizontal(int[] x,
int[] y,
int cnt)
protected void buildEdgeListVertical(int[] x,
int[] y,
int cnt)
protected int yNext(int k,
int[] x,
int[] y,
int cnt)
protected int xNext(int k,
int[] x,
int[] y,
int cnt)
protected void makeEdgeRecHorizontal(int lower,
int upper,
int yComp,
ch.randelshofer.awt.graphics.Edge edge,
int[] x,
int[] y)
protected void makeEdgeRecVertical(int lower,
int upper,
int xComp,
ch.randelshofer.awt.graphics.Edge edge,
int[] x,
int[] y)
protected void buildActiveList(int scan,
ch.randelshofer.awt.graphics.Edge active)
protected final void plotHClipped(int scan,
ch.randelshofer.awt.graphics.Edge active)
protected void plotVClipped(int scan,
ch.randelshofer.awt.graphics.Edge active)
protected void updateActiveList(int scan,
ch.randelshofer.awt.graphics.Edge active)
protected void prepareEdgeList(int scan)
protected void deleteAfter(ch.randelshofer.awt.graphics.Edge q)
protected void resortActiveList(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 | ||||||||