A Java 2D graphics conversion processing method and system

By converting Java 2D geometric objects into SVG DOM objects and leveraging the text file characteristics of SVG, the problems of excessively large exported images and low production efficiency in Java 2D graphics conversion are solved, achieving efficient graphics conversion and editing capabilities and reducing development costs.

CN115407973BActive Publication Date: 2026-07-24WUHAN FIBERHOME TECHNICAL SERVICES CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
WUHAN FIBERHOME TECHNICAL SERVICES CO LTD
Filing Date
2022-08-24
Publication Date
2026-07-24

AI Technical Summary

Technical Problem

Existing Java 2D technology suffers from problems such as excessively large exported images, low production efficiency, and high development costs during the graphics conversion process. In particular, it cannot efficiently export and edit complex graphics such as large topological maps.

Method used

By converting Java 2D geometry objects into SVG DOM objects and leveraging the text file characteristics of SVG, closed-screen image drawing is achieved. A drawing context description class and group manager are created, a GUI component iterator is used, XML output stream operations are established, and SVG files are generated.

Benefits of technology

It achieves efficient image conversion without being limited by image size and memory, reducing development costs while retaining image editing capabilities and compatibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115407973B_ABST
    Figure CN115407973B_ABST
Patent Text Reader

Abstract

The application discloses a Java 2D graphics conversion processing method and system, and relates to the field of computer software programming.The method comprises the following steps: writing corresponding SVG geometric shapes based on geometric shapes in Java 2D, and converting geometric objects of Java 2D into DOM objects of SVG for expressing geometric shapes; creating a drawing context description class for realizing closed-screen image drawing, and creating an SVG group manager for putting a plurality of DOM objects of SVG into the same group; creating a GUI component traverser for opening and closing a double-buffer switch of a GUI component, and constructing an SVG Graphics 2D object based on the specified DOM object; and establishing a tool class for XML output stream operation, and converting the SVG Graphics 2D object into an SVG file.The application has high conversion efficiency, and can effectively reduce development cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer software programming, and specifically to a Java 2D graphics conversion processing method and system. Background Technology

[0002] Early versions of AWT (Abstract Window Toolkit) only provided simple rendering tools, which were insufficient for rendering complex graphics, text, and images. The Java 2D API (a set of classes for advanced graphics and image processing) provides a more flexible and comprehensive toolkit, extending AWT and supporting more general graphics and rendering operations.

[0003] The `Graphics` class (the abstract base class for all graphics contexts) allows for drawing rectangles, ellipses, and polygons. `Graphics 2D` (a subclass of `Graphics`) enhances the concept of geometric rendering. For example, `Rectangle 2D` (for declaring rectangles defined by position and size) and `Ellipse 2D` (for declaring ellipses defined by frame rectangles) are higher-precision versions of the original `Rectangle` and `Ellipse`. Fill and stroke implementations provide `BasicStroke` (for defining line characteristics), `GradientPaint` (for gradient shading when drawing shapes), `TexturePaint` (texture), and `Color` (color) implementations through the `Paint` and `Stroke` interfaces, respectively. `AffineTransform` (2D affine transformations) defines linear transformations of Java 2D coordinates (providing mechanisms for implementing very complex graphics), such as scaling, translation, rotation, and shearing.

[0004] While Java 2D offers the ability to draw high-quality images and create rich clients, it also has the following drawbacks:

[0005] (1) Exporting images that are too large. To view the rich client content rendered by Java 2D outside the program, the only way is to export the content presented by the rich client as an image and then open it with graphics software. For large topology maps, this method may result in insufficient memory or video memory to allocate such a large image, or the image viewing software may be unable to open such a large image file after exporting the image.

[0006] (2) Low production efficiency. Since the graphic content drawn by the rich client can only be exported as an image, when the content needs to be edited, it is necessary to return to the rich client to operate again and export again. In order to meet the production needs of customers, it is necessary to develop the rich client to meet the needs of customers, but these needs may not meet the production and release goals of the client or are difficult to achieve.

