All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jpedal.parser.shape.N Maven / Gradle / Ivy

There is a newer version: 7.15.25
Show newest version
/*
 * ===========================================
 * Java Pdf Extraction Decoding Access Library
 * ===========================================
 *
 * Project Info:  http://www.idrsolutions.com
 * Help section for developers at http://www.idrsolutions.com/support/
 *
 * (C) Copyright 1997-2017 IDRsolutions and Contributors.
 *
 * This file is part of JPedal/JPDF2HTML5
 *
 @LICENSE@
 *
 * ---------------
 * N.java
 * ---------------
 */
package org.jpedal.parser.shape;

import java.awt.Shape;
import java.awt.geom.Area;

import org.jpedal.objects.GraphicsState;
import org.jpedal.objects.PdfPageData;
import org.jpedal.objects.PdfShape;
import org.jpedal.parser.Cmd;
import org.jpedal.parser.ParserOptions;
import org.jpedal.render.DynamicVectorRenderer;

public class N {

    public static void execute(final PdfShape currentDrawShape, final GraphicsState gs, final int formLevel, final Shape defaultClip, final ParserOptions parserOptions, final DynamicVectorRenderer current, final PdfPageData pageData) {

        final boolean useJavaFX = parserOptions.useJavaFX();
        final boolean renderPage = parserOptions.isRenderPage();

        if (currentDrawShape.isClip()) {

            //create clipped shape
            currentDrawShape.closeShape();

            if (useJavaFX) {
                gs.updateClip(currentDrawShape.getPath());
            } else {
                gs.updateClip(new Area(currentDrawShape.generateShapeFromPath(gs.CTM, 0, Cmd.n)));
            }

            if (formLevel == 0) {
                final int pageNum = parserOptions.getPageNumber();
                gs.checkWholePageClip(pageData.getMediaBoxHeight(pageNum) + pageData.getMediaBoxY(pageNum));
            }

            //always reset flag
            currentDrawShape.setClip(false);

            //save for later
            if (renderPage) {
                current.drawClip(gs, defaultClip, false);
            }
        }

        currentDrawShape.resetPath(); // flush all path ops stored

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy