📄 studydecoratemap.java
字号:
//
/* Rendition rend=RenditionImpl.getDefaultRendition() ;
rend.setValue(Rendition.STROKE_WIDTH ,3f) ;
rend.setValue(Rendition.STROKE ,Color.blue ) ;*/
//study paraller line
/* Rendition rendParallel = new RenditionImpl();
rendParallel.setValue(Rendition.STROKE, Color.red );
Rendition.ParallelLine parallel1 = new Rendition.ParallelLine(
3f, rendParallel);//负数,bottom,在基线的上面
Rendition.ParallelLine parallel2 = new Rendition.ParallelLine(
-3f, rendParallel);//正数,top,在基线的下面,如果为0,就覆盖原线,如果为正数就在它的下面或者使左边
//,如果为负数就在原线的上面或右边;
Rendition.ParallelLine[] parallelArray = {parallel1, parallel2};
Rendition rendBaseLine = new RenditionImpl();
rendBaseLine.setValue(Rendition.STROKE_OPACITY, 0f);
rendBaseLine.setValue(Rendition.STROKE_PARALLELARRAY, parallelArray);
*/
//
//study dashline
/* float[] dashlineArray=new float[2];
dashlineArray[0]=5;
dashlineArray[1]=2;
Rendition rend=new RenditionImpl();
rend.setValue(Rendition.STROKE_DASHARRAY ,dashlineArray);
rend.setValue(Rendition.STROKE_DASHOFFSET ,3);
rend.setValue(Rendition.STROKE_WIDTH ,2f);
rend.setValue(Rendition.STROKE ,Color.red );*/
//study line marker
/* Rendition rendSymbol=new RenditionImpl();
rendSymbol.setValue(Rendition.SYMBOL_MODE ,Rendition.SymbolMode .IMAGE );
rendSymbol.setValue(Rendition.SYMBOL_URL ,gifURL);
Rendition.Marker marker;//=new Rendition.Marker();
marker=new Rendition.Marker(rendSymbol);
Rendition.Marker[] markers=new Rendition.Marker[1];
markers[0]=marker;
Rendition rend=new RenditionImpl();
rend.setValue(Rendition.STROKE_MARKERARRAY ,markers);
rend.setValue(Rendition.STROKE ,Color.red );
rend.setValue(Rendition.STROKE_WIDTH ,3f);*/
//study font symbol
Rendition rend=new RenditionImpl();
rend.setValue(Rendition.SYMBOL_MODE ,Rendition.SymbolMode .FONT );
rend.setValue(Rendition.FONT_FAMILY ,"Mapinfo Cartographic") ;
rend.setValue(Rendition.FONT_SIZE ,16);
rend.setValue(Rendition.SYMBOL_STRING ,String.valueOf((char)33)) ;
selectionTheme.setRendition(rend) ;
selectionTheme.setSelection(selection) ;
featureLayer.getThemeList() .add(selectionTheme) ;
//
MapXtremeImageRenderer render=new MapXtremeImageRenderer(mapxtremeURL);
ImageRequestComposer imageRC=ImageRequestComposer.create(mapj,256,Color.white ,"image/png");
render.render(imageRC) ;
Image image=render.toImage() ;
DrawImage drawImage=new DrawImage(image);
this.getContentPane() .add(drawImage,BorderLayout.CENTER ) ;
this.setSize(800,600) ;
this.setVisible(true) ;
this.show() ;
}catch(Exception e)
{
System.out.println("get a "+e.getClass() +"\nwith message "+e.getMessage() ) ;
}
}
public void mapWithShape()
{
LabelThemeList themeList = null;
if ((themeList = featureLayer.getLabelThemeList() )!=null)
{
Polygon poly = new java.awt.Polygon();
poly.addPoint(2,2);
poly.addPoint(-2,2);
poly.addPoint(-2,-2);
poly.addPoint(2,-2);
Rendition polyRend = new RenditionImpl();
polyRend.setValue(Rendition.STROKE,Color.green);
polyRend.setValue(Rendition.FILL,Color.red);
Rendition rend = new RenditionImpl();
rend.setValue(Rendition.SYMBOL_MODE,Rendition.SymbolMode.SHAPE);
rend.setValue(Rendition.SYMBOL_SHAPE,new Rendition.SymbolShape(poly,polyRend));
OverrideTheme ot = new OverrideTheme(rend,"shapeTheme");
featureLayer.getThemeList().add(ot);
MapXtremeImageRenderer render=new MapXtremeImageRenderer(mapxtremeURL);
ImageRequestComposer imageRC=ImageRequestComposer.create(mapj,256,Color.white ,"image/png");
Image image;
try
{
render.render(imageRC);
image=render.toImage() ;
DrawImage drawImage=new DrawImage(image);
this.getContentPane() .add(drawImage,BorderLayout.CENTER );
this.setSize(800,600) ;
this.setVisible(true) ;
this.show() ;
}catch(Exception e)
{
System.out.println("get a "+e.getClass() +"\nwith message "+e.getMessage() ) ;
}
}
}
public void highlightPath2()
{
FeatureSet featureSet=null;
String attributeName="name";
String attributeValue="1t4";
Attribute attSearchValue=new Attribute(attributeValue);
ArrayList columns=new ArrayList();
DoubleRect allRect=new DoubleRect();
double width;
double height;
try
{
columns.add("name") ;
columns.add("length") ;
List listColName=new ArrayList();
List listColValue=new ArrayList();
List listOperator=new ArrayList();
listColName.add("name") ;
//
Attribute att1=new Attribute("52t49");
Attribute att2=new Attribute("54t53");
AttTuple attTuple1=new AttTuple(att1);
AttTuple attTuple2=new AttTuple(att2);
listColValue.add(attTuple1);
listColValue.add(attTuple2) ;
//
att1=new Attribute("54t57");
attTuple1=new AttTuple(att1);
listColValue.add(attTuple1) ;
//
att1=new Attribute("53t52");
attTuple1=new AttTuple(att1);
listColValue.add(attTuple1) ;
listOperator.add(AttOperator.eq);
featureLayer.setSelectable(true) ;
featureSet=featureLayer.searchByAttributes(columns,listColName,listOperator,listColValue,null);
if(featureSet==null)
{
System.out.println("null,retrun") ;
}
RewindableFeatureSet rfSet=new RewindableFeatureSet(featureSet);
boolean rewind= rfSet.isRewindable() ;
Feature feat = featureSet.getNextFeature();
allRect.initBounds() ;
while(feat!=null)
{
Geometry searchGeom = null;
DoublePoint center = pointCenter;
searchGeom = feat.getGeometry();
DoubleRect dr = searchGeom.getBounds();
allRect.merge(dr) ;
center = dr.center();
System.out.println("(" + dr.center().x + ", " + dr.center().y + ")"); //(fs);
feat = featureSet.getNextFeature();
}
rfSet.rewind() ;//用了这条语句也不能使rfSet的指针指向第一个记录
featureSet=featureLayer.searchByAttributes(columns,listColName,listOperator,listColValue,null);
SelectionTheme selectionTheme=new SelectionTheme("lineselect");
Selection selection=new Selection();
selection.add(featureSet) ;
//
Rendition rend=new RenditionImpl();
rend.setValue(Rendition.STROKE ,Color.blue );
rend.setValue(Rendition.STROKE_WIDTH ,3f);
selectionTheme.setRendition(rend) ;
selectionTheme.setSelection(selection) ;
featureLayer.getThemeList() .add(selectionTheme) ;
//reset the bound of mapj
pointCenter=allRect.center() ;
mapj.setCenter(pointCenter) ;
width=allRect.xmax -allRect.xmin ;
height=allRect.ymax -allRect.ymin ;
DoubleRect bound=new DoubleRect(pointCenter,width*1,height*1);
mapj.setBounds(bound) ;
MapXtremeImageRenderer render=new MapXtremeImageRenderer(mapxtremeURL);
ImageRequestComposer imageRC=ImageRequestComposer.create(mapj,256,Color.white ,"image/png");
render.render(imageRC) ;
render.toFile("e:\\mapinfo\\study\\png\\formobilephone.png") ;
/* Image image=render.toImage() ;
DrawImage drawImage=new DrawImage(image);
this.getContentPane() .add(drawImage,BorderLayout.CENTER ) ;
this.setSize(180,160) ;
this.setVisible(true) ;
this.show() ;*/
}catch(Exception e)
{
System.out.println("get a "+e.getClass() +"\nwith message "+e.getMessage() ) ;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -