Now a legend will display names for all elements if at least one of the pair color and label are different.
This commit is contained in:
parent
acf0d989d8
commit
1431bc4769
@ -39,10 +39,14 @@ public class GraphPointSetLegend {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public int compare(Pair<String, Color> o1, Pair<String, Color> o2) {
|
public int compare(Pair<String, Color> o1, Pair<String, Color> o2) {
|
||||||
return o1.car().compareTo(o2.car());
|
int comp = o1.car().compareTo(o2.car());
|
||||||
|
// Same text; let us see if the color is also identical.
|
||||||
|
return comp == 0 ? comp = Integer.valueOf(o1.cdr().getRGB())
|
||||||
|
.compareTo(Integer.valueOf(o2.cdr().getRGB())) : comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -167,8 +171,7 @@ public class GraphPointSetLegend {
|
|||||||
// System.out.println(legendEntries[i].toString() + "\tcontaines: "
|
// System.out.println(legendEntries[i].toString() + "\tcontaines: "
|
||||||
// + set.contains(legendEntries[i]));
|
// + set.contains(legendEntries[i]));
|
||||||
g.setColor(legendEntry.tail);
|
g.setColor(legendEntry.tail);
|
||||||
Rectangle2D stringBounds = fm.getStringBounds(
|
Rectangle2D stringBounds = fm.getStringBounds(legendEntry.head, g);
|
||||||
legendEntry.head, g);
|
|
||||||
xOffs = (int) (maxX - stringBounds.getWidth() - 5);
|
xOffs = (int) (maxX - stringBounds.getWidth() - 5);
|
||||||
g.drawString(legendEntry.head, xOffs, yOffs);
|
g.drawString(legendEntry.head, xOffs, yOffs);
|
||||||
// g.drawString(legendEntries[i].head, 80, 80);
|
// g.drawString(legendEntries[i].head, 80, 80);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user