Examples of PSResource


Examples of org.apache.xmlgraphics.ps.PSResource

     */
    public void notifyResourceUsageOnPage(Collection resources) {
        preparePageResources();
        Iterator iter = resources.iterator();
        while (iter.hasNext()) {
            PSResource res = (PSResource)iter.next();
            notifyResourceUsageOnPage(res);
        }
    }
View Full Code Here

Examples of org.apache.xmlgraphics.ps.PSResource

     */
    public void writeDocumentResources(PSGenerator gen) throws IOException {
        if (usedResources != null) {
            Iterator iter = usedResources.iterator();
            while (iter.hasNext()) {
                PSResource res = (PSResource)iter.next();
                if (documentSuppliedResources == null
                        || !documentSuppliedResources.contains(res)) {
                    registerNeededResource(res);
                }
            }
View Full Code Here

Examples of org.apache.xmlgraphics.ps.PSResource

            throw new IllegalArgumentException("uri must not be empty or null");
        }
        if (this.formResources == null) {
            this.formResources = new java.util.HashMap();
        }
        PSResource form = (PSResource)this.formResources.get(uri);
        if (form == null) {
            form = new PSImageFormResource(this.formResources.size() + 1, uri);
            this.formResources.put(uri, form);
        }
        return form;
View Full Code Here

Examples of org.apache.xmlgraphics.ps.PSResource

        }

        public void selectFont(Font f, char mapped) throws IOException {
            int encoding = mapped / 256;
            String postfix = (encoding == 0 ? null : Integer.toString(encoding));
            PSResource res = getResourceForFont(f, postfix);
            gen.useFont("/" + res.getName(), f.getFontSize() / 1000f);
            gen.getResourceTracker().notifyResourceUsageOnPage(res);
        }
View Full Code Here

Examples of org.apache.xmlgraphics.ps.PSResource

            //Skip procsets and encoding
            gotoDSCComment(parser, DSCConstants.BEGIN_RESOURCE);
            gotoDSCComment(parser, DSCConstants.BEGIN_RESOURCE);
            gotoDSCComment(parser, DSCConstants.BEGIN_RESOURCE);

            PSResource form2 = new PSResource(PSResource.TYPE_FORM, "FOPForm:2");
            checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE, form2);
            DSCCommentTitle title = (DSCCommentTitle)parser.nextEvent().asDSCComment();
            assertEquals("image/jpeg test/resources/images/bgimg300dpi.jpg", title.getTitle());

            String resourceContent = getResourceContent(parser);

            if (level == 3) {
                assertContains(resourceContent, "/FOPForm:2");
                assertContains(resourceContent, "/DCTDecode filter");
                assertContains(resourceContent, "/ReusableStreamDecode filter");
            } else {
                assertContains(resourceContent, "/FOPForm:2");
                assertContains(resourceContent, "/DCTDecode filter");
                assertAbsent(resourceContent, "/ReusableStreamDecode filter");
            }

            //---=== Page 1 ===---
            DSCCommentPage page = (DSCCommentPage)gotoDSCComment(parser, DSCConstants.PAGE);
            assertEquals(1, page.getPagePosition());

            PSResource form1 = new PSResource(PSResource.TYPE_FORM, "FOPForm:1");
            checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE, form1);
            title = (DSCCommentTitle)parser.nextEvent().asDSCComment();
            assertEquals("image/jpeg test/resources/images/bgimg72dpi.jpg", title.getTitle());
            resourceContent = getResourceContent(parser);
View Full Code Here

