Example usage for java.awt.geom PathIterator WIND_EVEN_ODD

List of usage examples for java.awt.geom PathIterator WIND_EVEN_ODD

Introduction

In this page you can find the example usage for java.awt.geom PathIterator WIND_EVEN_ODD.

Prototype

int WIND_EVEN_ODD

To view the source code for java.awt.geom PathIterator WIND_EVEN_ODD.

Click Source Link

Document

The winding rule constant for specifying an even-odd rule for determining the interior of a path.

Usage

From source file:fi.nls.oskari.printout.printing.PDPageContentStream.java

/**
 * Fill the path.// w  w  w . j av a 2 s  .c om
 * 
 * @param windingRule
 *            the winding rule to be used for filling
 * 
 * @throws IOException
 *             If there is an error while filling the path.
 */
public void fill(int windingRule) throws IOException {
    if (inTextMode) {
        throw new IOException("Error: fill is not allowed within a text block.");
    }
    if (windingRule == PathIterator.WIND_NON_ZERO) {
        appendRawCommands(FILL_NON_ZERO);
    } else if (windingRule == PathIterator.WIND_EVEN_ODD) {
        appendRawCommands(FILL_EVEN_ODD);
    } else {
        throw new IOException("Error: unknown value for winding rule");
    }

}

From source file:fi.nls.oskari.printout.printing.PDPageContentStream.java

/**
 * Clip path./*  w ww.  j a v  a  2 s  .c o m*/
 * 
 * @param windingRule
 *            the winding rule to be used for clipping
 * 
 * @throws IOException
 *             If there is an error while clipping the path.
 */
public void clipPath(int windingRule) throws IOException {
    if (inTextMode) {
        throw new IOException("Error: clipPath is not allowed within a text block.");
    }
    if (windingRule == PathIterator.WIND_NON_ZERO) {
        appendRawCommands(CLIP_PATH_NON_ZERO);
        appendRawCommands(NOP);
    } else if (windingRule == PathIterator.WIND_EVEN_ODD) {
        appendRawCommands(CLIP_PATH_EVEN_ODD);
        appendRawCommands(NOP);
    } else {
        throw new IOException("Error: unknown value for winding rule");
    }
}

From source file:org.apache.pdfbox.pdmodel.edit.PDPageContentStream.java

/**
 * Fill the path./*from w w w.  j a  v a2  s .c  o  m*/
 * 
 * @param windingRule the winding rule to be used for filling 
 * 
 * @throws IOException If there is an error while filling the path.
 */
public void fill(int windingRule) throws IOException {
    if (windingRule == PathIterator.WIND_NON_ZERO) {
        appendRawCommands(FILL_NON_ZERO);
    } else if (windingRule == PathIterator.WIND_EVEN_ODD) {
        appendRawCommands(FILL_EVEN_ODD);
    } else {
        throw new IOException("Error: unknown value for winding rule");
    }

}

From source file:org.apache.pdfbox.pdmodel.edit.PDPageContentStream.java

/**
 * Clip path./* w w  w  .  j  a  v  a  2s  .co m*/
 * 
 * @param windingRule the winding rule to be used for clipping
 *  
 * @throws IOException If there is an error while clipping the path.
 */
public void clipPath(int windingRule) throws IOException {
    if (windingRule == PathIterator.WIND_NON_ZERO) {
        appendRawCommands(CLIP_PATH_NON_ZERO);
        appendRawCommands(NOP);
    } else if (windingRule == PathIterator.WIND_EVEN_ODD) {
        appendRawCommands(CLIP_PATH_EVEN_ODD);
        appendRawCommands(NOP);
    } else {
        throw new IOException("Error: unknown value for winding rule");
    }
}

From source file:org.apache.pdfbox.pdmodel.PDPageContentStream.java

