Package ghidra.service.graph
Class GraphDisplayOptions
java.lang.Object
ghidra.service.graph.GraphDisplayOptions
- All Implemented Interfaces:
OptionsChangeListener
- Direct Known Subclasses:
DefaultGraphDisplayOptions
,ProgramGraphDisplayOptions
Class for managing graph display options. This includes color options for each vertex
and edge type and shapes for vertex types.
-
Constructor Summary
ModifierConstructorDescriptionGraphDisplayOptions
(GraphType graphType) Constructs a new GraphTypeDisplayOptions for the givenGraphType
protected
GraphDisplayOptions
(GraphType graphType, Tool tool, HelpLocation help) Constructs a new GraphTypeDisplayOptions for the givenGraphType
and initializes from tool options. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addChangeListener
(ChangeListener listener) Adds a ChangeListener to be notified when display options changeprotected void
configureEdgeType
(String edgeType, Color color) Sets default values for edge types.protected void
configureEdgeType
(String edgeType, String themeColorId) Sets default values for edge types using theme color ids.protected void
configureVertexType
(String vertexType, VertexShape vertexShape, Color color) Sets default values for vertex types.protected void
configureVertexType
(String vertexType, VertexShape vertexShape, String themeColorId) Sets default values for vertex types using theme color ids.void
displayEditor
(Tool tool, HelpLocation help) Pop up a dialog for editing these graph display options.int
Returns the length of the arrow.Returns the default color for edges that don't have an edge type setReturns the name of the default graph layout algorithmReturns the default color for vertices that don't have an vertex type setreturns theVertexShape
for any vertex that has not vertex type definedgetEdgeColor
(AttributedEdge edge) Returns the color that will be used to draw the edgegetEdgeColor
(String edgeType) Returns the color for the given edge typeReturns the attribute key that can be used to override the color of an edgegetEdgePriority
(String edgeType) Returns the priority for the given edge type.Returns the color for edge selectionsReturns the edge type that is the preferred edge for layout purposesgetFont()
Returns the font being used to render vertex labelsReturns theGraphType
that this object provides display options forReturns the label position relative to the vertex.int
Returns the maximum number of nodes that can be in a displayed graphReturns the name for the root Options name for thisGraphDisplayOptions
getVertexColor
(AttributedVertex vertex) Returns the color that will be used to draw the vertexgetVertexColor
(String vertexType) Returns the color for the given vertex typeReturns the attribute key that can be used to override the color of a vertex.getVertexLabel
(AttributedVertex vertex) Returns the text that will be displayed as the label for the given vertexReturns the attribute key that can override the vertices label textReturns the vertex selection colorgetVertexShape
(AttributedVertex vertex) Returns theVertexShape
that will be used to draw the vertex's shapegetVertexShape
(String vertexType) Returns theVertexShape
for vertices that have the given vertex typeReturns the attribute key that can be used to override the shape of a vertex.protected void
void
initializeFromOptions
(Tool tool) Loads values from tool optionsboolean
Returns true if thisGraphDisplayOptions
instance has been constructed with a tool for getting/saving option values in the tool optionsvoid
optionsChanged
(ToolOptions options, String optionName, Object oldValue, Object newValue) Notification that an option changed.protected void
registerOptions
(Tool tool, HelpLocation help) Registers this GraphTypeDisplayOptions withToolOptions
.protected void
registerOptions
(ToolOptions toolOptions, HelpLocation help) void
removeChangeListener
(ChangeListener listener) Removes the listener so that it won't be notified of changes any longervoid
setArrowLength
(int length) Sets the length of the arrow.void
setDefaultEdgeColor
(Color color) Sets the default color to be used by edges that don't have a edge type setvoid
setDefaultEdgeColor
(String themeColorId) Sets the default color to be used by vertices that don't have a vertex type set.void
setDefaultLayoutAlgorithmName
(String defaultLayout) Sets the name of the default layout algorithmvoid
setDefaultVertexColor
(Color color) Sets the default color to be used by vertices that don't have a vertex type setvoid
setDefaultVertexColor
(String themeColorId) Sets the default color to be used by vertices that don't have a vertex type set.void
setDefaultVertexShape
(VertexShape shape) Sets the default shape to be used by vertices that don't have a vertex type setvoid
setEdgeColor
(String edgeType, Color color) Sets the color for edges with the given edge typevoid
setEdgeColor
(String edgeType, String themeColorId) Sets the edge color using a theme color id.void
setEdgeColorOverrideAttributeKey
(String attributeKey) Sets the attribute key that can be used to override the color for an edge.void
setEdgeSelectionColor
(Color edgeSelectionColor) Sets the edge selection color.void
setEdgeSelectionColor
(String themeColorId) Sets the edge selection color using the theme color defined by the given color id.void
setFavoredEdgeType
(String favoredEdgeType) Sets the favored edge type.void
Sets the font to use for drawing vertex labelsvoid
void
setLabelPosition
(GraphLabelPosition labelPosition) Sets the label position relative to the vertex.void
setMaxNodeCount
(int maxNodeCount) Sets the maximum number of nodes a graph can have and still be displayed.void
setUsesIcons
(boolean b) Sets whether the graph rendering mode is to use icons or not.void
setVertexColor
(String vertexType, Color color) Sets the color for vertices with the given vertex type.void
setVertexColor
(String vertexType, String themeColorId) Sets the vertex color using a theme color id.void
setVertexColorOverrideAttributeKey
(String attributeKey) Sets the attribute key that can be used to override the color for a vertex.void
setVertexLabelOverrideAttributeKey
(String attributeKey) Sets the attribute key that can be used to override the label text shown for the vertex.void
setVertexSelectionColor
(Color vertexSelectionColor) Sets the vertex selection color.void
setVertexSelectionColor
(String themeColorId) Sets the vertex selection color using the theme color defined by the given color id.void
setVertexShape
(String vertexType, VertexShape vertexShape) Sets theVertexShape
to use for vertices with the given vertex typevoid
setVertexShapeOverrideAttributeKey
(String attributeKey) Sets the attribute key that can be used to override the shape for a vertex.boolean
Returns true if the rendering mode is to use icons for the vertices.
-
Constructor Details
-
GraphDisplayOptions
Constructs a new GraphTypeDisplayOptions for the givenGraphType
- Parameters:
graphType
- TheGraphType
for which to define display options
-
GraphDisplayOptions
Constructs a new GraphTypeDisplayOptions for the givenGraphType
and initializes from tool options. Note this form should only be used for display options onGraphType
s that have options registered in the tool.- Parameters:
graphType
- TheGraphType
for which to define display optionstool
- the tool from which to initialize fromToolOptions
help
- the help location
-
-
Method Details
-
initializeDefaults
protected void initializeDefaults() -
addChangeListener
Adds a ChangeListener to be notified when display options change- Parameters:
listener
- the listener to be notified.
-
removeChangeListener
Removes the listener so that it won't be notified of changes any longer- Parameters:
listener
- the listener to be removed
-
setDefaultVertexShape
Sets the default shape to be used by vertices that don't have a vertex type set- Parameters:
shape
- the default vertex shape
-
setDefaultVertexColor
Sets the default color to be used by vertices that don't have a vertex type set- Parameters:
color
- the default vertex shape
-
setDefaultVertexColor
Sets the default color to be used by vertices that don't have a vertex type set. The color is set via a themeColorId, which means the client defined a theme color for this.- Parameters:
themeColorId
- the theme color id to use for the default vertex color
-
setDefaultEdgeColor
Sets the default color to be used by edges that don't have a edge type set- Parameters:
color
- the default edge shape
-
setDefaultEdgeColor
Sets the default color to be used by vertices that don't have a vertex type set. The color is set via a themeColorId, which means the client defined a theme color for this.- Parameters:
themeColorId
- the theme color id to use for the default vertex 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
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
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
Returns the attribute key that can override the vertices label text- Returns:
- the attribute key that can override the vertices label text
-
setVertexColorOverrideAttributeKey
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
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
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
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
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
Returns theVertexShape
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
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
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
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
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
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
Returns theGraphType
that this object provides display options for- Returns:
- the
GraphType
that this object provides display options for
-
getVertexColor
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
Sets the color for vertices with the given vertex type. Note that this method does not allow the vertex color to be registered in tool options. SeesetVertexColor(String, String)
.- Parameters:
vertexType
- the vertex type for which to set its colorcolor
- the color to use for vertices with the given vertex type
-
setVertexColor
Sets the vertex color using a theme color id. By using a theme color id, this property is eligible to be registered as a tool option.- Parameters:
vertexType
- the vertex type for which to set its colorthemeColorId
- the theme color id of the color for this vertex type
-
setVertexShape
Sets theVertexShape
to use for vertices with the given vertex type- Parameters:
vertexType
- the vertex type for which to set its shapevertexShape
- theVertexShape
to use for vertices with the given vertex type
-
getEdgeColor
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
Sets the edge color using a theme color id. By using a theme color id, this property is eligible to be registered as a tool option.- Parameters:
edgeType
- the edge type for which to set its colorthemeColorId
- the theme color id of the color for this edge type
-
setEdgeColor
Sets the color for edges with the given edge type- Parameters:
edgeType
- the edge type for which to set its colorcolor
- the new color for edges with the given edge type
-
optionsChanged
public void optionsChanged(ToolOptions options, String optionName, Object oldValue, 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 interfaceOptionsChangeListener
- Parameters:
options
- options object containing the property that changedoptionName
- name of option that changedoldValue
- old value of the optionnewValue
- new value of the option- Throws:
OptionsVetoException
- if a change is rejected
-
getRootOptionsName
Returns the name for the root Options name for thisGraphDisplayOptions
- Returns:
- the name for the root Options name for this
GraphDisplayOptions
-
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
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
returns theVertexShape
for any vertex that has not vertex type defined- Returns:
- the
VertexShape
for any vertex that has not vertex type defined
-
getVertexShape
Returns theVertexShape
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
Returns the vertex selection color- Returns:
- the vertex selection color
-
setVertexSelectionColor
Sets the vertex selection color. Use this method only if this color does not appear in the tool options.- Parameters:
vertexSelectionColor
- the color to use for highlighting selected vertices
-
setVertexSelectionColor
Sets the vertex selection color using the theme color defined by the given color id. This method will allow the property to be registered to the tool options.- Parameters:
themeColorId
- the color id to use for highlighting vertices.
-
getEdgeSelectionColor
Returns the color for edge selections- Returns:
- the color fore edge selections
-
setEdgeSelectionColor
Sets the edge selection color. Using the method means the color will not appear in the tool options.- Parameters:
edgeSelectionColor
- color to use for highlighting selected edges
-
setEdgeSelectionColor
Sets the edge selection color using the theme color defined by the given color id. This method will allow the property to be registered to the tool options.- Parameters:
themeColorId
- the color id to use for highlighting edges.
-
getDefaultLayoutAlgorithmNameLayout
Returns the name of the default graph layout algorithm- Returns:
- the name of the default graph layout algorithms
-
setDefaultLayoutAlgorithmName
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
Returns the label position relative to the vertex. Note this is only relevant ifusesIcons()
is false- Returns:
- the label position relative to the vertex
-
setLabelPosition
Sets the label position relative to the vertex. Note this is only relevant ifusesIcons()
is false.- Parameters:
labelPosition
- theGraphLabelPosition
to use for rendering vertex labels
-
setFont
Sets the font to use for drawing vertex labels- Parameters:
font
- the font to use for drawing vertex labels
-
setFont
-
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 thisGraphDisplayOptions
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
Registers this GraphTypeDisplayOptions withToolOptions
. 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:
tool
- The tool to use to register optionshelp
- the help location to be used by theOptionsDialog
for display/editing these options
-
registerOptions
-
displayEditor
Pop up a dialog for editing these graph display options. If the options are registered with tool options, show the tool options with the appropriate graph options selected. Otherwise, show an editor for locally editing these options.- Parameters:
tool
- the toolhelp
- the help location to use if the options are edited locally
-
configureVertexType
Sets default values for vertex types. This method does not allow the vertexType color to be eligible to be registered as a tool option.- Parameters:
vertexType
- the vertex type whose default color and shape are being definedvertexShape
- the default vertex shape for the given vertex typecolor
- the default color for the given vertex type
-
configureVertexType
Sets default values for vertex types using theme color ids. This makes them eligible to be registered as tool options.- Parameters:
vertexType
- the vertex type whose default color and shape are being definedvertexShape
- the default vertex shape for the given vertex typethemeColorId
- the color id for the theme color to be used as the color.
-
configureEdgeType
Sets default values for edge types. This method does not allow the vertexType color to be eligible to be registered as a tool option.- Parameters:
edgeType
- the edge type whose default color and shape are being definedcolor
- the default color for the given edge type
-
configureEdgeType
Sets default values for edge types using theme color ids. This makes them eligible to be registered as tool options.- Parameters:
edgeType
- the edge type whose default color and shape are being definedthemeColorId
- the color id for the theme color to be used as the color.
-
initializeFromOptions
Loads values from tool options- Parameters:
tool
- the tool from which to update values.
-