?? renderclass.java~28~
字號:
package myfirstmap;
import com.mapinfo.mapj.MapJ;
import com.mapinfo.xmlprot.mxtj.ImageRequestComposer;
import java.awt.Color;
import com.mapinfo.util.DoubleRect;
import com.mapinfo.util.DoublePoint;
import com.mapinfo.unit.LinearUnit;
import com.mapinfo.mapxtreme.client.MapXtremeImageRenderer;
import java.util.HashMap;
import java.util.Map;
import com.mapinfo.xmlprot.mxtj.SvgConditions;
import com.mapinfo.dp.annotation.AnnotationDataProvider;
import com.mapinfo.dp.annotation.AnnotationDataProviderHelper;
import com.mapinfo.dp.annotation.AnnotationTableDescHelper;
import com.mapinfo.dp.util.LocalDataProviderRef;
import com.mapinfo.mapj.Layer;
public class RenderClass
{
public RenderClass()
{
}
public void StudyRenderNameAndMDF()
{
/*In this example, a base map has been created and saved as a named resource. Another map
containing multiple layers has been created and saved as a map definition file. The MDF will be
loaded into the MapJ object. When the ImageRequestComposer object is created, the named
resource will be overlaid by the number of layers specified by the integer value passed in the
constructor.*/
MapJ mapj=new MapJ();
String namedMapURL="file:///E:\\MapInfo\\mapxtreme\\MapXtreme-4.7.0\\Tomcat-4.1\\webapps\\mapxtreme47\\resources\\layers\\world";
String namedMapName="ZPADMINISTRATIVE3";
int overlayIndex=1;//mdf中的地圖將有多少層來覆蓋現在添加進去的命名地圖,這個多少層由overlayIndex決定
String mimeType="image/png";
String mdfFilePath="E:\\MapInfo\\study\\mapmdf\\pointline.mdf";
String mapxtremeURL="http://901-32:8083/mapxtreme47/mapxtreme";
try
{
mapj.loadMapDefinition(mdfFilePath);
DoublePoint point=new DoublePoint(108.9608,34.2729);
DoubleRect bounds=new DoubleRect(point,0.31,0.21);
mapj.setBounds(bounds) ;
//set distance unit
LinearUnit unit=LinearUnit.kilometer ;
mapj.setDistanceUnits(unit) ;
mapj.setDeviceBounds(new DoubleRect(0,0,800,600)) ;
}catch(java.io.IOException ioe)
{
System.out.println("get a "+ioe.getClass() +"\nwith message "+ioe.getMessage() ) ;
}
ImageRequestComposer imageRC=ImageRequestComposer.create(namedMapURL,namedMapName,mapj,overlayIndex,
ImageRequestComposer.MAX_COLORS_TRUECOLOR ,
Color.white,mimeType);
//ImageRequestComposer imageRC2=ImageRequestComposer.create(mapj,256,Color.white ,"image/png");
MapXtremeImageRenderer render=new MapXtremeImageRenderer(mapxtremeURL);
try
{
render.render(imageRC);
render.toFile("e:\\mapinfo\\study\\mapimage\\studyRenderNamedAndMDF_1.png") ;
}catch(Exception e)
{
System.out.println("get a "+e.getClass() +"\nwith message "+e.getMessage() ) ;
e.printStackTrace() ;
}
}
public void studySVG()
{
Map eventMap = new HashMap();
eventMap.put("onmouseover", "OnMouseOver_Event");
SvgConditions svgConditions=new SvgConditions(eventMap);
String mapxtremeURL="http://901-32:8083/mapxtreme47/mapxtreme";
String mdfFilePath="E:\\MapInfo\\study\\mapmdf\\pointline.mdf";
MapJ mapj=new MapJ();
DoublePoint point=new DoublePoint(108.9608,34.2729);
DoubleRect bounds=new DoubleRect(point,0.31,0.21);
mapj.setBounds(bounds) ;
//set distance unit
LinearUnit unit=LinearUnit.kilometer ;
mapj.setDistanceUnits(unit) ;
try
{
mapj.loadMapDefinition(mdfFilePath);
}catch(java.io.IOException ioe)
{
System.out.println("get a "+ioe.getClass() +"\nwith message "+ioe.getMessage() ) ;
}
mapj.setDeviceBounds(new DoubleRect(0,0,800,600)) ;
ImageRequestComposer imageRC=ImageRequestComposer.create(mapj,256,Color.white ,"image/wbmp");
imageRC.setSvgConditions(svgConditions) ;
MapXtremeImageRenderer render=new MapXtremeImageRenderer(mapxtremeURL);
try
{
render.render(imageRC);
render.toFile("e:\\mapinfo\\study\\mapimage\\wbmp_1.wbmp") ;
}catch(java.lang.Exception e)
{
System.out.println("get a "+e.getClass() +"\nwith message "+e.getMessage() ) ;
}
}
public void studyAnimateLayer()
{
AnnotationTableDescHelper atdh = new AnnotationTableDescHelper("Animation_Layer");
AnnotationDataProviderHelper adph = new AnnotationDataProviderHelper();
LocalDataProviderRef ldpr=null;
try
{
ldpr = new LocalDataProviderRef(adph);
}catch(Exception e)
{
e.printStackTrace() ;
return;
}
MapJ mapj=new MapJ();
DoublePoint point=new DoublePoint(108.9608,34.2729);
DoubleRect bounds=new DoubleRect(point,0.31,0.21);
mapj.setBounds(bounds) ;
//set distance unit
LinearUnit unit=LinearUnit.kilometer ;
mapj.setDistanceUnits(unit) ;
String mdfFilePath="E:\\MapInfo\\study\\mapmdf\\pointline.mdf";
try
{
mapj.loadMapDefinition(mdfFilePath);
}catch(java.io.IOException ioe)
{
ioe.printStackTrace() ;
return;
}
try
{
Layer animate_layer = (Layer) mapj.getLayers().insertLayer(ldpr, atdh, 0,
"Animation_Layer");
}catch(Exception e2)
{
e2.printStackTrace() ;
return;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -