public interface CyCustomGraphics2Factory<T extends CustomGraphicLayer>
Factory to create CyCustomGraphics2
objects.
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 underlying CustomGraphicLayer
not the type
of the resulting CyCustomGraphics2
object 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());
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.BarChart |
Box Chart | org.cytoscape.BoxChart |
Heat Map Chart | org.cytoscape.HeatMapChart |
Line Chart | org.cytoscape.LineChart |
Pie Chart | org.cytoscape.PieChart |
Ring Chart | org.cytoscape.RingChart |
Linear Gradient | org.cytoscape.LinearGradient |
Radial Gradient | org.cytoscape.RadialGradient |
To 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);
Property Name | Type | Description |
---|---|---|
cy_dataColumns | List<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_values | List<Double> | Specific values to use for each segment of the chart. If cy_dataColumns is specified, this property does not need to be set. |
cy_colors | List<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_dataColumns property list, if the list contains only columns of simple numerical types (no List types). If cy_dataColumns contains List-typed columns, it must contain as many colors as elements in the list values. |
cy_colorScheme | String | Name of a predefined color scheme. Use this property instead of cy_colors to have the colors chosen automatically. Values: CONTRASTING, MODULATED, RAINBOW, RANDOM |
cy_itemLabels | List<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_dataColumns property list. |
cy_itemLabelsColumn | CyColumnIdentifier | Name 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_showItemLabels | Boolean | Set to true to show value labels |
cy_borderWidth | Float | Border width |
cy_borderColor | java.awt.Color | Border color |
Property Name | Type | Description |
---|---|---|
cy_orientation | String | Values: HORIZONTAL, VERTICAL |
cy_domainLabelsColumn | CyColumnIdentifier | Name of a data column to use for domain labels. The column should be of type List. |
cy_rangeLabelsColumn | CyColumnIdentifier | Name of a data column to use for range labels. The column should be of type List. |
cy_domainLabelPosition | String | Values: STANDARD, DOWN_45, DOWN_90, UP_45, UP_90 |
cy_globalRange | Boolean | If true, all charts' range (min and max bounds) will be automatically set to the network-wide range. |
cy_range | List<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_range must be set to true. |
cy_showDomainAxis | Boolean | Set to true to show the domain axis. |
cy_showRangeAxis | Boolean | Set to true to show the range axis. |
cy_axisWidth | Float | Axis stroke width. |
cy_axisColor | java.awt.Color | Axis line color. |
Property Name | Type | Description |
---|---|---|
cy_type | String | Values: GROUPED, STACKED, HEAT_STRIPS, UP_DOWN |
cy_separation | Double | Separation between bars. Value must be between 0.0 and 0.5 |
Property Name | Type | Description |
---|---|---|
cy_lineWidth | Float | Line width |
Property Name | Type | Description |
---|---|---|
cy_startAngle | Double | Start angle for the first pie section. |
Property Name | Type | Description |
---|---|---|
cy_startAngle | Double | Start angle for the first section. |
cy_holeSize | Double | Width of the hole in the center of the ring. |
Property Name | Type | Description |
---|---|---|
cy_gradientFractions | List<Float> | Numbers ranging from 0.0 to 1.0 specifying the distribution of colors along the gradient. See javadocs for java.awt.MultipleGradientPaint for more detail. |
cy_gradientColors | List<java.awt.Color> | List of colors corresponding to each fraction value. |
Property Name | Type | Description |
---|---|---|
cy_angle | Double | Slope (rotation) of the gradient, in degrees. |
Property Name | Type | Description |
---|---|---|
cy_center | java.awt.geom.Point2D | Center of the gradient. Each coordinate must be between 0.0 and 1.0. |
Module: presentation-api
To use this in your app, include the following dependency in your POM:
<dependency> <groupId>org.cytoscape</groupId> <artifactId>presentation-api</artifactId> </dependency>
Modifier and Type | Field and Description |
---|---|
static String |
GROUP
Optional property key that tells Cytoscape under which group it
should add the editor created by this factory (see
createEditor(CyCustomGraphics2) ). |
Modifier and Type | Method and Description |
---|---|
JComponent |
createEditor(CyCustomGraphics2<T> customGraphics)
Creates a UI component that configures the given
CyCustomGraphics2 . |
String |
getDisplayName()
Return the
CyCustomGraphics2 name which is will be displayed to the user. |
Icon |
getIcon(int width,
int height) |
String |
getId()
Return the prefix to identify this Custom Graphics factory.
|
CyCustomGraphics2<T> |
getInstance(CyCustomGraphics2<T> customGraphics)
Get a new instance of a
CyCustomGraphics2 that is a clone of the passed argument. |
CyCustomGraphics2<T> |
getInstance(Map<String,Object> properties)
Get a new instance of a
CyCustomGraphics2 with the passed properties. |
CyCustomGraphics2<T> |
getInstance(String input)
Get a new instance of a
CyCustomGraphics2 . |
Class<? extends CyCustomGraphics2<T>> |
getSupportedClass() |
static final String GROUP
createEditor(CyCustomGraphics2)
).String getId()
String getDisplayName()
CyCustomGraphics2
name which is will be displayed to the user.Icon getIcon(int width, int height)
width
- height
- CyCustomGraphics2<T> getInstance(String input)
CyCustomGraphics2
. The string argument may
be used by some implementations to create the initial CyCustomGraphics2
objects.
This is the method that will be used to take a String passthrough mapping and create the
correct CyCustomGraphics2
instance. Note that the prefix defined
above will get removed from the string before this method is called.input
- a possible input string that may be used to create the
instance. Not all implementations will use this.CyCustomGraphics2<T> getInstance(CyCustomGraphics2<T> customGraphics)
CyCustomGraphics2
that is a clone of the passed argument.customGraphics
- another Custom GraphicsCyCustomGraphics2<T> getInstance(Map<String,Object> properties)
CyCustomGraphics2
with the passed properties.
The properties object should contain the same keys that are returned by the corresponding
CyCustomGraphics2.getProperties()
implementation.properties
- optional properties to initialize the new custom graphics.Class<? extends CyCustomGraphics2<T>> getSupportedClass()
JComponent createEditor(CyCustomGraphics2<T> customGraphics)
CyCustomGraphics2
.customGraphics
- the CyCustomGraphics2
to be configured.CyCustomGraphics2
or null if the factory does not want to provide a visual editor.Copyright 2011-2015 Cytoscape Consortium. All rights reserved.