Author: scooter
Date: 2011-11-21 17:01:40 -0800 (Mon, 21 Nov 2011)
New Revision: 27547
Modified:
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/command/ValueUtils.java
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/view/PieChart.java
Log:
Attempt to tweak contrasting colors a little. Algorithm still doesn't work well
when we have exactly 4 colors...
Modified:
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/command/ValueUtils.java
===================================================================
---
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/command/ValueUtils.java
2011-11-22 00:59:13 UTC (rev 27546)
+++
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/command/ValueUtils.java
2011-11-22 01:01:40 UTC (rev 27547)
@@ -483,16 +483,18 @@
// This is like rainbow, but we alternate sides of the color wheel
private static List<Color> generateContrastingColors(int nColors) {
- // System.out.println("Generating contrasting colors");
+ System.out.println("Generating contrasting colors");
List<Color> values = new ArrayList<Color>();
- float divs = ((float)nColors)/2.0f;
+ float divs = (float)nColors+((float)nColors)*0.2f; // Add
fuzz to avoid cycles
for (float i = 0.0f; i < (float)nColors; i += 1.0f) {
- //
System.out.println("Color("+(i/divs)+","+1.0f+","+1.0f+")");
+
System.out.println("Color("+(i/divs)+","+1.0f+","+1.0f+")");
values.add(new Color(Color.HSBtoRGB(i/divs, 1.0f,
1.0f)));
i += 1.0f;
if (i >= (float)nColors) break;
- //
System.out.println("Color("+((i/divs)+0.5f)+","+1.0f+","+1.0f+")");
- values.add(new Color(Color.HSBtoRGB((i/divs)+0.5f,
1.0f, 1.0f)));
+ float hue = (i/divs)+0.25f;
+ if (hue >= 1.0f) hue = hue - 1.0f;
+ System.out.println("Color("+hue+","+1.0f+","+1.0f+")");
+ values.add(new Color(Color.HSBtoRGB(hue, 1.0f, 1.0f)));
}
return values;
}
Modified:
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/view/PieChart.java
===================================================================
---
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/view/PieChart.java
2011-11-22 00:59:13 UTC (rev 27546)
+++
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/view/PieChart.java
2011-11-22 01:01:40 UTC (rev 27547)
@@ -123,6 +123,8 @@
String label = null;
if (labels != null && labels.size() > 0)
label = labels.get(slice);
+ if (values.get(slice) == 0.0) continue;
+ // System.out.println("Slice "+slice+" label: "+label+"
value = "+values.get(slice)+" color = "+colors.get(slice));
CustomGraphic[] cg = createSlice(bbox, arcStart,
values.get(slice), label, colors.get(slice), view);
cgList.add(cg[0]);
if (cg[1] != null)
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.