Class JsonDisplay

  • All Implemented Interfaces:
    AdditionalInformationHandler, CleanUpHandler, Destroyable, GlobalInfoSupporter, LoggingLevelHandler, LoggingSupporter, OptionHandler, QuickInfoSupporter, ShallowCopySupporter<Actor>, SizeOfHandler, Stoppable, StoppableWithFeedback, TextSupporter, VariablesInspectionHandler, VariableChangeListener, Actor, ClearableDisplay, DisplayTypeSupporter, ErrorHandler, InputConsumer, ComponentSupplier, DisplayPanelProvider, TextSupplier, MenuBarProvider, SendToActionSupporter, Serializable, Comparable

    public class JsonDisplay
    extends AbstractGraphicalDisplay
    implements DisplayPanelProvider, TextSupplier
    Displays a JSON object as tree structure.

    Input/output:
    - accepts:
       org.json.simple.JSONAware


    Valid options are:

    -D <int> (property: debugLevel)
        The greater the number the more additional info the scheme may output to 
        the console (0 = off).
        default: 0
        minimum: 0
     
    -name <java.lang.String> (property: name)
        The name of the actor.
        default: JsonDisplay
     
    -annotation <adams.core.base.BaseText> (property: annotations)
        The annotations to attach to this actor.
        default: 
     
    -skip (property: skip)
        If set to true, transformation is skipped and the input token is just forwarded 
        as it is.
     
    -stop-flow-on-error (property: stopFlowOnError)
        If set to true, the flow gets stopped in case this actor encounters an error;
         useful for critical actors.
     
    -short-title (property: shortTitle)
        If enabled uses just the name for the title instead of the actor's full 
        name.
     
    -width <int> (property: width)
        The width of the dialog.
        default: 800
        minimum: -1
     
    -height <int> (property: height)
        The height of the dialog.
        default: 600
        minimum: -1
     
    -x <int> (property: x)
        The X position of the dialog (>=0: absolute, -1: left, -2: center, -3: right
        ).
        default: -1
        minimum: -3
     
    -y <int> (property: y)
        The Y position of the dialog (>=0: absolute, -1: top, -2: center, -3: bottom
        ).
        default: -1
        minimum: -3
     
    -writer <adams.gui.print.JComponentWriter> (property: writer)
        The writer to use for generating the graphics output.
        default: adams.gui.print.NullWriter
     
    -preview (property: preview)
        If enabled, a text area is shown that displays the JSON object associated 
        with the currently selected node in the tree.
     
    -expand (property: expand)
        If enabled, the tree gets fully expanded.
     
    -sort-keys (property: sortKeys)
        If enabled, the keys of JSONObject objects will get sorted for display.
     
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_Tree

        protected JsonSupporter m_Tree
        the tree displaying the JSON object.
      • m_Preview

        protected boolean m_Preview
        whether to offer preview.
      • m_Expand

        protected boolean m_Expand
        whether to fully expand the tree.
      • m_SortKeys

        protected boolean m_SortKeys
        whether to sort the keys of JSONObject objects.
    • Constructor Detail

      • JsonDisplay

        public JsonDisplay()
    • Method Detail

      • setPreview

        public void setPreview​(boolean value)
        Sets whether to show a preview text area.
        Parameters:
        value - if true then text area is displayed
      • getPreview

        public boolean getPreview()
        Returns whether to show a preview text area.
        Returns:
        true if text area is displayed
      • previewTipText

        public String previewTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setExpand

        public void setExpand​(boolean value)
        Sets whether to fully expand the tree or not.
        Parameters:
        value - if true then the tree gets fully expanded
      • getExpand

        public boolean getExpand()
        Returns whether to fully expand the tree or not.
        Returns:
        true if text area is displayed
      • expandTipText

        public String expandTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setSortKeys

        public void setSortKeys​(boolean value)
        Sets whether to sort the keys of JSONObject objects.
        Parameters:
        value - if true then keys get sorted
      • getSortKeys

        public boolean getSortKeys()
        Returns whether to sort the keys of JSONObject objects.
        Returns:
        true if keys get sorted
      • sortKeysTipText

        public String sortKeysTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • accepts

        public Class[] accepts()
        Returns the class that the consumer accepts.
        Specified by:
        accepts in interface InputConsumer
        Returns:
        the Class of objects that can be processed
      • display

        protected void display​(Token token)
        Displays the token (the panel and dialog have already been created at this stage).
        Specified by:
        display in class AbstractDisplay
        Parameters:
        token - the token to display
      • createDisplayPanel

        public DisplayPanel createDisplayPanel​(Token token)
        Creates a new display panel for the token.
        Specified by:
        createDisplayPanel in interface DisplayPanelProvider
        Parameters:
        token - the token to display in a new panel, can be null
        Returns:
        the generated panel
      • displayPanelRequiresScrollPane

        public boolean displayPanelRequiresScrollPane()
        Returns whether the created display panel requires a scroll pane or not.
        Specified by:
        displayPanelRequiresScrollPane in interface DisplayPanelProvider
        Returns:
        true if the display panel requires a scroll pane