[0007] (3) High cost. Development needs that require the use of Java 2D API are generally quite complex, such as large topology diagrams. Usually, a drawing component is developed to meet the requirements, but if it is necessary to provide operation for other applications (such as supporting editing in Visio software), a conversion method must be developed for the corresponding application, which greatly increases the development cost. Summary of the Invention

[0008] In view of the shortcomings of the existing technology, the purpose of this invention is to provide a Java2D graphics conversion processing method and system with high conversion efficiency and effective reduction of development costs.

[0009] To achieve the above objectives, this invention provides a Java 2D graphics conversion processing method, which specifically includes the following steps:

[0010] Based on the geometry in Java 2D, we write the corresponding SVG geometry and convert the Java 2D geometry objects into SVG DOM objects to represent the geometry.

[0011] Create a drawing context description class for implementing closed-screen image drawing, and create an SVG group manager for putting multiple SVG DOM objects into the same group;

[0012] Create a GUI component iterator that uses double-buffered switches to turn GUI components on and off, and construct an SVG Graphics 2D object based on the specified DOM object;

[0013] Create a utility class for XML output stream operations to convert SVG Graphics 2D objects into SVG files.

[0014] Based on the above technical solution, the specific steps of writing corresponding SVG geometric shapes based on Java 2D geometry and converting Java 2D geometric objects into SVG DOM objects for expressing geometric shapes include:

[0015] Create an SVG Shape class to represent geometry in SVG, and write corresponding SVG geometry for the geometry in Java2D;

[0016] Define the `createElement` method for DOM objects that represent SVG geometry, so that each SVG geometry creates a DOM object by implementing the `createElement` method and based on its own properties;

[0017] Create an image decoder to implement image decoding in Java 2D;

[0018] Create a geometry object converter factory to convert Java 2D geometry objects into SVG DOM objects used to represent geometry.

[0019] Based on the above technical solution, the image decoder's decoding of images in Java 2D specifically involves:

[0020] If you need to generate SVG files from images in Java 2D, you can implement the Base64 Image Encoder class and write the images directly into the SVG according to the Base64 format.

[0021] If you need to save images in Java 2D separately in PNG format, you can implement the PngImage Encoder class and place the images in the same directory as the SVG files according to the PNG format to achieve separate storage of images and SVG files.

[0022] Based on the above technical solution, the specific steps for creating a drawing context description class for implementing closed-screen image drawing include:

[0023] Create an SVG Graphics 2D class that inherits from Graphics;

[0024] Implement the drawing and filling methods defined in Graphics in the SVG Graphics 2D class.

[0025] Based on the above technical solution, the group is used to combine multiple SVG DOM objects into one object.

[0026] Based on the above technical solutions,

[0027] The group can be generated in two ways: a first generation method and a second generation method.

[0028] The first generation method is to generate groups based on the dimensions of GUI components;

[0029] The second generation method is to generate groups based on all the content that needs to be drawn during the Java 2D drawing process.

[0030] Based on the above technical solution, for the created GUI component iterator:

[0031] Before drawing the SVG, the GUI component iterator iterates through all the GUI components to be drawn in turn and turns off the double buffering switch of the GUI components.

[0032] After the SVG is drawn, the GUI component iterator restores the double-buffered switches of all GUI components.

[0033] Based on the above technical solution, when constructing an SVG Graphics 2D object based on a specified DOM object, the specific steps for drawing the SVG Graphics 2D object are as follows:

[0034] Obtain the GUI component object to be drawn as an SVG, and draw it by calling the paint method of the GUI component object with the SVGGraphics 2D object as a parameter;

[0035] Convert the GUI component object and all its child components into SVG objects and save them to the DOM model of the SVGGraphics 2D object.

[0036] Based on the above technical solution, when constructing an SVG Graphics 2D object based on a specified DOM object, the specific steps for drawing the SVG Graphics 2D object are as follows:

[0037] Iterate through the custom drawing components and call the drawing methods of the custom drawing components to draw the SVG Graphics 2D object as a parameter;

