List of usage examples for org.jfree.chart JFreeChart getTitle
public TextTitle getTitle()
From source file:Util.PacketGenerator.java
public static void GenerateGraph() { try {/*from w w w . j ava2 s. c o m*/ for (int j = 6; j <= 6; j++) { File real = new File("D:\\Mestrado\\SketchMatrix\\trunk\\Simulations\\Analise\\Scenario1\\Topology" + j + "\\Real.csv"); for (int k = 1; k <= 4; k++) { File simu = new File( "D:\\Mestrado\\SketchMatrix\\trunk\\Simulations\\Analise\\Scenario1\\Topology" + j + "\\SimulacaoInstancia" + k + ".csv"); FileInputStream simuFIS = new FileInputStream(simu); DataInputStream simuDIS = new DataInputStream(simuFIS); BufferedReader simuBR = new BufferedReader(new InputStreamReader(simuDIS)); FileInputStream realFIS = new FileInputStream(real); DataInputStream realDIS = new DataInputStream(realFIS); BufferedReader realBR = new BufferedReader(new InputStreamReader(realDIS)); String lineSimu = simuBR.readLine(); String lineReal = realBR.readLine(); XYSeries matrix = new XYSeries("Matriz", false, true); while (lineSimu != null && lineReal != null) { lineSimu = lineSimu.replaceAll(",", "."); String[] simuMatriz = lineSimu.split(";"); String[] realMatriz = lineReal.split(";"); for (int i = 0; i < simuMatriz.length; i++) { try { Integer valorReal = Integer.parseInt(realMatriz[i]); Float valorSimu = Float.parseFloat(simuMatriz[i]); matrix.add(valorReal.doubleValue() / 1000.0, valorSimu.doubleValue() / 1000.0); } catch (NumberFormatException ex) { } } lineSimu = simuBR.readLine(); lineReal = realBR.readLine(); } simuFIS.close(); simuDIS.close(); simuBR.close(); realFIS.close(); realDIS.close(); realBR.close(); double maxPlot = Double.max(matrix.getMaxX(), matrix.getMaxY()) * 1.1; XYSeries middle = new XYSeries("Referncia"); ; middle.add(0, 0); middle.add(maxPlot, maxPlot); XYSeries max = new XYSeries("Superior 20%"); max.add(0, 0); max.add(maxPlot, maxPlot * 1.2); XYSeries min = new XYSeries("Inferior 20%"); min.add(0, 0); min.add(maxPlot, maxPlot * 0.8); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(middle); dataset.addSeries(matrix); dataset.addSeries(max); dataset.addSeries(min); JFreeChart chart; if (k == 4) { chart = ChartFactory.createXYLineChart("Matriz de Trfego", "Real", "CMO-MT", dataset); } else { chart = ChartFactory.createXYLineChart("Matriz de Trfego", "CMO-MT", "Zhao", dataset); } chart.setBackgroundPaint(Color.WHITE); chart.getPlot().setBackgroundPaint(Color.WHITE); chart.getTitle().setFont(new Font("Times New Roman", Font.BOLD, 13)); chart.getLegend().setItemFont(new Font("Times New Roman", Font.TRUETYPE_FONT, 10)); chart.getXYPlot().getDomainAxis().setLabelFont(new Font("Times New Roman", Font.BOLD, 10)); chart.getXYPlot().getDomainAxis() .setTickLabelFont(new Font("Times New Roman", Font.TRUETYPE_FONT, 1)); chart.getXYPlot().getRangeAxis().setLabelFont(new Font("Times New Roman", Font.BOLD, 10)); chart.getXYPlot().getRangeAxis() .setTickLabelFont(new Font("Times New Roman", Font.TRUETYPE_FONT, 1)); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer(); renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, true); renderer.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[] { 0.1f }, 0.0f)); renderer.setSeriesShape(1, new Ellipse2D.Float(-1.5f, -1.5f, 3f, 3f)); renderer.setSeriesStroke(2, new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[] { 3.0f }, 0.0f)); renderer.setSeriesStroke(3, new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[] { 3.0f }, 0.0f)); renderer.setSeriesPaint(0, Color.BLACK); renderer.setSeriesPaint(1, Color.BLACK); renderer.setSeriesPaint(2, Color.BLACK); renderer.setSeriesPaint(3, Color.BLACK); int width = (int) (192 * 1.5f); /* Width of the image */ int height = (int) (144 * 1.5f); /* Height of the image */ File XYChart = new File( "D:\\Mestrado\\SketchMatrix\\trunk\\Simulations\\Analise\\Scenario1\\Topology" + j + "\\SimulacaoInstancia" + k + ".jpeg"); ChartUtilities.saveChartAsJPEG(XYChart, chart, width, height); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:net.imglib2.script.analysis.BarChart.java
static private void setBackgroundDefault(final JFreeChart chart) { BasicStroke gridStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 1.0f }, 0.0f); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRangeGridlineStroke(gridStroke); plot.setDomainGridlineStroke(gridStroke); plot.setBackgroundPaint(new Color(235, 235, 235)); plot.setRangeGridlinePaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setOutlineVisible(false);/*w w w . j a v a2 s. co m*/ plot.getDomainAxis().setAxisLineVisible(false); plot.getRangeAxis().setAxisLineVisible(false); plot.getDomainAxis().setLabelPaint(Color.gray); plot.getRangeAxis().setLabelPaint(Color.gray); plot.getDomainAxis().setTickLabelPaint(Color.gray); plot.getRangeAxis().setTickLabelPaint(Color.gray); chart.getTitle().setPaint(Color.gray); }
From source file:net.imglib2.script.analysis.Histogram.java
static private final void setBackgroundDefault(final JFreeChart chart) { BasicStroke gridStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 1.0f }, 0.0f); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeGridlineStroke(gridStroke); plot.setDomainGridlineStroke(gridStroke); plot.setBackgroundPaint(new Color(235, 235, 235)); plot.setRangeGridlinePaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setOutlineVisible(false);//from w ww .j a va2 s . c o m plot.getDomainAxis().setAxisLineVisible(false); plot.getRangeAxis().setAxisLineVisible(false); plot.getDomainAxis().setLabelPaint(Color.gray); plot.getRangeAxis().setLabelPaint(Color.gray); plot.getDomainAxis().setTickLabelPaint(Color.gray); plot.getRangeAxis().setTickLabelPaint(Color.gray); chart.getTitle().setPaint(Color.gray); }
From source file:org.ala.spatial.web.services.GDMWSController.java
public static void generateChart5(String outputdir, String plotName, String plotData) { try {/*w w w. java 2 s. c om*/ CSVReader csv = new CSVReader(new FileReader(plotData)); List<String[]> rawdata = csv.readAll(); double[][] dataCht = new double[2][rawdata.size() - 1]; for (int i = 1; i < rawdata.size(); i++) { String[] row = rawdata.get(i); dataCht[0][i - 1] = Double.parseDouble(row[0]); dataCht[1][i - 1] = Double.parseDouble(row[1]); } DefaultXYDataset dataset = new DefaultXYDataset(); dataset.addSeries("", dataCht); System.out.println("Setting up jChart for " + plotName); //generateChartByType(plotName, plotName, "f("+plotName+")", null, outputdir, "xyline", plotName); JFreeChart jChart = ChartFactory.createXYLineChart(plotName, plotName, "f(" + plotName + ")", dataset, PlotOrientation.VERTICAL, false, false, false); jChart.getTitle().setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14)); XYPlot plot = (XYPlot) jChart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlineStroke(new BasicStroke(0.5F, 0, 1)); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlineStroke(new BasicStroke(0.5F, 0, 1)); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setAutoRangeIncludesZero(false); domain.setAxisLineVisible(false); domain.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setAutoRangeIncludesZero(false); range.setAxisLineVisible(false); range.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); System.out.println("Writing image...."); ChartUtilities.saveChartAsPNG(new File(outputdir + "plots/" + plotName + ".png"), jChart, 500, 500); ChartUtilities.saveChartAsPNG(new File(outputdir + "plots/" + plotName + "_thumb.png"), jChart, 210, 140); } catch (Exception e) { System.out.println("Unable to generate charts 2 and 3:"); e.printStackTrace(System.out); } }
From source file:jmbench.plots.SummaryWhiskerPlot.java
public void displayWindow(int width, int height) { JFreeChart chart = createChart(); ChartFrame window = new ChartFrame(chart.getTitle().getText(), chart); window.setMinimumSize(new Dimension(width, height)); window.setPreferredSize(window.getMinimumSize()); window.setVisible(true);//from ww w . j av a 2s.c o m }
From source file:com.tencent.wstt.apt.chart.PieChart.java
private JFreeChart createChart() { this.dataset = new DefaultPieDataset(); final JFreeChart chart = ChartFactory.createPieChart("??", this.dataset, true, true, false); chart.getTitle().setFont(new Font("", Font.BOLD, 20)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}:{1}")); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false);//from ww w .j a v a2 s. c o m plot.setLabelGap(0.02); return chart; }
From source file:daylightchart.options.chart.TitleOptions.java
/** * {@inheritDoc}/*from w w w .j a v a 2 s . c o m*/ * * @see BaseChartOptions#copyFromChart(org.jfree.chart.JFreeChart) */ @Override public void copyFromChart(final JFreeChart chart) { final TextTitle title = chart.getTitle(); if (title != null) { titleFont = title.getFont(); titlePaint = title.getPaint(); titleText = title.getText(); } }
From source file:net.sf.dynamicreports.test.jasper.chart.ChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//from w w w.ja v a 2 s.c o m chartCountTest("summary.chart1", 1); JFreeChart chart = getChart("summary.chart1", 0); TextTitle title = chart.getTitle(); Assert.assertEquals("title", "title", title.getText()); Assert.assertEquals("title color", Color.BLUE, title.getPaint()); Assert.assertEquals("title font", new Font("Arial", Font.BOLD, 10), title.getFont()); Assert.assertEquals("title position", RectangleEdge.RIGHT, title.getPosition()); TextTitle subtitle = (TextTitle) chart.getSubtitle(1); Assert.assertEquals("subtitle", "subtitle", subtitle.getText()); Assert.assertEquals("subtitle color", Color.CYAN, subtitle.getPaint()); Assert.assertEquals("subtitle font", new Font("Arial", Font.PLAIN, 10), subtitle.getFont()); LegendTitle legend = (LegendTitle) chart.getSubtitle(0); Assert.assertEquals("legend color", Color.BLUE, legend.getItemPaint()); Assert.assertEquals("legend backgroundcolor", Color.LIGHT_GRAY, legend.getBackgroundPaint()); Assert.assertEquals("legend font", new Font("Courier New", Font.PLAIN, 10), legend.getItemFont()); Assert.assertEquals("legend position", RectangleEdge.LEFT, legend.getPosition()); chartCountTest("summary.chart2", 1); chart = getChart("summary.chart2", 0); Assert.assertNull("legend", chart.getLegend()); Assert.assertEquals("plot orientation", PlotOrientation.HORIZONTAL, chart.getCategoryPlot().getOrientation()); Assert.assertEquals("plot series colors", Color.BLUE, chart.getPlot().getDrawingSupplier().getNextPaint()); Assert.assertEquals("plot series colors", Color.GREEN, chart.getPlot().getDrawingSupplier().getNextPaint()); Assert.assertEquals("plot series colors", Color.RED, chart.getPlot().getDrawingSupplier().getNextPaint()); }
From source file:userInterface.MonitoringTeamRole.EnvironmentJPanel.java
private void jLabel1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel1MouseClicked // TODO add your handling code here: JFreeChart chart = createChart(createDataset()); chart.setBackgroundPaint(Color.YELLOW); chart.getTitle().setPaint(Color.red); ChartFrame frame = new ChartFrame("XYChart", chart); frame.setVisible(true);/*from w w w . ja v a 2 s . co m*/ frame.setSize(450, 500); }
From source file:daylightchart.options.chart.TitleOptions.java
/** * {@inheritDoc}/* w w w . ja v a 2 s . c o m*/ * * @see BaseChartOptions#updateChart(org.jfree.chart.JFreeChart) */ @Override public void updateChart(final JFreeChart chart) { if (hideTitle) { final TextTitle title = chart.getTitle(); if (title != null) { title.setFont(titleFont); title.setPaint(titlePaint); title.setText(titleText); } } else { chart.setTitle((TextTitle) null); } }