Package org.xhtmlrenderer.layout

Examples of org.xhtmlrenderer.layout.SharedContext


    public BasicPanel() {
        this(new NaiveUserAgent());
    }

    public BasicPanel(UserAgentCallback uac) {
        sharedContext = new SharedContext(uac);
        mouseTracker = new MouseTracker(this);

        init();
    }
View Full Code Here


        sharedContext = newSharedContext(dotsPerPixel, userAgent);
        layoutContext = newLayoutContext();
  }

    private SharedContext newSharedContext(int dotsPerPixel, UserAgentCallback userAgent) {
        SharedContext context = new SharedContext(userAgent);

        AWTFontResolver fontResolver = new AWTFontResolver();
        context.setFontResolver(fontResolver);

        SwingReplacedElementFactory replacedElementFactory = new SwingReplacedElementFactory();
        context.setReplacedElementFactory(replacedElementFactory);

        context.setTextRenderer(new Java2DTextRenderer());
        context.setDPI(72 * this.dotsPerPoint);
        context.setDotsPerPixel(dotsPerPixel);
        context.setPrint(false);
        context.setInteractive(false);
        return context;
    }
View Full Code Here

    /**
     * Resets all rendered fonts on the current document to the font size
     * specified in the document's styling instructions.
     */
    public void resetFontSize() {
        SharedContext rc = getSharedContext();
        rc.getTextRenderer().setFontScale(1.0F);
        setDocument(getDocument());
    }
View Full Code Here

    /**
     * Applies a change in scale for fonts using the rendering context's text
     * renderer.
     */
    private void scaleFont(float scaleBy) {
        SharedContext rc = getSharedContext();
        float fs = rc.getTextRenderer().getFontScale() * scaleBy;
        if (fs < minFontScale || fs > maxFontScale) return;
        rc.getTextRenderer().setFontScale(fs);
        setDocument(getDocument());
    }
View Full Code Here

        _dotsPerPoint = dotsPerPoint;
       
        _outputDevice = new ITextOutputDevice(_dotsPerPoint);
       
        ITextUserAgent userAgent = new ITextUserAgent(_outputDevice);
        _sharedContext = new SharedContext(userAgent);
        userAgent.setSharedContext(_sharedContext);
        _outputDevice.setSharedContext(_sharedContext);
       
        ITextFontResolver fontResolver = new ITextFontResolver(_sharedContext);
        _sharedContext.setFontResolver(fontResolver);
View Full Code Here

        try {
            if (j2dr == null) {

                j2dr = new Java2DRenderer(file, 1024);
                SharedContext context = j2dr.getSharedContext();
                context.setPrint(true);
                context.setInteractive(false);
                context.setDPI(72f);

                context.getTextRenderer().setSmoothingThreshold(0);

            }

            return Printable.PAGE_EXISTS;
        } catch (Exception ex) {
View Full Code Here

        aboutDlg.setVisible(true);
    }

    private void togglePrintPreview() {
        try {
            SharedContext sharedContext = root.panel.view.getSharedContext();

            // flip status--either we are in "print" mode (print media) or non-print (screen media)
            if (sharedContext.isPrint()) {
                sharedContext.setPrint(false);
                sharedContext.setInteractive(true);
            } else {
                sharedContext.setPrint(true);
                sharedContext.setInteractive(false);
            }
            print_preview.putValue(Action.SHORT_DESCRIPTION,
                    ! sharedContext.isPrint() ? "Print preview" : "Normal view");
            root.panel.reloadPage();
            root.panel.view.repaint();
        } catch (Exception ex) {
            Uu.p(ex);
        }
View Full Code Here

    // toolbar.add(print);
        toolbar.setFloatable(false);
    }

  private void loadCustomFonts() {
    SharedContext rc = view.getSharedContext();
    try {
      rc.setFontMapping("Fuzz", Font.createFont(Font.TRUETYPE_FONT,
          new DemoMarker().getClass().getResourceAsStream("/demos/fonts/fuzz.ttf")));
    } catch (Exception ex) {
      Uu.p(ex);
    }
  }
View Full Code Here

            }
        });
    }

    private void setAntiAlias(XHTMLPanel introPanel) {
        SharedContext sharedContext = introPanel.getSharedContext();
        sharedContext.setTextRenderer(new Java2DTextRenderer());
    }
View Full Code Here

    public BasicPanel() {
        this(new NaiveUserAgent());
    }

    public BasicPanel(UserAgentCallback uac) {
        sharedContext = new SharedContext(uac);
        mouseTracker = new MouseTracker(this);
        formSubmissionListener = new FormSubmissionListener() {
            public void submit(String query) {
                System.out.println("Form Submitted!");
                System.out.println("Data: " + query);
View Full Code Here

TOP

Related Classes of org.xhtmlrenderer.layout.SharedContext

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.