INTViewer is based upon the J/CarnacPro toolkit. You'll need to add the JCarnacProWrapper module to your dependencies to access the J/CarnacPro API.
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.
Each layer extends com.interactive.jcarnac2d.view.cgPlotView. As a result, the following often-used methods are available for any 2D layer:
public cgTransformation getTransformation(); public cgShapeListLayer getShapeList();com.interactive.intviewerapi.windows.AnnotationView also extends com.interactive.jcarnac2d.view.cgPlotView. The same methods are available for that view.
As a result, when you need to add a shape to a 2D window, you have a choice between adding that shape to:
In this example, we draw a rectangle in a time slice layer:
IMapSeismicLayer layer = ... cgRectangle rect = new cgRectangle(400, 420, 500, 480); cgAttribute attr = new cgGraphicAttribute(); attr.setLineColor(Color.RED); attr.setFillStyle(cgGraphicAttribute.CG_LS_EMPTY); rect.setAttribute(attr); cgShapeListLayer shapeList = ((AbstractLayer2D) layer).getShapeListLayer(); shapeList.addShape(rect);In this example, we draw an image in the annotation view:
import com.interactive.intviewerapi.shapes.Image; AbstractLayer2D layer = ... BufferedImage bi = ImageIO.read(new File("C:\\myimage.jpg")); cgTransformation tr = layer.getTransformation(); 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 cgShapeListLayer shapeList = layer.getViewerWindow().getAnnotationView().getShapeList(); cgGraphicAttribute attr = new cgGraphicAttribute(); //leave blank; attributes will not affect images but this line is required Image img = new Image(imgRect.x, imgRect.y, imgRect.width, imgRect.height, bi, false, false); img.setAttribute(attr); shapeList.addShape(img);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.
Persistent shapes are grouped in the com.interactive.intviewerapi.shapes package: