Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* {{{ header & license
* Copyright (c) 2006 Patrick Wright
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* }}}
*/
package org.xhtmlrenderer.swing;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xhtmlrenderer.extend.NamespaceHandler;
import org.xhtmlrenderer.extend.UserAgentCallback;
import org.xhtmlrenderer.extend.UserInterface;
import org.xhtmlrenderer.layout.BoxBuilder;
import org.xhtmlrenderer.layout.LayoutContext;
import org.xhtmlrenderer.layout.SharedContext;
import org.xhtmlrenderer.render.BlockBox;
import org.xhtmlrenderer.render.Box;
import org.xhtmlrenderer.render.RenderingContext;
import org.xhtmlrenderer.render.ViewportBox;
import org.xhtmlrenderer.simple.extend.XhtmlNamespaceHandler;
import org.xhtmlrenderer.util.Configuration;
import org.xhtmlrenderer.util.ImageUtil;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Map;
/**
*
Renders an XML files, formatted with CSS, as an Box. Input is a document in the form of file or URL,
* and output is the root of the Box model. A BoxRenderer is not intended to be re-used for multiple document
* sources; just create new BoxRenderers for each one you need. BoxRenderer is not thread-safe.
* Standard usage pattern is
*
*
* File xhtml = ...
* BoxRenderer rend = new BoxRenderer(xhtml);
* Box rootBox = rend.render();
*
*
*
The document is not loaded, and layout and render don't take place, until {@link #render()} is called.
* Subsequent calls to {@link #render()} don't result in a reload; create a new BoxRenderer instance to do so.
*
*
As with {@link RootPanel}, you can access the
* {@link org.xhtmlrenderer.layout.SharedContext} instance that will be used by this renderer and change settings
* to control the rendering process; use {@link #getSharedContext()}.
*
*
Not thread-safe.
*/
public class BoxRenderer {
private static final int DEFAULT_HEIGHT = 1000;
private static final int DEFAULT_DOTS_PER_POINT = 1;
private static final int DEFAULT_DOTS_PER_PIXEL = 1;
private SharedContext sharedContext;
private Java2DOutputDevice outputDevice;
private Document doc;
private Box root;
/**
* Whether we've completed rendering; image will only be rendered once.
*/
private boolean rendered;
private final String sourceDocument;
private final String sourceDocumentBase;
private final int width;
private int height;
private static final int NO_HEIGHT = -1;
private Map