Package ghidra.app.util.viewer.field
Class FieldFactory
- java.lang.Object
-
- ghidra.app.util.viewer.field.FieldFactory
-
- All Implemented Interfaces:
ExtensionPoint
- Direct Known Subclasses:
AbstractVariableFieldFactory
,AddressFieldFactory
,ArrayValuesFieldFactory
,AssignedVariableFieldFactory
,BytesFieldFactory
,DummyFieldFactory
,EolCommentFieldFactory
,FieldNameFieldFactory
,FunctionCallFixupFieldFactory
,FunctionPurgeFieldFactory
,FunctionRepeatableCommentFieldFactory
,FunctionSignatureFieldFactory
,FunctionSignatureSourceFieldFactory
,FunctionTagFieldFactory
,InstructionMaskValueFieldFactory
,LabelFieldFactory
,MemoryBlockStartFieldFactory
,MnemonicFieldFactory
,OpenCloseFieldFactory
,OperandFieldFactory
,ParallelInstructionFieldFactory
,PcodeFieldFactory
,PlateFieldFactory
,PostCommentFieldFactory
,PreCommentFieldFactory
,RegisterFieldFactory
,RegisterTransitionFieldFactory
,SeparatorFieldFactory
,SpaceFieldFactory
,SpacerFieldFactory
,ThunkedFunctionFieldFactory
,XRefFieldFactory
public abstract class FieldFactory extends java.lang.Object implements ExtensionPoint
NOTE: ALL FIELDFACTORY CLASSES MUST END IN "FieldFactory". If not, the ClassSearcher will not find them. Base class for Field Factories.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.Font
baseFont
protected java.awt.Color
color
protected java.lang.String
colorOptionName
static java.awt.Font
DEFAULT_FIELD_FONT
protected Options
displayOptions
protected boolean
enabled
static java.lang.String
FONT_OPTION_NAME
protected HighlightProvider
hlProvider
protected FieldFormatModel
model
protected java.lang.String
name
protected int
startX
protected int
style
protected java.lang.String
styleOptionName
protected java.awt.Color
underlineColor
protected int
width
-
Constructor Summary
Constructors Modifier Constructor Description FieldFactory(java.lang.String name)
Constructs a FieldFactory with given name.protected
FieldFactory(java.lang.String name, FieldFormatModel model, HighlightProvider highlightProvider, Options displayOptions, Options fieldOptions)
Base constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract boolean
acceptsType(int category, java.lang.Class<?> proxyObjectClass)
Used to specify which format models this field can belong to.void
displayOptionsChanged(Options options, java.lang.String optionName, java.lang.Object oldValue, java.lang.Object newValue)
Notifications that the display options changed.void
fieldOptionsChanged(Options options, java.lang.String optionName, java.lang.Object oldValue, java.lang.Object newValue)
Notifications that the field options changed.java.awt.Color
getDefaultColor()
Returns the default field color.abstract ListingField
getField(ProxyObj<?> obj, int varWidth)
Generates a Field based on the given information.abstract FieldLocation
getFieldLocation(ListingField bf, java.math.BigInteger index, int fieldNum, ProgramLocation loc)
Return a FieldLocation that corresponds to the given index, fieldNum, and ProgramLocation IF and ONLY IF the given programLocation is the type generated by this class'sgetFieldLocation(ListingField, BigInteger, int, ProgramLocation)
.FieldFormatModel
getFieldModel()
Returns the FieldModel that this factory belongs to.java.lang.String
getFieldName()
Returns the Field name.java.lang.String
getFieldText()
Returns a description of the fields generated by this factory.java.awt.FontMetrics
getMetrics()
Returns the font metrics used by this field factoryprotected java.awt.FontMetrics
getMetrics(int fontStyle)
abstract ProgramLocation
getProgramLocation(int row, int col, ListingField bf)
Returns the Program location for the given object, row, col, and groupPathint
getStartX()
Returns the starting x position for the fields generated by this factory.int
getWidth()
Returns the width of the fields generated by this factory.protected boolean
hasSamePath(ListingField bf, ProgramLocation loc)
protected void
initDisplayOptions()
boolean
isEnabled()
Returns true if this FieldFactory is currently enabled to generate Fields.abstract FieldFactory
newInstance(FieldFormatModel formatModel, HighlightProvider highlightProvider, ToolOptions options, ToolOptions fieldOptions)
Returns a new instance of this FieldFactory that can be used to generate fields instead of being used as a prototype.void
optionsChanged(Options options, java.lang.String optionName, java.lang.Object oldValue, java.lang.Object newValue)
Notification that the Options have changed.void
servicesChanged()
Notification the services changed.void
setEnabled(boolean state)
Turns on or off the generating of Fields by this FieldFactory.void
setStartX(int x)
Sets the starting x position for the fields generated by this factory.void
setWidth(int w)
Sets the width of the fields generated by this factory.
-
-
-
Field Detail
-
FONT_OPTION_NAME
public static final java.lang.String FONT_OPTION_NAME
- See Also:
- Constant Field Values
-
DEFAULT_FIELD_FONT
public static final java.awt.Font DEFAULT_FIELD_FONT
-
model
protected FieldFormatModel model
-
name
protected java.lang.String name
-
startX
protected int startX
-
width
protected int width
-
color
protected java.awt.Color color
-
underlineColor
protected java.awt.Color underlineColor
-
baseFont
protected java.awt.Font baseFont
-
style
protected int style
-
enabled
protected boolean enabled
-
hlProvider
protected HighlightProvider hlProvider
-
colorOptionName
protected java.lang.String colorOptionName
-
styleOptionName
protected java.lang.String styleOptionName
-
displayOptions
protected Options displayOptions
-
-
Constructor Detail
-
FieldFactory
protected FieldFactory(java.lang.String name, FieldFormatModel model, HighlightProvider highlightProvider, Options displayOptions, Options fieldOptions)
Base constructor- Parameters:
name
- the name of the fieldmodel
- the model that the field belongs to.highlightProvider
- the HightLightStringProvider.displayOptions
- the Options for display properties.fieldOptions
- the Options for field specific properties.
-
FieldFactory
public FieldFactory(java.lang.String name)
Constructs a FieldFactory with given name. Used only as potential field.- Parameters:
name
- the name of the field.
-
-
Method Detail
-
initDisplayOptions
protected void initDisplayOptions()
-
optionsChanged
public void optionsChanged(Options options, java.lang.String optionName, java.lang.Object oldValue, java.lang.Object newValue)
Notification that the Options have changed.- Parameters:
options
- the Options object that changed. Will be either the display options or the field options.optionName
- the name of the property that changed.oldValue
- the old value of the property.newValue
- the new value of the property.
-
servicesChanged
public void servicesChanged()
Notification the services changed. Subclasses should override this method if they care about service changes.
-
newInstance
public abstract FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider highlightProvider, ToolOptions options, ToolOptions fieldOptions)
Returns a new instance of this FieldFactory that can be used to generate fields instead of being used as a prototype.- Parameters:
formatModel
- the model that the field belongs to.highlightProvider
- the HightLightProvider.options
- the Options for display properties.fieldOptions
- the Options for field specific properties.
-
displayOptionsChanged
public void displayOptionsChanged(Options options, java.lang.String optionName, java.lang.Object oldValue, java.lang.Object newValue)
Notifications that the display options changed.- Parameters:
options
- the Display Options object that changed.optionName
- the name of the property that changed.oldValue
- the old value of the property.newValue
- the new value of the property.
-
fieldOptionsChanged
public void fieldOptionsChanged(Options options, java.lang.String optionName, java.lang.Object oldValue, java.lang.Object newValue)
Notifications that the field options changed.- Parameters:
options
- the Field Options object that changed.optionName
- the name of the property that changed.oldValue
- the old value of the property.newValue
- the new value of the property.
-
getFieldName
public java.lang.String getFieldName()
Returns the Field name.
-
getDefaultColor
public java.awt.Color getDefaultColor()
Returns the default field color.
-
getStartX
public int getStartX()
Returns the starting x position for the fields generated by this factory.
-
setStartX
public void setStartX(int x)
Sets the starting x position for the fields generated by this factory.
-
getWidth
public int getWidth()
Returns the width of the fields generated by this factory.
-
setWidth
public void setWidth(int w)
Sets the width of the fields generated by this factory.
-
getFieldModel
public FieldFormatModel getFieldModel()
Returns the FieldModel that this factory belongs to.
-
isEnabled
public boolean isEnabled()
Returns true if this FieldFactory is currently enabled to generate Fields.
-
setEnabled
public void setEnabled(boolean state)
Turns on or off the generating of Fields by this FieldFactory.- Parameters:
state
- if true, this factory will generate fields.
-
getField
public abstract ListingField getField(ProxyObj<?> obj, int varWidth)
Generates a Field based on the given information.- Parameters:
obj
- The object that the generated field will report some information about.varWidth
- the additional distance along the x axis to place the generated field.- Returns:
- the newly generated FactoryField that shows some property or information about the given object.
-
getFieldLocation
public abstract FieldLocation getFieldLocation(ListingField bf, java.math.BigInteger index, int fieldNum, ProgramLocation loc)
Return a FieldLocation that corresponds to the given index, fieldNum, and ProgramLocation IF and ONLY IF the given programLocation is the type generated by this class'sgetFieldLocation(ListingField, BigInteger, int, ProgramLocation)
. Each FieldFactory should generate and process a unique ProgramLocation class.- Parameters:
bf
- the ListingField at the current cursor.index
- the line index (corresponds to an address)fieldNum
- the index of field within the layout to try and get a FieldLocation.loc
- the ProgramLocation to be converted into a FieldLocation.
-
getProgramLocation
public abstract ProgramLocation getProgramLocation(int row, int col, ListingField bf)
Returns the Program location for the given object, row, col, and groupPath- Parameters:
row
- the row within this fieldcol
- the col on the given row within this field.bf
- the ListingField containing the cursor.
-
acceptsType
public abstract boolean acceptsType(int category, java.lang.Class<?> proxyObjectClass)
Used to specify which format models this field can belong to.- Parameters:
category
- the category for this fieldproxyObjectClass
- the type of proxy object used by this field- Returns:
- true if this class accepts the given category.
-
hasSamePath
protected boolean hasSamePath(ListingField bf, ProgramLocation loc)
-
getFieldText
public java.lang.String getFieldText()
Returns a description of the fields generated by this factory.
-
getMetrics
public java.awt.FontMetrics getMetrics()
Returns the font metrics used by this field factory
-
getMetrics
protected java.awt.FontMetrics getMetrics(int fontStyle)
- Returns:
- Returns the metrics.
-
-