List of usage examples for org.jfree.chart.renderer.category LineAndShapeRenderer setShapesVisible
public void setShapesVisible(boolean visible)
From source file:com.etest.view.tq.charts.SubjectTestLineChart.java
public static JFreeChart discriminationIndex(int tqCoverageId) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (CellItem ci : CellItemDAO.getItemAnalysisResult(tqCoverageId)) { dataset.setValue((int) (ci.getDiscriminationIndex() * 100), "Discrimination Index", String.valueOf(ci.getItemNo())); }//from w ww.j a v a 2 s. co m JFreeChart chart = ChartFactory.createLineChart("Item Analysis Report", "Item No.", "Discrimination Index (%)", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // customise the renderer... LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setFillPaint(Color.white); return chart; }
From source file:com.etest.view.tq.charts.SubjectTestLineChart.java
public static JFreeChart difficultIndex(int tqCoverageId) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (CellItem ci : CellItemDAO.getItemAnalysisResult(tqCoverageId)) { dataset.setValue((int) (ci.getDifficultIndex() * 100), "Difficulty Index", String.valueOf(ci.getItemNo())); }// www . j av a 2s. c o m JFreeChart chart = ChartFactory.createLineChart("Item Analysis Report", "Item No.", "Difficulty Index (%)", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // customise the renderer... LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setFillPaint(Color.white); return chart; }
From source file:com.sun.japex.report.ChartGenerator.java
static protected void configureLineChart(JFreeChart chart) { CategoryPlot plot = chart.getCategoryPlot(); final DrawingSupplier supplier = new DefaultDrawingSupplier(DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, // Draw a small diamond new Shape[] { new Polygon(new int[] { 3, 0, -3, 0 }, new int[] { 0, 3, 0, -3 }, 4) }); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); plot.setDrawingSupplier(supplier);//ww w. java 2s . c om LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setStroke(new BasicStroke(2.0f)); CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); }
From source file:spec.reporter.Utils.java
public static void createBmResultGraph(BenchmarkRecord record) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); String iterName = ""; double max = 0; double min = Long.MAX_VALUE; for (int i = 0; i < record.iterRecords.size(); i++) { BenchmarkRecord.IterationRecord iterRecord = (BenchmarkRecord.IterationRecord) record.iterRecords .get(i);//www.java 2 s . com String shortName = iterRecord.iterName.replaceFirst("ation", ""); if (iterRecord.score > max) { max = iterRecord.score; iterName = shortName; } if (iterRecord.score < min) { min = iterRecord.score; } dataset.addValue(iterRecord.score, " ", shortName); } JFreeChart chart = ChartFactory.createLineChart(" ", "iterations", Constants.WORKLOAD_METRIC, dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(new Color(201, 222, 254)); plot.setRangeGridlinePaint(Color.WHITE); if (record.isValidRun() && min != Long.MAX_VALUE) { plot.getRangeAxis().setRange(min - 10, max + 10); } else { plot.getRangeAxis().setRange(0, max + 10); } ValueMarker vm = new ValueMarker(record.maxScore); vm.setLabel(Utils.df.format(record.maxScore)); vm.setLabelAnchor(RectangleAnchor.TOP_LEFT); vm.setLabelTextAnchor(TextAnchor.HALF_ASCENT_LEFT); plot.addRangeMarker(vm); CategoryMarker marker = new CategoryMarker(iterName); marker.setDrawAsLine(true); marker.setPaint(vm.getPaint()); plot.addDomainMarker(marker); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setFillPaint(Color.WHITE); renderer.setSeriesPaint(0, Color.BLUE.darker()); try { ChartUtilities.saveChartAsJPEG(new File(Utils.getFullImageName(record.name + "_results")), chart, 300, 200); } catch (Exception e) { System.out.println("Problems..."); } }
From source file:com.tonbeller.jpivot.chart.ChartFactory.java
/** * Creates a line chart with default settings. * * @param title the chart title./* w w w. j a v a2s . co m*/ * @param categoryAxisLabel the label for the category axis. * @param valueAxisLabel the label for the value axis. * @param data the dataset for the chart. * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return a line chart. */ public static JFreeChart createLineChart(String title, java.awt.Font titleFont, String categoryAxisLabel, String valueAxisLabel, CategoryDataset data, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls, CategoryURLGenerator urlGenerator) { CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); ValueAxis valueAxis = new NumberAxis(valueAxisLabel); LineAndShapeRenderer renderer = new LineAndShapeRenderer(); renderer.setLinesVisible(true); renderer.setShapesVisible(false); if (tooltips) { renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator()); } if (urls) { renderer.setItemURLGenerator(urlGenerator); } CategoryPlot plot = new CategoryPlot(data, categoryAxis, valueAxis, renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, titleFont, plot, legend); return chart; }
From source file:com.sun.japex.ChartGenerator.java
static private void configureLineChart(JFreeChart chart) { CategoryPlot plot = chart.getCategoryPlot(); final DrawingSupplier supplier = new DefaultDrawingSupplier(DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, // Draw a small diamond new Shape[] { new Polygon(new int[] { 3, 0, -3, 0 }, new int[] { 0, 3, 0, -3 }, 4) }); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); plot.setDrawingSupplier(supplier);// w w w. j a va2 s. c o m LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setStroke(new BasicStroke(2.0f)); }
From source file:org.talend.dataprofiler.chart.ChartDecorator.java
/** * Decorate the benford law chart. in this method the line chart will be overlay on top of bar chart. * // w ww . j av a 2 s . c om * @param dataset * @param barChart * @param title * @param categoryAxisLabel * @param dotChartLabels * @param formalValues * @return JFreeChart */ @SuppressWarnings("deprecation") public static JFreeChart decorateBenfordLawChartByKCD(CategoryDataset dataset, Object customerDataset, JFreeChart barChart, String title, String categoryAxisLabel, List<String> dotChartLabels, double[] formalValues) { CategoryPlot barplot = barChart.getCategoryPlot(); decorateBarChart(barChart, new BenfordLawLineAndShapeRenderer()); // display percentage on top of the bar DecimalFormat df = new DecimalFormat(PERCENT_FORMAT); barplot.getRenderer().setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", df)); //$NON-NLS-1$ barplot.getRenderer().setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER)); // set the display of Y axis NumberAxis numAxis = (NumberAxis) barplot.getRangeAxis(); numAxis.setNumberFormatOverride(df); CategoryDataset lineDataset = getLineDataset(dotChartLabels, formalValues); JFreeChart lineChart = ChartFactory.createLineChart(null, title, categoryAxisLabel, lineDataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = lineChart.getCategoryPlot(); if (customerDataset != null) { barplot.setDataset(2, new EncapsulationCumstomerDataset(dataset, customerDataset)); } // show the value on the right axis of the chart(keep the comment) // NumberAxis numberaxis = new NumberAxis(DefaultMessagesImpl.getString("TopChartFactory.Value")); // plot.setRangeAxis(10, numberaxis); NumberAxis vn = (NumberAxis) plot.getRangeAxis(); vn.setNumberFormatOverride(df); // set points format LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setPaint(COLOR_LIST.get(1)); renderer.setSeriesShape(1, new Rectangle2D.Double(-1.5, -1.5, 3, 3)); renderer.setShapesVisible(true); // show the point shape renderer.setBaseLinesVisible(false);// do not show the line // add the bar chart into the line chart CategoryItemRenderer barChartRender = barplot.getRenderer(); barplot.setDataset(0, lineDataset); barplot.setRenderer(0, plot.getRenderer()); barplot.setDataset(1, dataset); barplot.setRenderer(1, barChartRender); return barChart; }
From source file:org.pentaho.plugin.jfreereport.reportcharts.LineChartExpression.java
protected void configureChart(final JFreeChart chart) { super.configureChart(chart); final CategoryPlot cpl = chart.getCategoryPlot(); final CategoryItemRenderer renderer = cpl.getRenderer(); renderer.setStroke(translateLineStyle(lineWidth, lineStyle)); if (renderer instanceof LineAndShapeRenderer) { final LineAndShapeRenderer shapeRenderer = (LineAndShapeRenderer) renderer; shapeRenderer.setShapesVisible(isMarkersVisible()); shapeRenderer.setBaseShapesFilled(isMarkersVisible()); }// w w w . j a v a 2 s.c om }
From source file:peakmlviewer.widgets.IPeakIntensityGraph.java
@SuppressWarnings("deprecation") public IPeakIntensityGraph(Composite parent, int style) { super(parent, style | SWT.EMBEDDED); // create the components linechart = ChartFactory.createLineChart(null, "", "Intensity", dataset, PlotOrientation.VERTICAL, false, // legend false, // tooltips false // urls );/* ww w . j a va 2 s.c om*/ CategoryPlot plot = (CategoryPlot) linechart.getPlot(); CategoryAxis axis = (CategoryAxis) plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setShapesFilled(true); renderer.setShapesVisible(true); linechart.setBackgroundPaint(java.awt.Color.WHITE); linechart.setBorderVisible(false); linechart.setAntiAlias(true); plot.setBackgroundPaint(java.awt.Color.WHITE); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); // add the components // -------------------------------------------------------------------------------- // This uses the SWT-trick for embedding AWT-controls in an SWT-Composite. try { System.setProperty("sun.awt.noerasebackground", "true"); } catch (NoSuchMethodError error) { ; } // create a new ChartPanel, without the popup-menu (5x false) java.awt.Frame frame = org.eclipse.swt.awt.SWT_AWT.new_Frame(this); frame.add(new ChartPanel(linechart, false, false, false, false, false)); // -------------------------------------------------------------------------------- }
From source file:org.bench4Q.console.ui.section.R_RealSessionShowSection.java
private JPanel printPic() throws IOException { double[][] value = new double[2][testduring]; for (int i = 0; i < value[0].length; ++i) { value[0][i] = i;//from w w w . ja v a 2 s.c o m value[1][i] = loadStart[i]; } // calculate the avrg load start every second. int avrgLoad = 0; for (int i = 0; i < loadStart.length; i++) { avrgLoad += loadStart[i]; } avrgLoad /= testduring; DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset(); String series1 = "real"; for (int i = 0; i < value[0].length; ++i) { defaultcategorydataset.addValue(value[1][i], series1, new Integer((int) value[0][i])); } JFreeChart chart = ChartFactory.createLineChart("REAL LOAD:" + avrgLoad, "time", "load", defaultcategorydataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) chart.getPlot(); categoryplot.setBackgroundPaint(Color.WHITE); categoryplot.setRangeGridlinePaint(Color.white); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setAutoRangeIncludesZero(true); LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer(); lineandshaperenderer.setShapesVisible(false); lineandshaperenderer.setSeriesStroke(0, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 1F, 1F }, 0.0F)); return new ChartPanel(chart); }