本文整理汇总了Java中org.fit.cssbox.css.DOMAnalyzer类的典型用法代码示例。如果您正苦于以下问题:Java DOMAnalyzer类的具体用法?Java DOMAnalyzer怎么用?Java DOMAnalyzer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DOMAnalyzer类属于org.fit.cssbox.css包,在下文中一共展示了DOMAnalyzer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: analyze
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的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: JSAnalyzer
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的package包/类
/**
* Creates a new JS analyzer
* @param da Initialized CSSBox analyzer
* @param basePath The URL of the document
*/
public JSAnalyzer(DOMAnalyzer da, URL basePath)
{
this.da = da;
this.doc = da.getRoot().getOwnerDocument();
this.basePath = basePath;
// JavaScript
manager = new ScriptEngineManager();
engine = manager.getEngineByName("rhino");
// Global objects
HTMLListener htmlListener = new EmptyHTMLListener();
CSSListener cssListener = new EmptyCSSListener();
ParserListener parserListener = new EmptyParserListener();
jsaf = new DefaultCSSBoxFactory(doc, basePath,
htmlListener, cssListener, parserListener);
document = (Document) jsaf.create(doc, JSAdapterType.DOCUMENT);
window = new Window();
window.document = document;
pDOMException = new PrototypeDOMException();
pNode = new PrototypeNode();
}
开发者ID:rkocman,项目名称:JSDOMBox,代码行数:28,代码来源:JSAnalyzer.java
示例3: StyleImport
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的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
示例4: SimpleBrowser
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的package包/类
/**
* Creates a new application window and displays the rendered document
* @param root The root DOM element of the document body
* @param baseurl The base URL of the document used for completing the relative paths
* @param decoder The CSS analyzer that provides the effective style of the elements
*/
public SimpleBrowser(Element root, URL baseurl, DOMAnalyzer decoder)
{
docroot = root;
this.decoder = decoder;
initComponents(baseurl);
}
开发者ID:radkovo,项目名称:CSSBox,代码行数:13,代码来源:SimpleBrowser.java
示例5: main
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的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
示例6: renderDocument
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的package包/类
private BufferedImage renderDocument(Document doc)
{
//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);
contentCanvas.createLayout(windowSize);
return contentCanvas.getImage();
}
开发者ID:radkovo,项目名称:CSSBox,代码行数:26,代码来源:ReferenceTestCase.java
示例7: createDecoder
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的package包/类
private void createDecoder()
{
decoder = new DOMAnalyzer(doc, base);
if (encoding == null)
encoding = decoder.getCharacterEncoding();
decoder.setDefaultEncoding(encoding);
decoder.attributesToStyles();
decoder.addStyleSheet(null, CSSNorm.stdStyleSheet(), DOMAnalyzer.Origin.AGENT);
decoder.addStyleSheet(null, CSSNorm.userStyleSheet(), DOMAnalyzer.Origin.AGENT);
decoder.getStyleSheets();
}
开发者ID:radkovo,项目名称:CSSBox,代码行数:12,代码来源:ReplacedText.java
示例8: analyze
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的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
示例9: main
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的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
示例10: BoxFactory
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的package包/类
/**
* Create a new factory.
* @param decoder The CSS decoder used for obtaining the DOM styles.
* @param baseurl Base URL used for completing the relative URLs in the document.
*/
public BoxFactory(DOMAnalyzer decoder, URL baseurl)
{
this.decoder = decoder;
this.baseurl = baseurl;
this.next_order = 0;
this.config = new BrowserConfig();
this.html = new HTMLBoxFactory(this);
}
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:14,代码来源:BoxFactory.java
示例11: BrowserCanvas
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的package包/类
/**
* Creates a new instance of the browser engine for a document. After creating the engine,
* the layout itself may be computed by calling {@link #createLayout(Dimension)}.
* @param root the <body> element of the document to be rendered
* @param decoder the CSS decoder used to compute the style
* @param baseurl the document base URL
*/
public BrowserCanvas(org.w3c.dom.Element root, DOMAnalyzer decoder, URL baseurl)
{
this.root = root;
this.decoder = decoder;
this.baseurl = baseurl;
this.config = new BrowserConfig();
this.createImage = true;
this.autoSizeUpdate = true;
}
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:17,代码来源:BrowserCanvas.java
示例12: PdfBrowserCanvas
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的package包/类
/**
* Creates a canvas from a PDF file and computes the layout.
* @param document the PDF document
* @param startPage starting page
* @param endPage ending page
* @param decoder DOM analyzer
* @param dim preferred canvas dimension
* @param baseurl base URL for loading referenced data
*/
public PdfBrowserCanvas(PDDocument document, int startPage, int endPage, DOMAnalyzer decoder, Dimension dim, URL baseurl)
{
super(null, decoder, dim, baseurl);
this.pdfdocument = document;
this.startPage = startPage;
this.endPage = endPage;
createPdfLayout(dim);
pdfLoaded = true;
}
开发者ID:radkovo,项目名称:Pdf2Dom,代码行数:19,代码来源:PdfBrowserCanvas.java
示例13: BoxFactory
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的package包/类
/**
* Create a new factory.
* @param decoder The CSS decoder used for obtaining the DOM styles.
* @param baseurl Base URL used for completing the relative URLs in the document.
*/
public BoxFactory(DOMAnalyzer decoder, URL baseurl)
{
this.decoder = decoder;
this.baseurl = baseurl;
this.next_order = 0;
this.overflowPropagated = false;
this.config = new BrowserConfig();
this.html = new HTMLBoxFactory(this);
}
开发者ID:radkovo,项目名称:CSSBox,代码行数:15,代码来源:BoxFactory.java
示例14: BrowserCanvas
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的package包/类
/**
* Creates a new instance of the browser engine for a document. After creating the engine,
* the layout itself may be computed by calling {@link #createLayout(Dimension)}.
* @param root the <body> element of the document to be rendered
* @param decoder the CSS decoder used to compute the style
* @param baseurl the document base URL
*/
public BrowserCanvas(org.w3c.dom.Element root, DOMAnalyzer decoder, URL baseurl)
{
this.root = root;
this.decoder = decoder;
this.baseurl = baseurl;
this.config = new BrowserConfig();
this.createImage = true;
this.autoSizeUpdate = true;
this.autoMediaUpdate = true;
}
开发者ID:radkovo,项目名称:CSSBox,代码行数:18,代码来源:BrowserCanvas.java
示例15: analyze
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的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
示例16: applyEffectiveStylesToStyleAttributes
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的package包/类
private static void applyEffectiveStylesToStyleAttributes(final Document doc, final URL relativeUrl) {
DOMAnalyzer da = new DOMAnalyzer(doc, relativeUrl);
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
da.stylesToDomInherited();
}
开发者ID:JayStGelais,项目名称:easy-mail,代码行数:9,代码来源:HtmlProcessor.java
示例17: main
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的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
示例18: main
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的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
示例19: renderURL
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的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
示例20: SimpleExample
import org.fit.cssbox.css.DOMAnalyzer; //导入依赖的package包/类
public SimpleExample(DOMAnalyzer da, URL url)
{
this.da = da;
this.url = url;
initComponents();
}
开发者ID:rkocman,项目名称:JSDOMBox,代码行数:7,代码来源:SimpleExample.java
注:本文中的org.fit.cssbox.css.DOMAnalyzer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论