use of org.jfree.chart.labels.PieSectionLabelGenerator in project MtgDesktopCompanion by nicho92.
the class ManaRepartitionPanel method refresh.
private void refresh() {
this.removeAll();
JFreeChart chart = ChartFactory.createPieChart3D(// chart title
"Color repartition", // data
getManaRepartitionDataSet(), // include legend
false, true, true);
pane = new ChartPanel(chart);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setSectionPaint("Black", Color.BLACK);
plot.setSectionPaint("White", Color.WHITE);
plot.setSectionPaint("Blue", Color.BLUE);
plot.setSectionPaint("Green", Color.GREEN);
plot.setSectionPaint("Red", Color.RED);
plot.setSectionPaint("Multi", Color.YELLOW);
plot.setSectionPaint("Uncolor", Color.GRAY);
plot.setSectionPaint("black", Color.BLACK);
plot.setSectionPaint("white", Color.WHITE);
plot.setSectionPaint("blue", Color.BLUE);
plot.setSectionPaint("green", Color.GREEN);
plot.setSectionPaint("red", Color.RED);
plot.setSectionPaint("multi", Color.YELLOW);
plot.setSectionPaint("uncolor", Color.GRAY);
plot.setSimpleLabels(true);
PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{1}", new DecimalFormat("0"), new DecimalFormat("0.00%"));
plot.setLabelGenerator(generator);
this.add(pane, BorderLayout.CENTER);
this.revalidate();
this.repaint();
}
use of org.jfree.chart.labels.PieSectionLabelGenerator in project SIMVA-SoS by SESoS.
the class PiePlot method drawSimpleLabels.
/**
* Draws the pie section labels in the simple form.
*
* @param g2 the graphics device.
* @param keys the section keys.
* @param totalValue the total value for all sections in the pie.
* @param plotArea the plot area.
* @param pieArea the area containing the pie.
* @param state the plot state.
*
* @since 1.0.7
*/
protected void drawSimpleLabels(Graphics2D g2, List keys, double totalValue, Rectangle2D plotArea, Rectangle2D pieArea, PiePlotState state) {
Composite originalComposite = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
Rectangle2D labelsArea = this.simpleLabelOffset.createInsetRectangle(pieArea);
double runningTotal = 0.0;
Iterator iterator = keys.iterator();
while (iterator.hasNext()) {
Comparable key = (Comparable) iterator.next();
boolean include;
double v = 0.0;
Number n = getDataset().getValue(key);
if (n == null) {
include = !getIgnoreNullValues();
} else {
v = n.doubleValue();
include = getIgnoreZeroValues() ? v > 0.0 : v >= 0.0;
}
if (include) {
runningTotal = runningTotal + v;
// work out the mid angle (0 - 90 and 270 - 360) = right,
// otherwise left
double mid = getStartAngle() + (getDirection().getFactor() * ((runningTotal - v / 2.0) * 360) / totalValue);
Arc2D arc = new Arc2D.Double(labelsArea, getStartAngle(), mid - getStartAngle(), Arc2D.OPEN);
int x = (int) arc.getEndPoint().getX();
int y = (int) arc.getEndPoint().getY();
PieSectionLabelGenerator myLabelGenerator = getLabelGenerator();
if (myLabelGenerator == null) {
continue;
}
String label = myLabelGenerator.generateSectionLabel(this.dataset, key);
if (label == null) {
continue;
}
g2.setFont(this.labelFont);
FontMetrics fm = g2.getFontMetrics();
Rectangle2D bounds = TextUtilities.getTextBounds(label, g2, fm);
Rectangle2D out = this.labelPadding.createOutsetRectangle(bounds);
Shape bg = ShapeUtilities.createTranslatedShape(out, x - bounds.getCenterX(), y - bounds.getCenterY());
if (this.labelShadowPaint != null && this.shadowGenerator == null) {
Shape shadow = ShapeUtilities.createTranslatedShape(bg, this.shadowXOffset, this.shadowYOffset);
g2.setPaint(this.labelShadowPaint);
g2.fill(shadow);
}
if (this.labelBackgroundPaint != null) {
g2.setPaint(this.labelBackgroundPaint);
g2.fill(bg);
}
if (this.labelOutlinePaint != null && this.labelOutlineStroke != null) {
g2.setPaint(this.labelOutlinePaint);
g2.setStroke(this.labelOutlineStroke);
g2.draw(bg);
}
g2.setPaint(this.labelPaint);
g2.setFont(this.labelFont);
TextUtilities.drawAlignedString(label, g2, x, y, TextAnchor.CENTER);
}
}
g2.setComposite(originalComposite);
}
use of org.jfree.chart.labels.PieSectionLabelGenerator in project MtgDesktopCompanion by nicho92.
the class RarityRepartitionPanel method refresh.
private void refresh() {
this.removeAll();
JFreeChart chart = ChartFactory.createPieChart3D(// chart title
"Rarity repartition", // data
getRarityRepartitionDataSet(), // include legend
false, true, true);
pane = new ChartPanel(chart);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setSectionPaint("Uncommon", Color.GRAY);
plot.setSectionPaint("Common", Color.WHITE);
plot.setSectionPaint("Rare", Color.YELLOW);
plot.setSectionPaint("Mythic Rare", Color.ORANGE);
PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0} = {1}", new DecimalFormat("0"), new DecimalFormat("0.00%"));
plot.setLabelGenerator(generator);
this.add(pane, BorderLayout.CENTER);
}
use of org.jfree.chart.labels.PieSectionLabelGenerator in project MtgDesktopCompanion by nicho92.
the class TypeRepartitionPanel method refresh.
private void refresh() {
this.removeAll();
JFreeChart chart = ChartFactory.createPieChart3D(// chart title
"Type repartition", // data
getTypeRepartitionDataSet(), // include legend
false, true, true);
pane = new ChartPanel(chart);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setSectionPaint("B", Color.BLACK);
plot.setSectionPaint("W", Color.WHITE);
plot.setSectionPaint("U", Color.BLUE);
plot.setSectionPaint("G", Color.GREEN);
plot.setSectionPaint("R", Color.RED);
plot.setSectionPaint("multi", Color.YELLOW);
plot.setSectionPaint("uncolor", Color.GRAY);
PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0} = {1}", new DecimalFormat("0"), new DecimalFormat("0.00%"));
plot.setLabelGenerator(generator);
this.add(pane, BorderLayout.CENTER);
}
Aggregations