plot.setDomainGridlinePaint(Color.white);
plot.setDomainGridlinesVisible(true);
logger.debug("set renderer");
StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer();
renderer.setDrawBarOutline(false);
renderer.setBaseItemLabelsVisible(true);
if (percentageValue)
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", new DecimalFormat("#,##.#%")));
else if(makePercentage)
renderer.setRenderAsPercentages(true);
/*
else
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
*/
renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
if(maxBarWidth!=null){
renderer.setMaximumBarWidth(maxBarWidth.doubleValue());
}
boolean document_composition=false;
if(mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION))document_composition=true;
logger.debug("Calling Url Generation");
MyCategoryUrlGenerator mycatUrl=null;
if(rootUrl!=null){
logger.debug("Set MycatUrl");
mycatUrl=new MyCategoryUrlGenerator(rootUrl);
mycatUrl.setDocument_composition(document_composition);
mycatUrl.setCategoryUrlLabel(categoryUrlName);
mycatUrl.setSerieUrlLabel(serieUrlname);
}
if(mycatUrl!=null)
renderer.setItemURLGenerator(mycatUrl);
logger.debug("Text Title");
TextTitle title =setStyleTitle(name, styleTitle);
chart.setTitle(title);
if(subName!= null && !subName.equals("")){
TextTitle subTitle =setStyleTitle(subName, styleSubTitle);
chart.addSubtitle(subTitle);
}
logger.debug("Style Labels");
Color colorSubInvisibleTitle=Color.decode("#FFFFFF");
StyleLabel styleSubSubTitle=new StyleLabel("Arial",12,colorSubInvisibleTitle);
TextTitle subsubTitle =setStyleTitle("", styleSubSubTitle);
chart.addSubtitle(subsubTitle);
// NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
// set the background color for the chart...
chart.setBackgroundPaint(color);
logger.debug("Axis creation");
// set the range axis to display integers only...
NumberFormat nf = NumberFormat.getNumberInstance(locale);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
if(makePercentage)
rangeAxis.setNumberFormatOverride(NumberFormat.getPercentInstance());
else
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
if(rangeIntegerValues==true){
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
}
rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
rangeAxis.setLabelPaint(styleXaxesLabels.getColor());
rangeAxis.setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor());
rangeAxis.setNumberFormatOverride(nf);
if(rangeAxisLocation != null) {
if(rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_LEFT")) {
plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT);
} else if(rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_RIGHT")) {
plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_RIGHT);
}else if(rangeAxisLocation.equalsIgnoreCase("TOP_OR_RIGHT")) {
plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_RIGHT);
} else if(rangeAxisLocation.equalsIgnoreCase("TOP_OR_LEFT")) {
plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT);
}
}
renderer.setDrawBarOutline(false);
logger.debug("Set series color");
int seriesN=dataset.getRowCount();
if(orderColorVector != null && orderColorVector.size()>0){
logger.debug("color serie by SERIES_ORDER_COLORS template specification");
for (int i = 0; i < seriesN; i++) {
if( orderColorVector.get(i)!= null){
Color color = orderColorVector.get(i);
renderer.setSeriesPaint(i, color);
}
}
}
else
if(colorMap!=null){
for (int i = 0; i < seriesN; i++) {
String serieName=(String)dataset.getRowKey(i);
// if serie has been rinominated I must search with the new name!
String nameToSearchWith = (seriesLabelsMap != null && seriesLabelsMap.containsKey(serieName)) ? seriesLabelsMap.get(serieName).toString() : serieName;
Color color=(Color)colorMap.get(nameToSearchWith);
if(color!=null){
renderer.setSeriesPaint(i, color);
renderer.setSeriesItemLabelFont(i, new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
}
}
}
logger.debug("If cumulative set series paint "+cumulative);
if(cumulative){
int row=dataset.getRowIndex("CUMULATIVE");
if(row!=-1){
if(color!=null)
renderer.setSeriesPaint(row, color);
else
renderer.setSeriesPaint(row, Color.WHITE);
}
}
MyStandardCategoryItemLabelGenerator generator=null;
logger.debug("Are there addition labels "+additionalLabels);
logger.debug("Are there value labels "+showValueLabels);
if(showValueLabels){
renderer.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator());
renderer.setBaseItemLabelsVisible(true);
renderer.setBaseItemLabelFont(new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
renderer.setBaseItemLabelPaint(styleValueLabels.getColor());
if (valueLabelsPosition.equalsIgnoreCase("inside")) {
renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.CENTER, TextAnchor.BASELINE_LEFT));
renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.CENTER, TextAnchor.BASELINE_LEFT));
} else {
renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.OUTSIDE3, TextAnchor.BASELINE_LEFT));
renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.OUTSIDE3, TextAnchor.BASELINE_LEFT));
}
}
else if(additionalLabels){
generator = new MyStandardCategoryItemLabelGenerator(catSerLabels,"{1}", NumberFormat.getInstance());
logger.debug("generator set");
double orient=(-Math.PI / 2.0);
logger.debug("add labels style");
if(styleValueLabels.getOrientation()!= null && styleValueLabels.getOrientation().equalsIgnoreCase("horizontal")){
orient=0.0;
}
renderer.setBaseItemLabelFont(new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
renderer.setBaseItemLabelPaint(styleValueLabels.getColor());
logger.debug("add labels style set");
renderer.setBaseItemLabelGenerator(generator);
renderer.setBaseItemLabelsVisible(true);
//vertical labels
renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.OUTSIDE12, TextAnchor.CENTER, TextAnchor.CENTER,
orient));
renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.OUTSIDE12, TextAnchor.CENTER, TextAnchor.CENTER,
orient));
logger.debug("end of add labels ");