Package org.gephi.preview.api
Class PreviewProperty
- java.lang.Object
-
- org.gephi.preview.api.PreviewProperty
-
public class PreviewProperty extends Object
Define a (key, value) pair property attached to aPreviewPropertiesinstance.Preview properties are created by renderers to let users configure how items should be rendered. Each property should have a unique name and a type. Users should use the static
createProperty()methods to create instances.Static default property names are defined in this class to help renderers to reuse external properties and have cleaner code.
Properties can be grouped by categories, which default are
PreviewProperty.CATEGORY_NODES,PreviewProperty.CATEGORY_EDGES,PreviewProperty.CATEGORY_NODE_LABELS,PreviewProperty.CATEGORY_EDGE_LABELSandPreviewProperty.CATEGORY_EDGE_ARROWS.- Author:
- Mathieu Bastian
- See Also:
Renderer.getProperties()
-
-
Field Summary
Fields Modifier and Type Field Description static StringARROW_SIZEArrowFloatproperty defining the arrow size.static StringBACKGROUND_COLORGeneralColorproperty of the background colorstatic StringCATEGORY_EDGE_ARROWSEdge arrow categorystatic StringCATEGORY_EDGE_LABELSEdge Label categorystatic StringCATEGORY_EDGESEdge categorystatic StringCATEGORY_NODE_LABELSNode Label categorystatic StringCATEGORY_NODESNode categorystatic StringDIRECTEDGeneralBooleanproperty which indicates wheter the graph is directedstatic StringEDGE_COLOREdgeEdgeColorproperty defining the edge color.static StringEDGE_CURVEDEdgeBooleanproperty whether to draw curved edges.static StringEDGE_LABEL_COLOREdge LabelDependantOriginalColorproperty defining the color label.static StringEDGE_LABEL_FONTEdge LabelFontproperty defining edge label's font.static StringEDGE_LABEL_MAX_CHAREdge LabelIntegerproperty defining the maximum number of characters.static StringEDGE_LABEL_OUTLINE_COLOREdge Label OutlineDependantColorproperty defining the outline color.static StringEDGE_LABEL_OUTLINE_OPACITYEdge Label OutlineFloatproperty between 0-100 which defines the opacity.static StringEDGE_LABEL_OUTLINE_SIZEEdge Label OutlineFloatproperty defining the outline size.static StringEDGE_LABEL_SHORTENEdge LabelBooleanproperty defining whether the label is shortened.static StringEDGE_OPACITYEdgeFloatproperty between 0-100 which defines the opacity.static StringEDGE_RADIUSEdgeFloatproperty defining an extra distance between the node and the edge.static StringEDGE_RESCALE_WEIGHTEdgeBooleanproperty defining whether edge's weight should be rescaled between fixed bounds.static StringEDGE_RESCALE_WEIGHT_MAXEdgefloatproperty defining the minimum weight when edge weight rescaling is enabled.static StringEDGE_RESCALE_WEIGHT_MINEdgefloatproperty defining the minimum weight when edge weight rescaling is enabled.static StringEDGE_THICKNESSEdgeFloatproperty for the edge's thicknessstatic StringMARGINGeneralFloatproperty in percentage (0-100) describing the margin size.static StringMOVINGGeneralBooleanproperty set astruewhen the user is panning the canvas.static StringNODE_BORDER_COLORNodeDependantColorproperty which defines the border color.static StringNODE_BORDER_FIXEDNodeBooleanproperty which indicates if the border size is either fixed or relative to the node sizestatic StringNODE_BORDER_WIDTHNodeFloatproperty defining the node border size.static StringNODE_LABEL_BOX_COLORstatic StringNODE_LABEL_BOX_OPACITYstatic StringNODE_LABEL_COLORNode LabelDependantOriginalColorproperty defining the color label.static StringNODE_LABEL_FONTNode LabelFontproperty defining node label's font.static StringNODE_LABEL_MAX_CHARNode LabelIntegerproperty defining the maximum number of characters.static StringNODE_LABEL_OUTLINE_COLORNode Label OutlineDependantColorproperty defining the outline color.static StringNODE_LABEL_OUTLINE_OPACITYNode Label OutlineFloatproperty between 0-100 which defines the opacity.static StringNODE_LABEL_OUTLINE_SIZENode Label OutlineFloatproperty defining the outline size.static StringNODE_LABEL_PROPORTIONAL_SIZENode LabelBooleanproperty defining whether to use node's size in label size calculation.static StringNODE_LABEL_SHORTENNode LabelBooleanproperty defining whether the label is shortened.static StringNODE_LABEL_SHOW_BOXstatic StringNODE_OPACITYNodeFloatproperty between 0-100 which defines the opacity.static StringNODE_PER_NODE_OPACITYNodeBooleanproperty indicating whether or not to use the opacity value defined as part of the Node color.static StringSHOW_EDGE_LABELSEdge LabelBooleanproperty defining whether to show edge labels.static StringSHOW_EDGESEdgeBooleanproperty defining whether to show edges.static StringSHOW_NODE_LABELSNode LabelBooleanproperty defining whether to show node labels.static StringVISIBILITY_RATIOGeneralFloatproperty which indicates the ratio of the visible graph used in preview.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PreviewPropertycreateProperty(Object source, String name)Create a new preview property.static PreviewPropertycreateProperty(Object source, String name, Class type)Create a new preview property.static PreviewPropertycreateProperty(Object source, String name, Class type, String displayName, String description, String category)Create a new preview property.static PreviewPropertycreateProperty(Object source, String name, Class type, String displayName, String description, String category, String... dependantProperties)Create a new preview property.StringgetCategory()Returns the category of this property ornullif not set.StringgetDescription()Returns the description of this property ornullif not set.StringgetDisplayName()Returns the display name of this property ornullif not set.StringgetName()Returns the (unique) name of this property.ObjectgetSource()Returns the source object of this property.ClassgetType()Returns the type of this property.<T> TgetValue()Returns the property value.PreviewPropertysetValue(Object value)Sets this property value and return it.
-
-
-
Field Detail
-
DIRECTED
public static final String DIRECTED
GeneralBooleanproperty which indicates wheter the graph is directed- See Also:
- Constant Field Values
-
BACKGROUND_COLOR
public static final String BACKGROUND_COLOR
GeneralColorproperty of the background color- See Also:
- Constant Field Values
-
VISIBILITY_RATIO
public static final String VISIBILITY_RATIO
GeneralFloatproperty which indicates the ratio of the visible graph used in preview. For instance if 0.5 only 50% of nodes items are built.- See Also:
- Constant Field Values
-
MARGIN
public static final String MARGIN
GeneralFloatproperty in percentage (0-100) describing the margin size. For instance if the value is 4 the size of the margin is 4% of the total graph width.- See Also:
- Constant Field Values
-
NODE_BORDER_FIXED
public static final String NODE_BORDER_FIXED
NodeBooleanproperty which indicates if the border size is either fixed or relative to the node size- See Also:
- Constant Field Values
-
NODE_BORDER_WIDTH
public static final String NODE_BORDER_WIDTH
NodeFloatproperty defining the node border size.- See Also:
- Constant Field Values
-
NODE_BORDER_COLOR
public static final String NODE_BORDER_COLOR
NodeDependantColorproperty which defines the border color. A dependant color value is either the node's color or a custom color.- See Also:
- Constant Field Values
-
NODE_OPACITY
public static final String NODE_OPACITY
NodeFloatproperty between 0-100 which defines the opacity. 100 means opaque.- See Also:
- Constant Field Values
-
NODE_PER_NODE_OPACITY
public static final String NODE_PER_NODE_OPACITY
NodeBooleanproperty indicating whether or not to use the opacity value defined as part of the Node color. If true, NODE_OPACITY will be ignored.- See Also:
- Constant Field Values
-
SHOW_EDGES
public static final String SHOW_EDGES
EdgeBooleanproperty defining whether to show edges.- See Also:
- Constant Field Values
-
EDGE_THICKNESS
public static final String EDGE_THICKNESS
EdgeFloatproperty for the edge's thickness- See Also:
- Constant Field Values
-
EDGE_CURVED
public static final String EDGE_CURVED
EdgeBooleanproperty whether to draw curved edges. Afalsevalue means straight edges.- See Also:
- Constant Field Values
-
EDGE_COLOR
public static final String EDGE_COLOR
EdgeEdgeColorproperty defining the edge color. It could be the source's color, the target's color, a mixed color, the edge's original color or a custom color.- See Also:
- Constant Field Values
-
EDGE_OPACITY
public static final String EDGE_OPACITY
EdgeFloatproperty between 0-100 which defines the opacity. 100 means opaque.- See Also:
- Constant Field Values
-
EDGE_RESCALE_WEIGHT
public static final String EDGE_RESCALE_WEIGHT
EdgeBooleanproperty defining whether edge's weight should be rescaled between fixed bounds.- See Also:
- Constant Field Values
-
EDGE_RESCALE_WEIGHT_MIN
public static final String EDGE_RESCALE_WEIGHT_MIN
Edgefloatproperty defining the minimum weight when edge weight rescaling is enabled.- See Also:
- Constant Field Values
-
EDGE_RESCALE_WEIGHT_MAX
public static final String EDGE_RESCALE_WEIGHT_MAX
Edgefloatproperty defining the minimum weight when edge weight rescaling is enabled.- See Also:
- Constant Field Values
-
EDGE_RADIUS
public static final String EDGE_RADIUS
EdgeFloatproperty defining an extra distance between the node and the edge.- See Also:
- Constant Field Values
-
ARROW_SIZE
public static final String ARROW_SIZE
ArrowFloatproperty defining the arrow size.- See Also:
- Constant Field Values
-
SHOW_NODE_LABELS
public static final String SHOW_NODE_LABELS
Node LabelBooleanproperty defining whether to show node labels.- See Also:
- Constant Field Values
-
NODE_LABEL_FONT
public static final String NODE_LABEL_FONT
Node LabelFontproperty defining node label's font.- See Also:
- Constant Field Values
-
NODE_LABEL_PROPORTIONAL_SIZE
public static final String NODE_LABEL_PROPORTIONAL_SIZE
Node LabelBooleanproperty defining whether to use node's size in label size calculation.- See Also:
- Constant Field Values
-
NODE_LABEL_COLOR
public static final String NODE_LABEL_COLOR
Node LabelDependantOriginalColorproperty defining the color label. The color could either be the node's color, the label original color if it has any or a custom color.- See Also:
- Constant Field Values
-
NODE_LABEL_SHORTEN
public static final String NODE_LABEL_SHORTEN
Node LabelBooleanproperty defining whether the label is shortened.- See Also:
- Constant Field Values
-
NODE_LABEL_MAX_CHAR
public static final String NODE_LABEL_MAX_CHAR
Node LabelIntegerproperty defining the maximum number of characters.- See Also:
- Constant Field Values
-
NODE_LABEL_OUTLINE_SIZE
public static final String NODE_LABEL_OUTLINE_SIZE
Node Label OutlineFloatproperty defining the outline size.- See Also:
- Constant Field Values
-
NODE_LABEL_OUTLINE_OPACITY
public static final String NODE_LABEL_OUTLINE_OPACITY
Node Label OutlineFloatproperty between 0-100 which defines the opacity. 100 means opaque.- See Also:
- Constant Field Values
-
NODE_LABEL_OUTLINE_COLOR
public static final String NODE_LABEL_OUTLINE_COLOR
Node Label OutlineDependantColorproperty defining the outline color. The color can be the node's color or a custom color.- See Also:
- Constant Field Values
-
NODE_LABEL_SHOW_BOX
public static final String NODE_LABEL_SHOW_BOX
- See Also:
- Constant Field Values
-
NODE_LABEL_BOX_COLOR
public static final String NODE_LABEL_BOX_COLOR
- See Also:
- Constant Field Values
-
NODE_LABEL_BOX_OPACITY
public static final String NODE_LABEL_BOX_OPACITY
- See Also:
- Constant Field Values
-
SHOW_EDGE_LABELS
public static final String SHOW_EDGE_LABELS
Edge LabelBooleanproperty defining whether to show edge labels.- See Also:
- Constant Field Values
-
EDGE_LABEL_FONT
public static final String EDGE_LABEL_FONT
Edge LabelFontproperty defining edge label's font.- See Also:
- Constant Field Values
-
EDGE_LABEL_COLOR
public static final String EDGE_LABEL_COLOR
Edge LabelDependantOriginalColorproperty defining the color label. The color could either be the edge's color, the label original color if it has any or a custom color.- See Also:
- Constant Field Values
-
EDGE_LABEL_SHORTEN
public static final String EDGE_LABEL_SHORTEN
Edge LabelBooleanproperty defining whether the label is shortened.- See Also:
- Constant Field Values
-
EDGE_LABEL_MAX_CHAR
public static final String EDGE_LABEL_MAX_CHAR
Edge LabelIntegerproperty defining the maximum number of characters.- See Also:
- Constant Field Values
-
EDGE_LABEL_OUTLINE_SIZE
public static final String EDGE_LABEL_OUTLINE_SIZE
Edge Label OutlineFloatproperty defining the outline size.- See Also:
- Constant Field Values
-
EDGE_LABEL_OUTLINE_OPACITY
public static final String EDGE_LABEL_OUTLINE_OPACITY
Edge Label OutlineFloatproperty between 0-100 which defines the opacity. 100 means opaque.- See Also:
- Constant Field Values
-
EDGE_LABEL_OUTLINE_COLOR
public static final String EDGE_LABEL_OUTLINE_COLOR
Edge Label OutlineDependantColorproperty defining the outline color. The color can be the edge's color or a custom color.- See Also:
- Constant Field Values
-
MOVING
public static final String MOVING
GeneralBooleanproperty set astruewhen the user is panning the canvas. Helps to conditionally hide elements while moving to speed things up.- See Also:
- Constant Field Values
-
CATEGORY_NODES
public static final String CATEGORY_NODES
Node category
-
CATEGORY_EDGES
public static final String CATEGORY_EDGES
Edge category
-
CATEGORY_NODE_LABELS
public static final String CATEGORY_NODE_LABELS
Node Label category
-
CATEGORY_EDGE_LABELS
public static final String CATEGORY_EDGE_LABELS
Edge Label category
-
CATEGORY_EDGE_ARROWS
public static final String CATEGORY_EDGE_ARROWS
Edge arrow category
-
-
Method Detail
-
createProperty
public static PreviewProperty createProperty(Object source, String name)
Create a new preview property. Thenameshould be unique.- Parameters:
source- the property source, for instance the renderername- the property's name- Returns:
- a new preview property
-
createProperty
public static PreviewProperty createProperty(Object source, String name, Class type)
Create a new preview property. Thenameshould be unique. If the type is different from basic types (Integer, Float, Double, String, Boolean or Color) make sure to implement aPropertyEditorand register it:PropertyEditorManager.registerEditor(MyType.class, MyTypePropertyEditor.class);
- Parameters:
source- the property source, for instance the renderername- the property's nametype- the property's value type- Returns:
- a new preview property
-
createProperty
public static PreviewProperty createProperty(Object source, String name, Class type, String displayName, String description, String category)
Create a new preview property. Thenameshould be unique. If the type is different from basic types (Integer, Float, Double, String, Boolean or Color) make sure to implement aPropertyEditorand register it:PropertyEditorManager.registerEditor(MyType.class, MyTypePropertyEditor.class);
The category can be one of the default categories:- PreviewProperty.CATEGORY_NODES
- PreviewProperty.CATEGORY_EDGES
- PreviewProperty.CATEGORY_NODE_LABELS
- PreviewProperty.CATEGORY_EDGE_LABELS
- PreviewProperty.CATEGORY_EDGE_ARROWS
- Parameters:
source- the property source, for instance the renderername- the property's nametype- the property's value typedisplayName- the property's display namedescription- the property's descriptioncategory- the property's category- Returns:
- a new preview property
-
createProperty
public static PreviewProperty createProperty(Object source, String name, Class type, String displayName, String description, String category, String... dependantProperties)
Create a new preview property. Thenameshould be unique. If the type is different from basic types (Integer, Float, Double, String, Boolean or Color) make sure to implement aPropertyEditorand register it:PropertyEditorManager.registerEditor(MyType.class, MyTypePropertyEditor.class);
The category can be one of the default categories:- PreviewProperty.CATEGORY_NODES
- PreviewProperty.CATEGORY_EDGES
- PreviewProperty.CATEGORY_NODE_LABELS
- PreviewProperty.CATEGORY_EDGE_LABELS
- PreviewProperty.CATEGORY_EDGE_ARROWS
dependantPropertieslist is used to automatically disable the property if the dependant property is not selected. The dependant properties need to beBooleantype.- Parameters:
source- the property source, for instance the renderername- the property's nametype- the property's value typedisplayName- the property's display namedescription- the property's descriptioncategory- the property's categorydependantProperties- a list of boolean properties this property depend on- Returns:
- a new preview property
-
getValue
public <T> T getValue()
Returns the property value.- Type Parameters:
T- the return type- Returns:
- the property value or
null
-
setValue
public PreviewProperty setValue(Object value)
Sets this property value and return it. The value can benull.- Parameters:
value- the value to be set- Returns:
- this property instance
-
getName
public String getName()
Returns the (unique) name of this property.- Returns:
- the property's name
-
getType
public Class getType()
Returns the type of this property.- Returns:
- this property's type
-
getDisplayName
public String getDisplayName()
Returns the display name of this property ornullif not set.- Returns:
- this property's display name or
null
-
getDescription
public String getDescription()
Returns the description of this property ornullif not set.- Returns:
- this property's description or
null
-
getSource
public Object getSource()
Returns the source object of this property.- Returns:
- this property's source object
-
getCategory
public String getCategory()
Returns the category of this property ornullif not set.- Returns:
- this property's category or
null
-
-