1
1
package org .baderlab .csplugins .enrichmentmap .style ;
2
2
3
- import static org .cytoscape .view .presentation .property .BasicVisualLexicon .EDGE_LABEL_TRANSPARENCY ;
4
- import static org .cytoscape .view .presentation .property .BasicVisualLexicon .EDGE_LINE_TYPE ;
5
- import static org .cytoscape .view .presentation .property .BasicVisualLexicon .EDGE_STROKE_UNSELECTED_PAINT ;
6
- import static org .cytoscape .view .presentation .property .BasicVisualLexicon .EDGE_TRANSPARENCY ;
7
- import static org .cytoscape .view .presentation .property .BasicVisualLexicon .EDGE_UNSELECTED_PAINT ;
8
- import static org .cytoscape .view .presentation .property .BasicVisualLexicon .EDGE_WIDTH ;
9
- import static org .cytoscape .view .presentation .property .BasicVisualLexicon .NETWORK_BACKGROUND_PAINT ;
10
- import static org .cytoscape .view .presentation .property .BasicVisualLexicon .NODE_BORDER_PAINT ;
11
- import static org .cytoscape .view .presentation .property .BasicVisualLexicon .NODE_BORDER_TRANSPARENCY ;
12
- import static org .cytoscape .view .presentation .property .BasicVisualLexicon .NODE_BORDER_WIDTH ;
13
- import static org .cytoscape .view .presentation .property .BasicVisualLexicon .NODE_FILL_COLOR ;
14
- import static org .cytoscape .view .presentation .property .BasicVisualLexicon .NODE_LABEL ;
15
- import static org .cytoscape .view .presentation .property .BasicVisualLexicon .NODE_LABEL_TRANSPARENCY ;
16
- import static org .cytoscape .view .presentation .property .BasicVisualLexicon .NODE_SHAPE ;
17
- import static org .cytoscape .view .presentation .property .BasicVisualLexicon .NODE_SIZE ;
18
- import static org .cytoscape .view .presentation .property .BasicVisualLexicon .NODE_TOOLTIP ;
19
- import static org .cytoscape .view .presentation .property .BasicVisualLexicon .NODE_TRANSPARENCY ;
3
+ import static org .cytoscape .view .presentation .property .BasicVisualLexicon .*;
20
4
import static org .cytoscape .view .presentation .property .NodeShapeVisualProperty .DIAMOND ;
21
5
import static org .cytoscape .view .presentation .property .NodeShapeVisualProperty .ELLIPSE ;
22
6
import static org .cytoscape .view .presentation .property .NodeShapeVisualProperty .RECTANGLE ;
@@ -272,6 +256,20 @@ private void setEdgePaint(VisualStyle vs, EMStyleOptions options) {
272
256
vs .addVisualMappingFunction (edgeStrokePaint );
273
257
}
274
258
259
+
260
+ public static Color [] getColorPalette (int datasetCount ) {
261
+ final ColorBrewer colorBrewer ;
262
+ // Try colorblind and/or print friendly colours first
263
+ if (datasetCount <= 4 ) // Try a colorblind safe color scheme first
264
+ colorBrewer = ColorBrewer .Paired ; // http://colorbrewer2.org/#type=qualitative&scheme=Paired&n=4
265
+ else if (datasetCount <= 5 ) // Same--more than 5, it adds a RED that can be confused with the edge selection color
266
+ colorBrewer = ColorBrewer .Paired ; // http://colorbrewer2.org/#type=qualitative&scheme=Paired&n=5
267
+ else
268
+ colorBrewer = ColorBrewer .Set3 ; // http://colorbrewer2.org/#type=qualitative&scheme=Set3&n=12
269
+
270
+ return colorBrewer .getColorPalette (datasetCount );
271
+ }
272
+
275
273
private DiscreteMapping <String , Paint > createEdgeColorMapping (EMStyleOptions options , VisualProperty <Paint > vp ) {
276
274
int dataSetCount = options .getEnrichmentMap ().getDataSetCount ();
277
275
boolean distinctEdges = options .getEnrichmentMap ().getParams ().getCreateDistinctEdges ();
@@ -292,17 +290,7 @@ private DiscreteMapping<String, Paint> createEdgeColorMapping(EMStyleOptions opt
292
290
List <EMDataSet > dataSets = options .getEnrichmentMap ().getDataSetList ();
293
291
294
292
// if (dataSetCount > 1 && distinctEdges) {
295
- final ColorBrewer colorBrewer ;
296
-
297
- // Try colorblind and/or print friendly colours first
298
- if (dataSets .size () <= 4 ) // Try a colorblind safe color scheme first
299
- colorBrewer = ColorBrewer .Paired ; // http://colorbrewer2.org/#type=qualitative&scheme=Paired&n=4
300
- else if (dataSets .size () <= 5 ) // Same--more than 5, it adds a RED that can be confused with the edge selection color
301
- colorBrewer = ColorBrewer .Paired ; // http://colorbrewer2.org/#type=qualitative&scheme=Paired&n=5
302
- else
303
- colorBrewer = ColorBrewer .Set3 ; // http://colorbrewer2.org/#type=qualitative&scheme=Set3&n=12
304
-
305
- Color [] colors = colorBrewer .getColorPalette (dataSets .size ());
293
+ Color [] colors = getColorPalette (dataSets .size ());
306
294
307
295
// Do not use the filtered data sets here, because we don't want edge colours changing when filtering
308
296
for (int i = 0 ; i < dataSets .size (); i ++) {
0 commit comments