XHTMLPanel panel = new XHTMLPanel(); panel.setDocument("http://www.google.com");
/** * 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()); }
public void install(XHTMLPanel panel) { this.panel = panel; if (!checkDocument()) { return; } panel.setTransferHandler(handler); panel.addMouseListener(this); panel.addMouseMotionListener(this); }
/** * Creates a new renderer with no document specified. */ public Graphics2DRenderer() { panel = new XHTMLPanel(); panel.setInteractive(false); }
/** * Loads and renders a Document given a uri. * The uri is resolved by the UserAgentCallback * * @param uri */ public void setDocument(String uri) { setDocument(loadDocument(uri), uri); }
public void init() throws Exception { Container contentPane = this.getContentPane(); XHTMLPanel panel = new XHTMLPanel(); panel.getSharedContext().getTextRenderer().setSmoothingThreshold(0); // Anti-aliasing for all font sizes panel.setDocument(new File("c:\\Temp\\MyExperiment\\T2 BioCatalogue Plugin\\BioCatalogue Plugin\\resources\\test.html")); FSScrollPane scroll = new FSScrollPane(panel); contentPane.add(scroll); this.setTitle("XHTML rendered test"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.pack(); this.setSize(1024, 768); }
/** * Renders an XML Document instance. * Make sure that no relative resources are needed * * @param doc The document to render. */ public void setDocument(Document doc) { setDocument(doc, ""); }
g2r.getSharedContext().setDPI(72f); g2r.getSharedContext().getTextRenderer().setSmoothingThreshold(0); g2r.getSharedContext().setUserAgentCallback(panel.getSharedContext().getUserAgentCallback()); g2r.setDocument(panel.getDocument(), panel.getSharedContext().getUac().getBaseURL()); g2r.getSharedContext().setReplacedElementFactory(panel.getSharedContext().getReplacedElementFactory()); g2r.layout(g2, null); g2r.getPanel().assignPagePrintPositions(g2); if (page >= g2r.getPanel().getRootLayer().getPages().size()) { return Printable.NO_SUCH_PAGE; g2r.getPanel().paintPage(g2, page);
/** * Description of the Method * * @param evt PARAM */ public void actionPerformed(ActionEvent evt) { panel.getSharedContext().setDebug_draw_font_metrics(!panel.getSharedContext().debugDrawFontMetrics()); panel.repaint(); } }
panel = new XHTMLPanel(); int width = 360; int height = 500; panel.setPreferredSize(new Dimension(width, height)); JScrollPane scroll = new JScrollPane(panel); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scroll.setPreferredSize(new Dimension(width, height)); panel.addMouseTrackingListener(new LinkListener());
/** * Renders a Document read from an InputStream using a URL * as a base URL for relative paths. * * @param file The file to read the Document from. Relative paths * will be resolved based on the file's parent directory. */ // TODO: should throw more specific exception (PWW 25/07/2006) public void setDocument(File file) throws Exception { resetListeners(); File parent = file.getAbsoluteFile().getParentFile(); String parentURL = ( parent == null ? "" : parent.toURI().toURL().toExternalForm()); setDocument( loadDocument(file.toURI().toURL().toExternalForm()), parentURL ); }
public void run() { try { long st = System.currentTimeMillis(); URL url = null; if (uri.startsWith("http://")) url = new URL(uri); else url = new File(uri).toURL(); System.err.println("loading " + url.toString() + "!"); panel.setDocument(url.toExternalForm()); long el = System.currentTimeMillis() - st; XRLog.general("loadDocument(" + url.toString() + ") in " + el + "ms, render may take longer"); HTMLTest.this.setTitle(BASE_TITLE + "- " + panel.getDocumentTitle() + " " + "(" + url.toString() + ")"); } catch (Exception ex) { Uu.p(ex); } panel.repaint(); } });
private static void setDocumentStyle(XHTMLPanel view) { JLabel label = new JLabel(); Font font = label.getFont(); String css = ".launcher-font-style { " + "font-family: '" + font.getFontName() + "';" + "font-size: " + font.getSize2D() + "pt;" + "}"; Document doc = view.getDocument(); Element style = doc.createElement("style"); style.appendChild(doc.createTextNode(css)); doc.getElementsByTagName("head").item(0).appendChild(style); view.setDocument(doc); }
/** * Renders a Document using a URL as a base URL for relative * paths. * * @param doc The new document value * @param url The new document value */ public void setDocument(Document doc, String url) { resetListeners(); setDocument(doc, url, new XhtmlNamespaceHandler()); }
final XHTMLPanel p = new XHTMLPanel(); p.setDocumentFromString(h, resource, new XhtmlNamespaceHandler());
closeButton = new JButton(); fSScrollPane1 = new FSScrollPane(); xHTMLPanel1 = new XHTMLPanel(); xHTMLPanel1.setLayout(xHTMLPanel1Layout); xHTMLPanel1Layout.setHorizontalGroup( xHTMLPanel1Layout.createParallelGroup(Alignment.LEADING)
XHTMLPanel panel = new XHTMLPanel(new UAC());
/** * Gets the SharedContext for layout and rendering. * * @return see desc */ public SharedContext getSharedContext() { return panel.getSharedContext(); }
StringBuffer hlText = new StringBuffer(); if (this.dotInfo == null) { getComponent().getRootBox().clearSelection(modified); getComponent().repaint(); lastHighlightedString = ""; return; getComponent().getRootBox().clearSelection(modified); } else { boolean endBeforeStart = (this.markInfo.range.compareBoundaryPoints( Range.START_TO_START, this.dotInfo.range) >= 0); getComponent().getRootBox().clearSelection(modified); InlineText t1 = (endBeforeStart) ? this.dotInfo.text : this.markInfo.text; InlineText t2 = (!endBeforeStart) ? this.dotInfo.text : this.markInfo.text; getComponent().repaint(); lastHighlightedString = Util.replace(s, PARA_EQUIV, "\n\n");
private boolean checkDocument() { while (true) { if (this.document != panel.getDocument() || textInlineMap == null) { this.document = panel.getDocument(); textInlineMap = null; this.dotInfo = null; this.markInfo = null; this.lastSelectionRange = null; try { this.docRange = (DocumentRange) panel.getDocument(); this.docTraversal = (DocumentTraversal) panel.getDocument(); if (this.document != null && this.createMaps()) { return true; } try { Thread.sleep(10); } catch (InterruptedException e) { return false; } } catch (ClassCastException cce) { XRLog.layout(Level.WARNING, "Document instance cannot create ranges: no selection possible"); return false; } } return true; } }