Additional Modification of Trace Processors and Seismic Generators

If you would like your trace processor or seismic generator to utilize the property sheet within the Seismic Workbench there are a couple of small modifications that you must make to your processor or generator.

  • The first step is to override the getLookupObjects method.
  • The second is to create a method to add your list of properties to an IMemento object.

Creating a getLookupObjects Method

The first step is a fairly simple step. We need to create an array of objects and return it. This array of objects is what is searched by NetBeans when we do a lookup. The following is a simple example taken from the Random Volume seismic generator:

    protected Object[] getLookupObjects() {
        ArrayList<Object> list = new ArrayList<Object>();
        IMemento memento = this.getLookupMemento();
        list.add(memento);
        return list.toArray();
    }

This method creates a List of Objects, fills the array with the IMemento object that contains our properties, and then returns the list as an array. The creation and filling of the IMemento object is discussed in the next section.

Creating and Filling an IMemento Object

The first step is to create the IMemento object. This is accomplished by the following two lines of code:

    Collection<? extends IMementoFactory> factories = Lookup.getDefault().lookupAll(IMementoFactory.class);
    IMemento processorMemento = factories.iterator().next().createMemento("SeismicGenerator");

You are free to change the name SeismicGenerator to whatever you wish, this is only a placeholder.

The next step is to fill the IMemento object with all of the values that your generator or processor requires. This is accomplished by creating a child for each property that your class needs input for.

    IMemento nameOfProperty = processorMemento.createChild("IntegerProperty");

IntegerProperty is the type of property that this child is referring to. The following are the valid property types for the Seismic Workbench:

  • StringProperty
  • BooleanProperty
  • FileProperty
  • IntegerProperty
  • FloatProperty
  • FloatArrayProperty
  • IntegerArrayProperty
  • ComboProperty

These names replace IntegerProperty in the child creation line depending on what type of property you require. They must be placed as the name of the child exactly as they are spelled above.

All of these properties require a set of four different arguments.

  • The first is the name; this is what will be displayed as the name on the property sheet.
  • The second is the mementoName; this is what will be referred to by the IPersistent methods saveState and restoreState.
  • The third is the required field; this is a true or false value that states whether or not that field must be filled out before execution. This will most likely be true.
  • The final field is the default field; this field is the default value for this property.

Additionally, ComboProperties require a list of items that will be the drop down list displayed to the user. These are done by adding a child to the ComboProperty called ListElement. ListElements have two different arguments.

  • The first is the text field; this field is the text that will be displayed inside the combo box.
  • The second is the value field; this field is the value that corresponds to the text in the combo box.

The following code is an example on how to build your IMemento from INTViewer's AGC trace processor.

    private IMemento getLookupMemento() {
        Collection<? extends IMementoFactory> factories = Lookup.getDefault().lookupAll(IMementoFactory.class);
        IMemento processorMemento = factories.iterator().next().createMemento("Properties");
        IMemento measurementMemento = processorMemento.createChild("ComboProperty");
        measurementMemento.putString("name", "Measurement Unit");
        measurementMemento.putString("mementoName", "measurementUnit");
        measurementMemento.putString("required", "true");
        measurementMemento.putString("default", Integer.toString(SeismicProperties.AGC_SAMPLE));
        IMemento sampleMemento = measurementMemento.createChild("ListElement");
        sampleMemento.putString("text", "Samples");
        sampleMemento.putString("value", Integer.toString(SeismicProperties.AGC_SAMPLE));
        IMemento timeMemento = measurementMemento.createChild("ListElement");
        timeMemento.putString("text", "Seconds");
        timeMemento.putString("value", Integer.toString(SeismicProperties.AGC_TIME));
        IMemento windowMemento = processorMemento.createChild("FloatProperty");
        windowMemento.putString("name", "Window Length");
        windowMemento.putString("mementoName", "windowLength");
        windowMemento.putString("required", "true");
        windowMemento.putString("default", Float.toString(250));
        return processorMemento;
    }