A walkthrough is available to show how to implement contextual menus with layers.
Actions of type java.swing.Action or com.interactive.intviewerapi.layers.actions.LayerAction can be added to the popup menu. Implementations of com.interactive.intviewerapi.layers.actions.LayerAction will be provided the layer and point where the user clicked.
public class CustomLayerAction extends AbstractLayerAction {
public CustomLayerAction() {
super("Custom Action");
}
@Override
public void performAction(ILayer2D layer, int x, int y) {
// do stuff here
}
}
Layers are names are resolved using the ILayer2D.getType method. The default implementation of this method returns the simple name of the implementation class.
To add an action to a layer type name and the full path to the action class should be specified in the layer.xml of the plugin.
For a Seismic layer in a XSection window (ISeismicLayer in IXSectionWindow)
<folder name="LayerActions">
<folder name="ViewerSeismicLayer">
<file name="org-yourpackage-CustomLayerAction.instance">
<attr name="position" intvalue="150"/>
</file>
</folder>
</folder>
For a Horizon layer in a XSection window (IHorizonLayer in IXSectionWindow)
<folder name="LayerActions">
<folder name="ViewerHorizonLayer">
<file name="org-yourpackage-CustomLayerAction.instance">
<attr name="position" intvalue="150"/>
</file>
</folder>
</folder>
Use the _hidden extension to remove an action from a layer popup menu.
<folder name="LayerActions">
<folder name="ViewerMapHorizonLayer">
<file name="com-interactive-intviewer-control-BroadcastSelectedPointAction.instance_hidden">
<attr name="position" intvalue="150"/>
</file>
</folder>
</folder>
It is also possible to add a bit of organization to the popup menu by adding separators.
<folder name="LayerActions">
<folder name="ViewerMapHorizonLayer">
<file name="com-interactive-intviewer-control-LayerEditorAction.instance">
<attr name="position" intvalue="100"/>
</file>
<file name="com-interactive-intviewer-control-BroadcastSelectedPointAction.instance">
<attr name="position" intvalue="110"/>
</file>
<file name="Separator1.instance">
<attr name="position" intvalue="120"/>
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
</file>
<file name="org-yourpackage-CustomLayerAction.instance">
<attr name="position" intvalue="150"/>
</file>
</folder>
</folder>