An Improved Approach for Creating SVG/XML Code and SVG/XML DOM Nodes using Java Los Angeles CA

Learn to write a method that deals with the escape sequences required for the quotation marks that surround attribute values in XML and a method that makes it possible to create a general node in the DOM tree being used to represent an SVG graphic.

Local Companies

Moyea Software
92295612365
Hot building, ring street
LA, CA
Interneer Inc.
8005586832 x85
6101 W. Centinela Ave.
Culver City, CA
Cornerstone Concepts Inc
818-247-3909
600 W Broadway
Glendale, CA
Greene Computer Corporation
(818) 956-4961
200 S. Louise Street
Glendale, CA
Corticalx Inc Software Solutions & Technology
818-500-0881
425 E Colorado St
Glendale, CA
Alphatier Systems
818-409-8920
517 Griswold St
Glendale, CA
TimeTECH - Customizable Time and Attendance / Workforce Management Solutions
905-677-7009
7420 Airport Rd 203
Mississauga, CA
Hutchinson & Bloodgood, LLP
(818) 637-5000
101 N. Brand Blvd. #1600
Glendale, CA
Telsoft Solutions
818-545-8680
100 N Brand Blvd
Glendale, CA
Abraxas Technologies Inc
818-502-9100
450 N Brand Blvd
Glendale, CA

provided by: 
Originally published at Internet.com


Java Programming Notes # 2214 * Preface * General * Viewing tip * Figures * Listings * Supplementary material * General background information * Preview * Discussion and sample code * The Svg07 program * The Svg08 program * Run the program * Summary * What's next? * Complete program listings * Copyright * Resources * About the author -----------------------------------

Preface

General

This is the second lesson in a series designed to teach you how to write servlets to produce SVG code that will be rendered in graphic form by an SVG-compatible browser.

An SVG graphics library

In the previous lesson titled "Java JAXP, Creating graphics using Java and SVG" (see Resources) I taught you how write your own SVG graphics library to eliminate, or at least alleviate the requirement to write raw XML code or raw JAXP DOM code, making it possible for you to produce SVG output simply by making typical Java method calls.

At the end of the previous lesson, I promised that this lesson would teach you how to take what you learned in the previous lesson and apply it to the generation of XHTML files containing in-line SVG/XML code. I also promised that this lesson would teach you how to apply that knowledge to the writing of servlets that produce XHTML output containing in-line SVG/XML code. Upon further consideration, however, I decided to delay that material until the lesson following this one.

Upgrading the SVG graphics library

In this lesson, I will provide two more methods for the SVG graphics library that make it even easier to write servlets to produce SVG output. The first method eliminates the frustration of dealing with the escape sequences required for the quotation marks that surround attribute values in XML. The second method makes it possible to create a general node in the DOM tree being used to represent an SVG graphic.

Viewing tip

I recommend that you open another copy of this document in a separate browser window and use the following links to easily find and view the figures and listings while you are reading about them. You may also find it useful to open a third browser window at the Resources section near the end of the document. That will make it easy for you to open those resources when they are mentioned in the text.

Figures

* Figure 1. Svg07 screen output. * Figure 2. Recommended usage of the makeElement method. * Figure 3. Graphic output from Svg08. * Figure 4. Recommended usage of the makeNode method.

Listings

* Listing 1. Beginning of the class named Svg07. * Listing 2. The beginning of the makeElement method. * Listing 3. Dealing with elements that have no attributes. * Listing 4. Processing the attributes. * Listing 5. Decision: empty element or non-empty element. * Listing 6. Remaining code in the main method. * Listing 7. Begin creating the DOM tree. * Listing 8. Create the root node named svg. * Listing 9. Beginning of the makeNode method. * Listing 10. Append new node to its parent. * Listing 11. Nodes that have no attributes. * Listing 12. Processing the attribute names and values. * Listing 13. Show outline of the canvas. * Listing 14. Create a group container named g. * Listing 15. Draw a blue line. * Listing 16. The makeLine method. * Listing 17. Draw the black ellipse. * Listing 18. The makeEllipse method. * Listing 19. Draw the red ellipse. * Listing 20. Draw the green rotated ellipse. * Listing 21. Transform the DOM and write the output file. * Listing 22. The program named Svg07. * Listing 23. The program named Svg08.

Supplementary material

I recommend that you also study the other lessons in my extensive collection of online Java tutorials. You will find a consolidated index at www.DickBaldwin.com.

General background information

According to the W3C

"SVG is a language for describing two-dimensional graphics in XML. SVG allows for three types of graphic objects: vector graphic shapes (e.g., paths consisting of straight lines and curves), images and text. Graphical objects can be grouped, styled, transformed and composited into previously rendered objects. The feature set includes nested transformations, clipping paths, alpha masks, filter effects and template objects."

Not easy reading

The Scalable Vector Graphics (SVG) 1.1 Specification is extensive. Unfortunately, a person needs a fairly strong background in XML to be able to understand much of the information in the specification, thereby reducing the accessibility of that information to Java programmers who lack such a background in XML.

Will present in a more understandable form

While I don't claim to have expertise in XML, I do know enough about the topic that I can usually make sense of the material provided in the SVG specification. One of my objectives for this series is to extract much of the important information from the specification and to present it in such a way as to make it accessible to Java programmers who lack a strong background in XML and who don't have the time available to gain that background knowledge.

Author: Richard G. Baldwin

Read article at Internet.com site

Featured Local Company

Moyea Software

92295612365
Hot building, ring street
LA, CA

Related Local Events
Automation Technology Expo West (ATX West)
Dates: 2/9/2010 - 2/11/2010
Location: Anaheim Convention Center
Anaheim, CA
View Details

SOLAR POWER - Exhibition and Conference
Dates: 10/12/2010 - 10/14/2010
Location: Los Angeles Convention & Exhibition Center
Los Angeles, CA
View Details

REAL-TIME & EMBEDDED COMPUTING CONFERENCE - LONG BEACH 2009
Dates: 10/1/2009 - 10/1/2009
Location: Marriott Long Beach
Long Beach, CA
View Details

2009 IEEE Petroleum and Chemical Industry Technical Conference (PCIC 2009)
Dates: 9/14/2009 - 9/16/2009
Location:
Anaheim, CA
View Details

Medical Design & Manufacturing - Trade
Dates: 6/9/2009 - 6/11/2009
Location: CANON COMMUNICATIONS LLC
Los Angeles, CA
View Details