MapXtreme for Java Map rendering

Source: Internet
Author: User
Tags time interval

Map rendering refers specifically to the process of generating map images.
1, three kinds of rendering methods
First, Mapxtremeimagerenderer remote rendering using Mapxtremeimagerenderer to handle.
Remote rendering indicates that an application that contains a MAPJ object will follow an instance of Mapxtremeservlet to create a map. MAPJ Customers
The machine sends its request (how to render and render what) to the Mapxtremeservlet, which processes the request, and then returns the result
To Mapxtremeimagerenderer.
(1) Bitmap files (GIF, JPEG, etc.) that use ToFile () on the local system-typically used to store images on the intermediate layer, and then
Makes the browser request a file from the server.
(2), Java output stream object using Tostream ()-stream can be expressed as a file (same as above) or memory stored information
(as a Java image object, as below); two-tier structure using Tostream, the client can store images in memory.
(3) A Java image object using Toimage ()-Saves the grid in memory and can be used directly for display.
Because you rely on system resources such as JVMs and fonts that the client system might not have, Mapxtremeimagerenderer is
The most common way to render a map.

Second, Localrenderer
Localrenderer renders the map as a java2d graphics2d or BufferedImage object. Graphics2D objects usually source
From BufferedImage or Swing components. All rendering is done on the client computer. Because all renders are calculated on the client
Machine is complete, the resource required to render the map must reside on the client computer (font, video card, etc.).

Third, Encodedimagerenderer
MapXtreme Java provides a special renderer to help users create maps using animated images.

2, the output of the data

First, raster data output
MapXtreme Java supports a variety of raster output formats, including GIF, JPEG, PNG, and WBMP. The loss of raster images
The out format is specified in Imagerequestcomposer by MIME type. MIME is a kind of non text number for image data
According to the format standard. The following guidelines will help you determine the type of format that best suits your specific needs.
image/jpeg-jpeg-applies to layers with more than 256 colors.
Image/gif-gif-applies to up to 256 colors of layers.
image/png-png-is an alternative format for GIF format, which is suitable for layers with more than 256 colors.
image/wbmp-wbmp-is used to generate graphics in a handheld device similar to mobile phones and PDAs.
Image/svg+xml-svg-is used to describe the format of two-dimensional vector graphics in XML.
For example, to output JPEG, you can use the imagerequestcomposer shown below:
Imagerequestcomposer.create (MAPJ, maxcolors, bgcolor, "image/jpeg");
Maxcolors: Low 256
bgcolor: Picture background Color.Blue
PNG output is recommended when using grid files. The GIF output is limited to a maximum of 256 colors, but the grid file usually has at least
256 RGB or grayscale colors. Adding a vector layer may introduce more than 256 colors,

Second, SVG output

Scalable Vector Graphics (English: Scalable Vector graphics,svg) is a graphical format for describing two-dimensional vector graphics based on Extensible Markup Language (XML).
Benefits

(1), image file readable, easy to modify and edit
(2), with the existing technology can be interactive integration. SVG files can also embed JavaScript script to control SVG objects
(3), SVG graphics format can facilitate the establishment of text indexing, so as to achieve content-based image search
(4), SVG graphics format to support a variety of filters and special effects, without changing the image content of the premise of the bitmap format can be similar to the effect of text shadow
(5), SVG graphics format can be used to dynamically generate graphics. For example, SVG can dynamically generate interactive maps, embed Web pages, and display to end users

Example

<?xml version= "1.0"?>
<! DOCTYPE svg public "-//W3C//DTD svg 1.1//en" 
    "Http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns= "Http://www.w3.org/2000/svg" version= "1.1" width= "467" height= "462" 
    >
  <!--This is the Red Square: -->
  <rect x= "2px" y= "width=" "height=" "rx=" "", "fill=" stroke= "Red", "Black" "stroke-width="
         >
  <!--This is the Blue square:-->
  <rect x= "140" y= "," width= "height=" "", "rx=" fill= "Blue"
         stroke= "Black" stroke-width= "2px" fill-opacity= "0.7"/>
</svg>

MapXtreme Java Edition supports the export of map images in SVG format, in order to specify the export format as SVG, the MIME type can be set in Imagerequestcomposer.
For example: Imagerequestcomposer.create (Mymap, imagerequestcomposer.max_colors_256, Color.White, "Image/svg+xml");
You can also add JavaScript events to SVG
An SVG document also has an event handler tool similar to an event handler in an HTML document. SVG documents can provide
Signals for several types of events, such as mouse movement, resizing, and so on. This feature can be used to implement interactive operations.


3, the introduction of the renderer
(1), composite rendering device
The MapXtreme Java renderer, called a composite renderer, can be used to specify the layers that need to be repaint when the graphic is updated. It's only in the ministry.
It is especially useful when layers contain change information. Compositerenderer can be used to divide layers in mapj into static and
A dynamically rendered layer. Static layers will only be repaint once and stored locally as bitmaps. Dynamic layers will be based on each rendering request
Re-painting.
Composite renderer provides practical applications, such as the ability to display vehicles moving along the road.
Displays the moving object on the map. GPS apps can show a truck moving along a map of the freeway. Basic map
Just draw once, and the truck symbol will be drawn at any time as needed (for example, each position changes).
Remember the following information when using Compositerenderer:
The static layer is plotted as a locally stored bitmap. A large amount of memory will be used at this time, and an image of 640 x 480 will occupy at least 2.7MB
Memory.
Changing the scaling on the MAPJ causes the static layer to deform. The line will appear as a step or jagged shape.
Changing the center of the mapj causes the edges of the static layer to be translated. At this point, you can regenerate the static layer.

(2), progressive rendering
Progressive rendering is one of the powerful features provided by MapXtreme Java to send part of a map image to the client and then
send a more complete image within a specified time interval until the full image is received. This feature enables faster reception of portions of the image than when the entire map image is finished shading
and then sent to the image.
Progressive rendering is useful when you need to regenerate layers that spend a lot of time accessing the underlying data. The total time used to display the entire image is slightly increased compared to sending
a final image using progressive rendering. The
client controls whether the image is progressive rendered, and how long it takes to return through the special MIME type used by Imagerequestcomposer
. This MIME type takes the following form: multipart/image;imagetype=xxx;interval=yyy
where xxx is the MIME (such as image/gif, image/jpg, etc.) of the image to be returned, yyy Is the update time
interval in milliseconds. Progressive rendering is enabled by the Isdone () Boolean method on the Mapxtremeimagereneder class. If the Isdone () is set to
Ture, then the Tostream (), ToFile (), and Toimage () methods on the Mapxtremeimagerenderer return the next
Image block of data in the stream. The Isdone () method can be used to traverse and retrieve each successive image in the stream until it is not retrieved.

String MIME = "multipart/image;imagetype=image/png;interval=750";
Imagerequestcomposer IRC = imagerequestcomposer.create (MAPJ, imagerequestcomposer.max_colors_256, Color.WHITE, 
MIME);
Mapxtremeimagerenderer renderer = new Mapxtremeimagerenderer ("Http://localhost:8090/MapXtreme/servlet/mapxtreme");
while (!renderer.isdone ()) {
	image image = Renderer.toimage ();
	Do something with the image
}


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.