Interface CyCustomGraphics2Factory<T extends CustomGraphicLayer>
-
public interface CyCustomGraphics2Factory<T extends CustomGraphicLayer>Factory to create
CyCustomGraphics2objects. CyCustomGraphics2Factory objects are registered as OSGi services and will be used by Renderers to create the actual custom graphics implementations. Note that the type parameter T of CyCustomGraphics2Factory is the type of the underlyingCustomGraphicLayernot the type of the resultingCyCustomGraphics2object this factory creates.The pattern is to register CyCustomGraphics2Factory implementations as OSGi services in your CyActivator class.
CyCustomGraphics2Factory myCustomGraphics2Factory = new MyCustomGraphics2Factory(); registerService(bundleContext, myCustomGraphics2Factory, CyCustomGraphics2Factory.class, new Properties());
Charts
Cytoscape provides some predefined custom graphics factories for creating charts. These factories can be retreived as OSGi services by using their IDs.
Bar Chart org.cytoscape.BarChartBox Chart org.cytoscape.BoxChartHeat Map Chart org.cytoscape.HeatMapChartLine Chart org.cytoscape.LineChartPie Chart org.cytoscape.PieChartRing Chart org.cytoscape.RingChartLinear Gradient org.cytoscape.LinearGradientRadial Gradient org.cytoscape.RadialGradientTo retrieve a reference to a predefined chart factory you must use an OSGi service listener. For example:
public class CustomChartListener { private static final String FACTORY_ID = "org.cytoscape.PieChart"; private CyCustomGraphics2Factory<?> factory; public void addCustomGraphicsFactory(CyCustomGraphics2Factory<?> factory, Map<Object,Object> serviceProps) { if(FACTORY_ID.equals(factory.getId())) { this.factory = factory; } } public void removeCustomGraphicsFactory(CyCustomGraphics2Factory<?> factory, Map<Object,Object> serviceProps) { this.factory = null; } public CyCustomGraphics2Factory<?> getFactory() { return factory; } }Register the listener in your CyActivator class.
CustomChartListener customChartListener = new CustomChartListener(); registerServiceListener(context, customChartListener, "addCustomGraphicsFactory", "removeCustomGraphicsFactory", CyCustomGraphics2Factory.class);
Use the factory to create an instance of CyCustomGraphics2 for your charts. The data and appearance of the charts are controlled by a Map of properties that are passed to the getInstance() method.
CyCustomGraphics2Factory<?> customGraphicsFactory = customChartListener.getFactory(); CyColumnIdentifierFactory columnIdFactory; // Get OSGi service CyColumnIdentifier columnId = columnIdFactory.createColumnIdentifier(chartColumn); Map<String,Object> chartProps = new HashMap<String,Object>(); chartProps.put("cy_dataColumns", Arrays.asList(columnId)); chartProps.put("cy_colorScheme", "CONTRASTING"); CyCustomGraphics2<?> customGraphics = customGraphicsFactory.getInstance(chartProps); // Set the custom graphics on the visual style VisualStyle visualStyle = visualMappingManager.getCurrentVisualStyle(); CyApplicationManager appManager; // Get OSGi service RenderingEngine> engine = appManager.getCurrentRenderingEngine(); VisualLexicon lexicon = engine.getVisualLexicon(); VisualProperty<CyCustomGraphics> visualProperty = lexicon.lookup(CyNode.class, "NODE_CUSTOMGRAPHICS_1"); if (visualProperty != null) visualStyle.setDefaultValue(visualProperty, customGraphics);Chart Properties
All built-in properties start with the "cy_" prefix. If you are writing an App that provides additional properties please specify your own prefix in order to prevent name collisions.All Charts
Property Name Type Description cy_dataColumnsList<CyColumnIdentifier>Names of data columns from the default node table. Columns of type List become separate groups (or data series) in the chart (for example a ring chart will have a separate ring for each group). The column type must be numerical. cy_valuesList<Double>Specific values to use for each segment of the chart. If cy_dataColumnsis specified, this property does not need to be set.cy_colorsList<java.awt.Color>List of specific colors to use with each data column (if the column contains single numbers) or value. The color list should have one entry for every corresponding entry in the cy_dataColumnsproperty list, if the list contains only columns of simple numerical types (no List types). Ifcy_dataColumnscontains List-typed columns, it must contain as many colors as elements in the list values.cy_colorSchemeStringName of a predefined color scheme. Use this property instead of cy_colorsto have the colors chosen automatically. Values: CONTRASTING, MODULATED, RAINBOW, RANDOMcy_itemLabelsList<String>Labels to use for each segment of the chart (for example each slice of a pie chart.) The label list should have one entry for every corresponding entry in the cy_dataColumnsproperty list.cy_itemLabelsColumnCyColumnIdentifierName of a data column to use for value labels. The column should be of type List, each element in the list will be used as a label. cy_showItemLabelsBooleanSet to true to show value labels cy_borderWidthFloatBorder width cy_borderColorjava.awt.ColorBorder color Bar/Box/Line/Heat Charts
Property Name Type Description cy_orientationStringValues: HORIZONTAL, VERTICAL cy_domainLabelsColumnCyColumnIdentifierName of a data column to use for domain labels. The column should be of type List. cy_rangeLabelsColumnCyColumnIdentifierName of a data column to use for range labels. The column should be of type List. cy_domainLabelPositionStringValues: STANDARD, DOWN_45, DOWN_90, UP_45, UP_90 cy_globalRangeBooleanIf true, all charts' range (min and max bounds) will be automatically set to the network-wide range. cy_rangeList<Double>Allows the global range to be set manually. Must be a list with exactly two elements. Specifies the lower (first element) and upper bound for the range axis. The property cy_rangemust be set to true.cy_showDomainAxisBooleanSet to true to show the domain axis. cy_showRangeAxisBooleanSet to true to show the range axis. cy_axisWidthFloatAxis stroke width. cy_axisColorjava.awt.ColorAxis line color. Bar Charts
Property Name Type Description cy_typeStringValues: GROUPED, STACKED, HEAT_STRIPS, UP_DOWN cy_separationDoubleSeparation between bars. Value must be between 0.0 and 0.5 Line Charts
Property Name Type Description cy_lineWidthFloatLine width Pie Charts
Property Name Type Description cy_startAngleDoubleStart angle for the first pie section. Ring Charts
Property Name Type Description cy_startAngleDoubleStart angle for the first section. cy_holeSizeDoubleWidth of the hole in the center of the ring. Gradients
Property Name Type Description cy_gradientFractionsList<Float>Numbers ranging from 0.0 to 1.0 specifying the distribution of colors along the gradient. See javadocs for java.awt.MultipleGradientPaintfor more detail.cy_gradientColorsList<java.awt.Color>List of colors corresponding to each fraction value. Linear Gradient
Property Name Type Description cy_angleDoubleSlope (rotation) of the gradient, in degrees. Radial Gradient
Property Name Type Description cy_centerjava.awt.geom.Point2DCenter of the gradient. Each coordinate must be between 0.0 and 1.0. Module:
presentation-apiTo use this in your app, include the following dependency in your POM:
<dependency> <groupId>org.cytoscape</groupId> <artifactId>presentation-api</artifactId> </dependency>
Cytoscape Backwards Compatibility (SPI Interface): We expect that this interface will be implemented. Therefore to maintain backwards compatibility this interface will only be modified for major version updates.
-
-
Field Summary
Fields Modifier and Type Field Description static StringGROUPOptional property key that tells Cytoscape under which group it should add the editor created by this factory (seecreateEditor(CyCustomGraphics2)).
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description JComponentcreateEditor(CyCustomGraphics2<T> customGraphics)Creates a UI component that configures the givenCyCustomGraphics2.StringgetDisplayName()Return theCyCustomGraphics2name which is will be displayed to the user.IcongetIcon(int width, int height)StringgetId()Return the prefix to identify this Custom Graphics factory.CyCustomGraphics2<T>getInstance(String input)Get a new instance of aCyCustomGraphics2.CyCustomGraphics2<T>getInstance(Map<String,Object> properties)Get a new instance of aCyCustomGraphics2with the passed properties.CyCustomGraphics2<T>getInstance(CyCustomGraphics2<T> customGraphics)Get a new instance of aCyCustomGraphics2that is a clone of the passed argument.Class<? extends CyCustomGraphics2<T>>getSupportedClass()
-
-
-
Field Detail
-
GROUP
static final String GROUP
Optional property key that tells Cytoscape under which group it should add the editor created by this factory (seecreateEditor(CyCustomGraphics2)).- See Also:
- Constant Field Values
-
-
Method Detail
-
getId
String getId()
Return the prefix to identify this Custom Graphics factory. This is used by the passthrough mapping logic to figure out if a given String value should be mapped to this factory.- Returns:
- the prefix for this CyCustomGraphics2Factory
-
getDisplayName
String getDisplayName()
Return theCyCustomGraphics2name which is will be displayed to the user.- Returns:
- display name as String.
-
getIcon
Icon getIcon(int width, int height)
- Parameters:
width-height-- Returns:
- an optional icon that represents a custom graphics type.
-
getInstance
CyCustomGraphics2<T> getInstance(String input)
Get a new instance of aCyCustomGraphics2. The string argument may be used by some implementations to create the initialCyCustomGraphics2objects. This is the method that will be used to take a String passthrough mapping and create the correctCyCustomGraphics2instance. Note that the prefix defined above will get removed from the string before this method is called.- Parameters:
input- a possible input string that may be used to create the instance. Not all implementations will use this.- Returns:
- the new instance
-
getInstance
CyCustomGraphics2<T> getInstance(CyCustomGraphics2<T> customGraphics)
Get a new instance of aCyCustomGraphics2that is a clone of the passed argument.- Parameters:
customGraphics- another Custom Graphics- Returns:
- the new instance
-
getInstance
CyCustomGraphics2<T> getInstance(Map<String,Object> properties)
Get a new instance of aCyCustomGraphics2with the passed properties. The properties object should contain the same keys that are returned by the correspondingCyCustomGraphics2.getProperties()implementation.- Parameters:
properties- optional properties to initialize the new custom graphics.- Returns:
- the new instance
-
getSupportedClass
Class<? extends CyCustomGraphics2<T>> getSupportedClass()
- Returns:
- the class that this factory creates. This is used by the deserialization mechanism to find the factory method that can deserialize a given string.
-
createEditor
JComponent createEditor(CyCustomGraphics2<T> customGraphics)
Creates a UI component that configures the givenCyCustomGraphics2.- Parameters:
customGraphics- theCyCustomGraphics2to be configured.- Returns:
- a UI panel that configures the given
CyCustomGraphics2or null if the factory does not want to provide a visual editor.
-
-