Class GraphDisplayOptions

    • Constructor Detail

      • GraphDisplayOptions

        public GraphDisplayOptions​(GraphType graphType)
        Constructs a new GraphTypeDisplayOptions for the given GraphType
        Parameters:
        graphType - The GraphType for which to define display options
      • GraphDisplayOptions

        public GraphDisplayOptions​(GraphType graphType,
                                   Tool tool)
        Constructs a new GraphTypeDisplayOptions for the given GraphType and initializes from tool options. Note this form should only be used for display options on GraphTypes that have options registered in the tool.
        Parameters:
        graphType - The GraphType for which to define display options
        tool - the tool from which to initialize from ToolOptions
    • Method Detail

      • initializeDefaults

        protected void initializeDefaults()
      • addChangeListener

        public void addChangeListener​(javax.swing.event.ChangeListener listener)
        Adds a ChangeListener to be notified when display options change
        Parameters:
        listener - the listener to be notified.
      • removeChangeListener

        public void removeChangeListener​(javax.swing.event.ChangeListener listener)
        Removes the listener so that it won't be notified of changes any longer
        Parameters:
        listener - the listener to be removed
      • setDefaultVertexShape

        public void setDefaultVertexShape​(VertexShape shape)
        Sets the default shape to be used by vertices that don't have a vertex type set
        Parameters:
        shape - the default vertex shape
      • setDefaultVertexColor

        public void setDefaultVertexColor​(java.awt.Color color)
        Sets the default color to be used by vertices that don't have a vertex type set
        Parameters:
        color - the default vertex shape
      • setDefaultEdgeColor

        public void setDefaultEdgeColor​(java.awt.Color color)
        Sets the default color to be used by edges that don't have a edge type set
        Parameters:
        color - the default edge shape
      • getDefaultEdgeColor

        public java.awt.Color getDefaultEdgeColor()
        Returns the default color for edges that don't have an edge type set
        Returns:
        the default color for edges that don't have an edge type set
      • getDefaultVertexColor

        public java.awt.Color getDefaultVertexColor()
        Returns the default color for vertices that don't have an vertex type set
        Returns:
        the default color for vertices that don't have an vertex type set
      • setVertexLabelOverrideAttributeKey

        public void setVertexLabelOverrideAttributeKey​(java.lang.String attributeKey)
        Sets the attribute key that can be used to override the label text shown for the vertex. Normally, the vertex's name is shown as the label.
        Parameters:
        attributeKey - the attribute key that, if set, will be used to define the vertice's label
      • getVertexLabelOverride

        public java.lang.String getVertexLabelOverride()
        Returns the attribute key that can override the vertices label text
        Returns:
        the attribute key that can override the vertices label text
      • setVertexColorOverrideAttributeKey

        public void setVertexColorOverrideAttributeKey​(java.lang.String attributeKey)
        Sets the attribute key that can be used to override the color for a vertex. Normally, the color is determined by the vertex type, which will be mapped to a color
        Parameters:
        attributeKey - the attribute key that, if set, will be used to define the vertice's color
      • setEdgeColorOverrideAttributeKey

        public void setEdgeColorOverrideAttributeKey​(java.lang.String attributeKey)
        Sets the attribute key that can be used to override the color for an edge. Normally, the color is determined by the edge type, which will be mapped to a color
        Parameters:
        attributeKey - the attribute key that, if set, will be used to define the edge's color
      • getEdgeColorOverrideAttributeKey

        public java.lang.String getEdgeColorOverrideAttributeKey()
        Returns the attribute key that can be used to override the color of an edge
        Returns:
        the attribute key that can be used to override the color of an edge
      • setVertexShapeOverrideAttributeKey

        public void setVertexShapeOverrideAttributeKey​(java.lang.String attributeKey)
        Sets the attribute key that can be used to override the shape for a vertex. Normally, the shape is determined by the vertex type, which will be mapped to a shape
        Parameters:
        attributeKey - the attribute key that, if set, will be used to define the vertice's shape
      • getVertexLabel

        public java.lang.String getVertexLabel​(AttributedVertex vertex)
        Returns the text that will be displayed as the label for the given vertex
        Parameters:
        vertex - the vertex for which to get label text
        Returns:
        the text that will be displayed as the label for the given vertex
      • getVertexShape

        public VertexShape getVertexShape​(AttributedVertex vertex)
        Returns the VertexShape that will be used to draw the vertex's shape
        Parameters:
        vertex - the vertex for which to get the shape
        Returns:
        the VertexShape that will be used to draw the vertex's shape
      • getVertexColor

        public java.awt.Color getVertexColor​(AttributedVertex vertex)
        Returns the color that will be used to draw the vertex
        Parameters:
        vertex - the vertex for which to get the color
        Returns:
        the color that will be used to draw the vertex
      • getEdgeColor

        public java.awt.Color getEdgeColor​(AttributedEdge edge)
        Returns the color that will be used to draw the edge
        Parameters:
        edge - the edge for which to get the color
        Returns:
        the color that will be used to draw the edge
      • getEdgePriority

        public java.lang.Integer getEdgePriority​(java.lang.String edgeType)
        Returns the priority for the given edge type. This is used by layout algorithms to determine which edges should have more influence on the layout.
        Parameters:
        edgeType - the edge type for which to get it's priority
        Returns:
        the priority for the given edge type
      • getFavoredEdgeType

        public java.lang.String getFavoredEdgeType()
        Returns the edge type that is the preferred edge for layout purposes
        Returns:
        the edge type that is the preferred edge for layout purposes
      • setFavoredEdgeType

        public void setFavoredEdgeType​(java.lang.String favoredEdgeType)
        Sets the favored edge type. The favored edge type is used to influence layout algorithms
        Parameters:
        favoredEdgeType - the edge type that is to be favored by layout algorithms
      • getGraphType

        public GraphType getGraphType()
        Returns the GraphType that this object provides display options for
        Returns:
        the GraphType that this object provides display options for
      • getVertexColor

        public java.awt.Color getVertexColor​(java.lang.String vertexType)
        Returns the color for the given vertex type
        Parameters:
        vertexType - the vertex type to get the color for
        Returns:
        the color for the given vertex type
      • setVertexColor

        public void setVertexColor​(java.lang.String vertexType,
                                   java.awt.Color color)
        Sets the color for vertices with the given vertex type
        Parameters:
        vertexType - the vertex type for which to set its color
        color - the color to use for vertices with the given vertex type
      • setVertexShape

        public void setVertexShape​(java.lang.String vertexType,
                                   VertexShape vertexShape)
        Sets the VertexShape to use for vertices with the given vertex type
        Parameters:
        vertexType - the vertex type for which to set its shape
        vertexShape - the VertexShape to use for vertices with the given vertex type
      • getEdgeColor

        public java.awt.Color getEdgeColor​(java.lang.String edgeType)
        Returns the color for the given edge type
        Parameters:
        edgeType - the edge type whose color is to be determined.
        Returns:
        the color for the given edge type.
      • setEdgeColor

        public void setEdgeColor​(java.lang.String edgeType,
                                 java.awt.Color color)
        Sets the color for edges with the given edge type
        Parameters:
        edgeType - the edge type for which to set its color
        color - the new color for edges with the given edge type
      • optionsChanged

        public void optionsChanged​(ToolOptions options,
                                   java.lang.String optionName,
                                   java.lang.Object oldValue,
                                   java.lang.Object newValue)
                            throws OptionsVetoException
        Description copied from interface: OptionsChangeListener
        Notification that an option changed.

        Note: to reject an options change, you can throw a OptionsVetoException.

        Specified by:
        optionsChanged in interface OptionsChangeListener
        Parameters:
        options - options object containing the property that changed
        optionName - name of option that changed
        oldValue - old value of the option
        newValue - new value of the option
        Throws:
        OptionsVetoException - if a change is rejected
      • getRootOptionsName

        public java.lang.String getRootOptionsName()
        Returns the name for the root Options name for this GraphDisplayOptions
        Returns:
        the name for the root Options name for this GraphDisplayOptions
      • getVertexColorOverrideAttributeKey

        public java.lang.String getVertexColorOverrideAttributeKey()
        Returns the attribute key that can be used to override the color of a vertex. Normally, a vertex is colored based on its vertex type. However, if this value is non-null, a vertex can override its color by setting an attribute using this key name.
        Returns:
        the attribute key that can be used to override the color of a vertex
      • getVertexShapeOverrideAttributeKey

        public java.lang.String getVertexShapeOverrideAttributeKey()
        Returns the attribute key that can be used to override the shape of a vertex. Normally, a vertex has a shape based on its vertex type. However, if this value is non-null, a vertex can override its shape by setting an attribute using this key name.
        Returns:
        the attribute key that can be used to override the shape of a vertex
      • getDefaultVertexShape

        public VertexShape getDefaultVertexShape()
        returns the VertexShape for any vertex that has not vertex type defined
        Returns:
        the VertexShape for any vertex that has not vertex type defined
      • getVertexShape

        public VertexShape getVertexShape​(java.lang.String vertexType)
        Returns the VertexShape for vertices that have the given vertex type
        Parameters:
        vertexType - the vertex type for which to get its asigned shape
        Returns:
        the VertexShape for vertices that have the given vertex type
      • getVertexSelectionColor

        public java.awt.Color getVertexSelectionColor()
        Returns the vertex selection color
        Returns:
        the vertex selection color
      • setVertexSelectionColor

        public void setVertexSelectionColor​(java.awt.Color vertexSelectionColor)
        Sets the vertex selection color
        Parameters:
        vertexSelectionColor - the color to use for highlighting selected vertices
      • getEdgeSelectionColor

        public java.awt.Color getEdgeSelectionColor()
        Returns the color for edge selections
        Returns:
        the color fore edge selections
      • setEdgeSelectionColor

        public void setEdgeSelectionColor​(java.awt.Color edgeSelectionColor)
        Sets the edge selection color
        Parameters:
        edgeSelectionColor - color to use for highlighting selected edges
      • getDefaultLayoutAlgorithmNameLayout

        public java.lang.String getDefaultLayoutAlgorithmNameLayout()
        Returns the name of the default graph layout algorithm
        Returns:
        the name of the default graph layout algorithms
      • setDefaultLayoutAlgorithmName

        public void setDefaultLayoutAlgorithmName​(java.lang.String defaultLayout)
        Sets the name of the default layout algorithm
        Parameters:
        defaultLayout - the name of the layout algorithm to use by default
      • usesIcons

        public boolean usesIcons()
        Returns true if the rendering mode is to use icons for the vertices. If using icons, the label is drawn inside the shape.
        Returns:
        true if the rendering mode is to use icons.
      • setUsesIcons

        public void setUsesIcons​(boolean b)
        Sets whether the graph rendering mode is to use icons or not. If using icons, the label and shape are drawn together into a cached icon. Otherwise, the shapes are drawn on the fly and labeled separately.
        Parameters:
        b - true to render in icon mode.
      • getLabelPosition

        public GraphLabelPosition getLabelPosition()
        Returns the label position relative to the vertex. Note this is only relevant if usesIcons() is false
        Returns:
        the label position relative to the vertex
      • setLabelPosition

        public void setLabelPosition​(GraphLabelPosition labelPosition)
        Sets the label position relative to the vertex. Note this is only relevant if usesIcons() is false.
        Parameters:
        labelPosition - the GraphLabelPosition to use for rendering vertex labels
      • setFont

        public void setFont​(java.awt.Font font)
        Sets the font to use for drawing vertex labels
        Parameters:
        font - the font to use for drawing vertex labels
      • getFont

        public java.awt.Font getFont()
        Returns the font being used to render vertex labels
        Returns:
        the font being used to render vertex labels
      • getArrowLength

        public int getArrowLength()
        Returns the length of the arrow. The width will be proportional to the length. Note: this option is not exposed in the Options because it is too specific to a graph instance and wouldn't be appropriate to apply to shared options.
        Returns:
        the size if the arrow
      • setArrowLength

        public void setArrowLength​(int length)
        Sets the length of the arrow. The width will be proportional to the length. Note: this option is not exposed in the Options because it is too specific to a graph instance and wouldn't be appropriate to apply to shared options.
        Parameters:
        length - the size of the arrow
      • getMaxNodeCount

        public int getMaxNodeCount()
        Returns the maximum number of nodes that can be in a displayed graph
        Returns:
        the maximum number of nodes that can be in a displayed graph
      • setMaxNodeCount

        public void setMaxNodeCount​(int maxNodeCount)
        Sets the maximum number of nodes a graph can have and still be displayed. Be careful, setting this value too high can result in Ghidra running out of memory and/or making the system very sluggish.
        Parameters:
        maxNodeCount - the maximum number of nodes a graph can have and still be displayed.
      • isRegisteredWithTool

        public boolean isRegisteredWithTool()
        Returns true if this GraphDisplayOptions instance has been constructed with a tool for getting/saving option values in the tool options
        Returns:
        true if this GraphDisplayOptions instance is connected to tool options
      • registerOptions

        public void registerOptions​(ToolOptions toolOptions,
                                    HelpLocation help)
        Registers this GraphTypeDisplayOptions with ToolOptions. Note: this should only be used by plugins or other objects that get instantiated immediately when the tool is constructed. Otherwise, if the tool exits and this hasn't been called, any saved option values will be lost.

        Parameters:
        toolOptions - the ToolOptions to register these options with
        help - the help location to be used by the OptionsDialog for display/editing these options
      • configureVertexType

        protected void configureVertexType​(java.lang.String vertexType,
                                           VertexShape vertexShape,
                                           java.awt.Color color)
        Sets default values for vertex types
        Parameters:
        vertexType - the vertex type whose default color and shape are being defined
        vertexShape - the default vertex shape for the given vertex type
        color - the default color for the given vertex type
      • configureEdgeType

        protected void configureEdgeType​(java.lang.String edgeType,
                                         java.awt.Color color)
        Sets default values for edge types
        Parameters:
        edgeType - the edge type whose default color and shape are being defined
        color - the default color for the given edge type
      • initializeFromOptions

        public void initializeFromOptions​(Tool tool)
        Loads values from tool options
        Parameters:
        tool - the tool from which to update values.