bluewood_cn
路人甲
路人甲
  • 注册日期2004-04-19
  • 发帖数118
  • QQ
  • 铜币551枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1939回复:1

我再 EDN上发现的代码根据 style文件得到symbol的代码

楼主#
更多 发布于:2005-09-05 14:41
import java.io.*;<BR><BR>import com.esri.arcgis.display.*;<BR>import com.esri.arcgis.server.*;<BR>import com.esri.arcgis.system.*;<BR><BR>public class GetSymbolFromServerStyleGallery {<BR><BR>    private static AoInitialize aoInit;<BR>    private IServerContext sc;<BR>    public GetSymbolFromServerStyleGallery() {}<BR><BR>    private void connectToServer() {<BR><BR>        String host = "husker";<BR>        String domain = "gisdomain";<BR>        String user = "user1";<BR>        String password = "password";<BR><BR>        try {<BR> <BR>    // Initialize ArcObjects for Server usage<BR>            new ServerInitializer().initializeServer(domain,<BR>                    user, password);<BR>                    <BR>            // Connect to the host machine where the ArcGIS Server Object Manager is running<BR>            ServerConnection connection = new ServerConnection();<BR>            connection.connect(host);<BR><BR> // Get the SOM and create an empty context.<BR>            IServerObjectManager som = connection.getServerObjectManager();<BR>            sc = som.createServerContext("", "");<BR><BR>        } catch (Exception ex) {<BR>            ex.printStackTrace();<BR>        }<BR>    }<BR><BR>    public void listMarkerSymbols() {<BR><BR>        try {<BR><BR>           // Create the object on the server, within the empty context.<BR>            ServerStyleGallery ssg = new ServerStyleGallery(sc.createObject(ServerStyleGallery.getClsid()));<BR><BR>            //You need to add the style file, by name, to the ServerStyleGallery<BR>            String path = "C:\\ArcGIS\\Styles\\Caves.ServerStyle";<BR>            ssg.addFile(path);<BR><BR>     //Get the list of all Marker Symbols from the Default category of the gallery<BR>            EnumServerStyleGalleryItem items =<BR>                    new EnumServerStyleGalleryItem(ssg.getItems(<BR>                            "Marker Symbols", path, "Default"));<BR><BR>    //Iterate through the collection and print out the name and the size of each symbol<BR>            IStyleGalleryItem item = items.next();<BR><BR>            while (item != null) {<BR><BR>                IMarkerSymbol sms = new IMarkerSymbolProxy(item.getItem());<BR>                System.out.println("Symbol Name: " + item.getName());<BR>                System.out.println("Symbol Size: " + sms.getSize());<BR>                System.out.println("");<BR>                item = items.next();<BR>            }<BR><BR>           //Once we are done using the objects in the server context, remove them and release the context<BR>            sc.removeAll();<BR>            sc.releaseContext();<BR><BR>        } catch (IOException ex) {<BR>            ex.printStackTrace();<BR>        }<BR>    }<BR><BR>    public static void main(String[] args) {<BR><BR>        GetSymbolFromServerStyleGallery getsymbolfromserverstylegallery = new<BR>                GetSymbolFromServerStyleGallery();<BR><BR>        getsymbolfromserverstylegallery.connectToServer();<BR>        getsymbolfromserverstylegallery.listMarkerSymbols();<BR><BR>    }<BR>}<BR>
喜欢0 评分0
cftao2008
路人甲
路人甲
  • 注册日期2005-03-09
  • 发帖数141
  • QQ
  • 铜币568枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2005-09-05 21:31
多谢!受益匪浅啊!<img src="images/post/smile/dvbbs/em02.gif" />
举报 回复(0) 喜欢(0)     评分
游客

返回顶部