Package org.apache.fop.pdf

Examples of org.apache.fop.pdf.PDF3DProjection


                        + "must either be 'perspective' or 'orthographic'.");
                return;
            }
            boolean isOrtho = "orthographic".equalsIgnoreCase(attr);

            PDF3DProjection p = pdfi.factory.make3DViewProjection(isOrtho);

            // Clipping style can be "auto" (default) or "custom"
            // ---------------------------------------------------------------
            attr = DOMUtil.getAttribute(proj, "clipping");
            if (attr.length() > 0) {
                if ("custom".equalsIgnoreCase(attr)) {
                    p.setClippingMode(PDF3DProjection.CLIPPING_MODE_EXPLICIT);
                    // check for near and far plane settings
                    attr = DOMUtil.getAttribute(proj, "near");
                    if (attr.length() > 0) {
                        double near = Double.parseDouble(attr);
                        if (!isOrtho && near <= 0.0d) {
                            log.error("The near clipping plane distance shall "
                                    + "be positive for perspective "
                                    + "projections.");
                        } else if (isOrtho && near < 0.0d) {
                            log.error("The near clipping plane distance shall "
                                    + "be positive for perspective "
                                    + "projections.");
                        } else {
                            p.setNearClippingPlane(near);
                        }
                    } else if (!isOrtho) {
                        log.error("Near clipping plane setting is required "
                                + "for perspective projections when using the "
                                + "custom clipping mode.");
                    }
                    attr = DOMUtil.getAttribute(proj, "far");
                    if (attr.length() > 0) {
                        double far = Double.parseDouble(attr);
                        p.setFarClippingPlane(far);
                    }
                } else if ("auto".equalsIgnoreCase(attr)) {
                    p.setClippingMode(PDF3DProjection.CLIPPING_MODE_AUTOMATIC);
                }
            }

            // Attributes only used in orthographic or
            // perspective projections below
            if (isOrtho) {
                // Orthographic settings only

                // Orthographic projection scaling
                // -----------------------------------------------------------
                attr = DOMUtil.getAttribute(proj, "orthographic-scaling");
                if (attr.length() > 0) {
                    try {
                        double factor = Double.parseDouble(attr);
                        p.setOrthoScaling(factor);
                    } catch (NumberFormatException e) {
                        log.warn("Illegal orthographic-scaling value found.");
                    }
                }

                // Orthographic projection binding strategy (scale-to-fit)
                // -----------------------------------------------------------
                attr = DOMUtil.getAttribute(proj, "orthographic-binding");
                if (attr.length() > 0) {
                    if ("width".equalsIgnoreCase(attr)) {
                        p
                            .setOrthoScaleBindingMode(PDF3DProjection.ORTHOGRAPHIC_SCALING_MODE_WIDTH);
                    } else if ("height".equalsIgnoreCase(attr)) {
                        p
                            .setOrthoScaleBindingMode(PDF3DProjection.ORTHOGRAPHIC_SCALING_MODE_HEIGHT);
                    } else if ("min".equalsIgnoreCase(attr)) {
                        p
                            .setOrthoScaleBindingMode(PDF3DProjection.ORTHOGRAPHIC_SCALING_MODE_MIN);
                    } else if ("max".equalsIgnoreCase(attr)) {
                        p
                            .setOrthoScaleBindingMode(PDF3DProjection.ORTHOGRAPHIC_SCALING_MODE_MIN);
                    } else if ("absolute".equalsIgnoreCase(attr)) {
                        p
                            .setOrthoScaleBindingMode(PDF3DProjection.ORTHOGRAPHIC_SCALING_MODE_ABSOLUTE);
                    } else {
                        log.warn("Illegal orthographic-binding value '" + attr
                                + "' found.");
                    }
                }
            } else {
                // Perspective settings only

                // FOV: Field of view (double value between 0 and 180)
                // -----------------------------------------------------------
                attr = DOMUtil.getAttribute(proj, "fov");
                if (attr.length() > 0) {
                    try {
                        double fov = Double.parseDouble(attr);
                        if (fov > 0d && fov <= 180d) {
                            p.setFieldOfView(fov);
                        } else {
                            throw new Exception(
                                "FOV must be between 0 and 180.");
                        }
                    } catch (Exception e) {
                        log.error("FOV must be a decimal number between 0 "
                                + "and 180");
                    }
                } else if (isOrtho) {
                    log.error("Field of view (FOV) setting is required for "
                            + "perspective projections.");
                }

                // Perspective projection scaling
                // -----------------------------------------------------------
                attr = DOMUtil.getAttribute(proj, "perspective-scaling");
                if (attr.length() > 0) {
                    if ("width".equalsIgnoreCase(attr)) {
                        p
                            .setPerspScalingMode(PDF3DProjection.PERSPECTIVE_SCALING_MODE_WIDTH);
                    } else if ("height".equalsIgnoreCase(attr)) {
                        p
                            .setPerspScalingMode(PDF3DProjection.PERSPECTIVE_SCALING_MODE_HEIGHT);
                    } else if ("min".equalsIgnoreCase(attr)) {
                        p
                            .setPerspScalingMode(PDF3DProjection.PERSPECTIVE_SCALING_MODE_MIN);
                    } else if ("max".equalsIgnoreCase(attr)) {
                        p
                            .setPerspScalingMode(PDF3DProjection.PERSPECTIVE_SCALING_MODE_MAX);
                    } else {
                        // none of the keywords found, try custom factor
                        try {
                            double factor = Double.parseDouble(attr);
                            p.setPerspCustomScaling(factor);
                        } catch (NumberFormatException e) {
                            log.warn("Illegal perspective-scaling value '"
                                    + attr + "' found.");
                        }
                    }
View Full Code Here

TOP

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

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.