• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DocumentSource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.fit.cssbox.io.DocumentSource的典型用法代码示例。如果您正苦于以下问题:Java DocumentSource类的具体用法?Java DocumentSource怎么用?Java DocumentSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DocumentSource类属于org.fit.cssbox.io包,在下文中一共展示了DocumentSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: analyze

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
@Override
public ElementBox analyze(DocumentSource docSource, Dimension dim)
        throws Exception
{
    DOMSource parser = new DefaultDOMSource(docSource);
    w3cdoc = parser.parse();

    // Create the CSS analyzer
    DOMAnalyzer da = new DOMAnalyzer(w3cdoc, docSource.getURL());
    da.attributesToStyles();
    da.addStyleSheet(null, CSSNorm.stdStyleSheet(), DOMAnalyzer.Origin.AGENT);
    da.addStyleSheet(null, CSSNorm.userStyleSheet(), DOMAnalyzer.Origin.AGENT);
    da.getStyleSheets();
    
    BufferedImage tmpImg = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
    canvas = new BrowserCanvas(da.getRoot(), da, docSource.getURL());
    canvas.setImage(tmpImg);
    canvas.getConfig().setLoadImages(true);
    canvas.getConfig().setLoadBackgroundImages(true);
    canvas.createLayout(dim);

    return canvas.getViewport();
}
 
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:24,代码来源:DefaultAnalyzer.java


示例2: StyleImport

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
public StyleImport(String urlstring) throws IOException, SAXException
{
    //Open the network connection 
    DocumentSource docSource = new DefaultDocumentSource(urlstring);
    
    //Parse the input document
    DOMSource parser = new DefaultDOMSource(docSource);
    doc = parser.parse();
    
    //Create the CSS analyzer
    DOMAnalyzer da = new DOMAnalyzer(doc, docSource.getURL());
    da.getStyleSheets(); //load the author style sheets
    da.localizeStyles(); //put the style sheets into the document header
    
    docSource.close();
}
 
开发者ID:radkovo,项目名称:CSSBox,代码行数:17,代码来源:StyleImport.java


示例3: main

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
/**
 * @param args the command line arguments
 */
public static void main(String args[]) 
{
	if (args.length != 1)
	{
		System.err.println("Usage: SimpleBrowser <url>");
		System.exit(0);
	}
	
    try {
        //Open the network connection 
        DocumentSource docSource = new DefaultDocumentSource(args[0]);
        
        //Parse the input document
        DOMSource parser = new DefaultDOMSource(docSource);
        Document doc = parser.parse();
        
        //Create the CSS analyzer
        DOMAnalyzer da = new DOMAnalyzer(doc, docSource.getURL());
        da.attributesToStyles(); //convert the HTML presentation attributes to inline styles
        da.addStyleSheet(null, CSSNorm.stdStyleSheet(), DOMAnalyzer.Origin.AGENT); //use the standard style sheet
        da.addStyleSheet(null, CSSNorm.userStyleSheet(), DOMAnalyzer.Origin.AGENT); //use the additional style sheet
        da.addStyleSheet(null, CSSNorm.formsStyleSheet(), DOMAnalyzer.Origin.AGENT); //render form fields using css
        da.getStyleSheets(); //load the author style sheets
        
        //Display the result
        SimpleBrowser test = new SimpleBrowser(da.getRoot(), docSource.getURL(), da);
        test.setSize(1275, 750);
        test.setVisible(true);
        
        docSource.close();
        
    } catch (Exception e) {
        System.out.println("Error: "+e.getMessage());
        e.printStackTrace();
    }
}
 
开发者ID:radkovo,项目名称:CSSBox,代码行数:40,代码来源:SimpleBrowser.java


示例4: createDocumentSource

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
/**
 * Creates a new instance of the {@link org.fit.cssbox.io.DocumentSource} class registered in the browser configuration.
 * @param url the URL to be given to the document source.
 * @return the document source.
 * @throws IOException 
 */