Examples of org.apache.xmlgraphics.ps.PSResource

        in = new java.io.BufferedInputStream(in);
        try {
            DSCParser parser = new DSCParser(in);

            //The first form is for arrow_down_small.png (to be reused)
            PSResource form1 = new PSResource(PSResource.TYPE_FORM, "FOPForm:1");
            PSResource helvetica = new PSResource(PSResource.TYPE_FONT, "Helvetica");
            PSResource helveticaBold = new PSResource(PSResource.TYPE_FONT, "Helvetica-Bold");

            PSResource res;
            DSCCommentPages pages = (DSCCommentPages)gotoDSCComment(parser, DSCConstants.PAGES);
            assertEquals(2, pages.getPageCount());

            DSCCommentDocumentSuppliedResources supplied
                = (DSCCommentDocumentSuppliedResources)gotoDSCComment(parser,
                        DSCConstants.DOCUMENT_SUPPLIED_RESOURCES);
            Set resources = supplied.getResources();
            assertEquals(4, resources.size());
            assertTrue(resources.contains(form1));
            assertTrue("Expected barcode.eps as supplied resource",
                    resources.contains(new PSResource(PSResource.TYPE_FILE,
                            "test/resources/images/barcode.eps")));

            DSCCommentDocumentNeededResources needed
                = (DSCCommentDocumentNeededResources)gotoDSCComment(parser,
                        DSCConstants.DOCUMENT_NEEDED_RESOURCES);
            resources = needed.getResources();
            assertEquals(2, resources.size());
            assertTrue("Expected Helvetica as needed resource",
                    resources.contains(new PSResource(PSResource.TYPE_FONT, "Helvetica")));
            assertTrue("Expected Helvetica-Bold as needed resource",
                    resources.contains(new PSResource(PSResource.TYPE_FONT, "Helvetica-Bold")));

            //Some document structure checking
            assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_DEFAULTS));
            assertNotNull(gotoDSCComment(parser, DSCConstants.END_DEFAULTS));
            assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_PROLOG));
            assertNotNull(gotoDSCComment(parser, DSCConstants.END_PROLOG));
            assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_SETUP));

            //Check includes for the two referenced base 14 fonts
            DSCCommentIncludeResource include;
            Collection strings = new java.util.HashSet(
                    Arrays.asList(new String[] {"Helvetica", "Helvetica-Bold"}));
            for (int i = 0; i < 2; i++) {
                include = (DSCCommentIncludeResource)gotoDSCComment(
                        parser, DSCConstants.INCLUDE_RESOURCE);
                res = include.getResource();
                assertEquals(PSResource.TYPE_FONT, res.getType());
                strings.remove(res.getName());
            }
            assertEquals(0, strings.size());

            checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE,
                    new PSResource(PSResource.TYPE_ENCODING, "WinAnsiEncoding"));

            //Here, we encounter form 1 again
            checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE, form1);

            assertNotNull(gotoDSCComment(parser, DSCConstants.END_SETUP));
            //Now the actual pages begin

            //---=== Page 1 ===---
            DSCCommentPage page = (DSCCommentPage)gotoDSCComment(parser, DSCConstants.PAGE);
            assertEquals(1, page.getPagePosition());

            assertEquals(DSCAtend.class,
                    gotoDSCComment(parser, DSCConstants.PAGE_RESOURCES).getClass());
            assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_PAGE_SETUP));
            assertNotNull(gotoDSCComment(parser, DSCConstants.END_PAGE_SETUP));

            PSResource form2 = new PSResource(PSResource.TYPE_FORM, "FOPForm:2");
            checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE, form2);
            assertNotNull(gotoDSCComment(parser, DSCConstants.PAGE_TRAILER));

            AbstractResourcesDSCComment pageResources;
            pageResources = (AbstractResourcesDSCComment)gotoDSCComment(
View Full Code Here

Examples of org.apache.xmlgraphics.ps.PSResource

        Map fontResources = new java.util.HashMap();
        Iterator iter = fonts.keySet().iterator();
        while (iter.hasNext()) {
            String key = (String)iter.next();
            Typeface tf = getTypeFace(fontInfo, fonts, key);
            PSResource fontRes = new PSResource(PSResource.TYPE_FONT, tf.getFontName());
            fontResources.put(key, fontRes);
            embedFont(gen, tf, fontRes);

            if (tf instanceof SingleByteFont) {
                SingleByteFont sbf = (SingleByteFont)tf;

                if (encodeAllCharacters) {
                    sbf.encodeAllUnencodedCharacters();
                }

                for (int i = 0, c = sbf.getAdditionalEncodingCount(); i < c; i++) {
                    SingleByteEncoding encoding = sbf.getAdditionalEncoding(i);
                    defineEncoding(gen, encoding);
                    String postFix = "_" + (i + 1);
                    PSResource derivedFontRes = defineDerivedFont(gen, tf.getFontName(),
                            tf.getFontName() + postFix, encoding.getName());
                    fontResources.put(key + postFix, derivedFontRes);
                }
            }
        }
View Full Code Here

Examples of org.apache.xmlgraphics.ps.PSResource

        Map fontResources = new java.util.HashMap();
        Iterator iter = fonts.keySet().iterator();
        while (iter.hasNext()) {
            String key = (String)iter.next();
            Typeface tf = getTypeFace(fontInfo, fonts, key);
            PSResource fontRes = new PSResource("font", tf.getFontName());
            fontResources.put(key, fontRes);
            if (FontType.TYPE1 == tf.getFontType()) {
                if (tf instanceof CustomFont) {
                    CustomFont cf = (CustomFont)tf;
                    if (isEmbeddable(cf)) {
                        resTracker.registerSuppliedResource(fontRes);
                    }
                    if (tf instanceof SingleByteFont) {
                        SingleByteFont sbf = (SingleByteFont)tf;
                        for (int i = 0, c = sbf.getAdditionalEncodingCount(); i < c; i++) {
                            SingleByteEncoding encoding = sbf.getAdditionalEncoding(i);
                            PSResource encodingRes = new PSResource(
                                    PSResource.TYPE_ENCODING, encoding.getName());
                            resTracker.registerSuppliedResource(encodingRes);
                            PSResource derivedFontRes = new PSResource(
                                    PSResource.TYPE_FONT, tf.getFontName() + "_" + (i + 1));
                            resTracker.registerSuppliedResource(derivedFontRes);
                        }
                    }
                }
View Full Code Here

Examples of org.apache.xmlgraphics.ps.PSResource

     * @return the PSResource instance that represents the encoding
     * @throws IOException In case of an I/O problem
     */
    public static PSResource defineEncoding(PSGenerator gen, SingleByteEncoding encoding)
            throws IOException {
        PSResource res = new PSResource(PSResource.TYPE_ENCODING, encoding.getName());
        gen.writeDSCComment(DSCConstants.BEGIN_RESOURCE, res);
        gen.writeln("/" + encoding.getName() + " [");
        String[] charNames = encoding.getCharNameMap();
        for (int i = 0; i < 256; i++) {
            if (i > 0) {
View Full Code Here

Examples of org.apache.xmlgraphics.ps.PSResource

     * @return the PSResource representing the derived font
     * @throws IOException In case of an I/O problem
     */
    public static PSResource defineDerivedFont(PSGenerator gen, String baseFontName, String fontName,
            String encoding) throws IOException {
        PSResource res = new PSResource(PSResource.TYPE_FONT, fontName);
        gen.writeDSCComment(DSCConstants.BEGIN_RESOURCE, res);
        gen.commentln("%XGCDependencies: font " + baseFontName);
        gen.commentln("%XGC+ encoding " + encoding);
        gen.writeln("/" + baseFontName + " findfont");
        gen.writeln("dup length dict begin");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.