Source: http://mindprod.com/jgloss/htmlrendering.html
HTML rendering<!-- alias rendering HTML -->
HTML rendering refers to analying the tags such as <b> and merging them with the text to produce a
formatted display.
In Applets
If you writing Java source code for an Applet
, you can persuade the browser you are
running
<!-- macro JDisplay htmlrendering.example101.javafrag --><!-- generated -->
java
.
net
.
URL
url
=
new
java
.
net
.
URL
(
"http://mindprod.com"
)
;
getAppletContext
(
)
.
showDocument
(
url
)
;
<!-- /generated by JDisplay -->
That code will fail with a NullPointerException
if you attempt it in an application.
You can catch all exceptions and just ignore the request in code that sometimes runs as an Applet and sometimes
as an application.
There are some catches:
- The URL must be absolute and must have a protocol e.g. http:
or file:
. Use getDocumentBase
or getCodeBase
and the URL
context-constructor to make it absolute if you have a relative one. You
must always have at least filename in your relative part.
- Older versions of Opera did not work showDocument
if there is a trailing
#XXXX
on your URL.
- Netscape 4.79 does not work at all with JApplet
s.
-
showDocument
ignores the BASE TARGET
of the current
page. You must specify it explicitly as the second parameter to showDocument
.
In Applications
- Unfortunately showDocument
does not allow you to take a hunk of HTML you have
in a String, perhaps as the result of a POST, and display it. In that case you somehow have to persuade your
server to put that html in a file where you can find it via URL. Alternatively you could use Sun’s
not-free HTML rendering classes.
- In <!-- macro Java 1.2 --><!-- generated -->Java version 1.2
<!-- /generated by Java --> there is javax.swing.text
.HTMLEditorKit
. which offers primitive HTML 3.2 rendering ability, inching toward HTML 4
compatibility. It also supports surprising amount of CSS. You use it like this:
<!-- macro JDisplay htmlrendering.example1.javafrag --><!-- generated -->
output
=
new
JEditorPane
(
)
;
output
.
setContentType
(
"text/html"
)
;
output
.
setEditable
(
false
)
;
<!-- /generated by JDisplay -->
From then on text in the pane is rendered as HTML. You can also use
<!-- macro JDisplay htmlrendering.example2.javafrag --><!-- generated -->
output
.
setPage
(
"http://mindprod.com"
)
;
<!-- /generated by JDisplay -->
to render a page.
- Here is how you can render and URL pointing to an HTML page inside Java.
-
/*
* @(#)TestHTMLRendering.java
*
* Summary: Eaxample use of Java HTML Rendering. Renders HTML 3.2 plus some CSS. Does not ignore comments properly. Does not.
*
* Copyright: (c) 2009-2010 Roedy Green, Canadian Mind Products, http://mindprod.com
*
* Licence: This software may be copied and used freely for any purpose but military.
* http://mindprod.com/contact/nonmil.html
*
* Requires: JDK 1.6+
*
* Created with: IntelliJ IDEA IDE.
*
* Version History:
* 1.0 2009-01-01 - initial version
*/
package com.mindprod.example;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import java.awt.Color;
import java.awt.Container;
import java.io.IOException;
import static java.lang.System.err;
import static java.lang.System.out;
/**
* Eaxample use of Java HTML Rendering. Renders HTML 3.2 plus some CSS. Does not ignore comments properly. Does not.
* <p/>
* implement clickable links.
*
* @author Roedy Green, Canadian Mind Products
* @version 1.0 2009-01-01 - initial version
* @since 2009-01-01
*/
@SuppressWarnings( { "UnusedDeclaration" } )
final class TestHTMLRendering
{
// ------------------------------ CONSTANTS ------------------------------
/**
* height of frame in pixels
*/
private static final int height = 1000;
/**
* width of frame in pixels
*/
private static final int width = 1000;
private static final String RELEASE_DATE = "2007-10-04";
/**
* title for frame
*/
private static final String TITLE_STRING = "HTML Rendering";
/**
* URL of page we want to display
*/
private static final String URL = "http://mindprod.com/index.html";
/**
* program version
*/
private static final String VERSION_STRING = "1.0";
// --------------------------- main() method ---------------------------
/**
* Debugging harness for a JFrame
*
* @param args command line arguments are ignored.
*/
@SuppressWarnings( { "UnusedParameters" } )
public static void main( String args[] )
{
// Invoke the run method on the Swing event dispatch thread
// Sun now recommends you call ALL your GUI methods on the Swing
// event thread, even the initial setup.
// Could also use invokeAndWait and catch exceptions
SwingUtilities.invokeLater( new Runnable()
{
/**
* } fire up a JFrame on the Swing thread
*/
public void run()
{
out.println( "Starting" );
final JFrame jframe =
new JFrame( TITLE_STRING + " " + VERSION_STRING );
Container contentPane = jframe.getContentPane();
jframe.setSize( width, height );
contentPane.setBackground( Color.YELLOW );
contentPane.setForeground( Color.BLUE );
jframe.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
try
{
out.println( "acquiring URL" );
JEditorPane jep = new JEditorPane( URL );
out.println( "URL acquired" );
JScrollPane jsp =
new JScrollPane( jep,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
contentPane.add( jsp );
}
catch ( IOException e )
{
err.println( "can't find URL" );
contentPane.add( new JLabel( "can't find URL" ) );
}
jframe.validate();
jframe.setVisible( true );
// Shows page, with HTML comments erroneously displayed.
// The links are not clickable.
}
} );
}// end main
}// end TestHTMLRendering
- In older JVMs, if you are writing an application you are SOL. For applications, there is no standard HTML
rendering class, though BISS-AWT has some primitive HTML rendering code.
-
Flying Saucer
is very rigid about standards.
It will not render the typical crap you find on the web, only your own carefully validated markup.
-
JDIC Browser
is a
means to embed Gecko into your Java app, giving pretty much all the rendering engine you might need.
分享到:
相关推荐
《Physically Based Rendering: From Theory to Implementation》第三版的配套源代码。
[Morgan Kaufmann series in computer graphics and geometric modeling] Matt Pharr, Wenzel Jakob, Greg Humphreys - Physically Based Rendering. From Theory to Implementation (2017, Morgan Kaufmann)
Conditional-Rendering:用CodeSandbox创建
This book on rendering considers REAL rendering systems,integrating complex geometry, procedural shading, and globalillumination. It is edited by Ian Stephenson, but each chapter has beenwritten by a ...
title = {Differentiable Volumetric Rendering: Learning Implicit 3D Representations without 3D Supervision}, author = {Niemeyer, Michael and Mescheder, Lars and Oechsle, Michael and Geiger, Andreas},...
Physically Based Rendering - From Theory to Implementation 3rd edition.part2.rar
Real Time Rendering 游戏开发 实时渲染,英文原版,文字高清版。 @本资源由火山资源组提供
amira_blender_rendering关于AMIRA Blender Rendering:使用Blender进行真实感渲染的工具。 该项目旨在为基于物理的真实感渲染提供一个精益的程序框架,并使专家和初学者都可以使用它。 该项目基于渲染功能及其 ...
Volume Rendering 纯 C++ 实现 Raycasting 实现的 Volume Rendering 算法。 数据下载 一份 CBCT 数据,在 下载并放入 文件夹下。 基本知识 看不了公式可以访问 HTML 页面: Raycasting is not the same as raytracing...
对于理解渲染的各个部分,构建渲染器很有用,特别是在体渲染方面,提供了很详细的介绍。
该插件添加了实用程序,可在Tailwind CSS中使用image-rendering 。 安装 将此插件添加到您的项目中: # Install using pnpm pnpm install --save-dev tailwindcss-image-rendering # Install using npm npm install...
总计225M,1000多页,这是第八章 CHAPTER 08. FILM AND THE IMAGING PIPELINE
pybullet_rendering 模拟器的外部渲染。安装使用点 pip install pybullet_rendering从源代码安装NumPy pip install numpy从源代码安装PyBullet git clone ...
总计225M,1000多页,这是第五章 CHAPTER 05. COLOR AND RADIOMETRY
快速开始本指南将帮助您在开发机器上运行dotcom-rendering应用程序。安装Node.js 在开始之前,需要确保已安装的唯一东西是 我们建议使用 (尤其是与结合使用)。 在一台机器上管理多个版本的Node.js很棒。运行说明$ ...
Azure 远程渲染欢迎使用。 此服务使您能够在 HoloLens 2 等设备上实时渲染高度复杂的 3D 模型。 可以在此处找到 Azure 远程渲染的完整文档: : 此存储库包含以下文件夹: Unity - 此文件夹包含用于 Unity 游戏引擎的...
-渲染后的图片渲染后的图片\ n使用Waifu2x-Extension-GUI与腾讯云的GPU云服务器渲染(下次考虑使用华为云的免费GPU云服务器)\ n备注:\ n还要渲染美少女万华镜2,5的CG以及逆流茶会的图\ n sp的封面图渲染选错了\ n ...
Ray_Tracing_Rendering 光线跟踪算法,可基于单个光线生成环境。 它包括四个阶段,包括降噪和两个球体上的光线跟踪 第1部分 第2部分 第三部分 第4部分
试剂服务器渲染问题您希望Reagent在服务器上生成HTML并将渲染的页面发送到浏览器。...server-rendering步骤2:将必要的依赖项和插件添加到project.clj :dependencies [[org.clojure/clojure " 1.7.0 " ]
边缘渲染 在查看实时项目。 当前,大多数3D城市Web可视化效果如下所示: 对比度非常差,很难理解建筑物的形状。 在这个项目中,我不仅使用边缘渲染来显示建筑物形状,还使用边缘渲染。 自定义边缘,再结合精美的矢量...