public DocumentSource createDocumentSource(URL url) throws IOException
{
    try
    {
        Constructor<? extends DocumentSource> constr = getDocumentSourceClass().getConstructor(URL.class);
        return constr.newInstance(url);
    } catch (Exception e) {
        Throwable cause = e; //find if there is an IOException cause and throw it
        while (cause != null && !(cause instanceof IOException))
            cause = e.getCause();
        if (cause != null && cause instanceof IOException)
            throw (IOException) cause;
        //no IO exception cause, this should not happen (some internal reflection problem)
        log.error("Could not create the DocumentSource instance: " + e.getMessage());
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:radkovo,项目名称:CSSBox,代码行数:25,代码来源:BrowserConfig.java


示例5: analyze

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
@Override
public Viewport analyze(DocumentSource docSource, Dimension dim)
        throws Exception
{
    DOMSource parser = new DefaultDOMSource(docSource);
    w3cdoc = parser.parse();

    // Create the CSS analyzer
    DOMAnalyzer da = new DOMAnalyzer(w3cdoc, docSource.getURL());
    da.attributesToStyles();
    da.addStyleSheet(null, CSSNorm.stdStyleSheet(), DOMAnalyzer.Origin.AGENT);
    da.addStyleSheet(null, CSSNorm.userStyleSheet(), DOMAnalyzer.Origin.AGENT);
    da.getStyleSheets();
    
    BufferedImage tmpImg = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
    canvas = new BrowserCanvas(da.getRoot(), da, docSource.getURL());
    canvas.setImage(tmpImg);
    canvas.getConfig().setLoadImages(true);
    canvas.getConfig().setLoadBackgroundImages(true);
    canvas.createLayout(dim);

    return canvas.getViewport();
}
 
开发者ID:radkovo,项目名称:SwingBox,代码行数:24,代码来源:DefaultAnalyzer.java


示例6: analyzeFonts

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
public void analyzeFonts(URL base, URL url, String encoding,
		Map<String, HashSet<Character>> fontCharMap, String... fontNames)
		throws IOException, SAXException {
	DocumentSource docSource = new DefaultDocumentSource(base,
			url.toExternalForm());

	DOMSource parser = new DOMSource(docSource, encoding);
	Document doc = parser.parse();

	DOMFontAnalyzer da = new DOMFontAnalyzer(doc, base);
	da.setDefaultEncoding(encoding);
	da.attributesToStyles();
	da.getStyleSheets();

	da.setTargetFonts(fontNames);
	da.analyzeFontUsage(fontCharMap);
	
	docSource.close();
}
 
开发者ID:tjumyk,项目名称:web-font-generator,代码行数:20,代码来源:CSSFontMatcher.java


示例7: main

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
/**
 * @param args the command line arguments
 */
public static void main(String args[]) 
{
	if (args.length != 1)
	{
		System.err.println("Usage: SimpleBrowser <url>");
		System.exit(0);
	}
	
    try {
        //Open the network connection 
        DocumentSource docSource = new DefaultDocumentSource(args[0]);
        
        //Parse the input document
        DOMSource parser = new DefaultDOMSource(docSource);
        Document doc = parser.parse();
        
        //Create the CSS analyzer
        DOMAnalyzer da = new DOMAnalyzer(doc, docSource.getURL());
        da.attributesToStyles(); //convert the HTML presentation attributes to inline styles
        da.addStyleSheet(null, CSSNorm.stdStyleSheet(), DOMAnalyzer.Origin.AGENT); //use the standard style sheet
        da.addStyleSheet(null, CSSNorm.userStyleSheet(), DOMAnalyzer.Origin.AGENT); //use the additional style sheet
        da.getStyleSheets(); //load the author style sheets
        
        //Display the result
        SimpleBrowser test = new SimpleBrowser(da.getRoot(), docSource.getURL(), da);
        test.setSize(1275, 750);
        test.setVisible(true);
        
        docSource.close();
        
    } catch (Exception e) {
        System.out.println("Error: "+e.getMessage());
        e.printStackTrace();
    }
}
 
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:39,代码来源:SimpleBrowser.java


示例8: createDocumentSource

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
/**
 * Creates a new instance of the {@link org.fit.cssbox.io.DocumentSource} class registered in the browser configuration
 * ({@link org.fit.cssbox.layout.BrowserConfig}).
 * @param urlstring the URL to be given to the document source.
 * @return the document source.
 */
public DocumentSource createDocumentSource(URL base, String urlstring)
{
    try
    {
        Constructor<? extends DocumentSource> constr = config.getDocumentSourceClass().getConstructor(URL.class, String.class);
        return constr.newInstance(base, urlstring);
    } catch (Exception e) {
        System.err.println("BoxFactory: Warning: could not create the DocumentSource instance: " + e.getMessage());
        return null;
    }
}
 
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:18,代码来源:BoxFactory.java


示例9: createDOMSource

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
/**
 * Creates a new instance of the {@link org.fit.cssbox.io.DOMSource} class registered in the browser configuration
 * ({@link org.fit.cssbox.layout.BrowserConfig}).
 * @param src the document source to be given to the DOM source.
 * @return the DOM source.
 */
public DOMSource createDOMSource(DocumentSource src)
{
    try
    {
        Constructor<? extends DOMSource> constr = config.getDOMSourceClass().getConstructor(DocumentSource.class);
        return constr.newInstance(src);
    } catch (Exception e) {
        System.err.println("BoxFactory: Warning: could not create the DOMSource instance: " + e.getMessage());
        return null;
    }
}
 
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:18,代码来源:BoxFactory.java


示例10: createDOMSource

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
/**
 * Creates a new instance of the {@link org.fit.cssbox.io.DOMSource} class registered in the browser configuration
 * ({@link org.fit.cssbox.layout.BrowserConfig}).
 * @param src the document source to be given to the DOM source.
 * @return the DOM source.
 */
public DOMSource createDOMSource(DocumentSource src)
{
    try
    {
        Constructor<? extends DOMSource> constr = getDOMSourceClass().getConstructor(DocumentSource.class);
        return constr.newInstance(src);
    } catch (Exception e) {
        log.warn("BoxFactory: Warning: could not create the DOMSource instance: " + e.getMessage());
        return null;
    }
}
 
开发者ID:radkovo,项目名称:CSSBox,代码行数:18,代码来源:BrowserConfig.java


示例11: analyze

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
@Override
  public Viewport analyze(DocumentSource d, Dimension dim)
          throws Exception
  {
  	@SuppressWarnings("resource")
InputStream is = (d != null)? d.getInputStream() : null;
  	
  	if (!(is instanceof DocumentInputStream)) {
  		return super.analyze(d, dim);
  	}
  	
  	DocumentInputStream dIs = (DocumentInputStream) is;
  	
  	w3cdoc = dIs.getDocument();
  	URL address = ((Html5DocumentImpl)w3cdoc).getAddress();
  	
      // Create the CSS analyzer
      DOMAnalyzer da = new DOMAnalyzer(w3cdoc, address);
      da.attributesToStyles();
      da.addStyleSheet(null, CSSNorm.stdStyleSheet(), DOMAnalyzer.Origin.AGENT);
      da.addStyleSheet(null, CSSNorm.userStyleSheet(), DOMAnalyzer.Origin.AGENT);
      da.getStyleSheets();
      
      BufferedImage tmpImg = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
      canvas = new BrowserCanvas(da.getRoot(), da, address);
      canvas.setImage(tmpImg);
      canvas.getConfig().setLoadImages(true);
      canvas.getConfig().setLoadBackgroundImages(true);
      canvas.createLayout(dim);

      return canvas.getViewport();
  }
 
开发者ID:ITman1,项目名称:ScriptBox,代码行数:33,代码来源:ScriptAnalyzer.java


示例12: main

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args)
{
    if (args.length != 2)
    {
        System.err.println("Usage: ComputeStyles <url> <output_file>");
        System.exit(0);
    }
    
    try {
        //Open the network connection 
        DocumentSource docSource = new DefaultDocumentSource(args[0]);
        
        //Parse the input document
        DOMSource parser = new DefaultDOMSource(docSource);
        Document doc = parser.parse();
        
        //Create the CSS analyzer
        DOMAnalyzer da = new DOMAnalyzer(doc, docSource.getURL());
        da.attributesToStyles(); //convert the HTML presentation attributes to inline styles
        da.addStyleSheet(null, CSSNorm.stdStyleSheet(), DOMAnalyzer.Origin.AGENT); //use the standard style sheet
        da.addStyleSheet(null, CSSNorm.userStyleSheet(), DOMAnalyzer.Origin.AGENT); //use the additional style sheet
        da.getStyleSheets(); //load the author style sheets
        
        //Compute the styles
        System.err.println("Computing style...");
        da.stylesToDomInherited();
        
        //Save the output
        PrintStream os = new PrintStream(new FileOutputStream(args[1]));
        Output out = new NormalOutput(doc);
        out.dumpTo(os);
        os.close();
        
        docSource.close();
        
        System.err.println("Done.");
        
    } catch (Exception e) {
        System.err.println("Error: "+e.getMessage());
        e.printStackTrace();
    }

}
 
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:47,代码来源:ComputeStyles.java


示例13: main

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
/**
 * main method
 */
public static void main(String[] args)
{
    if (args.length != 1)
    {
        System.err.println("Usage: TextBoxes <url>");
        System.exit(0);
    }
    
    try {
        //Open the network connection 
        DocumentSource docSource = new DefaultDocumentSource(args[0]);
        
        //Parse the input document
        DOMSource parser = new DefaultDOMSource(docSource);
        Document doc = parser.parse();
        
        //Create the CSS analyzer
        DOMAnalyzer da = new DOMAnalyzer(doc, docSource.getURL());
        da.attributesToStyles(); //convert the HTML presentation attributes to inline styles
        da.addStyleSheet(null, CSSNorm.stdStyleSheet(), DOMAnalyzer.Origin.AGENT); //use the standard style sheet
        da.addStyleSheet(null, CSSNorm.userStyleSheet(), DOMAnalyzer.Origin.AGENT); //use the additional style sheet
        da.getStyleSheets(); //load the author style sheets
        
        //Create the browser canvas
        BrowserCanvas browser = new BrowserCanvas(da.getRoot(), da, docSource.getURL());
        //Disable the image loading
        browser.getConfig().setLoadImages(false);
        browser.getConfig().setLoadBackgroundImages(false);
        
        //Create the layout for 1000x600 pixels
        browser.createLayout(new java.awt.Dimension(1000, 600));
        
        //Display the result
        printTextBoxes(browser.getViewport());
        
        docSource.close();
        
    } catch (Exception e) {
        System.err.println("Error: "+e.getMessage());
        e.printStackTrace();
    }

}
 
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:47,代码来源:TextBoxes.java


示例14: read

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
/**
 * Reads input data and converts them to "elements"
 * 
 * @param is
 *            the input source
 * @param url
 *            the source of data
 * @param cba
 *            the instance of {@link CSSBoxAnalyzer}
 * @return the list of elements. Note that, this method returns instance of
 *         LinkedList.
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
public List<ElementSpec> read(DocumentSource docSource, CSSBoxAnalyzer cba, Dimension dim)
        throws IOException
{
    // ale ked sa pouzije setText() neviem nic o url, nic sa nenastavuje ,
    // moze byt null
    // (URL) doc.getProperty(Document.StreamDescriptionProperty)

    if (cba == null)
        throw new IllegalArgumentException(
                "CSSBoxAnalyzer can not be NULL !!!\nProvide your custom implementation or check instantiation of DefaultAnalyzer object...");

    List<ElementSpec> elements = new LinkedList<ElementSpec>();// ArrayList<ElementSpec>(1024);
    elements.add(new ElementSpec(SimpleAttributeSet.EMPTY, ElementSpec.EndTagType));

    // System.err.print("used Reader and encoding ? " +
    // is.getCharacterStream() + "  ,  ");
    // InputStreamReader r = (InputStreamReader)is.getCharacterStream();
    // System.err.println(r.getEncoding());

    ElementBox root;
    try
    {
        // System.err.println("analyzing...");
        root = cba.analyze(docSource, dim);
        // System.err.println("analyzing finished...");
    } catch (Exception e)
    {
        throw new IOException(e);
    }

    if (root instanceof Viewport)
    {
        // root should by an instance of Viewport
        buildViewport(elements, (Viewport) root);
    }
    else
    {
        buildElements(elements, root);
    }

    // System.err.println("num. of elements : " + elements.size());
    // System.err.println("Root min width : " + root.getMinimalWidth() +
    // " ,normal width : " + root.getWidth() + " ,maximal width : " +
    // root.getMaximalWidth());

    // TODO po skonceni nacitavania aj nejake info spravit
    // >> Document.TitleProperty - observer, metainfo
    return elements;
}
 
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:64,代码来源:ContentReader.java


示例15: registerDocumentSource

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
/**
 * Sets the class used by CSSBox for obtaining documents based on their URLs.
 * @param documentSourceClass the new document source class
 */
public void registerDocumentSource(Class<? extends DocumentSource> documentSourceClass)
{
    this.documentSourceClass = documentSourceClass;
}
 
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:9,代码来源:BrowserConfig.java


示例16: getDocumentSourceClass

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
/**
 * Obtains the class used by CSSBox for obtaining documents based on their URLs.
 * @return the used class
 */
public Class<? extends DocumentSource> getDocumentSourceClass()
{
    return documentSourceClass;
}
 
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:9,代码来源:BrowserConfig.java


示例17: renderURL

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
/**
 * Renders the URL and prints the result to the specified output stream in the specified
 * format.
 * @param urlstring the source URL
 * @param out output stream
 * @param type output type
 * @return true in case of success, false otherwise
 * @throws SAXException 
 */
public boolean renderURL(String urlstring, OutputStream out, Type type, String pageFormat) throws IOException, SAXException
{
    if (!urlstring.startsWith("http:") &&
        !urlstring.startsWith("ftp:") &&
        !urlstring.startsWith("file:"))
            urlstring = "http://" + urlstring;
    
    //Open the network connection 
    DocumentSource docSource = new DefaultDocumentSource(urlstring);
  
    //Parse the input document
    DOMSource parser = new DefaultDOMSource(docSource);
    Document doc = parser.parse();
   
    //create the media specification
    MediaSpec media = new MediaSpec(mediaType);
    media.setDimensions(windowSize.width, windowSize.height);
    media.setDeviceDimensions(windowSize.width, windowSize.height);

    //Create the CSS analyzer
    DOMAnalyzer da = new DOMAnalyzer(doc, docSource.getURL());
    da.setMediaSpec(media);
    
    da.attributesToStyles(); //convert the HTML presentation attributes to inline styles
    da.addStyleSheet(null, CSSNorm.stdStyleSheet(), DOMAnalyzer.Origin.AGENT); //use the standard style sheet
    da.addStyleSheet(null, CSSNorm.userStyleSheet(), DOMAnalyzer.Origin.AGENT); //use the additional style sheet
    da.addStyleSheet(null, CSSNorm.formsStyleSheet(), DOMAnalyzer.Origin.AGENT); //render form fields using css
    da.getStyleSheets(); //load the author style sheets

    BrowserCanvas contentCanvas = new BrowserCanvas(da.getRoot(), da, docSource.getURL());
    contentCanvas.setAutoMediaUpdate(false); //we have a correct media specification, do not update
    contentCanvas.getConfig().setClipViewport(cropWindow);
    contentCanvas.getConfig().setLoadImages(loadImages);
    contentCanvas.getConfig().setLoadBackgroundImages(loadBackgroundImages);

    if (type == Type.PNG)
    {
        contentCanvas.createLayout(windowSize);
        ImageIO.write(contentCanvas.getImage(), "png", out);
    }
    else if (type == Type.SVG)
    {
        setDefaultFonts(contentCanvas.getConfig());
        contentCanvas.createLayout(windowSize);
        Writer w = new OutputStreamWriter(out, "utf-8");
        writeSVG(contentCanvas.getViewport(), w);
        w.close();
    }
    else if (type == Type.PDF)
    {
        setDefaultFonts(contentCanvas.getConfig());
        contentCanvas.createLayout(windowSize);
        writePDF(contentCanvas.getViewport(), out, pageFormat);
    }

    docSource.close();

    return true;
}
 
开发者ID:radkovo,项目名称:CSSBoxPdf,代码行数:69,代码来源:PdfImageRenderer.java


示例18: renderURL

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
/**
 * Renders the URL and prints the result to the specified output stream in
 * the specified format.
 * 
 * @param urlstring
 *            the source URL
 * @param out
 *            output stream
 * @param type
 *            output type
 * @return true in case of success, false otherwise
 * @throws SAXException
 */
private boolean renderURL(URL urlstring, URL baseUrl, OutputStream out)
		throws IOException, SAXException {
	// Open the network connection
	DocumentSource docSource = new DefaultDocumentSource(urlstring);


	// Parse the input document
	DOMSource parser = new DefaultDOMSource(docSource);
	Document doc = parser.parse();

	// create the media specification
	MediaSpec media = new MediaSpec(mediaType);
	media.setDimensions(windowSize.width, windowSize.height);
	media.setDeviceDimensions(windowSize.width, windowSize.height);

	// Create the CSS analyzer
	DOMAnalyzer da = new DOMAnalyzer(doc, baseUrl);
	da.setMediaSpec(media);
	da.attributesToStyles(); // convert the HTML presentation attributes to
								// inline styles
	da.addStyleSheet(baseUrl, CSSNorm.stdStyleSheet(),
			DOMAnalyzer.Origin.AGENT); // use the standard style sheet
	da.addStyleSheet(null, CSSNorm.userStyleSheet(),
			DOMAnalyzer.Origin.AGENT); // use the additional style sheet
	da.addStyleSheet(null, CSSNorm.formsStyleSheet(),
			DOMAnalyzer.Origin.AGENT); // render form fields using css
	da.getStyleSheets(); // load the author style sheets

	BrowserCanvas contentCanvas = new BrowserCanvas(da.getRoot(), da,
			baseUrl);
	// contentCanvas.setAutoMediaUpdate(false); // we have a correct media
	// // specification, do not
	// // update
	contentCanvas.getConfig().setClipViewport(cropWindow);
	contentCanvas.getConfig().setLoadImages(loadImages);
	contentCanvas.getConfig().setLoadBackgroundImages(loadBackgroundImages);
	contentCanvas.setPreferredSize(new Dimension(windowSize.width, 10));
	contentCanvas.setAutoSizeUpdate(true);

	setDefaultFonts(contentCanvas.getConfig());

	contentCanvas.createLayout(windowSize);
	contentCanvas.validate();
	ImageIO.write(contentCanvas.getImage(), "png", out);

	// Image image = contentCanvas.createImage(windowSize.width,
	// windowSize.height);

	docSource.close();

	return true;
}
 
开发者ID:riccardove,项目名称:easyjasub,代码行数:66,代码来源:CssBoxPngRenderer.java


示例19: decodeFont

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
public static Font decodeFont(DocumentSource fontSource, String format) throws FontFormatException, IOException
{
    //TODO decode other formats than TTF
    return Font.createFont(Font.TRUETYPE_FONT, fontSource.getInputStream());
}
 
开发者ID:radkovo,项目名称:CSSBox,代码行数:6,代码来源:FontDecoder.java


示例20: renderURL

import org.fit.cssbox.io.DocumentSource; //导入依赖的package包/类
/**
 * Renders the URL and prints the result to the specified output stream in the specified
 * format.
 * @param urlstring the source URL
 * @param out output stream
 * @param type output type
 * @return true in case of success, false otherwise
 * @throws SAXException 
 */
public boolean renderURL(String urlstring, OutputStream out, Type type) throws IOException, SAXException
{
    if (!urlstring.startsWith("http:") &&
        !urlstring.startsWith("https:") &&
        !urlstring.startsWith("ftp:") &&
        !urlstring.startsWith("file:"))
            urlstring = "http://" + urlstring;
    
    //Open the network connection 
    DocumentSource docSource = new DefaultDocumentSource(urlstring);
    
    //Parse the input document
    DOMSource parser = new DefaultDOMSource(docSource);
    Document doc = parser.parse();
    
    //create the media specification
    MediaSpec media = new MediaSpec(mediaType);
    media.setDimensions(windowSize.width, windowSize.height);
    media.setDeviceDimensions(windowSize.width, windowSize.height);

    //Create the CSS analyzer
    DOMAnalyzer da = new DOMAnalyzer(doc, docSource.getURL());
    da.setMediaSpec(media);
    da.attributesToStyles(); //convert the HTML presentation attributes to inline styles
    da.addStyleSheet(null, CSSNorm.stdStyleSheet(), DOMAnalyzer.Origin.AGENT); //use the standard style sheet
    da.addStyleSheet(null, CSSNorm.userStyleSheet(), DOMAnalyzer.Origin.AGENT); //use the additional style sheet
    da.addStyleSheet(null, CSSNorm.formsStyleSheet(), DOMAnalyzer.Origin.AGENT); //render form fields using css
    da.getStyleSheets(); //load the author style sheets
    
    BrowserCanvas contentCanvas = new BrowserCanvas(da.getRoot(), da, docSource.getURL());
    contentCanvas.setAutoMediaUpdate(false); //we have a correct media specification, do not update
    contentCanvas.getConfig().setClipViewport(cropWindow);
    contentCanvas.getConfig().setLoadImages(loadImages);
    contentCanvas.getConfig().setLoadBackgroundImages(loadBackgroundImages);

    if (type == Type.PNG)
    {
        contentCanvas.createLayout(windowSize);
        ImageIO.write(contentCanvas.getImage(), "png", out);
    }
    else if (type == Type.SVG)
    {
        setDefaultFonts(contentCanvas.getConfig());
        contentCanvas.createLayout(windowSize);
        Writer w = new OutputStreamWriter(out, "utf-8");
        writeSVG(contentCanvas.getViewport(), w);
        w.close();
    }
    
    docSource.close();

    return true;
}
 
开发者ID:radkovo,项目名称:CSSBox,代码行数:63,代码来源:ImageRenderer.java



注:本文中的org.fit.cssbox.io.DocumentSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ServiceContextHelper类代码示例发布时间:2022-05-22
下一篇:
Java Matrix3f类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap