jfreechart customize piechart to show absolute values and percentages

Use the MessageFormat symbol {1} for the absolute section value. See StandardPieSectionLabelGenerator for details. public class MyMinimalPieChartExample { private static final String KEY1 = “Datum 1”; public static final String KEY2 = “Datum 2”; public static void main(String[] args) { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue(KEY1, 99); dataset.setValue(KEY2, 77); JFreeChart someChart = ChartFactory.createPieChart( “Header”, dataset, … Read more

Math.abs returns wrong value for Integer.Min_VALUE

Integer.MIN_VALUE is -2147483648, but the highest value a 32 bit integer can contain is +2147483647. Attempting to represent +2147483648 in a 32 bit int will effectively “roll over” to -2147483648. This is because, when using signed integers, the two’s complement binary representations of +2147483648 and -2147483648 are identical. This is not a problem, however, as … Read more