Class StyleMapEditor

All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants

public class StyleMapEditor extends JDialog implements ActionListener
A GUI for editing style maps for the annotation viewer.

A style map is an XML document that describes how each kind of output from a Text Analysis Engine is to be displayed in the annotation viewer. Each output type that the user wants to be displayed will have an entry in the style map. Each entry in the style map contains:

  • The CSS style used to display annotations of that type (for example "background:blue; color:white;" to display white text on a blue background.
  • A label used to identify the annotations in the annotation viewer

To invoke the editor, call the launchEditor(AnalysisEngineMetaData, String, CAS) method.

See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      The Constant serialVersionUID.
      See Also:
    • buttonPress

      private boolean buttonPress
      The button press.
    • populated

      private boolean populated
      The populated.
    • annotationFeaturesViewer

      private AnnotationFeaturesViewer annotationFeaturesViewer
      The annotation features viewer.
    • addTableEntryButton

      private ImageButton addTableEntryButton
      The add table entry button.
    • tableModel

      private StyleMapTableModel tableModel
      The table model.
    • annotationsTable

      private StyleMapTable annotationsTable
      The annotations table.
    • styleList

      private ArrayList styleList
      The style list.
    • removeTableRowButton

      private ImageButton removeTableRowButton
      The remove table row button.
    • moveRowUpButton

      private ImageButton moveRowUpButton
      The move row up button.
    • moveRowDownButton

      private ImageButton moveRowDownButton
      The move row down button.
    • okButton

      private JButton okButton
      The ok button.
    • cancelButton

      private JButton cancelButton
      The cancel button.
    • resetButton

      private JButton resetButton
      The reset button.
    • styleMapEditorDialog

      private JDialog styleMapEditorDialog
      The style map editor dialog.
    • colorNameMap

      private HashMap colorNameMap
      The color name map.
    • analysisEngineMetaData

      private AnalysisEngineMetaData analysisEngineMetaData
      The analysis engine meta data.
    • ae

      The ae.
    • med

      private TableGUIMediator med
      The med.
    • data

      Object[][] data
      The data.
  • Constructor Details

    • StyleMapEditor

      public StyleMapEditor(JFrame aOwner, CAS cas)
      Creates a new `Editor.
      Parameters:
      aOwner - the a owner
      cas - the cas
  • Method Details

    • getPreferredSize

      public Dimension getPreferredSize()
      Overrides:
      getPreferredSize in class Container
    • setTextAnalysisEngine

      @Deprecated public void setTextAnalysisEngine(TaeDescription tae)
      Sets the text analysis engine.
      Parameters:
      tae - the new text analysis engine
    • setAnalysisEngine

      public void setAnalysisEngine(AnalysisEngineDescription ae)
      Sets the analysis engine.
      Parameters:
      ae - the new analysis engine
    • launchEditor

      public String launchEditor(AnalysisEngineMetaData aAnalysisEngineMetaData, String aStyleMapXml, CAS cas)
      Displays the StyleMapEditor GUI and allows the user to edit a style map. When the user has finished, the new style map is returned.
      Parameters:
      aAnalysisEngineMetaData - Metadata for the AnalysisEngine whose style map is to be edited. This contains the AE's capabilities and type system definition, which are needed by the editor.
      aStyleMapXml - An existing style map XML document that will be loaded into the editor. This is optional, if null is passed in, a default style map will be automatically generated from the AE metadata.
      cas - the cas
      Returns:
      a new style map XML document. If the user cancels, null is returned.
    • createStyleList

      public ArrayList createStyleList(AnalysisEngineMetaData aAnalysisEngineMetaData, String aStyleMapXml)
      Creates a List of StyleMapEntry objects from the given AnalysisEngineMetaData and style map XML.
      Parameters:
      aAnalysisEngineMetaData - Metadata for the AnalysisEngine whose style map is being edited.
      aStyleMapXml - An existing style map XML document. This is optional, if null is passed in, a default style map will be automatically generated.
      Returns:
      an ArrayList containing one StyleMapEntry object for each output type declared in aTaeMetaData.
    • parseStyleList

      public ArrayList parseStyleList(String aStyleMapXml)
      Parses the style list.
      Parameters:
      aStyleMapXml - the a style map xml
      Returns:
      the array list
    • actionPerformed

      public void actionPerformed(ActionEvent evt)
      Specified by:
      actionPerformed in interface ActionListener
    • getAnnotationsTable

      protected StyleMapTable getAnnotationsTable()
      Gets the annotations table.
      Returns:
      the annotations table
    • launchGUI

      private boolean launchGUI(ArrayList aStyleList, CAS cas)
      Displays the Style Map Editor GUI and allows the user to interact with it.
      Parameters:
      aStyleList - an ArrayList containing the style map entries to be edited. When the user modifies a setting in the GUI, the elements of this List will be updated.
      cas - the cas
      Returns:
      true if the user exits the dialog by clicking the OK button, false if the user has clicked the Cancel button.
    • setUpColorEditor

      private void setUpColorEditor(JTable table)
      Sets the up color editor.
      Parameters:
      table - the new up color editor
    • generateStyleMap

      private String generateStyleMap(ArrayList aStyleList)
      Generates a style map XML document from the style list.
      Parameters:
      aStyleList - An ArrayList containing the style map entries to be written to XML.
      Returns:
      A style map XML document representing the information in aStyleList.
    • addRow

      public void addRow(String typeName)
      Adds the row.
      Parameters:
      typeName - the type name