{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-guides/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Drawing Shapes","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":"drawing-shapes","__idx":0},"children":["Drawing Shapes"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["INTViewer is based upon the J/CarnacPro toolkit. You'll need to add the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["JCarnacProWrapper"]}," module to your dependencies to access the J/CarnacPro API."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Many of the techniques used to manipulate shapes in J/CarnacPro can be used directly in INTViewer. Remember that J/CarnacPro shapes are generally defined in model coordinates: they scale automatically as your zoom or scroll your view."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Each layer extends com.interactive.jcarnac2d.view.cgPlotView. As a result, the following often-used methods are available for any 2D layer:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"             public cgTransformation getTransformation();\n             public cgShapeListLayer getShapeList();\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["com.interactive.intviewerapi.windows.AnnotationView also extends com.interactive.jcarnac2d.view.cgPlotView. The same methods are available for that view."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["As a result, when you need to add a shape to a 2D window, you have a choice between adding that shape to:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["the visualization of a specific layer, or"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["the annotation view that sits on top of all layers of that window."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"drawing-rectangles","__idx":1},"children":["Drawing Rectangles"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In this example, we draw a rectangle in a time slice layer:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"            IMapSeismicLayer layer = ...\n            cgRectangle rect = new cgRectangle(400, 420, 500, 480);\n            cgAttribute attr = new cgGraphicAttribute();\n            attr.setLineColor(Color.RED);\n            attr.setFillStyle(cgGraphicAttribute.CG_LS_EMPTY);\n            rect.setAttribute(attr);\n            cgShapeListLayer shapeList = ((AbstractLayer2D) layer).getShapeListLayer();\n            shapeList.addShape(rect);\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"drawing-images","__idx":2},"children":["Drawing Images"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In this example, we draw an image in the annotation view:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"            import com.interactive.intviewerapi.shapes.Image;\n            AbstractLayer2D layer = ...\n            BufferedImage  bi = ImageIO.read(new File(\"C:\\\\myimage.jpg\"));\n            cgTransformation tr = layer.getTransformation();\n            cgRect imgRect = tr.inverseTransform(new Rectangle(50, 50, 200, 200));      //This will return the coordinates of the given rectangle transformed from device coordinates to model coordinates\n            cgShapeListLayer shapeList = layer.getViewerWindow().getAnnotationView().getShapeList();\n            cgGraphicAttribute attr = new cgGraphicAttribute();                         //leave blank; attributes will not affect images but this line is required\n            Image img = new Image(imgRect.x, imgRect.y, imgRect.width, imgRect.height, bi, false, false);\n            img.setAttribute(attr);\n            shapeList.addShape(img);\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"persistent-shapes","__idx":3},"children":["Persistent shapes"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In many cases, you want to add shapes that keep their position and attributes across sessions. The public API provides access to J/CarnacPro shapes that are persistent."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Persistent shapes are grouped in the com.interactive.intviewerapi.shapes package:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/solutions/intviewer/api-reference"},"children":["shapes package"]}]}]},"headings":[{"value":"Drawing Shapes","id":"drawing-shapes","depth":1},{"value":"Drawing Rectangles","id":"drawing-rectangles","depth":3},{"value":"Drawing Images","id":"drawing-images","depth":3},{"value":"Persistent shapes","id":"persistent-shapes","depth":3}],"frontmatter":{"title":"Drawing Shapes","pageId":"intviewer-api-for-layers/drawing-shapes","seo":{"title":"Drawing Shapes"}},"lastModified":"2026-10-22T14:32:05.573Z","pagePropGetterError":{"message":"","name":""}},"slug":"/solutions/intviewer/intviewer-api-for-layers/drawing-shapes","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}