[0038] Include the custom drawing component as a group object in the DOM model, and include the content drawn by the custom drawing component as an SVG object within the group.

[0039] This invention provides a Java 2D graphics conversion processing system, comprising:

[0040] The conversion module is used to write corresponding SVG geometry based on the geometry in Java 2D, and convert the Java 2D geometry objects into SVG DOM objects for expressing the geometry.

[0041] The first creation module is used to create a drawing context description class for implementing closed-screen image drawing, and to create an SVG group manager for putting multiple SVG DOM objects into the same group;

[0042] The second creation module is used to create a GUI component iterator for turning double-buffered switches on and off GUI components, and to construct SVG Graphics2D objects based on specified DOM objects;

[0043] The execution module is used to create utility classes for XML output stream operations, converting SVG Graphics 2D objects into SVG files.

[0044] Compared with the prior art, the advantages of the present invention are: by utilizing the characteristic that SVG itself is a text file, a graphic copy in the same SVG format as the graphical user interface can be obtained based on the closed-screen printing image method, which is no longer limited by the image size and memory size, and has high conversion efficiency, which can effectively reduce development costs. Attached Figure Description

[0045] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0046] Figure 1 This is a flowchart of a Java 2D graphics conversion processing method according to an embodiment of the present invention. Detailed Implementation

[0047] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are some embodiments of this application, but not all embodiments.

[0048] See Figure 1 As shown, this embodiment of the invention provides a Java 2D graphics conversion method for converting Java 2D graphics into SVG (Scalable Vector Graphics) format. The method mainly includes two steps: the first step is to convert the geometric shapes described in Java 2D into geometric shapes in SVG; the second step is to replace the Java 2D Graphics 2D objects with SVG Graphics 2D objects. For the above two steps, the first step solves the problem of differences in drawing models, and the second step solves the problem of differences in drawing protocols. Through the synergistic effect of the two steps, Java 2D drawing objects are converted into SVG objects, enabling different Java 2D drawing applications to be converted using a unified format.

[0049] Specifically, the Java 2D graphics conversion processing method of the present invention includes the following steps:

[0050] S1: Based on the geometry in Java 2D, write the corresponding SVG geometry and convert the Java 2D geometry objects into SVG DOM objects (Document Object Model) to express the geometry.

[0051] It's important to note that in Java 2D, geometric shapes are described by implementing the Shape interface. To implement all geometric shapes described in Java 2D, a set of SVG-formatted geometric shapes must be designed. For Java 2D, this involves recording the coordinates, start and end points of these geometric shapes. Then, Graphics 2D outputs this information to the screen via a corresponding pipe, following the attribute descriptions in the geometric shapes. This information then instructs the GUI (Graphical User Interface) to mark a dirty region, waiting for the GUI to have free time to redraw the dirty region and achieve the desired graphic display.

[0052] When drawing GUI content into SVG, the graphics don't need to be displayed immediately. Instead, the representation is stored in an SVG file according to the SVG format. Since SVG is in XML (Extensible Markup Language) format, the best way to support reading and writing XML is to use the W3C (World Wide Web Consortium) specification, the Document Object Model. Therefore, when converting geometry described in the Java 2D version into geometry in SVG, the corresponding document object needs to be generated.

[0053] In this embodiment of the invention, corresponding SVG geometric shapes are written based on the geometric shapes in Java 2D, and the Java 2D geometric objects are converted into SVG DOM objects for expressing geometric shapes. Specific steps include:

[0054] S101: Create an SVG Shape class (an abstract class representing shapes) to express the geometry in SVG. Write the corresponding SVG geometry for the geometry in Java2D; for example, Rectangle 2D corresponds to SVG Rectangle (representing a rectangle in SVG), and Line 2D (used to represent a line segment in coordinate space) corresponds to SVG Line (representing a line in SVG).

[0055] S102: Define the create Element method for the DOM object used to represent SVG geometry, so that each SVG geometry creates a DOM object by implementing the create Element method and based on its own properties; after the create Element method is executed, an SVG tag representing the line is created.

