MapXtreme Java 4.8.2: Improving rendering quality
by: Minna Lunney
Obtaining the best looking maps possible starts with high-quality vector data and rasters, but is also heavily influenced by the rendering engine and style settings. Below are a couple of simple tricks you can use within MapXtreme Java to enhance the quality of maps displayed on screen or saved as an image.
Enable Anti-aliasing
Anti-aliasing adds gray or colored pixels to blend with the original pixels within an image, resulting in lines and edges that are less jagged. This feature can be enabled within the Web and StandAlone Managers, as well as within your Java programs.
To use anti-aliasing with the MXJ Manager (Web or StandAlone), follow these steps:
1) Browse to [MXJ_Home]/bin and open MapXtremeJavaManager-Web.lax or MapXtremeJavaManager-StandAlone.lax for editing.
2) Add the following lines to the end of the LAX file:
#
# ENABLE ANTI-ALIASING
#
lax.nl.java.option.additional=-Dcom.mapinfo.render.quality=true
3) Save and close the LAX file.
Within an MXJ program, you can direct your ImageRequestComposer object to use anti-aliasing with the following line of code:
myImageRequestComposer.setRendering(Rendering.QUALITY);
Below are screenshots that illustrate the difference anti-aliasing makes.
Without anti-aliasing:

Without Anti-Aliasing
With anti-aliasing:

With Anti-Aliasing
Adjust line caps and joins
This is a technique for maps that contain line features, such as highways. Line renditions share a number of properties, but two in particular are of interest here: stroke-linecap (what the ends of a line segment should look like) and stroke-linejoin (what the line should look like at the junction of two segments).
Here are the available stroke-linecap options:

available stroke-linecap options
Here are the available stroke-linejoin options:

By default, MXJ line styles will use “butt” for stroke-linecap and “miter” for stroke-linejoin. This may lead to jagged roads, especially at higher zoom levels.

To remedy this, open the MDF for the map in a text editor. Find every instance of the words “miter” and “butt,” and replace them with the word “round.” For example, the following style tag:
<style fill-opacity=”1.0″ stroke=”#990000″ stroke-opacity=”1.0″ stroke-width=”2.0″ stroke-linejoin=”miter” stroke-linecap=”butt” stroke-dasharray=”none” marker-continuous=”none” parallel-line=”none” symbol-mode=”font” symbol-foreground-opacity=”1.0″ symbol-background-opacity=”1.0″ />
Would be changed to this:
<style fill-opacity=”1.0″ stroke=”#990000″ stroke-opacity=”1.0″ stroke-width=”2.0″ stroke-linejoin=”round” stroke-linecap=”round” stroke-dasharray=”none” marker-continuous=”none” parallel-line=”none” symbol-mode=”font” symbol-foreground-opacity=”1.0″ symbol-background-opacity=”1.0″ />
Once this is done, save and close the MDF, then try rendering it again. You should see that the lines are much smoother.

Here are the available stroke-linejoin options:





0 Response to “Development Tips from our Experts!”