List of usage examples for org.jfree.util TableOrder BY_COLUMN
TableOrder BY_COLUMN
To view the source code for org.jfree.util TableOrder BY_COLUMN.
Click Source Link
From source file:org.pentaho.reporting.engine.classic.extensions.legacy.charts.LegacyChartType.java
private JFreeChart createChart(final Expression aExpression) { if (aExpression instanceof BarLineChartExpression) { final CategoryAxis catAxis = new CategoryAxis("Category");// NON-NLS final NumberAxis barsAxis = new NumberAxis("Value");// NON-NLS final NumberAxis linesAxis = new NumberAxis("Value2");// NON-NLS final CategoryPlot plot = new CategoryPlot(createDataset(), catAxis, barsAxis, new BarRenderer()); plot.setRenderer(1, new LineAndShapeRenderer()); // add lines dataset and axis to plot plot.setDataset(1, createDataset()); plot.setRangeAxis(1, linesAxis); // map lines to second axis plot.mapDatasetToRangeAxis(1, 1); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // set location of second axis plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); return new JFreeChart("Bar Line Chart", plot); }/*from w w w.ja v a 2 s . c om*/ if (aExpression instanceof RingChartExpression) { return ChartFactory.createRingChart("Ring Chart", createPieDataset(), true, false, false);// NON-NLS } if (aExpression instanceof AreaChartExpression) { return ChartFactory.createAreaChart("Area Chart", "Category", "Value", createDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof BarChartExpression) { return ChartFactory.createBarChart("Bar Chart", "Category", "Value", createDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof LineChartExpression) { return ChartFactory.createLineChart("Line Chart", "Category", "Value", createDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof MultiPieChartExpression) { return ChartFactory.createMultiplePieChart("Multi Pie Chart", createDataset(), TableOrder.BY_COLUMN, true, false, false);// NON-NLS } if (aExpression instanceof PieChartExpression) { return ChartFactory.createPieChart("Pie Chart", createPieDataset(), true, false, false);// NON-NLS } if (aExpression instanceof WaterfallChartExpressions) { return ChartFactory.createWaterfallChart("Bar Chart", "Category", "Value", createDataset(), PlotOrientation.HORIZONTAL, true, false, false);// NON-NLS } if (aExpression instanceof BubbleChartExpression) { return ChartFactory.createBubbleChart("Bubble Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof ExtendedXYLineChartExpression) { return ChartFactory.createXYLineChart("XY Line Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof ScatterPlotChartExpression) { return ChartFactory.createScatterPlot("Scatter Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof XYAreaLineChartExpression) { final NumberAxis catAxis = new NumberAxis("Range");// NON-NLS final NumberAxis barsAxis = new NumberAxis("Value");// NON-NLS final NumberAxis linesAxis = new NumberAxis("Value2");// NON-NLS final XYPlot plot = new XYPlot(createXYZDataset(), catAxis, barsAxis, new XYAreaRenderer()); plot.setRenderer(1, new XYLineAndShapeRenderer()); // add lines dataset and axis to plot plot.setDataset(1, createXYZDataset()); plot.setRangeAxis(1, linesAxis); // map lines to second axis plot.mapDatasetToRangeAxis(1, 1); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // set location of second axis plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); return new JFreeChart("XY Area Line Chart", plot);// NON-NLS } if (aExpression instanceof XYAreaChartExpression) { return ChartFactory.createXYAreaChart("XY Area Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof XYBarChartExpression) { return XYBarChartExpression.createXYBarChart("XY Bar Chart", "X", false, "Y", createIntervalXYDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof XYLineChartExpression) { return ChartFactory.createXYLineChart("XY Line Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof RadarChartExpression) { final SpiderWebPlot plot = new SpiderWebPlot(createDataset()); return new JFreeChart("Radar Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, true); } if (aExpression instanceof ThermometerChartExpression) { final DefaultValueDataset dataset = new DefaultValueDataset(new Double(65.0)); final ThermometerPlot plot = new ThermometerPlot(dataset); return new JFreeChart("Thermometer Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, true); } return null; }
From source file:org.exist.xquery.modules.jfreechart.Configuration.java
/** * Read configuration from node and initialize configuration. * @throws XPathException Thrown when an element cannot be read. *//* w w w. j av a 2 s.c om*/ public void parse(Node configuration) throws XPathException { if (configuration.getNodeType() == Node.ELEMENT_NODE && configuration.getLocalName().equals("configuration")) { //Get the First Child Node child = configuration.getFirstChild(); while (child != null) { //Parse each of the child nodes if (child.getNodeType() == Node.ELEMENT_NODE && child.hasChildNodes()) { if (child.getLocalName().equals("title")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'title' cannot be parsed"); } else { title = value; } } else if (child.getLocalName().equals("categoryAxisLabel")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'categoryAxisLabel' cannot be parsed"); } else { categoryAxisLabel = value; } } else if (child.getLocalName().equals("categoryAxisColor")) { Color value = Colour.getColor(getValue(child)); if (value == null) { throw new XPathException("Value for 'categoryAxisColor' cannot be parsed"); } else { categoryAxisColor = value; } } else if (child.getLocalName().equals("valueAxisLabel")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'valueAxisLabel' cannot be parsed"); } else { valueAxisLabel = value; } } else if (child.getLocalName().equals("valueAxisColor")) { Color value = Colour.getColor(getValue(child)); if (value == null) { throw new XPathException("Value for 'valueAxisColor' cannot be parsed"); } else { valueAxisColor = value; } } else if (child.getLocalName().equals("timeAxisLabel")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'timeAxisLabel' cannot be parsed"); } else { timeAxisLabel = value; } } else if (child.getLocalName().equals("timeAxisColor")) { Color value = Colour.getColor(getValue(child)); if (value == null) { throw new XPathException("Value for 'timeAxisColor' cannot be parsed"); } else { timeAxisColor = value; } } else if (child.getLocalName().equals("domainAxisLabel")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'domainAxisLabel' cannot be parsed"); } else { domainAxisLabel = value; } } else if (child.getLocalName().equals("rangeAxisLabel")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'rangeAxisLabel' cannot be parsed"); } else { rangeAxisLabel = value; } } else if (child.getLocalName().equals("pieSectionLabel")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'pieSectionLabel' cannot be parsed"); } else { pieSectionLabel = value; } } else if (child.getLocalName().equals("pieSectionNumberFormat")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'pieSectionNumberFormat' cannot be parsed"); } else { pieSectionNumberFormat = value; } } else if (child.getLocalName().equals("pieSectionPercentFormat")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'pieSectionPercentFormat' cannot be parsed"); } else { pieSectionPercentFormat = value; } } else if (child.getLocalName().equals("orientation")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'orientation' cannot be parsed"); } else if ("HORIZONTAL".equalsIgnoreCase(value)) { orientation = PlotOrientation.HORIZONTAL; } else if ("VERTICAL".equalsIgnoreCase(value)) { orientation = PlotOrientation.VERTICAL; } else { throw new XPathException("Wrong value for 'orientation'"); } } else if (child.getLocalName().equals("tableOrder")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'tableOrder' cannot be parsed"); } else if ("COLUMN".equalsIgnoreCase(value)) { order = TableOrder.BY_COLUMN; } else if ("ROW".equalsIgnoreCase(value)) { order = TableOrder.BY_ROW; } else { throw new XPathException("Wrong value for 'tableOrder'"); } } else if (child.getLocalName().equals("legend")) { Boolean value = parseBoolean(getValue(child)); if (value == null) { throw new XPathException("Value for 'legend' cannot be parsed"); } else { generateLegend = value; } } else if (child.getLocalName().equals("tooltips")) { Boolean value = parseBoolean(getValue(child)); if (value == null) { throw new XPathException("Value for 'tooltips' cannot be parsed"); } else { generateTooltips = value; } } else if (child.getLocalName().equals("urls")) { Boolean value = parseBoolean(getValue(child)); if (value == null) { throw new XPathException("Value for 'urls' cannot be parsed"); } else { generateUrls = value; } } else if (child.getLocalName().equals("width")) { Integer value = parseInteger(getValue(child)); if (value == null) { throw new XPathException("Value for 'width' cannot be parsed"); } else { imageWidth = value; } } else if (child.getLocalName().equals("height")) { Integer value = parseInteger(getValue(child)); if (value == null) { throw new XPathException("Value for 'height' cannot be parsed"); } else { imageHeight = value; } } else if (child.getLocalName().equals("titleColor")) { Color value = Colour.getColor(getValue(child)); if (value == null) { throw new XPathException("Value for 'titleColor' cannot be parsed"); } else { titleColor = value; } } else if (child.getLocalName().equals("chartBackgroundColor")) { Color value = Colour.getColor(getValue(child)); if (value == null) { throw new XPathException("Value for 'chartBackgroundColor' cannot be parsed"); } else { chartBackgroundColor = value; } } else if (child.getLocalName().equals("plotBackgroundColor")) { Color value = Colour.getColor(getValue(child)); if (value == null) { throw new XPathException("Value for 'plotBackgroundColor' cannot be parsed"); } else { plotBackgroundColor = value; } } else if (child.getLocalName().equals("seriesColors")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'seriesColors' cannot be parsed"); } else { seriesColors = value; } } else if (child.getLocalName().equals("sectionColors")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'sectionColors' cannot be parsed"); } else { sectionColors = value; } } else if (child.getLocalName().equals("sectionColorsDelimiter")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'sectionColorsDelimiter' cannot be parsed"); } else { sectionColorsDelimiter = value; } } else if (child.getLocalName().equals("rangeLowerBound")) { Double value = parseDouble(getValue(child)); if (value == null) { throw new XPathException("Value for 'rangeLowerBound' cannot be parsed"); } else { rangeLowerBound = value; } } else if (child.getLocalName().equals("rangeUpperBound")) { Double value = parseDouble(getValue(child)); if (value == null) { throw new XPathException("Value for 'rangeUpperBound' cannot be parsed"); } else { rangeUpperBound = value; } } else if (child.getLocalName().equals("categoryItemLabelGeneratorClass")) { String value = getValue(child); if (value == null) { throw new XPathException( "Value for 'categoryItemLabelGeneratorClass' cannot be parsed"); } else { categoryItemLabelGeneratorClass = value; } } else if (child.getLocalName().equals("categoryItemLabelGeneratorParameter")) { String value = getValue(child); if (value == null) { throw new XPathException( "Value for 'categoryItemLabelGeneratorParameter' cannot be parsed"); } else { categoryItemLabelGeneratorParameter = value; } } else if (child.getLocalName().equals("categoryItemLabelGeneratorNumberFormat")) { String value = getValue(child); if (value == null) { throw new XPathException( "Value for 'categoryItemLabelGeneratorNumberFormat' cannot be parsed"); } else { categoryItemLabelGeneratorNumberFormat = value; } } else if (child.getLocalName().equals("imageType")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'imageType' cannot be parsed"); } else { imageType = value; } } } //next node child = child.getNextSibling(); } } }
From source file:com.tonbeller.jpivot.chart.ChartComponent.java
/** * Entry point for producing charts, called by wcf render tag. * Produces a jfreechart dataset from olap model, then creates a chart and * writes it to the servlet container temp directory. * Returns a DOM document for Renderer to transform into html. * Requires that jfreechart servlet is installed in this application context. *//* w w w . j ava 2 s . c o m*/ public Document render(RequestContext context) throws Exception { // check if we need to produce a new chart if (dirty) { // clear old listeners dispatcher.clear(); this.result = olapModel.getResult(); this.cellIterator = result.getCells().iterator(); this.dimCount = result.getAxes().length; DefaultCategoryDataset dataset = null; switch (dimCount) { case 1: logger.info("1-dim data"); dataset = build1dimDataset(); break; case 2: logger.info("2-dim data"); dataset = build2dimDataset(); break; default: logger.error("less than 1 or more than 2 dimensions"); throw new IllegalArgumentException("ChartRenderer requires a 1 or 2 dimensional result"); } // re-set dirty flag dirty = false; // create font titleFont = new java.awt.Font(fontName, fontStyle, fontSize); CategoryURLGenerator urlGenerator = new jpivotCategoryURLGenerator(webControllerURL); // Create the chart object JFreeChart chart = null; switch (chartType) { case 1: chart = ChartFactory.createBarChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 2: chart = ChartFactory.createBarChart3D(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 3: chart = ChartFactory.createBarChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 4: chart = ChartFactory.createBarChart3D(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 5: chart = ChartFactory.createStackedBarChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 6: chart = ChartFactory.createStackedBarChart3D(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 7: chart = ChartFactory.createStackedBarChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 8: chart = ChartFactory.createStackedBarChart3D(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 9: chart = ChartFactory.createLineChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 10: chart = ChartFactory.createLineChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 11: chart = ChartFactory.createAreaChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 12: chart = ChartFactory.createAreaChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 13: chart = ChartFactory.createStackedAreaChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 14: chart = ChartFactory.createStackedAreaChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 15: chart = ChartFactory.createPieChart(chartTitle, titleFont, dataset, TableOrder.BY_COLUMN, showLegend, showTooltips, drillThroughEnabled, new jpivotPieURLGenerator(TableOrder.BY_COLUMN, dataset, webControllerURL)); break; case 16: chart = ChartFactory.createPieChart(chartTitle, titleFont, dataset, TableOrder.BY_ROW, showLegend, showTooltips, drillThroughEnabled, new jpivotPieURLGenerator(TableOrder.BY_ROW, dataset, webControllerURL)); break; case 17: chart = ChartFactory.create3DPieChart(chartTitle, titleFont, dataset, TableOrder.BY_COLUMN, showLegend, showTooltips, drillThroughEnabled, new jpivotPieURLGenerator(TableOrder.BY_COLUMN, dataset, webControllerURL)); break; case 18: chart = ChartFactory.create3DPieChart(chartTitle, titleFont, dataset, TableOrder.BY_ROW, showLegend, showTooltips, drillThroughEnabled, new jpivotPieURLGenerator(TableOrder.BY_ROW, dataset, webControllerURL)); break; default: throw new Exception("An unknown Chart Type was requested"); } try { chart.setBackgroundPaint(new java.awt.Color(bgColorR, bgColorG, bgColorB)); java.awt.Font slicerFont = new java.awt.Font(slicerFontName, slicerFontStyle, slicerFontSize); java.awt.Font axisFont = new java.awt.Font(axisFontName, axisFontStyle, axisFontSize); java.awt.Font axisTickFont = new java.awt.Font(axisTickFontName, axisTickFontStyle, axisTickFontSize); java.awt.Font legendFont = new java.awt.Font(legendFontName, legendFontStyle, legendFontSize); Plot plot = chart.getPlot(); if (plot instanceof CategoryPlot) { CategoryPlot catPlot = (CategoryPlot) plot; catPlot.getDomainAxis().setLabelFont(axisFont); catPlot.getRangeAxis().setLabelFont(axisFont); catPlot.getDomainAxis().setTickLabelFont(axisTickFont); catPlot.getRangeAxis().setTickLabelFont(axisTickFont); catPlot.getDomainAxis().setMaximumCategoryLabelWidthRatio(100.0f); double angle = -2.0 * Math.PI / 360.0 * (double) tickLabelRotate; CategoryLabelPositions oldp = catPlot.getDomainAxis().getCategoryLabelPositions(); CategoryLabelPositions newp = new CategoryLabelPositions( oldp.getLabelPosition(RectangleEdge.TOP), new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, angle, CategoryLabelWidthType.RANGE, 0.0f), oldp.getLabelPosition(RectangleEdge.LEFT), oldp.getLabelPosition(RectangleEdge.RIGHT)); catPlot.getDomainAxis().setCategoryLabelPositions(newp); } else if (plot instanceof PiePlot3D) { PiePlot3D piePlot = (PiePlot3D) plot; //piePlot.setSectionLabelFont(axisFont); piePlot.setLabelFont(axisFont); //piePlot.setSeriesLabelFont(axisTickFont); //piePlot.setSectionLabelType(piePlot.NO_LABELS); piePlot.setDirection(org.jfree.util.Rotation.CLOCKWISE); piePlot.setForegroundAlpha(0.5f); piePlot.setNoDataMessage("No data to display"); } else if (plot instanceof PiePlot) { PiePlot piePlot = (PiePlot) plot; //piePlot.setSectionLabelFont(axisFont); //piePlot.setSeriesLabelFont(axisTickFont); piePlot.setLabelFont(axisFont); //piePlot.setSectionLabelType(piePlot.NO_LABELS); } LegendTitle legend = (LegendTitle) chart.getLegend(); if (legend != null) { legend.setItemFont(legendFont); /* RectangleAnchor legendRectAnchor=RectangleAnchor.BOTTOM; switch (legendPosition){ case 0: legendRectAnchor = RectangleAnchor.LEFT; break; case 1: legendRectAnchor = RectangleAnchor.TOP; break; case 2: legendRectAnchor = RectangleAnchor.RIGHT; break; case 3: legendRectAnchor = RectangleAnchor.BOTTOM; break; } legend.setLegendItemGraphicAnchor(legendRectAnchor); */ RectangleEdge legendRectEdge = RectangleEdge.BOTTOM; switch (legendPosition) { case 0: legendRectEdge = RectangleEdge.LEFT; break; case 1: legendRectEdge = RectangleEdge.TOP; break; case 2: legendRectEdge = RectangleEdge.RIGHT; break; case 3: legendRectEdge = RectangleEdge.BOTTOM; break; } legend.setPosition(legendRectEdge); } if (showSlicer) { RectangleEdge slicerRectPos = RectangleEdge.BOTTOM; HorizontalAlignment slicerHorizAlignment = HorizontalAlignment.LEFT; switch (slicerPosition) { case 0: slicerRectPos = RectangleEdge.TOP; break; case 1: slicerRectPos = RectangleEdge.BOTTOM; break; case 2: slicerRectPos = RectangleEdge.RIGHT; break; case 3: slicerRectPos = RectangleEdge.LEFT; break; } switch (slicerAlignment) { case 4: slicerHorizAlignment = HorizontalAlignment.CENTER; break; case 3: slicerHorizAlignment = HorizontalAlignment.LEFT; break; case 2: slicerHorizAlignment = HorizontalAlignment.RIGHT; break; } TextTitle slicer = new TextTitle(buildSlicer(), slicerFont, Color.BLACK, slicerRectPos, slicerHorizAlignment, VerticalAlignment.CENTER, new RectangleInsets(0, 0, 0, 0)); slicer.setPosition(slicerRectPos); chart.addSubtitle(slicer); } info = new ChartRenderingInfo(new StandardEntityCollection()); // Write the chart image to the temporary directory HttpSession session = context.getSession(); filename = ServletUtilities.saveChartAsPNG(chart, chartWidth, chartHeight, info, session); } catch (Exception e) { filename = "public_error_500x300.png"; dirty = true; } } // new DOM document DocumentBuilder parser = XmlUtils.getParser(); // get an image map for the chart, wrap it in xchart tags String xchart = "<xchart>" + writeImageMap(filename, info, false) + "</xchart>"; /* if (logger.isDebugEnabled()) { logger.debug("Chart XML"); logger.debug(xchart); } */ // create an InputStream from the DOM document InputStream stream = new ByteArrayInputStream(xchart.getBytes("UTF-8")); document = parser.parse(stream); Element root = document.getDocumentElement(); // create url for img tag String graphURL = getGraphURL(context); Element img = document.createElement("img"); img.setAttribute("src", graphURL); img.setAttribute("width", new Integer(chartWidth).toString()); img.setAttribute("height", new Integer(chartHeight).toString()); img.setAttribute("style", "border:0;"); img.setAttribute("usemap", "#" + filename); root.appendChild(img); return document; }
From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo.java
private static JFreeChart createMultiplePieChart3D(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createMultiplePieChart3D("MultiplePie Chart 3D Demo 1", // chart title dataset, // data TableOrder.BY_COLUMN, // orientation true, // include legend true, // tooltips? false // URLs? );/*from ww w .jav a 2 s . c o m*/ chart.setBackgroundPaint(Color.white); MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot(); JFreeChart pieChart = plot.getPieChart(); PiePlot piePlot = (PiePlot) pieChart.getPlot(); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); piePlot.setSectionPaint("First", gp0); piePlot.setSectionPaint("Second", gp1); piePlot.setSectionPaint("Third", gp2); return chart; }
From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo2.java
private static JFreeChart createMultiplePieChart3D(CategoryDataset dataset) { MultiplePiePlot plot = new MultiplePiePlot(dataset); plot.setDataExtractOrder(TableOrder.BY_COLUMN); plot.setBackgroundPaint(null);//from w ww . j a v a 2 s . c o m plot.setOutlineStroke(null); JFreeChart pieChart = new JFreeChart(new PiePlot3D(null)); TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); seriesTitle.setPosition(RectangleEdge.BOTTOM); pieChart.setTitle(seriesTitle); pieChart.removeLegend(); pieChart.setBackgroundPaint(null); plot.setPieChart(pieChart); if (tooltips) { PieToolTipGenerator tooltipGenerator = new StandardPieToolTipGenerator(); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); pp.setToolTipGenerator(tooltipGenerator); } if (urls) { PieURLGenerator urlGenerator = new StandardPieURLGenerator(); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); pp.setURLGenerator(urlGenerator); } JFreeChart chart = new JFreeChart("MultiplePie Chart 3D Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); PiePlot piePlot = (PiePlot) pieChart.getPlot(); GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); piePlot.setSectionPaint("First", gp0); piePlot.setSectionPaint("Second", gp1); piePlot.setSectionPaint("Third", gp2); return chart; }
From source file:genlab.gui.jfreechart.EnhancedSpiderWebPlot.java
/** * Returns a collection of legend items for the radar chart. * * @return The legend items./*from w w w.j a va 2 s .c om*/ */ public LegendItemCollection getLegendItems() { LegendItemCollection result = new LegendItemCollection(); if (getDataset() == null) { return result; } List keys = null; if (this.dataExtractOrder == TableOrder.BY_ROW) { keys = this.dataset.getRowKeys(); } else if (this.dataExtractOrder == TableOrder.BY_COLUMN) { keys = this.dataset.getColumnKeys(); } if (keys != null) { int series = 0; Iterator iterator = keys.iterator(); Shape shape = getLegendItemShape(); while (iterator.hasNext()) { String label = iterator.next().toString(); String description = label; Paint paint = getSeriesPaint(series); Paint outlinePaint = getSeriesOutlinePaint(series); Stroke stroke = getSeriesOutlineStroke(series); LegendItem item = new LegendItem(label, description, null, null, shape, paint, stroke, outlinePaint); item.setDataset(getDataset()); result.add(item); series++; } } return result; }
From source file:spinworld.gui.RadarPlot.java
/** * Returns a collection of legend items for the spider web chart. * * @return The legend items (never <code>null</code>). *///from w w w . j a va2s . c om public LegendItemCollection getLegendItems() { LegendItemCollection result = new LegendItemCollection(); if (getDataset() == null) { return result; } List<?> keys = null; if (this.dataExtractOrder == TableOrder.BY_ROW) { keys = this.dataset.getRowKeys(); } else if (this.dataExtractOrder == TableOrder.BY_COLUMN) { keys = this.dataset.getColumnKeys(); } if (keys == null) { return result; } int series = 0; Iterator<?> iterator = keys.iterator(); Shape shape = getLegendItemShape(); while (iterator.hasNext()) { Comparable<?> key = (Comparable<?>) iterator.next(); String label = key.toString(); String description = label; Paint paint = getSeriesPaint(series); Paint outlinePaint = getSeriesOutlinePaint(series); Stroke stroke = getHeadOutlineStroke(series); LegendItem item = new LegendItem(label, description, null, null, shape, paint, stroke, outlinePaint); item.setDataset(getDataset()); item.setSeriesKey(key); item.setSeriesIndex(series); result.add(item); series++; } return result; }
From source file:genlab.gui.jfreechart.EnhancedSpiderWebPlot.java
/** * Returns the value to be plotted at the interseries of the * series and the category. This allows us to plot * <code>BY_ROW</code> or <code>BY_COLUMN</code> which basically is just * reversing the definition of the categories and data series being * plotted./* www.j av a2 s .com*/ * * @param series the series to be plotted. * @param cat the category within the series to be plotted. * * @return The value to be plotted (possibly <code>null</code>). * * @see #getDataExtractOrder() */ protected Number getPlotValue(int series, int cat) { Number value = null; if (this.dataExtractOrder == TableOrder.BY_ROW) { value = this.dataset.getValue(series, cat); } else if (this.dataExtractOrder == TableOrder.BY_COLUMN) { value = this.dataset.getValue(cat, series); } return value; }
From source file:NewGUI.Statistics.java
public void setChart(Boolean isChartBar) { SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd"); String sql = ""; String title1 = "", title2 = "", title3 = ""; String s1, s2, s3, s4;// ww w.j a v a 2 s . co m if (cboxType.getSelectedIndex() == 0) { s1 = "importing"; s2 = "import_type_id"; s3 = "thu nhp"; s4 = "import_type"; } else { s1 = "exporting"; s2 = "export_type_id"; s3 = "chi tiu"; s4 = "export_type"; } int caseSQL = 4 * (checkBoxCategory.isSelected() ? 1 : 0) + 2 * (checkBoxMonth.isSelected() ? 1 : 0) + (checkBoxYear.isSelected() ? 1 : 0); int year = jycFrom.getValue(); int month = cboxMonth.getSelectedIndex(); DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset(); DefaultPieDataset pieDataset = new DefaultPieDataset(); ArrayList<Integer> listAccount = filter.getListAcount(); for (int i = 0; i < listAccount.size(); i++) { String sql1 = "select x.user_id,user.userName,y.name,x.value,x.date from " + "(select a.id,a.user_id,a.value,a.date,a.category_id from " + "(select * from " + (cboxType.getSelectedIndex() == 0 ? "importing" : "exporting") + " where date between '" + df.format(jdcFrom.getDate()).toString() + "' and '" + df.format(jdcTo.getDate()).toString() + "' and user_id in(" + getAccountList() + ") " + getStringAmount() + " " + getStringText() + " " + getStringCategory() + ") as a," + "(select * from share where user_id = 1 and type_id=" + (cboxType.getSelectedIndex() == 0 ? 1 : 2) + ")as b where b.transaction_id=a.id)as x," + "user,import_type as y where x.user_id = user.id and x.category_id=y.id"; sql1 = "(" + sql1 + ")as x"; switch (caseSQL) { case 0: sql = "select sum(value),year(date),userName from " + sql1 + " where user_id=" + listAccount.get(i) + " group by(year(date))"; title1 = ""; title2 = "Bng thng k " + s3 + " cc nm"; title3 = ""; break; case 1: sql = "select sum(value),month(date),userName from " + sql1 + " where user_id=" + listAccount.get(i) + " and year(date)=" + year + " group by (month(date))"; title1 = "T."; title2 = "Bng thng k " + s3 + " trong nm " + year; title3 = ""; break; case 2: sql = "select sum(value),year(date),userName from " + sql1 + " where user_id=" + listAccount.get(i) + " and month(date)=" + month + " group by (year(date))"; title1 = ""; title2 = "Bng thng k " + s3 + " thng " + month + " trong cc nm"; title3 = ""; break; case 3: sql = "select sum(value),name,userName from " + sql1 + " where user_id=" + listAccount.get(i) + " and month(date)=" + month + " and year(date)=" + year + " group by name"; title1 = ""; title2 = "Bng thng k " + s3 + " thng " + month + " trong nm " + year; title3 = ""; break; case 4: sql = "select sum(value),year(date),userName from " + sql1 + " where user_id=" + listAccount.get(i) + " group by (year(date))"; title1 = ""; title2 = "Bng thng k " + s3 + " '" + "' trong cc nm"; title3 = ""; break; case 5: sql = "select sum(value),month(date),userName from " + sql1 + "where user_id=" + listAccount.get(i) + " and year(date)=" + year + " group by (month(date))"; title1 = "T."; title2 = "Bng thng k " + s3 + " '" + "' trong nm " + year; title3 = ""; break; case 6: sql = "select sum(value),year(date),userName from " + sql1 + " where user_id=" + listAccount.get(i) + " and month(date)=" + month + " group by (year(date))"; title1 = ""; title2 = "Bng thng k " + s3 + " '" + "' thng " + month + " trong cc nm"; title3 = ""; break; case 7: sql = "select sum(value),year(date),userName from " + sql1 + " where user_id=" + listAccount.get(i) + " and month(date)=" + month + " and year(date)=" + year; title1 = ""; title2 = "Bng thng k " + s3 + " '" + "' thng " + month + " trong nm " + year; title3 = ""; break; } System.out.println(sql); try { ResultSet rs = Database.stm.executeQuery(sql); while (rs.next()) { categoryDataset.setValue(rs.getInt(1), rs.getString(3), title1 + rs.getString(2)); } } catch (Exception ex) { System.out.println("Loi..."); } } if (isChartBar) { chart = ChartFactory.createBarChart3D("", title2, title3, categoryDataset, PlotOrientation.VERTICAL, true, true, false); } else { chart = ChartFactory.createMultiplePieChart3D(title2, categoryDataset, TableOrder.BY_COLUMN, true, true, true); } chartPanel.setChart(chart); jtabpanelView.setSelectedIndex(1); }
From source file:edu.uara.gui.tableeditor.ChartGenerationFrame.java
private void cbo_barChartTableOrderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbo_barChartTableOrderActionPerformed // TODO add your handling code here: if (this.cbo_barChartTableOrder.getSelectedItem().toString().equals("Column")) { this.datasetTable.setTableOrder(TableOrder.BY_COLUMN); this.refreshData(); } else {// w w w. j av a 2s.com this.datasetTable.setTableOrder(TableOrder.BY_ROW); this.refreshData(); } }