[0056] The DOM object describes what kind of tags should be generated when creating SVG, as well as the attribute values ​​in those tags.

[0057] In other words, by implementing an SVG object model library, to convert geometric shapes described in Java 2D into geometric shapes in SVG, it is necessary to define an SVG geometric shape for the same geometric shapes that Java 2D can describe, and then design a shape converter to convert the Java 2D geometric shape into an SVG DOM object used to express the geometric shape.

[0058] S103: Create a processing image decoder to implement image decoding in Java 2D;

[0059] It should be noted that Java 2D can draw images in addition to geometric shapes, so images also need to be fully represented in SVG. Therefore, an AbstractImage Encoder class can be designed to describe how to decode images.

[0060] In this embodiment of the invention, the decoding of images in Java 2D by the image decoder is specifically as follows:

[0061] If you need to generate SVG files from images in Java 2D, you can use the Base64 Image Encoder implementation class and write the images directly into the SVG according to the Base64 format (which uses 64 printable characters to represent binary data).

[0062] If you need to save images in Java 2D separately in PNG (Portable Network Graphics) format, you can implement the PngImage Encoder class and place the images in the same directory as the SVG files according to the PNG format to achieve separate storage of images and SVG files.

[0063] S104: Create a geometry object converter factory to convert Java 2D geometry objects into SVG DOM objects used to represent geometry.

[0064] Different geometric shapes require different conversion properties, so each geometric shape has a corresponding converter. The converter factory is responsible for returning the corresponding converter based on different geometric shapes. This converter can be found through the specific geometric instance object of the Shape to perform the conversion process.

[0065] S2: Create a drawing context description class for implementing closed-screen image drawing, and create an SVG group manager for putting multiple SVG DOM objects into the same group;

[0066] It should be noted that the Graphics class in the JDK (Java Software Development Kit) is the abstract base class for all graphics contexts, allowing applications to draw on components (already implemented on various devices) and on the closing screen image. Therefore, it is necessary to design an SVG Graphics 2D class that inherits from Graphics to implement a method for drawing the closing screen image.

[0067] In this embodiment of the invention, a drawing context description class for implementing closed-screen image drawing is created, and the specific steps include:

[0068] S201: Create an SVG Graphics 2D class that inherits from Graphics;

[0069] S202: Implement the drawing and filling methods defined in Graphics in the SVG Graphics 2D class.

[0070] The Graphics class defines two main categories of methods for drawing and filling geometric shapes, images, text, and filling geometric shapes. The SVG Graphics 2D class needs to implement these two categories of methods. Taking drawing a geometric shape as an example, firstly, the Shape object is converted into the corresponding SVG Shape object by obtaining the corresponding geometric shape converter. Then, the create Element method of the SVGShape object is used to create a DOM markup object in the SVG that represents the same geometric shape. Finally, the DOM markup object is added to the DOM tree.

[0071] It's important to note that groups play a crucial role in SVG object management. Groups are used to combine multiple SVG DOM objects into a single object for further manipulation. For example, a rectangle with a triangle on top can be visualized as drawing a house; this house is a group.

[0072] In this embodiment of the invention, the group is generated in two ways: a first generation method and a second generation method.

[0073] The first generation method is to generate groups based on the dimensions of GUI components. For example, if a button has an image on its left and text in the middle, then the button's name is used as the group's ID (identifier), and the parts that the button needs to draw, such as the rounded rectangle, the filled rounded rectangle, the image, and the text, are all members of the group.

[0074] The second generation method is to generate groups based on all the content to be drawn during the Java 2D rendering process. In Java 2D rendering, due to the need to draw complex content, this complex content is generally wrapped in classes. For example, when drawing a network element on a topology diagram, a custom Node object is defined to represent the network element object to be drawn. This Node object may contain network element icons, special icons, alarm indicators, and network element names. When drawing this information, they can be treated as a group. Annotations can be added to the custom Node class to mark it as an SVG group, and all the content to be drawn can be placed within a single group.

[0075] S3: Create a GUI component iterator for turning double-buffered switches on and off GUI components, and build an SVG Graphics 2D object based on the specified DOM object;

[0076] It's important to note that Java (a computer programming language) uses Swing (a user interface development kit) to write GUI interfaces. To avoid flickering during rendering, Swing employs double buffering. This involves first drawing the content onto a single image. When a redraw is needed, the content is drawn in memory onto a second image, and then the second image is overlaid on top of the first. This avoids the flickering caused by clearing content during rendering. Since double buffering involves drawing images, without modifying the double buffering mechanism, exported SVGs will only contain image tags, thus losing SVG editing capabilities.

[0077] Therefore, in this invention, for the created GUI component iterator:

[0078] Before drawing the SVG, the GUI component iterator iterates through all the GUI components to be drawn in turn and turns off the double buffering switch of the GUI components.

[0079] After the SVG is drawn, the GUI component iterator restores the double buffering switches of all GUI components to ensure that the use of the interface is not affected.

[0080] In this invention, if the user specifies a DOM object, an SVGGraphics 2D object is constructed based on the specified DOM object. It should be noted that when constructing the SVGGraphics 2D object based on the specified DOM object, the drawing of the SVGGraphics 2D object includes two drawing methods. The specific steps of the first drawing method are as follows:

[0081] S311: Obtain the GUI component object to be drawn as SVG, and draw it by calling the paint method (the method for drawing the container) of the GUI component object, with the SVG Graphics 2D object as the parameter;

[0082] S312: Converts the GUI component object and all its child components into SVG objects and saves them to the DOM model of the SVGGraphics 2D object. SVG is grouped on a component-by-component basis.

[0083] The specific steps for the second drawing method are as follows:

[0084] S321: Iterate through the custom drawing components and call the drawing method of the custom drawing components to draw the SVG Graphics 2D object as a parameter;

[0085] S322: Include the custom drawing component as a group object in the DOM model, and include the drawing content of the custom drawing component as an SVG object within the group.

[0086] S4: Create a utility class for XML output stream operations to convert SVG Graphics 2D objects into SVG files.

[0087] Specifically, we designed a utility class called XML Writer for XML output stream operations. XML Writer is used to write the DOM tree in an SVGGraphics 2D object into an SVG file. XML Writer implements the construction of a character stream based on the file path, provides writing operations for XML tags and traversal of the DOM tree, and writes the content of the DOM tree to the file through the character stream.

[0088] It's important to note that GUI components need to be drawn to be displayed, and this is also true in Java. Therefore, the JDK defines a drawing method `paint Component(Graphics g)` for each GUI component. Here, `Graphics` is an abstract class in the JDK, from which Java2D's `Graphics 2D` inherits. To seamlessly draw content from the screen into SVG, an `SVG Graphics 2D` class needs to be implemented, inheriting from `Graphics` and implementing an SVG-based implementation.

[0089] When it is necessary to draw the content of the GUI into the SVG, an SVGGraphics 2D object is generated according to the SVG save path. Then, when the paint Component method of the GUI component (the method for drawing each component in the container) is called, the Graphics 2D parameter is replaced with the SVG Graphics 2D object. During the execution of paint Component, the SVG Graphics 2D object is told how to draw geometric shapes, lines, text, image information, etc. The SVGGraphics 2D object saves the information to the DOM model according to the received information, and after the drawing is completed, it is output to the SVG file in the form of a stream.

[0090] Furthermore, the functions corresponding to steps S1 to S4 of this invention can be integrated into application software, and the application software can implement steps S1 to S4. Specifically, when using this application software, the specific usage steps are as follows:

[0091] a: Create a DOM document object based on W3C standards;

[0092] b: Pass the DOM document object as a parameter to SVG Graphics 2D to construct an SVG Graphics 2D object;

[0093] c: Obtain the GUI component object that needs to be output to SVG, pass the SVG Graphics 2D object as input parameter, and call the paint method of the GUI component object;

[0094] d: Construct an Xml Writer based on the path of the SVG output, and write the DOM objects in the SVG Graphics 2D object to the specified file as a character stream.

[0095] The Java 2D graphics conversion processing method of this invention utilizes the characteristic that SVG itself is a text file and obtains a graphic copy in the same SVG format as the graphical user interface by printing the image on closed screen. It is no longer limited by image size and memory size, and has high conversion efficiency, which can effectively reduce development costs.

[0096] It also has the following advantages: 1. No matter how complex or large the elements on the canvas are, they can be exported without having to be exported as segmented images as before. Even the exported common format can retain some basic operations on the interface, such as moving, selecting, and scaling; 2. It has stronger compatibility. SVG format can be opened, viewed, and edited by browsers, Office, WPS, and other mainstream office software; 3. It retains the existing results of upper-level development, reducing learning and development costs.

[0097] In one possible implementation, the present invention also provides a readable storage medium located in a PLC (Programmable Logic Controller) controller, on which a computer program is stored. When executed by a processor, this program implements the steps of the Java 2D graphics conversion processing method described below:

[0098] Based on the geometry in Java 2D, we write the corresponding SVG geometry and convert the Java 2D geometry objects into SVG DOM objects to represent the geometry.

[0099] Create a drawing context description class for implementing closed-screen image drawing, and create an SVG group manager for putting multiple SVG DOM objects into the same group;

[0100] Create a GUI component iterator that uses double-buffered switches to turn GUI components on and off, and construct an SVG Graphics 2D object based on the specified DOM object;

[0101] Create a utility class for XML output stream operations to convert SVG Graphics 2D objects into SVG files.

[0102] Storage media may be any combination of one or more computer-readable media. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. Computer-readable storage media may be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this document, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0103] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of transmitting, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wireline, optical fiber, RF, etc., or any suitable combination thereof.

[0104] Computer program code for performing the operations of this invention can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages—such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0105] The present invention provides a Java 2D graphics conversion processing system, comprising a conversion module, a first creation module, a second creation module, and an execution module.

[0106] The conversion module is used to write corresponding SVG geometric shapes based on the geometric shapes in Java 2D, and convert the Java 2D geometric objects into SVG DOM objects used to express the geometric shapes; the first creation module is used to create a drawing context description class for implementing closed-screen image drawing, and to create an SVG group manager for putting multiple SVG DOM objects into the same group; the second creation module is used to create a GUI component iterator for opening and closing double-buffered switches of GUI components, and to construct SVG Graphics 2D objects based on specified DOM objects; the execution module is used to create utility classes for XML output stream operations, and to convert SVG Graphics 2D objects into SVG files.

[0107] The above description is merely a specific embodiment of this application, enabling those skilled in the art to understand or implement this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.

[0108] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

Claims

1. A Java 2D graphics conversion processing method, characterized in that, Specifically, the following steps are included: Based on the geometry in Java 2D, write the corresponding SVG geometry and convert the Java 2D geometry objects into SVG DOM objects to express the geometry. Create a drawing context description class for implementing closed-screen image drawing, and create an SVG group manager for putting multiple SVG DOM objects into the same group; Create a GUI component iterator that uses a double-buffered switch to turn GUI components on and off, and construct an SVG Graphics 2D object based on the specified DOM object; Create a utility class for XML output stream operations to convert SVG Graphics 2D objects into SVG files; Specifically, for the created GUI component iterator: Before drawing the SVG, the GUI component iterator iterates through all the GUI components to be drawn in turn and turns off the double buffering switch of the GUI components. After the SVG is drawn, the GUI component iterator restores the double-buffered switches of all GUI components; The group is generated in two ways: a first generation method and a second generation method. The first generation method is to generate groups based on the dimensions of GUI components; The second generation method is to generate groups based on all the content that needs to be drawn during the Java 2D drawing process; Specifically, when constructing an SVG Graphics 2D object based on a specified DOM object, the drawing steps for the SVG Graphics 2D object are as follows: Iterate through the custom drawing components and call the drawing methods of the custom drawing components to draw the SVG Graphics 2D object as a parameter; Include the custom drawing component as a group object in the DOM model, and include the drawing content of the custom drawing component as an SVG object within the group; In this way, an annotation is added to the custom Node class to mark it as an SVG group, and all the content to be drawn is put into a group.

