?? selectionthemetest.java
字號:
package barchant;import java.lang.*;import java.util.*;import java.util.Hashtable;import java.awt.*;import com.mapinfo.mapj.*;import com.mapinfo.graphics.Rendition;import com.mapinfo.graphics.RenditionImpl;import java.util.ArrayList;import javax.swing.*;import com.mapinfo.mapj.BarChartProperties;import com.mapinfo.beans.vmapj.VisualMapJ;import com.mapinfo.beans.tools.*;import com.mapinfo.util.DoubleRect;import com.mapinfo.dp.FeatureSet;import com.mapinfo.theme.SelectionTheme;public class SelectionThemeTest extends JFrame{ public FeatureLayer lyr;//Feature對象用來訪問地圖對象 // public ArrayList cols; public VisualMapJ myMap;//可管理地圖集的各種狀態(tài),并向服務(wù)器轉(zhuǎn)發(fā)客戶請求 //public Hashtable ht; public SelectionThemeTest() { try{ //指上端的工具欄,工具欄默認(rèn)包含幾種功能,如果想添加其它功能可以看下面代碼 MapToolBar myMapToolBar=new MapToolBar(); //在工具欄上添加新功能 RadiusSelectionMapTool radTool =new RadiusSelectionMapTool(); //創(chuàng)建地圖 myMap=new VisualMapJ(); myMap.getMapJ().loadMapDefinition("d:\\program files\\MapInfo\\MapXtreme-4.7.0\\examples\\server\\data\\local\\world.mdf"); lyr = (FeatureLayer)myMap.getMapJ().getLayers().getLayer("World Countries"); // Assume layer as a FeatureLayer object ArrayList columns = new ArrayList(); // double x=12,y=-67; DoubleRect dp = new DoubleRect(-74,42,-73,42); FeatureSet fs = null; // Select the features at the specified location在給定位置搜索圖元 fs = lyr.searchWithinRectangle(columns, dp, null); // Create a SelectionTheme SelectionTheme selTheme = new SelectionTheme("PointSelection"); // Create a Selection object, and add the selected features Selection sel = new Selection();//該類用于定義一組圖元,但并不存圖元本身,只是保存主鍵便于再次查找 sel.add(fs); // Assign the Selection object to the SelectionTheme selTheme.setSelection(sel); // 定義Rendition控制圖元 Rendition rend = new RenditionImpl(); rend.setValue(Rendition.FILL, Color.red); selTheme.setRendition(rend); // Add the SelectionTheme to the layer's list of themes lyr.getThemeList().add(selTheme); //工具欄放上端 this.getContentPane().add(myMapToolBar,BorderLayout.NORTH); //地圖放中間 this.getContentPane().add(myMap,BorderLayout.CENTER); //圖例放右邊 // this.getContentPane().add(legend,BorderLayout.EAST); this.setVisible(true); this.show(); }catch(Exception e){ System.out.println("Error"); e.printStackTrace(); } } public static void main(String args[]){ SelectionThemeTest bclr=new SelectionThemeTest(); } }
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -