{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-guides/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Shapecreationevent","description":"Accelerate E&P application development and protect your innovation by consuming our Data and Domain APIs / Platform APIs.","lang":"en-US","meta":[{"name":"robots","content":"noindex"}],"llmstxt":{"hide":false}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"shapecreationevent","__idx":0},"children":["Shapecreationevent"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"shapecreatedevent","__idx":1},"children":["ShapeCreatedEvent"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This type of event is posted when a shape is created in one of the windows. A typical example would be when a polyline has been drawn in a map view for specifying an arbitrary path."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following example shows how to implement a listener that looks for polyline creation on map views, extract the coordinates in Inline/Xline domain and print them into a JTextPane jTextPane1."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"        public void onEvent(EventObject evt) {\n        if (evt instanceof ShapeCreatedEvent) {\n            Object source = evt.getSource();\n            cgShape shape = ((ShapeCreatedEvent) evt).getShape();\n            if (!(shape instanceof cgPolyline)) {\n                return;\n            }\n            if (source instanceof ILayer2D) {\n                ILayer2D layer = (ILayer2D) source;\n                ILayeredWindow window = layer.getViewerWindow();\n                if (window instanceof IMapWindow) {\n                    IMapWindow mapWindow = (IMapWindow) window;\n                    cgPolyline polyline = (cgPolyline) shape;\n                    double xValues[] = polyline.getXValues();\n                    double yValues[] = polyline.getYValues();\n                    if (mapWindow.getDisplayMode() == IMapWindow.XY) {\n                        // transform to IJ if map is in XY\n                        IJToXYTransformation tr = mapWindow.getIJToXYTransformation();\n                        if (tr == null || !tr.isValidCoordMatrix()) {\n                            return;\n                        }\n                        double tValues[];\n                        for (int i=0; i<xValues.length; i++) {\n                            tValues = tr.invCoordTrans(xValues[i], yValues[i]);\n                            xValues[i] = tValues[0];\n                            yValues[i] = tValues[1];\n                        }\n                    }\n                    // print the values into a text pane\n                    String buffer = \"\";\n                    for (int i=0; i<xValues.length; i++) {\n                        buffer += xValues[i] + \" \" + yValues[i] + \"\\n\";\n                    }\n                    jTextPane1.setText(buffer);\n                }\n            }\n        }\n    }\n"},"children":[]}]},"headings":[{"value":"Shapecreationevent","id":"shapecreationevent","depth":1},{"value":"ShapeCreatedEvent","id":"shapecreatedevent","depth":2}],"frontmatter":{"title":"Shapecreationevent","pageId":"events/shapecreationevent","seo":{"title":"Shapecreationevent"}},"lastModified":"2026-10-22T14:32:05.573Z","pagePropGetterError":{"message":"","name":""}},"slug":"/solutions/intviewer/events/shapecreationevent","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}