2. The Java 2D graphics conversion processing method as described in claim 1, characterized in that, The process of creating corresponding SVG geometric shapes based on Java 2D geometry and converting Java 2D geometric objects into SVG DOM objects for representing geometric shapes includes the following steps: Create an SVG Shape class to represent geometry in SVG, and write corresponding SVG geometry for the geometry in Java2D; Define the `createElement` method for DOM objects that represent SVG geometry, so that each SVG geometry creates a DOM object by implementing the `createElement` method and based on its own properties; Create an image decoder to implement image decoding in Java 2D; Create a geometry object converter factory to convert Java 2D geometry objects into SVG DOM objects used to represent geometry.

3. The Java 2D graphics conversion processing method as described in claim 2, characterized in that, The image decoder's decoding of images in Java 2D specifically involves: If you need to generate SVG files from images in Java 2D, you can implement the Base64 Image Encoder class and write the images directly into the SVG according to the Base64 format. If you need to save images in Java 2D separately in PNG format, you can implement the PngImage Encoder class and place the images in the same directory as the SVG files according to the PNG format to achieve separate storage of images and SVG files.

4. The Java 2D graphics conversion processing method as described in claim 1, characterized in that, The steps for creating a drawing context description class for implementing closed-screen image drawing include: Create an SVG Graphics 2D class that inherits from Graphics; Implement the drawing and filling methods defined in Graphics in the SVG Graphics 2D class.

5. The Java 2D graphics conversion processing method as described in claim 1, characterized in that: The group is used to combine multiple SVG DOM objects into a single object.

6. The Java 2D graphics conversion processing method as described in claim 1, characterized in that, When constructing an SVG Graphics 2D object based on a specified DOM object, the specific steps for drawing the SVG Graphics 2D object are as follows: Obtain the GUI component object to be drawn as an SVG, and draw it by calling the paint method of the GUI component object with the SVGGraphics 2D object as a parameter; Convert the GUI component object and all its child components into SVG objects and save them into the DOM model of the SVG Graphics2D object.

7. A Java 2D graphics conversion and processing system, characterized in that, include: The conversion module is used to write corresponding SVG geometry based on the geometry in Java 2D, and convert the Java 2D geometry objects into SVG DOM objects used to express the geometry. The first creation module is used to create a drawing context description class for implementing closed-screen image drawing, and to create an SVG group manager for putting multiple SVG DOM objects into the same group; The second creation module is used to create a GUI component iterator for turning double-buffered switches on and off GUI components, and to construct SVG Graphics 2D objects based on specified DOM objects; The execution module is used to create utility classes for XML output stream operations, converting SVG Graphics 2D objects into SVG files; Specifically, for the created GUI component iterator: Before drawing the SVG, the GUI component iterator iterates through all the GUI components to be drawn in turn and turns off the double buffering switch of the GUI components. After the SVG is drawn, the GUI component iterator restores the double-buffered switches of all GUI components; The group is generated in two ways: a first generation method and a second generation method. The first generation method is to generate groups based on the dimensions of GUI components; The second generation method is to generate groups based on all the content that needs to be drawn during the Java 2D drawing process; Specifically, when constructing an SVG Graphics 2D object based on a specified DOM object, the drawing steps for the SVG Graphics 2D object are as follows: Iterate through the custom drawing components and call the drawing methods of the custom drawing components to draw the SVG Graphics 2D object as a parameter; Include the custom drawing component as a group object in the DOM model, and include the drawing content of the custom drawing component as an SVG object within the group; In this way, an annotation is added to the custom Node class to mark it as an SVG group, and all the content to be drawn is put into a group.