Working with Auxiliary Widgets

This article shows how you can create your own auxiliary widget. We are going to create a sample auxiliary widget that shows the number of traces of the current selection.

The project is attached at the bottom of this article.

There are two classes:

StatisticsPanel extends the JPanel class.

StatisticsAuxiliaryPlotProvider extends the AbstractXSectionAuxiliaryPlotProvider class. The getComponent method of StatisticsAuxiliaryPlotProvider returns a StatisticsPanel instance

The layer.xml file registers the StatisticsAuxiliaryPlotProvider class:

The panel is updated when the model changes (onModelChanged method)

Once plugged, the "Statistics" widget is available from the contextual menu of the auxiliary graph:

The "Statistics" widget also has a contextual menu:

To complete this project, you would need to extend the AbstractXSectionAuxiliaryPlotProvider.getIcon() method so that it returns a better icon than the default.

You have the option to configure to your auxiliary widget:

  • is it shown by default?
  • if its shown by default (there can be several shown), is it selected?
  • where is it shown (which position)

In this example below:

    <folder name="AuxiliaryPlotProviders">
        <folder name="ViewerPlotXV">
            <file name="com-interactive-intviewer-view2d-AuxiliaryGraphPlotProvider.instance">
                <attr name="position" intvalue="100"/>
                <attr name="isDefault" boolvalue="true"/>
            </file>
            <file name="demos-auxiliarywidget-StatisticsAuxiliaryPlotProvider.instance">
                <attr name="position" intvalue="200"/>
                <attr name="isDefault" boolvalue="true"/>
                <attr name="isSelected" boolvalue="true"/>
            </file>
        </folder>
    </folder>

The "Auxiliary Graph" widget is shown in the first position, the "Statistics" widget is shown in the second position (see the "position" attributes)

Both widgets are shown by default (see the "isDefault" attributes)

The "Statistics" widget is selected by default (see the "isSelected" attribute)

Graphically, this is the default widget layout:

Remember that this layout is only the default layout that is loaded when INTViewer starts for the first time. The user might add, move or remove widgets and this new layout will be remembered as a preference for future windows. To customize this behavior, you would need to plug your own AbstractXSectionAuxiliaryPlotsContainer, which is beyond the scope of this article.