Java basics-how to display special mathematical symbols on the Web

Source: Internet
Author: User
Java basics-how to make the Web display of special mathematical symbols-general Linux technology-Linux programming and kernel information, the following is a detailed description. The rapid development of networks enables people to communicate with each other at different times and spaces. However, currently, communication is only limited to text or simple, pre-edited images. When talking about mathematics, people often suffer from the inability to directly express accurate meanings with simple mathematical symbols, which greatly limits the development of distance learning. At the same time, network communication is stuck in the near-original way. It can be said that only text is used to replace speech. This article describes the solutions to this problem using SVG and Java Development kits. With this solution, users on different network terminals can use mathematical languages similar to MathLab to describe their desired mathematical symbols. The server dynamically generates mathematical symbol images and sends them to other terminals.

Several existing solutions

Currently, the following mathematical symbol display solutions are available on the Internet:

◆ MathML is a language developed by W3C Based on XML standards to display mathematical symbols on the network. However, it is very complicated and IE currently does not support the required plug-ins. At the same time, because it needs to be explained on the client, the speed is also a problem.

◆ In the previous teaching software, Applet was used to solve the display of mathematical symbols. However, the speed problem and Microsoft's resistance to Applet have gradually lost its vitality.

◆ SVG is not currently supported by IE, but its plug-ins are relatively easy to obtain. Once Acrobat Reader is installed, the plug-in is automatically installed.

Related Technologies

XML

EXtensible Markup Language (XML) is an eXtensible metadatabase. XML is a Language developed by SGML (Standard General Markup Language). It aims to adapt to the Web application environment and normalize documents transmitted over the network. It expresses the semantic elements and their associations of the document content by means of structural tag definition, and provides the semantic format standard for online data exchange, and the implementation of various business documentation standard.

XSLT

XSLT (Extensible Stylesheet Language Transformation) is a Language that converts XML documents into other types of documents.

JAXP

JAXP (Java API for XML Processing) is a new XML toolkit launched by Sun. Supports the latest DOM and SAX APIs.

SVG

SVG (Scalabel Vector Graphics) is a standard for describing two-dimensional images in XML format. These XML documents end with the. svg extension and can be read and displayed by the SVG browser. Currently, most Web browsers support using plug-ins or ActiveX Controls (such as Adobe SVG Brower) to view SVG documents. The reason why "Scalable Vector images" are called is because SVG processes vector images rather than grating images. The vector image is scalable and does not reduce resolution or blur details when the image is scaled or rotated. You can also use a lightweight Portable format to describe complex images. Compared with other formats, the main advantages of the vector image format are: first, the size of the file containing the graphic information is small; second, the organization information is easy to understand.

In SVG, all images are composed of elements, such as line, path, and text.

JSP

JSP (Java Serve Page) can integrate the Java language into the HTML webpage environment on the Web Server, and use the Java program code contained in the webpage to replace the original CGI, ISAPI, or IDC program. It is mainly used to create dynamic web pages.

Design Concept
Obviously, the ASC Ⅱ character is not used to display mathematical symbols, which requires a customizable graphic specification. SVG exactly acts as this role. SVG is a standard for describing two-dimensional images in XML format and can be dynamically generated, which facilitates the generation of mathematical symbols.

The description of mathematical formulas can be completed in XML. XML is convenient and clear in describing an ordered nested structure, and it is a tree structure, while mathematical formulas can be abstracted into tree structures. For example, the following mathematical symbols can be abstracted.

Mathematical symbols

You can define symbol elements, such as the root number, number, and sum symbol. Add attributes that describe the characteristics of these elements, such as the length of the root number. In this way, the information of a mathematical formula can be fully described. Because our goal is to display, the upper or lower mark can be regarded as a sibling element, which is expressed in a unified way.

Formula Structure Tree

Because all the images displayed in SVG are composed of elements, You need to define the symbol display format based on the elements. 2. For letters or numbers, they are defined according to the current font style rules. For special symbols, they define the format of some feature parts.

Display format definition

According to the display characteristics of SVG elements, coordinates must be specified for each element. Therefore, after defining the format, you also need to obtain the displayed coordinate data. For example, the root number requires the leftmost coordinate, height, and width, and the number only needs to know the coordinates of the start position, 3.

Show coordinate data

For the convenience of user input, a set of input rules are defined in the system. The keyword starts with "$" and consists of three letters, such as table 1.

Table 1 custom keywords

$ SQR root number
$ Subscript
$ SIG summation symbol
$ FRA semicolon

The sub-element of the symbol is described in. Special symbols, such as summation characters and upper and lower bounds, are separated by commas. For example, the above mathematical symbols can be expressed as: $ SQR [243 $ SIG [n, I = 1] X $ hour ].

It should be noted that, when defining lexical information, we should try to conform to writing habits and avoid excessive nesting. For example, the subscript of a variable and the variable belong to a sibling relationship rather than a parent-child relationship.

It is the main flowchart for converting user input into graphical display. The JAXP package is used to convert the formula tree described in XML into an SVG file. You can convert SVG to JPG format or directly embed it into a webpage as needed.

Flowchart for converting user input to graphical display

Example

Describe the statement $ SQR [243 $ SIG [n, I = 1] X $ alias in the previous section.] The compiled XML file is:

Math. xml



243
N
I = 1

X
I



Convert it to an SVG file using JAXP and math. xsl:

Math. svg



243 243
N
I = 1 I = 1

X
I


For the final display image, see.



Running result Diagram

In addition, this mode can be used to display special symbols such as chemical symbols and maps. Especially in the development trend of network services and thin clients, such browser-only processing mechanisms will be vigorously developed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.