LISTING 1 {CODE} public class acetateLayer extends com.esri.mo.ui.bean.AcetateLayer{ com.esri.mo.ui.bean.Map m_map; public acetateLayer(com.esri.mo.ui.bean.Map map){ m_map = map; } public void paintComponent(Graphics g){ // Call the superclass paint component to clear the off-screen buffer super.paintComponent(g); // Retrieve the current graphics component Graphics2D g2d = (Graphics2D) g; /* Use the Map component to create a Transform - used to convert world coordinates * to pixel cooridinates in the Map display */ com.esri.mo.cs.geom.Transform t = m_map.getWorldToPixelTransform(); // Create the features to be displayed in the AcetateLayer double[] xx = {-90.0, -110.0, -100.0}; double[] yy = {30.0, 40.0, 50.0}; com.esri.mo.cs.geom.BasePointsArray bpa = new com.esri.mo.cs.geom.BasePointsArray(xx,yy); com.esri.mo.cs.geom.BasePolyline bpl = new com.esri.mo.cs.geom.BasePolyline(new com.esri.mo.cs.geom.BasePath(bpa)); com.esri.mo.cs.geom.BasePolygon bp = new com.esri.mo.cs.geom.BasePolygon(new com.esri.mo.cs.geom.BaseRing(bpa)); java.awt.geom.Area a1 = new java.awt.geom.Area(bpl); java.awt.geom.Area a2 = new java.awt.geom.Area(bp); // Transform the feature coordinates from world to pixel coordinates a1.transform(t.toAffine()); a2.transform(t.toAffine()); // Set the color for the graphics envionment and draw a line g2d.setColor(new Color(2, 3, 250, 100)); g2d.draw(a1); // Set the color for the graphics envionment and fill a polygon g2d.setColor(new Color(230, 3, 3, 100)); g2d.fill(a2); } } {/CODE} LISTING 2 {CODE} public class graphicsLayer extends BaseGraphicsLayer { public graphicsLayer(){ // Create fields to hold the feature geometry and attributes BaseField fld1 = new BaseField("shape", Field.Esri_SHAPE, 0,0); BaseField fld2 = new BaseField("string", java.sql.Types.VARCHAR, 10,0); BaseFields bfs = new BaseFields(); bfs.addField(fld1); bfs.addField(fld2); // Create the feature geometry double[] xx = {-90.0, -110.0, -100.0}; double[] yy = {30.0, 40.0, 50.0}; BasePointsArray bpa = new BasePointsArray(xx,yy ); com.esri.mo.cs.geom.BasePolygon bp = new com.esri.mo.cs.geom.BasePolygon(new BaseRing(bpa)); // Create a and add the geomtery and attributes BaseFeature bf = new BaseFeature(); bf.setFields(bfs); bf.setValue(0, bp); bf.setValue(1, "Area 1"); // Create an Element to add to the GraphicsLayer BaseFeatureElement bfe1 = new BaseFeatureElement((BaseFeature) bf.clone()); // Set the renderer for the Element BaseSimpleRenderer rd = new BaseSimpleRenderer(); SimplePolygonSymbol symbol = new SimplePolygonSymbol(); symbol.setPaint(new Color(0,20,250)); rd.setSymbol(symbol); bfe1.setRenderer(rd); // Add Element to the GraphicsLayer this.addElement(bfe1); } } LISTING 3 {CODE} public class featureLayer extends BaseFeatureLayer { BaseFields fields; private Vector featureStorage; public featureLayer() { // Call local method to create features createFeaturesAndFields(); /* Retrieve and set the feature class for this FeatureLayer * "MyData" can be replaced with any String value, it will be used * as the layer name in the legend entry */ BaseFeatureClass bfc = getFeatureClass("MyData"); setFeatureClass(bfc); // Construct and set the renderer for this FeatureLayer BaseSimpleRenderer rd = new BaseSimpleRenderer(); SimplePolygonSymbol symbol = new SimplePolygonSymbol(); symbol.setPaint(new Color(250,0,20)); rd.setSymbol(symbol); setRenderer(rd); /* Call local method to set layer capabilities. Since the capabilities of a * FeatureLayer must be set before it will display, and the setCapabilities() * method has protected access, a dynamic FeatureLayer must subclass BaseFeatureLayer */ layerCapabilities lc = new layerCapabilities(); setCapabilities(lc); } private void createFeaturesAndFields(){ // A Vector will store the feature geometry and attributes featureStorage = new Vector(); fields = new BaseFields(); // Call createDbfFields to add fields to the BaseFields array createDbfFields(); /* Create a new BaseFeature and set the fields template. Assign a unique DataID for * each feature. */ BaseFeature feature = new BaseFeature(); feature.setFields(fields); feature.setDataID(new BaseDataID("myData",0)); // Create the feature geomtry and add it, as well as any attributes, to the BaseFeature double[] xx = {-90.0, -110.0, -100.0}; double[] yy = {30.0, 40.0, 50.0}; BasePointsArray bpa = new BasePointsArray(xx,yy ); com.esri.mo.cs.geom.BasePolygon bp = new com.esri.mo.cs.geom.BasePolygon(new BaseRing(bpa)); feature.setValue(0, bp); feature.setValue(1, new Integer(2)); // Add the BaseFeature to the storage Vector featureStorage.addElement(feature); } private void createDbfFields() { // Add the appropriate fields needed by a feature layer fields.addField(new BaseField("#SHAPE#", Field.Esri_SHAPE, 0, 0)); fields.addField(new BaseField("ID", java.sql.Types.INTEGER, 9, 0)); } public BaseFeatureClass getFeatureClass(String Name) { // Create a new MemoryFeatureClass and add features in the storage Vector com.esri.mo.map.mem.MemoryFeatureClass featClass = null; try{ // Set the feature type to the appropriate value (POLYGON, LINE, POINT) featClass = new com.esri.mo.map.mem.MemoryFeatureClass(MapDataset.POLYGON, fields); } catch (IllegalArgumentException ie) { System.err.println("error creating the base class ="+ie.toString()); } // Set the name of this feature class, used to label the legend featClass.setName(Name); featClass.addFeature((Feature) featureStorage.elementAt(0)); return featClass; } private final class layerCapabilities extends com.esri.mo.map.dpy.LayerCapabilities { layerCapabilities() { for (int i = 0; i < this.size(); i++) { setAvailable(this.getCapabilityName(i),true); setEnablingAllowed(this.getCapabilityName(i),true); getCapability(i).setEnabled(true); } } } } {/CODE}