List of usage examples for org.jfree.chart.plot XYPlot setDomainGridlinePaint
public void setDomainGridlinePaint(Paint paint)
From source file:com.rapidminer.gui.plotter.charts.ParallelPlotter2.java
@Override public void updatePlotter() { prepareData();/* ww w . j a va2s.c o m*/ JFreeChart chart = createChart(this.dataset); // set the background color for the chart... chart.setBackgroundPaint(Color.white); // general plot settings XYPlot plot = chart.getXYPlot(); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); // domain axis SymbolAxis axis = null; if (this.dataTable.isSupportingColumnWeights()) { List<Double> weightList = new LinkedList<>(); for (int column = 0; column < dataTable.getNumberOfColumns(); column++) { if ((!dataTable.isSpecial(column)) && (column != colorColumn)) { weightList.add(this.dataTable.getColumnWeight(column)); } } double[] weights = new double[weightList.size()]; int index = 0; for (Double d : weightList) { weights[index++] = d; } axis = new WeightBasedSymbolAxis(null, domainAxisMap, weights); } else { axis = new SymbolAxis(null, domainAxisMap); } axis.setTickLabelFont(LABEL_FONT); axis.setLabelFont(LABEL_FONT_BOLD); // rotate labels if (isLabelRotating()) { axis.setTickLabelsVisible(true); axis.setVerticalTickLabels(true); } chart.getXYPlot().setDomainAxis(axis); // renderer final ColorizedLineAndShapeRenderer renderer = new ColorizedLineAndShapeRenderer(this.colorMap); plot.setRenderer(renderer); // legend settings if ((colorColumn >= 0) && (this.dataTable.isNominal(colorColumn))) { final LegendItemCollection legendItemCollection = new LegendItemCollection(); for (int i = 0; i < this.dataTable.getNumberOfValues(colorColumn); i++) { legendItemCollection.add(new LegendItem(this.dataTable.mapIndex(colorColumn, i), null, null, null, new Rectangle2D.Double(0, 0, 7, 7), getColorProvider() .getPointColor(i / (double) (this.dataTable.getNumberOfValues(colorColumn) - 1)), new BasicStroke(0.75f), Color.GRAY)); } chart.addLegend(new LegendTitle(new LegendItemSource() { @Override public LegendItemCollection getLegendItems() { return legendItemCollection; } })); LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setPosition(RectangleEdge.TOP); legend.setFrame(BlockBorder.NONE); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); legend.setItemFont(LABEL_FONT); } } else if (colorColumn >= 0) { chart.addLegend(new LegendTitle(new LegendItemSource() { @Override public LegendItemCollection getLegendItems() { LegendItemCollection itemCollection = new LegendItemCollection(); itemCollection.add(new LegendItem("Dummy")); return itemCollection; } }) { private static final long serialVersionUID = 1288380309936848376L; @Override public Object draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.lang.Object params) { if (dataTable.isDate(colorColumn) || dataTable.isTime(colorColumn) || dataTable.isDateTime(colorColumn)) { drawSimpleDateLegend(g2, (int) (area.getCenterX() - 170), (int) (area.getCenterY() + 7), dataTable, colorColumn, renderer.getMinColorValue(), renderer.getMaxColorValue()); return new BlockResult(); } else { final String minColorString = Tools.formatNumber(renderer.getMinColorValue()); final String maxColorString = Tools.formatNumber(renderer.getMaxColorValue()); drawSimpleNumericalLegend(g2, (int) (area.getCenterX() - 90), (int) (area.getCenterY() + 7), dataTable.getColumnName(colorColumn), minColorString, maxColorString); return new BlockResult(); } } @Override public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area) { draw(g2, area, null); } }); } // chart panel if (panel instanceof AbstractChartPanel) { panel.setChart(chart); } else { panel = new AbstractChartPanel(chart, getWidth(), getHeight() - MARGIN); final ChartPanelShiftController controller = new ChartPanelShiftController(panel); panel.addMouseListener(controller); panel.addMouseMotionListener(controller); } // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!! panel.getChartRenderingInfo().setEntityCollection(null); }
From source file:org.agmip.ui.afsirs.frames.GraphOutput.java
public void addRain() { XYSeries rainSeries = new XYSeries("RAIN"); double[][] RAIN = utils.getRain(); for (int i = 0; i < 10/*RAIN.length*/; i++) { for (int j = 0; j < 10/*RAIN[0].length*/; j++) { rainSeries.add(i * RAIN[0].length + j, RAIN[i][j]); }/* w w w .ja v a 2s . c o m*/ } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(rainSeries); JFreeChart chart = ChartFactory.createXYLineChart("Rain", "Days", "Inches", dataset/*, PlotOrientation.VERTICAL, true, true, false*/); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartPanel panel = new ChartPanel(chart); jTabbedPane1.addTab("Rain", panel); }
From source file:org.agmip.ui.afsirs.frames.GraphOutput.java
public void addEvaporationAndTranspiration() { XYSeries etSeries = new XYSeries("ET"); double[][] ET = utils.getET(); for (int i = 0; i < 10/*ET.length*/; i++) { for (int j = 0; j < 10/*ET[0].length*/; j++) { etSeries.add(i * ET[0].length + j, ET[i][j]); }//from w ww . j a va 2 s . c o m } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(etSeries); JFreeChart chart = ChartFactory.createXYLineChart("Evaporation Transpiration", "Days", "Inches", dataset/*, PlotOrientation.VERTICAL, true, true, false*/); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartPanel panel = new ChartPanel(chart); jTabbedPane1.addTab("Evaporation Transpiration", panel); }
From source file:be.nbb.demetra.dfm.output.FactorChart.java
@Override protected void onColorSchemeChange() { XYPlot plot = chartPanel.getChart().getXYPlot(); plot.setBackgroundPaint(themeSupport.getPlotColor()); plot.setDomainGridlinePaint(themeSupport.getGridColor()); plot.setRangeGridlinePaint(themeSupport.getGridColor()); chartPanel.getChart().setBackgroundPaint(themeSupport.getBackColor()); XYLineAndShapeRenderer factor = (XYLineAndShapeRenderer) plot.getRenderer(FACTOR_INDEX); factor.setBasePaint(themeSupport.getLineColor(FACTOR_COLOR)); XYLineAndShapeRenderer filtered = (XYLineAndShapeRenderer) plot.getRenderer(FILTERED_INDEX); filtered.setBasePaint(themeSupport.getLineColor(FILTERED_COLOR)); XYDifferenceRenderer difference = ((XYDifferenceRenderer) plot.getRenderer(DIFFERENCE_INDEX)); Color diffArea = SwingColorSchemeSupport.withAlpha(themeSupport.getAreaColor(DIFFERENCE_COLOR), 150); difference.setPositivePaint(diffArea); difference.setNegativePaint(diffArea); difference.setBasePaint(themeSupport.getLineColor(DIFFERENCE_COLOR)); }
From source file:com.itemanalysis.jmetrik.swing.GraphPanel.java
public void setLineChart(String title, String subtitle, String xlabel, String ylabel) { XYSeriesCollection dataset = new XYSeriesCollection(); chart = ChartFactory.createXYLineChart(title, // chart title xlabel, // x axis label ylabel, // y axis label dataset, // data chartOrientation, showLegend, // include legend true, // tooltips false // urls );/*from www . j a v a 2 s .c o m*/ if (showLegend) { LegendTitle chartTitle = chart.getLegend(); chartTitle.setPosition(legendPosition); } if (subtitle != null && !"".equals(subtitle)) { TextTitle subtitle1 = new TextTitle(subtitle); chart.addSubtitle(subtitle1); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); //can use this code to modify charts for book. DO NOT USE FOR NORMAL FUNCTIONING // NumberAxis yaxis = (NumberAxis)plot.getRangeAxis(); // yaxis.setTickUnit(new NumberTickUnit(.1)); ChartPanel panel = new ChartPanel(chart); panel.getPopupMenu().addSeparator(); this.addJpgMenuItem(this, panel.getPopupMenu()); // this.addEPSMenuItem(this, panel.getPopupMenu());//remove this line for public release versions panel.setPreferredSize(new Dimension(width, height)); chart.setPadding(new RectangleInsets(20.0, 5.0, 20.0, 5.0)); this.setBackground(Color.WHITE); this.add(panel); }
From source file:edu.ucla.stat.SOCR.chart.ChartGenerator.java
protected JFreeChart createQQChart(String title, String xLabel, String yLabel, XYDataset dataset, String other) {/*from w ww.ja v a 2s. c o m*/ // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title xLabel, // x axis label yLabel, // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); // renderer.setShapesVisible(true); renderer.setBaseShapesFilled(true); // renderer.setLinesVisible(false); renderer.setSeriesLinesVisible(1, true); renderer.setSeriesShapesVisible(1, false); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); //renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setUpperMargin(0); rangeAxis.setLowerMargin(0); // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setUpperMargin(0); domainAxis.setLowerMargin(0); // domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. //setQQSummary(dataset); // very confusing return chart; }
From source file:org.agmip.ui.afsirs.frames.GraphOutput.java
public void addWeather() { int nyr = utils.getNYR(); XYSeries etSeries = new XYSeries("ET"); double[][] ET = utils.getET(); for (int i = 0; i < 10/*ET.length*/; i++) { for (int j = 0; j < 10/*ET[0].length*/; j++) { etSeries.add(i * ET[0].length + j, ET[i][j]); }// w ww .j a v a 2 s.com } XYSeries rainSeries = new XYSeries("RAIN"); double[][] RAIN = utils.getRain(); for (int i = 0; i < 10/*RAIN.length*/; i++) { for (int j = 0; j < 10/*RAIN[0].length*/; j++) { rainSeries.add(i * RAIN[0].length + j, RAIN[i][j]); } } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(etSeries); dataset.addSeries(rainSeries); JFreeChart chart = ChartFactory.createXYLineChart("Weather Data", "Days", "Inches", dataset/*, PlotOrientation.VERTICAL, true, true, false*/); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartPanel panel = new ChartPanel(chart); jTabbedPane1.addTab("Weather", panel); }
From source file:br.usp.icmc.gazetteer.SemanticSearchTest.Grafico.java
public ChartPanel interpolado(int index) { // create the chart... JFreeChart graf = ChartFactory.createXYLineChart("Interpolado", // chart title "Recall", // x axis label "Precision", // y axis label createDatasetInterpoled(index), // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );/*from ww w .j a va 2 s.c o m*/ // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... graf.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) graf.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(false); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false); plot.setRenderer(1, renderer2); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. ChartPanel myChartPanel = new ChartPanel(graf, true); return myChartPanel; }
From source file:br.usp.icmc.gazetteer.SemanticSearchTest.Grafico.java
public ChartPanel media11() { // create the chart... JFreeChart graf = ChartFactory.createXYLineChart("Media 11 Pontos", // chart title "Recall", // x axis label "Precision", // y axis label createDatasetOnze(), // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );//from www .j av a2 s . co m // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... graf.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) graf.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(false); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false); plot.setRenderer(1, renderer2); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. ChartPanel myChartPanel = new ChartPanel(graf, true); return myChartPanel; }
From source file:br.usp.icmc.gazetteer.SemanticSearchTest.Grafico.java
public ChartPanel media11(int index) { // create the chart... JFreeChart graf = ChartFactory.createXYLineChart("Media 11 pontos", // chart title "Recall", // x axis label "Precision", // y axis label createDatasetOnze(index), // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );/*from w ww.j ava 2 s . c om*/ // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... graf.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) graf.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(false); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false); plot.setRenderer(1, renderer2); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. ChartPanel myChartPanel = new ChartPanel(graf, true); return myChartPanel; }