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

org.jpedal.render.utils.ShapeUtils Maven / Gradle / Ivy

The 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@
 *
 * ---------------
 * ShapeUtils.java
 * ---------------
 */
package org.jpedal.render.utils;


import java.awt.Shape;
import java.awt.geom.PathIterator;

/**
 * static helper methods for Clip code
 */
public class ShapeUtils {


    public static boolean isSimpleOutline(final Shape path) {

        int count = 0;
        final PathIterator i = path.getPathIterator(null);
        final float[] values = new float[6];

        while (!i.isDone() && count < 6) { //see if rectangle or complex clip
            //Get value before next called otherwise issues with pathIterator ending breaks everything
            final int value = i.currentSegment(values);

            i.next();

            count++;

            //If there is a curve, class as complex outline
            if (value == PathIterator.SEG_CUBICTO || value == PathIterator.SEG_QUADTO) {
                count = 6;
            }


        }
        return count < 6;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy