private void verifyChart(JRChart chart) { verifyReportElement(chart); if (chart.getEvaluationTimeValue() == EvaluationTimeEnum.AUTO) { addBrokenRule("Charts do not support Auto evaluation time.", chart); } JRChartDataset dataset = chart.getDataset(); if (dataset == null) { addBrokenRule("Chart dataset missing.", chart); } else { dataset.validate(this); } }
/** * */ public void writeXyBarChart( JRChart chart, String chartName) { if(chart != null) { write( "JRDesignChart " + chartName + " = new JRDesignChart(jasperDesign, JRChart.CHART_TYPE_XYBAR);\n"); writeChart( chart, chartName); JRChartDataset dataset = chart.getDataset(); if( dataset.getDatasetType() == JRChartDataset.TIMESERIES_DATASET ) { writeTimeSeriesDataset( (JRTimeSeriesDataset)dataset, chartName, "TimeSeriesDataset"); } else if( dataset.getDatasetType() == JRChartDataset.TIMEPERIOD_DATASET ){ writeTimePeriodDataset( (JRTimePeriodDataset)dataset, chartName, "XyDataset"); } else if( dataset.getDatasetType() == JRChartDataset.XY_DATASET ){ writeXyDataset( (JRXyDataset) chart.getDataset(), chartName, "XyDataset"); } writeBarPlot( (JRBarPlot) chart.getPlot(), chartName); flush(); } }
/** * */ public void writePieChart( JRChart chart, String chartName) { if(chart != null) { write( "JRDesignChart " + chartName + " = new JRDesignChart(jasperDesign, JRChart.CHART_TYPE_PIE);\n"); writeChart( chart, chartName); writePieDataset( (JRPieDataset)chart.getDataset(), chartName, "PieDataset"); // write plot JRPiePlot plot = (JRPiePlot) chart.getPlot(); if(plot != null) { String plotName = chartName + "PiePlot"; write( "JRDesignPiePlot " + plotName + " = (JRDesignPiePlot)" + chartName + ".getPlot();\n"); write( plotName + ".setShowLabels({0});\n", getBooleanText(plot.getShowLabels())); write( plotName + ".setCircular({0});\n", getBooleanText(plot.getCircular())); write( plotName + ".setLabelFormat(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(plot.getLabelFormat())); write( plotName + ".setLegendLabelFormat(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(plot.getLegendLabelFormat())); writePlot( plot, plotName); writeItemLabel( plot.getItemLabel(),plotName, "ItemLabel"); flush(); } flush(); } }
/** * Constructs a copy of an existing meter. * * @param plot the plot to copy */ public JRBaseMeterPlot(JRChartPlot plot, JRChart chart) { super(plot, chart); JRMeterPlot meterPlot = plot instanceof JRMeterPlot ? (JRMeterPlot)plot : null; if (meterPlot == null) { valueDisplay = new JRBaseValueDisplay(null, chart); } else { valueDisplay = new JRBaseValueDisplay(meterPlot.getValueDisplay(), chart); tickLabelFont = meterPlot.getTickLabelFont(); } }
protected JRBaseBar3DPlot(JRChartPlot plot, JRChart chart, ChartCopyObjectFactory copyObjectFactory) { super(plot, chart); JRBar3DPlot barPlot = plot instanceof JRBar3DPlot ? (JRBar3DPlot)plot : null; if (barPlot == null) { itemLabel = copyObjectFactory.copyItemLabel(null, chart); } else { categoryAxisLabelFont = barPlot.getCategoryAxisLabelFont(); categoryAxisTickLabelFont = getCategoryAxisTickLabelFont(); valueAxisLabelFont = barPlot.getValueAxisLabelFont(); valueAxisTickLabelFont = barPlot.getValueAxisTickLabelFont(); itemLabel = copyObjectFactory.copyItemLabel(barPlot.getItemLabel(), chart); } }
/** * */ public void writeXyBarChart(JRChart chart) throws IOException { writer.startElement(JRXmlConstants.ELEMENT_xyBarChart, getNamespace()); writeChart(chart); JRChartDataset dataset = chart.getDataset(); if( dataset.getDatasetType() == JRChartDataset.TIMESERIES_DATASET ){ writeTimeSeriesDataset( (JRTimeSeriesDataset)dataset ); } else if( dataset.getDatasetType() == JRChartDataset.TIMEPERIOD_DATASET ){ writeTimePeriodDataset( (JRTimePeriodDataset)dataset ); } else if( dataset.getDatasetType() == JRChartDataset.XY_DATASET ){ writeXyDataset( (JRXyDataset)dataset ); } writeBarPlot((JRBarPlot) chart.getPlot()); writer.closeElement(); }
@Override public Object createObject(Attributes attrs) { JRChart chart = (JRChart) digester.peek(); JRDesignPieDataset dataset = (JRDesignPieDataset)chart.getDataset(); String minPercentage = attrs.getValue(ATTRIBUTE_minPercentage); if(minPercentage != null && minPercentage.length() > 0) { dataset.setMinPercentage(Float.valueOf(minPercentage)); } String maxCount = attrs.getValue(ATTRIBUTE_maxCount); if(maxCount != null && maxCount.length() > 0) { dataset.setMaxCount(Integer.valueOf(maxCount)); } return dataset; }
@Override public void visitChart(JRChart chart) { JRBaseChart baseChart = null; if (chart != null) { baseChart = (JRBaseChart)get(chart); if (baseChart == null) { baseChart = new JRBaseChart(chart, this); } } setVisitResult(baseChart); }
/** * */ public void writePieChart(JRChart chart) throws IOException { writer.startElement(JRXmlConstants.ELEMENT_pieChart, getNamespace()); writeChart(chart); writePieDataset((JRPieDataset) chart.getDataset()); // write plot JRPiePlot plot = (JRPiePlot) chart.getPlot(); writer.startElement(JRXmlConstants.ELEMENT_piePlot); if(isNewerVersionOrEqual(JRConstants.VERSION_3_7_5)) { writer.addAttribute(JRXmlConstants.ATTRIBUTE_isShowLabels, plot.getShowLabels()); } writer.addAttribute(JRXmlConstants.ATTRIBUTE_isCircular, plot.getCircular()); if(isNewerVersionOrEqual(JRConstants.VERSION_3_1_0)) { writer.addAttribute(JRXmlConstants.ATTRIBUTE_labelFormat, plot.getLabelFormat()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_legendLabelFormat, plot.getLegendLabelFormat()); } writePlot(chart.getPlot()); writeItemLabel(plot.getItemLabel()); writer.closeElement(); writer.closeElement(); }
@Override public void visitChart(JRChart chart) { JRFillChart fillChart = null; if (chart != null) { fillChart = (JRFillChart)get(chart); if (fillChart == null) { fillChart = new JRFillChart(filler, chart, this); } } setVisitResult(fillChart); }
@Override public JRPrintElement convert(ReportConverter reportConverter, JRElement element) { JRBasePrintImage printImage = new JRBasePrintImage(reportConverter.getDefaultStyleProvider()); JRChart chart = (JRChart)element; copyElement(reportConverter, chart, printImage); printImage.copyBox(chart.getLineBox()); printImage.setAnchorName(JRExpressionUtil.getExpressionText(chart.getAnchorNameExpression())); printImage.setBookmarkLevel(chart.getBookmarkLevel()); printImage.setLinkType(chart.getLinkType()); printImage.setOnErrorType(OnErrorTypeEnum.ICON); printImage.setRenderer(getRenderer(reportConverter, chart)); printImage.setScaleImage(ScaleImageEnum.CLIP); return printImage; }
@Override public Object createObject( Attributes attrs ){ JRChart chart = (JRChart)digester.peek(); JRDesignScatterPlot plot = (JRDesignScatterPlot)chart.getPlot(); String isShowShapes = attrs.getValue( ATTRIBUTE_isShowShapes ); if( isShowShapes != null && isShowShapes.length() > 0 ){ plot.setShowShapes(Boolean.valueOf(isShowShapes) ); } String isShowLines = attrs.getValue( ATTRIBUTE_isShowLines ); if( isShowLines != null && isShowLines.length() > 0 ){ plot.setShowLines(Boolean.valueOf(isShowLines) ); } return plot; }
@Override public void customize(JFreeChart jfc, JRChart jrc) { Plot plot = jfc.getPlot(); if (plot instanceof XYPlot) { ((XYPlot)plot).setRenderer( new XYSplineRenderer()); } }
@Override public void customize(JFreeChart jfc, JRChart jrc) { if (jfc.getPlot() instanceof XYPlot) { Marker marker = createMarker(); if (marker != null) { addMarker(jfc.getPlot(), marker); } } }
@Override public void customize(JFreeChart jfc, JRChart jrc) { if (jfc.getPlot() instanceof XYPlot) { Marker marker = createMarker(); if (marker != null) { addMarker(jfc.getXYPlot(), marker); } } }
/** * */ public Color getForecolor(JRChartPlot plot) { JRChart chart = plot.getChart(); if (chart != null) { return getForecolor(chart); } return Color.black; }
@Override public void customize(JFreeChart jfc, JRChart jrc) { Plot plot = jfc.getPlot(); ItemsCounter itemsCounter = new LegendItemsCounter(plot); SeriesNameProvider seriesNameProvider = null; Object renderer = null; if (plot instanceof XYPlot) { XYPlot xyPlot = jfc.getXYPlot(); renderer = xyPlot.getRenderer(); seriesNameProvider = new XYPlotSeriesNameProvider(xyPlot); } else if (plot instanceof CategoryPlot) { CategoryPlot categoryPlot = jfc.getCategoryPlot(); renderer = categoryPlot.getRenderer(); seriesNameProvider = new CategorySeriesNameProvider(categoryPlot); } Integer legendItemIndex = CustomizerUtil.resolveIndex(this, itemsCounter, seriesNameProvider); if ( legendItemIndex != null && renderer instanceof AbstractRenderer ) { ShapeSetter shapeSetter = new AbstractRendererLegendShapeSetter((AbstractRenderer)renderer); if (legendItemIndex == -1) { updateItems(itemsCounter, shapeSetter); } else { updateItem(itemsCounter, shapeSetter, legendItemIndex); } } }
@Override public void visitChart(JRChart chart) { JRPrintElement printImage = ChartConverter.getInstance().convert(reportConverter, chart); addElement(parentFrame, printImage); addContour(reportConverter, parentFrame, printImage); }
/** * Constructs a new thermometer plot that is a copy of an existing one. * * @param plot the plot to copy * @param chart the parent chart */ public JRBaseThermometerPlot(JRChartPlot plot, JRChart chart) { super(plot, chart); JRThermometerPlot thermoPlot = plot instanceof JRThermometerPlot ? (JRThermometerPlot)plot : null; if (thermoPlot == null) { valueDisplay = new JRBaseValueDisplay(null, chart); } else { valueDisplay = new JRBaseValueDisplay(thermoPlot.getValueDisplay(), chart); } }
/** * */ public JRBaseBubblePlot(JRChartPlot plot, JRChart chart) { super(plot, chart); JRBubblePlot bubblePlot = plot instanceof JRBubblePlot ? (JRBubblePlot)plot : null; if (bubblePlot != null) { xAxisLabelFont = bubblePlot.getXAxisLabelFont(); xAxisTickLabelFont = bubblePlot.getXAxisTickLabelFont(); yAxisLabelFont = bubblePlot.getYAxisLabelFont(); yAxisTickLabelFont = bubblePlot.getYAxisTickLabelFont(); } }
public void writeHighLowChart(JRChart chart) throws IOException { writer.startElement(JRXmlConstants.ELEMENT_highLowChart, getNamespace()); writeChart(chart); writeHighLowDataset((JRHighLowDataset) chart.getDataset()); JRHighLowPlot plot = (JRHighLowPlot) chart.getPlot(); writer.startElement(JRXmlConstants.ELEMENT_highLowPlot); writer.addAttribute(JRXmlConstants.ATTRIBUTE_isShowOpenTicks, plot.getShowOpenTicks()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_isShowCloseTicks, plot.getShowCloseTicks()); writePlot(plot); writeExpression(JRXmlConstants.ELEMENT_timeAxisLabelExpression, plot.getTimeAxisLabelExpression(), false); writeAxisFormat(JRXmlConstants.ELEMENT_timeAxisFormat, plot.getTimeAxisLabelFont(), plot.getOwnTimeAxisLabelColor(), plot.getTimeAxisTickLabelFont(), plot.getOwnTimeAxisTickLabelColor(), plot.getTimeAxisTickLabelMask(), plot.getTimeAxisVerticalTickLabels(), plot.getOwnTimeAxisLineColor()); writeExpression(JRXmlConstants.ELEMENT_valueAxisLabelExpression, plot.getValueAxisLabelExpression(), false); writeAxisFormat(JRXmlConstants.ELEMENT_valueAxisFormat, plot.getValueAxisLabelFont(), plot.getOwnValueAxisLabelColor(), plot.getValueAxisTickLabelFont(), plot.getOwnValueAxisTickLabelColor(), plot.getValueAxisTickLabelMask(), plot.getValueAxisVerticalTickLabels(), plot.getOwnValueAxisLineColor()); if(isNewerVersionOrEqual(JRConstants.VERSION_3_5_0)) { writeExpression(JRXmlConstants.ELEMENT_domainAxisMinValueExpression, plot.getDomainAxisMinValueExpression(), false); writeExpression(JRXmlConstants.ELEMENT_domainAxisMaxValueExpression, plot.getDomainAxisMaxValueExpression(), false); writeExpression(JRXmlConstants.ELEMENT_rangeAxisMinValueExpression, plot.getRangeAxisMinValueExpression(), false); writeExpression(JRXmlConstants.ELEMENT_rangeAxisMaxValueExpression, plot.getRangeAxisMaxValueExpression(), false); } writer.closeElement(); writer.closeElement(); }
/** * */ protected JRBaseCandlestickPlot(JRChartPlot plot, JRChart chart) { super(plot, chart); JRCandlestickPlot candlestickPlot = plot instanceof JRCandlestickPlot ? (JRCandlestickPlot)plot : null; if (candlestickPlot != null) { timeAxisLabelFont = candlestickPlot.getTimeAxisLabelFont(); timeAxisTickLabelFont = candlestickPlot.getTimeAxisTickLabelFont(); valueAxisLabelFont = candlestickPlot.getValueAxisLabelFont(); valueAxisTickLabelFont = candlestickPlot.getValueAxisTickLabelFont(); } }
/** * */ public void writeAreaChart( JRChart chart, String chartName) { if(chart != null) { write( "JRDesignChart " + chartName + " = new JRDesignChart(jasperDesign, JRChart.CHART_TYPE_AREA);\n"); writeChart( chart, chartName); writeCategoryDataSet( (JRCategoryDataset) chart.getDataset(), chartName, "CategoryDataset"); writeAreaPlot( (JRAreaPlot) chart.getPlot(), chartName); flush(); } }
/** * Constructs a copy of an existing value format specification. * * @param valueDisplay the value formatting object to copy * @param chart the parent chart */ public JRBaseValueDisplay(JRValueDisplay valueDisplay, JRChart chart)//FIXMECHART these two parameters are no longer used; first one is always null { this.chart = chart; if (valueDisplay != null) { color = valueDisplay.getColor(); mask = valueDisplay.getMask(); font = valueDisplay.getFont(); } }
/** * Constructs a copy of an existing value format specification and registers * any expression in the new copy with the specified factory. * * @param valueDisplay the value formatting object to copy * @param factory the factory object to register expressions with */ public JRBaseValueDisplay(JRValueDisplay valueDisplay, JRBaseObjectFactory factory) { factory.put(valueDisplay, this); chart = (JRChart)factory.getVisitResult(valueDisplay.getChart()); color = valueDisplay.getColor(); mask = valueDisplay.getMask(); font = factory.getFont(chart, valueDisplay.getFont()); }
/** * */ public void writeLineChart( JRChart chart, String chartName) { if(chart != null) { write( "JRDesignChart " + chartName + " = new JRDesignChart(jasperDesign, JRChart.CHART_TYPE_LINE);\n"); writeChart( chart, chartName); writeCategoryDataSet( (JRCategoryDataset) chart.getDataset(), chartName, "CategoryDataset"); writeLinePlot( (JRLinePlot) chart.getPlot(), chartName); flush(); } }
@Override public JRFont getFont() { int i = 0; JRChart chart = null; while (chart == null && i < digester.getCount()) { Object obj = digester.peek(i); chart = obj instanceof JRChart ? (JRChart)obj : null; i++; } return new JRDesignFont(chart); }
/** * Constructs a copy of an existing item label specification. * * @param itemLabel the item label object to copy * @param chart the parent chart */ public JRBaseItemLabel(JRItemLabel itemLabel, JRChart chart) { this.chart = chart; if (itemLabel != null) { color = itemLabel.getColor(); backgroundColor = itemLabel.getBackgroundColor(); // mask = itemLabel.getMask(); font = itemLabel.getFont(); } }
/** * Constructs a copy of an existing item label specification and registers * any expression in the new copy with the specified factory. * * @param itemLabel the item label object to copy * @param factory the factory object to register expressions with */ public JRBaseItemLabel(JRItemLabel itemLabel, JRBaseObjectFactory factory) { factory.put(itemLabel, this); chart = (JRChart)factory.getVisitResult(itemLabel.getChart()); color = itemLabel.getColor(); backgroundColor = itemLabel.getBackgroundColor(); // mask = itemLabel.getMask(); font = factory.getFont(chart, itemLabel.getFont()); }
/** * */ public JRBaseScatterPlot(JRChartPlot plot, JRChart chart) { super(plot, chart); JRScatterPlot scatterPlot = plot instanceof JRScatterPlot ? (JRScatterPlot)plot : null; if (scatterPlot != null) { xAxisLabelFont = scatterPlot.getXAxisLabelFont(); xAxisTickLabelFont = scatterPlot.getXAxisTickLabelFont(); yAxisLabelFont = scatterPlot.getYAxisLabelFont(); yAxisTickLabelFont = scatterPlot.getYAxisTickLabelFont(); } }
/** * */ public JRBaseLinePlot(JRChartPlot plot, JRChart chart) { super(plot, chart); JRLinePlot linePlot = plot instanceof JRLinePlot ? (JRLinePlot)plot : null; if (linePlot != null) { categoryAxisLabelFont = linePlot.getCategoryAxisLabelFont(); categoryAxisTickLabelFont = linePlot.getCategoryAxisTickLabelFont(); valueAxisLabelFont = linePlot.getValueAxisLabelFont(); valueAxisTickLabelFont = linePlot.getValueAxisTickLabelFont(); } }
/** * */ protected void setChart(JRChart chart) { super.setElement(chart); linePen = new JRBasePen(this); getLinePen().setLineWidth(0f); setFill(FillEnum.SOLID); copyLineBox(chart.getLineBox()); setLinkType(chart.getLinkType()); setLinkTarget(chart.getLinkTarget()); }
@Override public Object createObject( Attributes atts ){ JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2); JRDesignChart chart = new JRDesignChart(jasperDesign, JRChart.CHART_TYPE_XYAREA); return chart; }
@Override public Object createObject( Attributes attrs ){ JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2); JRDesignChart chart = new JRDesignChart(jasperDesign, JRChart.CHART_TYPE_SCATTER); return chart; }
@Override public Object createObject(Attributes atts) { JRChart chart = (JRChart) digester.peek(); JRDesignCandlestickPlot plot = (JRDesignCandlestickPlot)chart.getPlot(); String isShowVolume = atts.getValue(ATTRIBUTE_isShowVolume); if (isShowVolume != null && isShowVolume.length() > 0) { plot.setShowVolume(Boolean.valueOf(isShowVolume)); } return plot; }
@Override public Object createObject(Attributes atts) { JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2); JRDesignChart chart = new JRDesignChart(jasperDesign, JRChart.CHART_TYPE_THERMOMETER); return chart; }
@Override public Object createObject( Attributes attrs ){ JRChart chart = (JRChart)digester.peek(); JRDesignAreaPlot plot = (JRDesignAreaPlot)chart.getPlot(); return plot; }
@Override public Object createObject(Attributes atts) { JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2); JRDesignChart chart = new JRDesignChart(jasperDesign, JRChart.CHART_TYPE_STACKEDAREA); return chart; }
/** * */ public void writeStackedBarChart( JRChart chart, String chartName) { if(chart != null) { write( "JRDesignChart " + chartName + " = new JRDesignChart(jasperDesign, JRChart.CHART_TYPE_STACKEDBAR);\n"); writeChart( chart, chartName); writeCategoryDataSet( (JRCategoryDataset) chart.getDataset(), chartName, "CategoryDataset"); writeBarPlot( (JRBarPlot) chart.getPlot(), chartName); flush(); } }
/** * */ public void writeBubbleChart( JRChart chart, String chartName) { if(chart != null) { write( "JRDesignChart " + chartName + " = new JRDesignChart(jasperDesign, JRChart.CHART_TYPE_BUBBLE);\n"); writeChart( chart, chartName); writeXyzDataset( (JRXyzDataset) chart.getDataset(), chartName, "XyzDataset"); writeBubblePlot( (JRBubblePlot) chart.getPlot(), chartName); flush(); } }