arcgissamples\cartography\DrawSymbolMain.java
/* Copyright 2010 ESRI * * All rights reserved under the copyright laws of the United States * and applicable international laws, treaties, and conventions. * * You may freely redistribute and use this sample code, with or * without modification, provided you include the original copyright * notice and use restrictions. * * See the use restrictions. * */ package arcgissamples.cartography; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Label; import java.awt.List; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; import java.io.IOException; import javax.swing.JFrame; import com.esri.arcgis.beans.map.MapBean; import com.esri.arcgis.carto.ColorRampSymbol; import com.esri.arcgis.carto.ColorSymbol; import com.esri.arcgis.carto.IActiveView; import com.esri.arcgis.carto.IElement; import com.esri.arcgis.carto.IGraphicsContainer; import com.esri.arcgis.carto.LineElement; import com.esri.arcgis.carto.MarkerElement; import com.esri.arcgis.carto.RectangleElement; import com.esri.arcgis.carto.TextElement; import com.esri.arcgis.display.AlgorithmicColorRamp; import com.esri.arcgis.display.ArrowMarkerSymbol; import com.esri.arcgis.display.BarChartSymbol; import com.esri.arcgis.display.CartographicLineSymbol; import com.esri.arcgis.display.CharacterMarkerSymbol; import com.esri.arcgis.display.DotDensityFillSymbol; import com.esri.arcgis.display.GradientFillSymbol; import com.esri.arcgis.display.HashLineSymbol; import com.esri.arcgis.display.I3DChartSymbol; import com.esri.arcgis.display.IChartSymbol; import com.esri.arcgis.display.IColor; import com.esri.arcgis.display.IFillSymbol; import com.esri.arcgis.display.ILineProperties; import com.esri.arcgis.display.ILineSymbol; import com.esri.arcgis.display.IMarkerSymbol; import com.esri.arcgis.display.ISymbolArray; import com.esri.arcgis.display.ITemplate; import com.esri.arcgis.display.ITextSymbol; import com.esri.arcgis.display.LineFillSymbol; import com.esri.arcgis.display.MarkerFillSymbol; import com.esri.arcgis.display.MarkerLineSymbol; import com.esri.arcgis.display.MultiLayerFillSymbol; import com.esri.arcgis.display.MultiLayerLineSymbol; import com.esri.arcgis.display.MultiLayerMarkerSymbol; import com.esri.arcgis.display.PictureFillSymbol; import com.esri.arcgis.display.PictureLineSymbol; import com.esri.arcgis.display.PictureMarkerSymbol; import com.esri.arcgis.display.PieChartSymbol; import com.esri.arcgis.display.RgbColor; import com.esri.arcgis.display.SimpleFillSymbol; import com.esri.arcgis.display.SimpleLineSymbol; import com.esri.arcgis.display.SimpleMarkerSymbol; import com.esri.arcgis.display.StackedChartSymbol; import com.esri.arcgis.display.Template; import com.esri.arcgis.display.TextSymbol; import com.esri.arcgis.display.esriArrowMarkerStyle; import com.esri.arcgis.display.esriColorRampAlgorithm; import com.esri.arcgis.display.esriGradientFillStyle; import com.esri.arcgis.display.esriIPictureType; import com.esri.arcgis.display.esriLineCapStyle; import com.esri.arcgis.display.esriLineJoinStyle; import com.esri.arcgis.display.esriMarkerFillStyle; import com.esri.arcgis.display.esriSimpleFillStyle; import com.esri.arcgis.display.esriSimpleLineStyle; import com.esri.arcgis.display.esriSimpleMarkerStyle; import com.esri.arcgis.display.esriTextVerticalAlignment; import com.esri.arcgis.geometry.Envelope; import com.esri.arcgis.geometry.IGeometry; import com.esri.arcgis.geometry.ISegmentCollection; import com.esri.arcgis.geometry.Line; import com.esri.arcgis.geometry.Path; import com.esri.arcgis.geometry.Point; import com.esri.arcgis.geometry.Polyline; import com.esri.arcgis.support.ms.stdole.StdFont; import com.esri.arcgis.system.AoInitialize; import com.esri.arcgis.system.EngineInitializer; import com.esri.arcgis.system.esriLicenseProductCode; import com.esri.arcgis.system.esriLicenseStatus; /** * This sample demonstrates ArcGIS symbol collection. * Note: This sample uses stop.bmp file. It should be presend in the path. */ public class DrawSymbolMain extends JFrame implements ActionListener { private static final long serialVersionUID = 1L; static AoInitialize aoInit; List listSymbols = new List(1, false); MapBean mapBean = new MapBean(); Label label = new Label(); double symbolSize = 10; static String pictureFile; /** * Constructor */ public DrawSymbolMain() { initUI(); } /** * Method to start the program execution. * @param s String[] */ public static void main(String s[]) { System.out.println("Starting Draw Symbol - An ArcObjects Java SDK Developer Sample"); //Get DEVKITHOME Home String devKitHome = System.getenv("AGSDEVKITJAVA"); if (!(new File(devKitHome).exists())) { System.out.println(devKitHome + " does not exist.\nExiting..."); System.exit(-1); } // Change the following line if you want to use different data for the symbol used for different markers. pictureFile = devKitHome + "java" + File.separator + "samples" + File.separator + "arcobjects" + File.separator + "cartography" + File.separator + "symbols" + File.separator + "drawsymbol" + File.separator + "src" + File.separator + "arcgissamples" + File.separator + "cartography" + File.separator + "icons" + File.separator + "stop.bmp"; File pictureFileFile = new File(pictureFile); if (!pictureFileFile.exists()) { System.out.println("Missing picture file: " + pictureFileFile.getAbsolutePath()); System.out.println("Some marker symbols will not show up. Continuing ..."); } try { EngineInitializer.initializeVisualBeans(); initializeArcGISLicenses(); new DrawSymbolMain(); } catch (Exception ex) { ex.printStackTrace(); } } static void initializeArcGISLicenses() { try { aoInit = new AoInitialize(); if (aoInit.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngine) == esriLicenseStatus.esriLicenseAvailable) aoInit.initialize(esriLicenseProductCode.esriLicenseProductCodeEngine); else if (aoInit.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeArcView) == esriLicenseStatus.esriLicenseAvailable) aoInit.initialize(esriLicenseProductCode.esriLicenseProductCodeArcView); } catch (Exception e) { e.printStackTrace(); } } /* * Lays out the User Interface, and sets up event listeners */ private void initUI() { this.setTitle("Draw Symbol Sample Application"); this.setSize(new Dimension(600, 500)); this.getContentPane().setLayout(new BorderLayout()); this.label.setText("Double Click to select symbol from the list."); this.listSymbols.add("SimpleMarkerSymbol"); this.listSymbols.add("ArrowMarkerSymbol"); this.listSymbols.add("CharacterMarkerSymbol"); this.listSymbols.add("PictureMarkerSymbol"); this.listSymbols.add("MultiLayerMarkerSymbol"); this.listSymbols.add("SimpleLineSymbol"); this.listSymbols.add("MarkerLineSymbol"); this.listSymbols.add("CartographicLineSymbol"); this.listSymbols.add("HashLineSymbol"); this.listSymbols.add("PictureLineSymbol"); this.listSymbols.add("MultiLayerLineSymbol"); this.listSymbols.add("SimpleFillSymbol"); this.listSymbols.add("GradientFillSymbol"); this.listSymbols.add("PictureFillSymbol"); this.listSymbols.add("MarkerFillSymbol"); this.listSymbols.add("LineFillSymbol"); this.listSymbols.add("MultiLayerFillSymbol"); this.listSymbols.add("DotDensityFillSymbol"); this.listSymbols.add("ColorSymbol"); this.listSymbols.add("ColorRampSymbol"); this.listSymbols.add("TextSymbol"); this.listSymbols.add("PieChartSymbol"); this.listSymbols.add("StackedChartSymbol"); this.listSymbols.add("BarChartSymbol"); // this.getContentPane().add(this.mapBean, BorderLayout.CENTER); this.getContentPane().add(this.listSymbols, BorderLayout.WEST); this.getContentPane().add(this.label, BorderLayout.SOUTH); this.setVisible(true); // set listeners this.listSymbols.addActionListener(this); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { try { aoInit.shutdown(); } catch(IOException ex) { // exit anyway } System.exit(0); } }); } /** * implements interface ActionListener * @see ActionListener#actionPerformed * @param event */ public void actionPerformed(ActionEvent event) { int index = this.listSymbols.getSelectedIndex(); try { IActiveView activeView = this.mapBean.getActiveView(); IGraphicsContainer graphicsContainer = activeView.getGraphicsContainer(); graphicsContainer.deleteAllElements(); //geometry for point symbols Point point = new Point(); point.setX( 450 ); point.setY( 450 ); Point point1 = new Point(); point1.setX( 200 ); point1.setY( 200 ); Point point2 = new Point(); point2.setX( 400 ); point2.setY( 400 ); Point point3 = new Point(); point3.setX( 600 ); point3.setY( 200 ); // geometry for line symbols Line line1 = new Line(); line1.putCoords( point1, point2 ); Line line2 = new Line(); line2.putCoords( point2, point3 ); ISegmentCollection segmentCollection = new Path(); segmentCollection.addSegment(line1, null, null); segmentCollection.addSegment(line2, null, null); Polyline polyline = new Polyline(); IGeometry geometry = (IGeometry)(segmentCollection); polyline.addGeometry(geometry, null, null); // geometry for polygon symbols Envelope envelope = new Envelope(); envelope.setXMin(100); envelope.setYMin(100); envelope.setXMax(800); envelope.setYMax(800); // IElement element = null; switch (index) { case 0: IMarkerSymbol markerSymbol = MakeNewSimpleMarkerSymbol(); MarkerElement markerElement = new MarkerElement(); markerElement.setSymbol(markerSymbol); markerElement.setGeometry(point); element = markerElement; break; case 1: IMarkerSymbol arrowMarkerSymbol = MakeNewArrowMarkerSymbol(); MarkerElement arrowMarkerElement = new MarkerElement(); arrowMarkerElement.setSymbol(arrowMarkerSymbol); arrowMarkerElement.setGeometry(point); element = arrowMarkerElement; break; case 2: IMarkerSymbol characterMarkerSymbol = MakeNewCharacterMarkerSymbol(); MarkerElement characterMarkerElement = new MarkerElement(); characterMarkerElement.setSymbol(characterMarkerSymbol); characterMarkerElement.setGeometry(point); element = characterMarkerElement; break; case 3: IMarkerSymbol pictureMarkerSymbol = MakeNewPictureMarkerSymbol(); MarkerElement pictureMarkerElement = new MarkerElement(); pictureMarkerElement.setSymbol(pictureMarkerSymbol); pictureMarkerElement.setGeometry(point); element = pictureMarkerElement; break; case 4: IMarkerSymbol multiLayerMarkerSymbol = MakeNewMultiLayerMarkerSymbol(); MarkerElement multiLayerMarkerElement = new MarkerElement(); multiLayerMarkerElement.setSymbol(multiLayerMarkerSymbol); multiLayerMarkerElement.setGeometry(point); element = multiLayerMarkerElement; break; case 5: ILineSymbol lineSymbol = MakeNewSimpleLineSymbol(); LineElement lineElement = new LineElement(); lineElement.setSymbol(lineSymbol); lineElement.setGeometry(polyline); element = lineElement; break; case 6: ILineSymbol markerLineSymbol = MakeNewMarkerLineSymbol(); LineElement markerLineElement = new LineElement(); markerLineElement.setSymbol(markerLineSymbol); markerLineElement.setGeometry(polyline); element = markerLineElement; break; case 7: ILineSymbol cartographicLineSymbol = MakeNewCartographicLineSymbol(); LineElement cartographicLineElement = new LineElement(); cartographicLineElement.setSymbol(cartographicLineSymbol); cartographicLineElement.setGeometry(polyline); element = cartographicLineElement; break; case 8: ILineSymbol hashLineSymbol = MakeNewHashLineSymbol(); LineElement hashLineElement = new LineElement(); hashLineElement.setSymbol(hashLineSymbol); hashLineElement.setGeometry(polyline); element = hashLineElement; break; case 9: ILineSymbol pictureLineSymbol = MakeNewPictureLineSymbol(); LineElement pictureLineElement = new LineElement(); pictureLineElement.setSymbol(pictureLineSymbol); pictureLineElement.setGeometry(polyline); element = pictureLineElement; break; case 10: ILineSymbol multiLayerLineSymbol = MakeNewMultiLayerLineSymbol(); LineElement multiLayerLineElement = new LineElement(); multiLayerLineElement.setSymbol(multiLayerLineSymbol); multiLayerLineElement.setGeometry(polyline); element = multiLayerLineElement; break; case 11: IFillSymbol fillSymbol = MakeNewSimpleFillSymbol(); RectangleElement rectangleElement = new RectangleElement(); rectangleElement.setSymbol(fillSymbol); rectangleElement.setGeometry(envelope); element = rectangleElement; break; case 12: IFillSymbol gradientFillSymbol = MakeNewGradientFillSymbol(); RectangleElement gradientFillElement = new RectangleElement(); gradientFillElement.setSymbol(gradientFillSymbol); gradientFillElement.setGeometry(envelope); element = gradientFillElement; break; case 13: IFillSymbol pictureFillSymbol = MakeNewPictureFillSymbol(); RectangleElement pictureFillElement = new RectangleElement(); pictureFillElement.setSymbol(pictureFillSymbol); pictureFillElement.setGeometry(envelope); element = pictureFillElement; break; case 14: IFillSymbol markerFillSymbol = MakeNewMarkerFillSymbol(); RectangleElement markerFillElement = new RectangleElement(); markerFillElement.setSymbol(markerFillSymbol); markerFillElement.setGeometry(envelope); element = markerFillElement; break; case 15: IFillSymbol lineFillSymbol = MakeNewLineFillSymbol(); RectangleElement lineFillElement = new RectangleElement(); lineFillElement.setSymbol(lineFillSymbol); lineFillElement.setGeometry(envelope); element = lineFillElement; break; case 16: IFillSymbol multiLayerFillSymbol = MakeNewMultiLayerFillSymbol(); RectangleElement multiLayerFillElement = new RectangleElement(); multiLayerFillElement.setSymbol(multiLayerFillSymbol); multiLayerFillElement.setGeometry(envelope); element = multiLayerFillElement; break; case 17: IFillSymbol dotDensityFillSymbol = MakeNewDotDensityFillSymbol(); RectangleElement dotDensityFillElement = new RectangleElement(); dotDensityFillElement.setSymbol(dotDensityFillSymbol); dotDensityFillElement.setGeometry(envelope); element = dotDensityFillElement; break; case 18: IFillSymbol colorSymbol = MakeNewColorSymbol(); RectangleElement colorElement = new RectangleElement(); colorElement.setSymbol(colorSymbol); colorElement.setGeometry(envelope); element = colorElement; break; case 19: IFillSymbol colorRampSymbol = MakeNewColorRampSymbol(); RectangleElement colorRampElement = new RectangleElement(); colorRampElement.setSymbol(colorRampSymbol); colorRampElement.setGeometry(envelope); element = colorRampElement; break; case 20: ITextSymbol textSymbol = MakeNewTextSymbol(); TextElement textElement = new TextElement(); textElement.setSymbol(textSymbol); textElement.setText("TextSymbol"); textElement.setGeometry(point); element = textElement; break; case 21: IMarkerSymbol pieChartSymbol = MakeNewPieChartSymbol(); MarkerElement pieChartElement = new MarkerElement(); pieChartElement.setSymbol(pieChartSymbol); pieChartElement.setGeometry(point); element = pieChartElement; break; case 22: IMarkerSymbol stackedChartSymbol = MakeNewStackedChartSymbol(); MarkerElement stackedChartElement = new MarkerElement(); stackedChartElement.setSymbol(stackedChartSymbol); stackedChartElement.setGeometry(point); element = stackedChartElement; break; case 23: IMarkerSymbol barChartSymbol = MakeNewBarChartSymbol(); MarkerElement barChartElement = new MarkerElement(); barChartElement.setSymbol(barChartSymbol); barChartElement.setGeometry(point); element = barChartElement; break; } graphicsContainer.addElement(element, 0); this.mapBean.getActiveView().refresh(); } catch (Exception e) { e.printStackTrace(); // never happens } } // private methods to create symbols private IMarkerSymbol MakeNewSimpleMarkerSymbol() { try { SimpleMarkerSymbol simpSym = new SimpleMarkerSymbol(); simpSym.setSize(this.symbolSize); simpSym.setStyle(esriSimpleMarkerStyle.esriSMSCircle); simpSym.setColor(RandomColor()); simpSym.setOutline(true); simpSym.setOutlineSize(0.1); simpSym.setOutlineColor(RandomColor()); return simpSym; } catch (IOException e) { e.printStackTrace(); // never happens } return null; } private IMarkerSymbol MakeNewArrowMarkerSymbol() { try { ArrowMarkerSymbol arrSym = new ArrowMarkerSymbol(); arrSym.setColor(RandomColor()); arrSym.setSize(this.symbolSize); arrSym.setStyle(esriArrowMarkerStyle.esriAMSPlain); arrSym.setAngle(45); return arrSym; } catch (IOException e) { e.printStackTrace(); // never happens } return null; } private IMarkerSymbol MakeNewCharacterMarkerSymbol() { try { CharacterMarkerSymbol charSym = new CharacterMarkerSymbol(); charSym.setColor(RandomColor()); charSym.setSize(this.symbolSize); charSym.setCharacterIndex(67); // StdFont font = new StdFont(); font.setName("ESRI Default Marker"); charSym.setFont(font); // return charSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private IMarkerSymbol MakeNewPictureMarkerSymbol() { try { PictureMarkerSymbol picSym = new PictureMarkerSymbol(); picSym.setSize(this.symbolSize); picSym.createMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, pictureFile); return picSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private IMarkerSymbol MakeNewMultiLayerMarkerSymbol() { try { MultiLayerMarkerSymbol multiSym = new MultiLayerMarkerSymbol(); multiSym.setSize(this.symbolSize); multiSym.addLayer(MakeNewPictureMarkerSymbol()); multiSym.addLayer(MakeNewCharacterMarkerSymbol()); return multiSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private ILineSymbol MakeNewSimpleLineSymbol() { try { SimpleLineSymbol simpSym = new SimpleLineSymbol(); simpSym.setColor(RandomColor()); simpSym.setWidth(this.symbolSize); simpSym.setStyle(esriSimpleLineStyle.esriSLSDashDot); return simpSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private ILineSymbol MakeNewMarkerLineSymbol() { try { MarkerLineSymbol markSym = new MarkerLineSymbol(); markSym.setWidth(this.symbolSize); markSym.setMarkerSymbolByRef(MakeNewSimpleMarkerSymbol()); // ITemplate template = new Template(); template.addPatternElement(this.symbolSize, this.symbolSize * 2); template.setInterval(1); //symbolSize * 3 ILineProperties lineProperties = markSym; lineProperties.setTemplateByRef(template); // return markSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private ILineSymbol MakeNewCartographicLineSymbol() { try { CartographicLineSymbol cartSym = new CartographicLineSymbol(); cartSym.setColor(RandomColor()); cartSym.setWidth(this.symbolSize); cartSym.setCap(esriLineCapStyle.esriLCSRound); cartSym.setJoin(esriLineJoinStyle.esriLJSMitre); // ITemplate template = new Template(); template.addPatternElement(this.symbolSize, this.symbolSize * 2); template.setInterval(1); //symbolSize * 3 ILineProperties lineProperties = cartSym; lineProperties.setTemplateByRef(template); // return cartSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private ILineSymbol MakeNewHashLineSymbol() { try { HashLineSymbol hashSym = new HashLineSymbol(); hashSym.setWidth(this.symbolSize); hashSym.setHashSymbolByRef(MakeNewSimpleLineSymbol()); // Template template = new Template(); template.addPatternElement(this.symbolSize, this.symbolSize * 2); template.setInterval(1); //symbolSize * 3 ILineProperties lineProperties = hashSym; lineProperties.setTemplateByRef(template); // return hashSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private ILineSymbol MakeNewPictureLineSymbol() { try { PictureLineSymbol picSym = new PictureLineSymbol(); picSym.setWidth(this.symbolSize); picSym.createLineSymbolFromFile(esriIPictureType.esriIPictureBitmap, pictureFile); return picSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private ILineSymbol MakeNewMultiLayerLineSymbol() { try { MultiLayerLineSymbol multiSym = new MultiLayerLineSymbol(); multiSym.setWidth(this.symbolSize); this.symbolSize = this.symbolSize / 2; multiSym.addLayer(MakeNewSimpleLineSymbol()); this.symbolSize = this.symbolSize * 2; multiSym.addLayer(MakeNewMarkerLineSymbol()); return multiSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private IFillSymbol MakeNewSimpleFillSymbol() { try { SimpleFillSymbol simpSym = new SimpleFillSymbol(); simpSym.setColor(RandomColor()); simpSym.setStyle(esriSimpleFillStyle.esriSFSSolid); simpSym.setOutline(MakeNewSimpleLineSymbol()); return simpSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private IFillSymbol MakeNewGradientFillSymbol() { try { GradientFillSymbol gradSym = new GradientFillSymbol(); // AlgorithmicColorRamp ramp = new AlgorithmicColorRamp(); ramp.setFromColor(RandomColor()); ramp.setToColor(RandomColor()); ramp.setAlgorithm(esriColorRampAlgorithm.esriLabLChAlgorithm); gradSym.setColorRamp(ramp); // gradSym.setGradientAngle(25); gradSym.setGradientPercentage(1); gradSym.setIntervalCount(100); gradSym.setStyle(esriGradientFillStyle.esriGFSLinear); gradSym.setOutline(null); return gradSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private IFillSymbol MakeNewPictureFillSymbol() { try { PictureFillSymbol picSym = new PictureFillSymbol(); picSym.createFillSymbolFromFile(esriIPictureType.esriIPictureBitmap, pictureFile); picSym.setAngle(30); return picSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private IFillSymbol MakeNewMarkerFillSymbol() { try { MarkerFillSymbol markSym = new MarkerFillSymbol(); markSym.setMarkerSymbolByRef(MakeNewCharacterMarkerSymbol()); markSym.setGridAngle(60); markSym.setStyle(esriMarkerFillStyle.esriMFSGrid); return markSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private IFillSymbol MakeNewLineFillSymbol() { try { LineFillSymbol lineSym = new LineFillSymbol(); lineSym.setSeparation(this.symbolSize * 1.5); lineSym.setLineSymbolByRef(MakeNewSimpleLineSymbol()); return lineSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private IFillSymbol MakeNewMultiLayerFillSymbol() { try { MultiLayerFillSymbol multiSym = new MultiLayerFillSymbol(); multiSym.addLayer(MakeNewSimpleFillSymbol()); multiSym.addLayer(MakeNewMarkerFillSymbol()); return multiSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private IFillSymbol MakeNewDotDensityFillSymbol() { try { DotDensityFillSymbol dotSym = new DotDensityFillSymbol(); dotSym.setColor(RandomColor()); // ISymbolArray array = dotSym; SimpleMarkerSymbol marker1 = new SimpleMarkerSymbol(); marker1.setColor(RandomColor()); marker1.setStyle(esriSimpleMarkerStyle.esriSMSCircle); array.addSymbol(marker1); SimpleMarkerSymbol marker2 = new SimpleMarkerSymbol(); marker2.setColor(RandomColor()); marker2.setStyle(esriSimpleMarkerStyle.esriSMSCross); array.addSymbol(marker2); // dotSym.setBackgroundColor(RandomColor()); dotSym.setDotCount(0, 100); dotSym.setDotCount(1, 50); dotSym.setDotSize(2); dotSym.setDotSpacing(2); dotSym.setFixedPlacement(false); dotSym.setOutline(MakeNewSimpleLineSymbol()); return dotSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private IFillSymbol MakeNewColorSymbol() { try { ColorSymbol colSym = new ColorSymbol(); colSym.setColor(RandomColor()); return colSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private IFillSymbol MakeNewColorRampSymbol() { try { ColorRampSymbol colSym = new ColorRampSymbol(); // AlgorithmicColorRamp ramp = new AlgorithmicColorRamp(); ramp.setFromColor(RandomColor()); ramp.setToColor(RandomColor()); ramp.setAlgorithm(esriColorRampAlgorithm.esriLabLChAlgorithm); colSym.setColorRamp(ramp); // colSym.setInvert(false); return colSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private ITextSymbol MakeNewTextSymbol() { try { TextSymbol txtSym = new TextSymbol(); txtSym.setColor(RandomColor()); // StdFont font = new StdFont(); font.setName("Helvetica"); txtSym.setFont(font); // txtSym.setSize(this.symbolSize); txtSym.setText("" + System.currentTimeMillis()); txtSym.setVerticalAlignment(esriTextVerticalAlignment.esriTVACenter); return txtSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private IMarkerSymbol MakeNewPieChartSymbol() { try { PieChartSymbol pieSym = new PieChartSymbol(); pieSym.setClockwise(true); // ISymbolArray array = pieSym; SimpleFillSymbol fill1 = new SimpleFillSymbol(); fill1.setColor(RandomColor()); fill1.setStyle(esriSimpleFillStyle.esriSFSSolid); array.addSymbol(fill1); SimpleFillSymbol fill2 = new SimpleFillSymbol(); fill2.setColor(RandomColor()); fill2.setStyle(esriSimpleFillStyle.esriSFSSolid); array.addSymbol(fill2); // IChartSymbol chart = pieSym; chart.setMaxValue(10); chart.setValue(0, 3); chart.setValue(1, 10); // I3DChartSymbol threeDChart = pieSym; threeDChart.setDisplay3D(true); threeDChart.setThickness(20); threeDChart.setTilt(30); return pieSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private IMarkerSymbol MakeNewStackedChartSymbol() { try { StackedChartSymbol stackSym = new StackedChartSymbol(); stackSym.setFixed(false); stackSym.setUseOutline(true); stackSym.setVerticalBar(false); stackSym.setWidth(30); // ISymbolArray array =stackSym; SimpleFillSymbol fill1 = new SimpleFillSymbol(); fill1.setColor(RandomColor()); fill1.setStyle(esriSimpleFillStyle.esriSFSSolid); array.addSymbol(fill1); SimpleFillSymbol fill2 = new SimpleFillSymbol(); fill2.setColor(RandomColor()); fill2.setStyle(esriSimpleFillStyle.esriSFSSolid); array.addSymbol(fill2); // IChartSymbol chart = stackSym; chart.setMaxValue(10); chart.setValue(0, 3); chart.setValue(1, 10); // I3DChartSymbol threeDChart = stackSym; threeDChart.setDisplay3D(true); threeDChart.setThickness(20); return stackSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } private IMarkerSymbol MakeNewBarChartSymbol() { try { BarChartSymbol barSym = new BarChartSymbol(); barSym.setShowAxes(true); barSym.setSpacing(2); barSym.setVerticalBars(true); barSym.setWidth(20); // ISymbolArray array = (barSym); SimpleFillSymbol fill1 = new SimpleFillSymbol(); fill1.setColor(RandomColor()); fill1.setStyle(esriSimpleFillStyle.esriSFSSolid); array.addSymbol(fill1); SimpleFillSymbol fill2 = new SimpleFillSymbol(); fill2.setColor(RandomColor()); fill2.setStyle(esriSimpleFillStyle.esriSFSSolid); array.addSymbol(fill2); // IChartSymbol chart = barSym; chart.setMaxValue(10); chart.setValue(0, 3); chart.setValue(1, 10); // I3DChartSymbol threeDChart = barSym; threeDChart.setDisplay3D(true); threeDChart.setThickness(20); // return barSym; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } // aux method private IColor RandomColor() { try { RgbColor randomColor = new RgbColor(); randomColor.setRed((int) (Math.random() * 255)); randomColor.setGreen((int) (Math.random() * 255)); randomColor.setBlue((int) (Math.random() * 255)); return randomColor; } catch (IOException e) { e.printStackTrace(); // never happened } return null; } }