Package org.apache.fop.pdf

Examples of org.apache.fop.pdf.PDFColor


    protected void applyColor(Color col, boolean fill) {
        preparePainting();

        Color c = col;
        if (col instanceof ColorExt) {
            PDFColor currentColour = new PDFColor(this.pdfDoc, col);
            currentStream.write(currentColour.getColorSpaceOut(fill));
        } else if (c.getColorSpace().getType()
                == ColorSpace.TYPE_RGB) {
            PDFColor currentColour = new PDFColor(c.getRed(), c.getGreen(),
                                         c.getBlue());
            currentStream.write(currentColour.getColorSpaceOut(fill));
        } else if (c.getColorSpace().getType()
                   == ColorSpace.TYPE_CMYK) {
            if (pdfDoc.getProfile().getPDFAMode().isPDFA1LevelB()) {
                //See PDF/A-1, ISO 19005:1:2005(E), 6.2.3.3
                //FOP is currently restricted to DeviceRGB if PDF/A-1 is active.
                throw new PDFConformanceException(
                        "PDF/A-1 does not allow mixing DeviceRGB and DeviceCMYK.");
            }
            PDFColor currentColour = new PDFColor(c);
            currentStream.write(currentColour.getColorSpaceOut(fill));
        } else if (c.getColorSpace().getType()
                   == ColorSpace.TYPE_2CLR) {
            // used for black/magenta
            float[] cComps = c.getColorComponents(new float[1]);
            double[] blackMagenta = new double[1];
View Full Code Here


        addRect(x, y, w, h, fill, fill);
    }

    protected void addFilledRect(int x, int y, int w, int h,
                                 ColorType col) {
        PDFColor pdfcol = new PDFColor(col);
        addRect(x, y, w, h, pdfcol, pdfcol);
    }
View Full Code Here

        h = h + area.getPaddingTop() + area.getPaddingBottom();

        // I'm not sure I should have to check for bg being null
        // but I do
        if ((bg != null) && (bg.alpha() == 0)) {
            this.addFilledRect(rx, ry, w, -h, new PDFColor(bg));
        }

        // rx = rx - area.getBorderLeftWidth();
        // ry = ry + area.getBorderTopWidth();
        // w = w + area.getBorderLeftWidth() + area.getBorderRightWidth();
        // h = h + area.getBorderTopWidth() + area.getBorderBottomWidth();

        // Handle line style
        // Offset for haft the line width!
        BorderAndPadding bp = area.getBorderAndPadding();
        // int left = rx - area.getBorderLeftWidth() / 2;
        // int right = rx + w + area.getBorderRightWidth() / 2;
        // int top = ry + area.getBorderTopWidth() / 2;
        // int bottom = ry - h - area.getBorderBottomWidth() / 2;
        // if (area.getBorderTopWidth() != 0)
        // addLine(left, top, right, top, area.getBorderTopWidth(),
        // new PDFColor(bp.getBorderColor(BorderAndPadding.TOP)));
        // if (area.getBorderLeftWidth() != 0)
        // addLine(left, ry + area.getBorderTopWidth(), left, bottom, area.getBorderLeftWidth(),
        // new PDFColor(bp.getBorderColor(BorderAndPadding.LEFT)));
        // if (area.getBorderRightWidth() != 0)
        // addLine(right, ry + area.getBorderTopWidth(), right, bottom, area.getBorderRightWidth(),
        // new PDFColor(bp.getBorderColor(BorderAndPadding.RIGHT)));
        // if (area.getBorderBottomWidth() != 0)
        // addLine(rx - area.getBorderLeftWidth(), bottom, rx + w + area.getBorderRightWidth(), bottom, area.getBorderBottomWidth(),
        // new PDFColor(bp.getBorderColor(BorderAndPadding.BOTTOM)));
        // Try using rectangles instead of lines. Line style will be a
        // problem though?
        int left = area.getBorderLeftWidth();
        int right = area.getBorderRightWidth();
        int top = area.getBorderTopWidth();
        int bottom = area.getBorderBottomWidth();
        // If style is solid, use filled rectangles
        if (top != 0)
            addFilledRect(rx, ry, w, top,
                          new PDFColor(bp.getBorderColor(BorderAndPadding.TOP)));
        if (left != 0)
            addFilledRect(rx - left, ry - h - bottom, left, h + top + bottom,
                          new PDFColor(bp.getBorderColor(BorderAndPadding.LEFT)));
        if (right != 0)
            addFilledRect(rx + w, ry - h - bottom, right, h + top + bottom,
                          new PDFColor(bp.getBorderColor(BorderAndPadding.RIGHT)));
        if (bottom != 0)
            addFilledRect(rx, ry - h - bottom, w, bottom,
                          new PDFColor(bp.getBorderColor(BorderAndPadding.BOTTOM)));
    }
View Full Code Here

        // a line with thickness 0 is still displayed
        if (th != 0) {
            switch (st) {
            case org.apache.fop.fo.properties.RuleStyle.DOUBLE:
                addLine(rx, ry, rx + w, ry, th / 3, st,
                        new PDFColor(area.getRed(), area.getGreen(),
                                     area.getBlue()));
                addLine(rx, ry + (2 * th / 3), rx + w, ry + (2 * th / 3),
                        th / 3, st,
                        new PDFColor(area.getRed(), area.getGreen(),
                                     area.getBlue()));
                break;
            case org.apache.fop.fo.properties.RuleStyle.GROOVE:
                addLine(rx, ry, rx + w, ry, th / 2, st,
                        new PDFColor(area.getRed(), area.getGreen(),
                                     area.getBlue()));
                addLine(rx, ry + (th / 2), rx + w, ry + (th / 2), th / 2, st,
                        new PDFColor(255, 255, 255));
                break;
            case org.apache.fop.fo.properties.RuleStyle.RIDGE:
                addLine(rx, ry, rx + w, ry, th / 2, st,
                        new PDFColor(255, 255, 255));
                addLine(rx, ry + (th / 2), rx + w, ry + (th / 2), th / 2, st,
                        new PDFColor(area.getRed(), area.getGreen(),
                                     area.getBlue()));
                break;
            default:
                addLine(rx, ry, rx + w, ry, th, st,
                        new PDFColor(area.getRed(), area.getGreen(),
                                     area.getBlue()));
            }
            this.currentXPosition += area.getContentWidth();
            this.currentYPosition += th;
        }
View Full Code Here

     * @param rs the rule style
     * @param stroke the line color
     */
    protected void addLine(int x1, int y1, int x2, int y2, int th, int rs,
                           PDFPathPaint stroke) {
        PDFColor lstroke = null;
        if (rs == org.apache.fop.fo.properties.RuleStyle.DOTTED)
            lstroke = new PDFColor(0.7f, 0.7f, 0.7f);
        else
            lstroke = (PDFColor)stroke;
        if (x1 == x2) {
            addRect(x1, y1, th, y2 - y1 + 1, lstroke, lstroke);
        } else if (y1 == y2) {
View Full Code Here

            h *= -1;

        int row = (int)((pageHeight - (y / 100)) * 100 * yFactor);
        int col = (int)(x * xFactor);

        PDFColor sc = (PDFColor)stroke;
        PDFColor fc = (PDFColor)fill;

        sc.setColorSpace(ColorSpace.DEVICE_RGB);
        fc.setColorSpace(ColorSpace.DEVICE_RGB);

        int lineshade =
            (int)(100
                  - ((0.3f * sc.red() + 0.59f * sc.green() + 0.11f * sc.blue())
                     * 100f));
        int fillshade =
            (int)(100
                  - ((0.3f * fc.red() + 0.59f * fc.green() + 0.11f * fc.blue())
                     * 100f));
        if (debug)
            System.out.println("TXTRenderer.addRect(" + x + ", " + y + ", "
                               + w + ", " + h + ", " + stroke + ", " + fill
                               + ") fillshade=" + fillshade);
View Full Code Here

    boolean printBMP(FopImage img, int x, int y, int w,
                     int h) throws FopImageException {
        if (debug)
            System.out.println("TXTRenderer.printBMP(" + img + ", " + x
                               + ", " + y + ", " + w + ", " + h + ")");
        addRect(x, y, w, h, new PDFColor(1f, 1f, 1f),
                new PDFColor(0f, 0f, 0f));
        int nameh = (int)(h * yFactor / 2);
        if (nameh > 0) {
            int namew = (int)(w * xFactor);

            if (namew > 4) {
View Full Code Here

            h *= -1;
        else
            y += h;


        PDFColor sc = (PDFColor)stroke;
        PDFColor fc = (PDFColor)fill;

        sc.setColorSpace(ColorSpace.DEVICE_RGB);
        fc.setColorSpace(ColorSpace.DEVICE_RGB);

        int lineshade =
            (int)(100
                  - ((0.3f * sc.red() + 0.59f * sc.green() + 0.11f * sc.blue())
                     * 100f));
        int fillshade =
            (int)(100
                  - ((0.3f * fc.red() + 0.59f * fc.green() + 0.11f * fc.blue())
                     * 100f));

        int xpos = xoffset + (x / 100);
        if (xpos < 0) {
            xpos = 0;
View Full Code Here

        int size = area.getFontState().getFontSize();

        float red = area.getRed();
        float green = area.getGreen();
        float blue = area.getBlue();
        PDFColor theAreaColor = new PDFColor((double)area.getRed(),
                                             (double)area.getGreen(),
                                             (double)area.getBlue());

        // currentStream.add("\033*c" + (int)(100 - ((0.3f * red + 0.59f * green + 0.11f * blue) * 100f)) + "G\033*v2T");
        currentStream.add("\033*v1O\033*c"
 
View Full Code Here

        ColorType bg = area.getBackgroundColor();

        // I'm not sure I should have to check for bg being null
        // but I do
        if ((bg != null) && (bg.alpha() == 0)) {
            this.addRect(rx, ry, w, -h, new PDFColor(bg), new PDFColor(bg));
        }

    // floats & footnotes stuff
    renderAreaContainer(area.getBeforeFloatReferenceArea());
      renderAreaContainer(area.getFootnoteReferenceArea());
View Full Code Here

TOP

Related Classes of org.apache.fop.pdf.PDFColor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.