/**
 * Fill the path.//from   w  w w.  j av  a  2s . c o  m
 * 
 * @param windingRule the winding rule to be used for filling
 * @throws IOException If the content stream could not be written
 * @throws IllegalArgumentException If the parameter is not a valid winding rule.
 * @deprecated Use {@link #fill()} or {@link #fillEvenOdd} instead.
 */
@Deprecated
public void fill(int windingRule) throws IOException {
    if (windingRule == PathIterator.WIND_NON_ZERO) {
        fill();
    } else if (windingRule == PathIterator.WIND_EVEN_ODD) {
        fillEvenOdd();
    } else {
        throw new IllegalArgumentException("Error: unknown value for winding rule");
    }
}

From source file:org.apache.pdfbox.pdmodel.PDPageContentStream.java

/**
 * Clip path./*from w w w  .jav  a 2  s .  c  om*/
 * 
 * @param windingRule the winding rule to be used for clipping
 * @throws IOException If there is an error while clipping the path.
 * @throws IllegalStateException If the method was called within a text block.
 * @deprecated Use {@link #clip()} or {@link #clipEvenOdd} instead.
 */
@Deprecated
public void clipPath(int windingRule) throws IOException {
    if (inTextMode) {
        throw new IllegalStateException("Error: clipPath is not allowed within a text block.");
    }
    if (windingRule == PathIterator.WIND_NON_ZERO) {
        writeOperator("W");
    } else if (windingRule == PathIterator.WIND_EVEN_ODD) {
        writeOperator("W*");
    } else {
        throw new IllegalArgumentException("Error: unknown value for winding rule");
    }
    writeOperator("n");
}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfGraphics2D.java

private void followPath(Shape s, final int drawType) {
    if (s == null) {
        return;/*from  ww w. j a  v  a  2 s.com*/
    }
    if (drawType == PdfGraphics2D.STROKE) {
        if (!(stroke instanceof BasicStroke)) {
            s = stroke.createStrokedShape(s);
            followPath(s, PdfGraphics2D.FILL);
            return;
        }
    }
    if (drawType == PdfGraphics2D.STROKE) {
        setStrokeDiff(stroke, oldStroke);
        oldStroke = stroke;
        setStrokePaint();
    } else if (drawType == PdfGraphics2D.FILL) {
        setFillPaint();
    }
    final PathIterator points;
    if (drawType == PdfGraphics2D.CLIP) {
        points = s.getPathIterator(PdfGraphics2D.IDENTITY);
    } else {
        points = s.getPathIterator(transform);
    }
    final float[] coords = new float[6];
    int traces = 0;
    while (!points.isDone()) {
        ++traces;
        final int segtype = points.currentSegment(coords);
        normalizeY(coords);
        switch (segtype) {
        case PathIterator.SEG_CLOSE:
            cb.closePath();
            break;

        case PathIterator.SEG_CUBICTO:
            cb.curveTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
            break;

        case PathIterator.SEG_LINETO:
            cb.lineTo(coords[0], coords[1]);
            break;

        case PathIterator.SEG_MOVETO:
            cb.moveTo(coords[0], coords[1]);
            break;

        case PathIterator.SEG_QUADTO:
            cb.curveTo(coords[0], coords[1], coords[2], coords[3]);
            break;
        default:
            throw new IllegalStateException("Invalid segment type in path");
        }
        points.next();
    }
    switch (drawType) {
    case PdfGraphics2D.FILL:
        if (traces > 0) {
            if (points.getWindingRule() == PathIterator.WIND_EVEN_ODD) {
                cb.eoFill();
            } else {
                cb.fill();
            }
        }
        break;
    case PdfGraphics2D.STROKE:
        if (traces > 0) {
            cb.stroke();
        }
        break;
    default: // drawType==CLIP
        if (traces == 0) {
            cb.rectangle(0, 0, 0, 0);
        }
        if (points.getWindingRule() == PathIterator.WIND_EVEN_ODD) {
            cb.eoClip();
        } else {
            cb.clip();
        }
        cb.newPath();
    }
}