List of usage examples for org.jfree.chart ChartFactory createXYLineChart
public static JFreeChart createXYLineChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
From source file:org.operamasks.faces.render.graph.LineChartRenderer.java
protected JFreeChart createChart(UIChart comp) { Dataset dataset = createDataset(comp); JFreeChart chart = null;/*from w w w. j a va2 s . c o m*/ if (dataset instanceof CategoryDataset) { if (comp.isEffect3D()) { chart = ChartFactory.createLineChart3D(null, null, null, (CategoryDataset) dataset, getChartOrientation(comp), false, false, false); } else { chart = ChartFactory.createLineChart(null, null, null, (CategoryDataset) dataset, getChartOrientation(comp), false, false, false); } } else if (dataset instanceof TimeSeriesCollection) { chart = ChartFactory.createTimeSeriesChart(null, null, null, (XYDataset) dataset, false, false, false); ((XYPlot) chart.getPlot()).setOrientation(getChartOrientation(comp)); } else if (dataset instanceof XYDataset) { chart = ChartFactory.createXYLineChart(null, null, null, (XYDataset) dataset, getChartOrientation(comp), false, false, false); } return chart; }
From source file:gda.plots.DataMagnifierWindow.java
/** * Sets the SimplePlot to be magnified./*w w w .j a v a2 s . co m*/ * * @param simplePlot * the SimplePlot which the magnifier will be Magnifying * @param collection */ @Override public void setSimplePlot(SimplePlot simplePlot, XYSeriesCollection collection) { this.simplePlot = simplePlot; setTitle("Data Magnifier"); // The magnifiedPlot is effectively just another view of the data of the // simplePlot. By creating a JFreeChart and extracting its plot we get // all // the tediouse work done elsewhere. JFreeChart magnifiedChart = ChartFactory.createXYLineChart(simplePlot.getTitle(), null, null, collection, PlotOrientation.VERTICAL, false, false, false); magnifiedChart.setAntiAlias(false); magnifiedPlot = magnifiedChart.getXYPlot(); magnifiedPlot.setRenderer(simplePlot.getChart().getXYPlot().getRenderer()); if (simplePlot.isShowToolTip()) magnifiedPlot.getRenderer().setToolTipGenerator(new SimpleXYToolTipGenerator()); add(new DataMagnifierPanel()); }
From source file:org.audiveris.omr.util.ChartPlotter.java
/** * Creates a new {@code ChartPlotter} object. * * @param title chart title/*w w w . j ava 2 s.c o m*/ * @param xLabel x-axis label * @param yLabel y-axis label */ public ChartPlotter(String title, String xLabel, String yLabel) { chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, dataset, PlotOrientation.VERTICAL, true, // Show legend false, // Show tool tips false // urls ); final XYPlot plot = (XYPlot) chart.getPlot(); plot.setRenderer(renderer); }
From source file:com.griddynamics.jagger.reporting.chart.ChartHelper.java
public static JFreeChart createXYChart(String title, XYDataset data, String xLabel, String yLabel, int pointRadius, int lineThickness, ColorTheme theme) { JFreeChart chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, data, PlotOrientation.VERTICAL, true, false, false);/* w w w . java 2s. c o m*/ formatColorTheme(chart, theme); XYPlot plot = (XYPlot) chart.getPlot(); Shape icon = new Ellipse2D.Double(-pointRadius, -pointRadius, pointRadius * 2, pointRadius * 2); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); plot.setRenderer(renderer); Color[] colors = generateJetSpectrum(data.getSeriesCount()); for (int i = 0; i < data.getSeriesCount(); i++) { plot.getRenderer().setSeriesStroke(i, new BasicStroke(lineThickness)); plot.getRenderer().setSeriesShape(i, icon); ((XYLineAndShapeRenderer) plot.getRenderer()).setSeriesShapesVisible(i, true); ((XYLineAndShapeRenderer) plot.getRenderer()).setSeriesShapesFilled(i, true); plot.getRenderer().setSeriesPaint(i, colors[i]); } LegendTitle legend = chart.getLegend(); Font legendFont = legend.getItemFont(); float legendFontSize = legendFont.getSize(); Font newLegendFont = legendFont.deriveFont(legendFontSize * 0.6f); legend.setItemFont(newLegendFont); ValueAxis domainAxis = ((XYPlot) chart.getPlot()).getDomainAxis(); Font domainAxisLabelFont = domainAxis.getLabelFont(); float domainAxisLabelFontSize = domainAxisLabelFont.getSize(); domainAxis.setLabelFont(domainAxisLabelFont.deriveFont(domainAxisLabelFontSize * 0.6f)); Font domainAxisTickLabelFont = domainAxis.getTickLabelFont(); float domainAxisTickLabelFontSize = domainAxisTickLabelFont.getSize(); domainAxis.setTickLabelFont(domainAxisTickLabelFont.deriveFont(domainAxisTickLabelFontSize * 0.6f)); ValueAxis rangeAxis = ((XYPlot) chart.getPlot()).getRangeAxis(); Font rangeAxisLabelFont = rangeAxis.getLabelFont(); float rangeAxisLabelFontSize = rangeAxisLabelFont.getSize(); rangeAxis.setLabelFont(rangeAxisLabelFont.deriveFont(rangeAxisLabelFontSize * 0.6f)); Font rangeAxisTickLabelFont = rangeAxis.getTickLabelFont(); float rangeAxisTickLabelFontSize = rangeAxisTickLabelFont.getSize(); rangeAxis.setTickLabelFont(rangeAxisTickLabelFont.deriveFont(rangeAxisTickLabelFontSize * 0.6f)); return chart; }
From source file:sturesy.votinganalysis.TimeChart.java
/** * Creates an XYSeries-ChartPanel//w ww. j a v a2s.c om * * @param votes * votes to use * @return ChartPanel */ private ChartPanel getXYSeriesChart(Set<Vote> votes) { final XYSeries series = new XYSeries(Localize.getString("label.votes.over.time")); if (votes.size() != 0) { double[] dubble = createArrayOfVotes(votes); for (int i = 0; i < dubble.length; i++) { series.add(i, dubble[i]); } } final XYSeriesCollection data = new XYSeriesCollection(series); final JFreeChart chart = ChartFactory.createXYLineChart(Localize.getString("label.votes.over.time"), Localize.getString("label.time.seconds"), Localize.getString("label.amount.votes"), data, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(_background); chart.getPlot().setNoDataMessage("NO DATA"); chart.getXYPlot().getRenderer().setSeriesStroke(0, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f)); chart.getXYPlot().getRenderer().setSeriesPaint(0, new Color(255, 140, 0)); chart.getXYPlot().getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); chart.getXYPlot().getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartPanel chartpanel = new ChartPanel(chart); return chartpanel; }
From source file:org.gvsig.gui.beans.graphic.GraphicChartPanel.java
/** * Creates a chart./*from ww w .ja v a 2s . c om*/ * @param dataset the dataset. * @return A chart. */ private void createChart() { chart = ChartFactory.createXYLineChart(null, null, null, dataset, PlotOrientation.VERTICAL, false, true, true); // Definir la lista de colores XYPlot plot = chart.getXYPlot(); plot.getRenderer().setSeriesPaint(0, Color.red); plot.getRenderer().setSeriesPaint(1, Color.green); plot.getRenderer().setSeriesPaint(2, Color.blue); plot.getRenderer().setSeriesPaint(3, Color.cyan); plot.getRenderer().setSeriesPaint(4, Color.black); plot.getRenderer().setSeriesPaint(5, Color.darkGray); plot.getRenderer().setSeriesPaint(6, Color.gray); plot.getRenderer().setSeriesPaint(7, Color.magenta); plot.getRenderer().setSeriesPaint(8, Color.yellow); plot.getRenderer().setSeriesPaint(9, Color.orange); Image img = new ImageIcon(getClass().getResource("images/splash.png")).getImage(); plot.setBackgroundPaint(null); plot.setBackgroundImageAlpha(0.18f); plot.setBackgroundImage(img); }
From source file:fr.ign.cogit.simplu3d.rjmcmc.generic.visitor.StatsVisitor.java
/** * Creates a sample chart./*from w ww . j av a 2 s.c om*/ * * @param dataset * the dataset. * @return A sample chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart result = ChartFactory.createXYLineChart("volution de l'nergie", "Itration", "nergie", dataset, PlotOrientation.VERTICAL, true, true, true); result.setBorderPaint(Color.white); result.setBackgroundPaint(Color.white); final XYPlot plot = result.getXYPlot(); Font font = new Font("Verdana", Font.PLAIN, 32); Font font2 = new Font("Verdana", Font.PLAIN, 28); // axe x ValueAxis axis = plot.getDomainAxis(); axis.setLabelFont(font); axis.setTickLabelFont(font2); axis.setAutoRange(true); // axis.setFixedAutoRange(60000.0); // 60 seconds axis = plot.getRangeAxis(); // axe y ValueAxis axis2 = plot.getRangeAxis(); axis2.setLabelFont(font); axis2.setTickLabelFont(font2); axis2.setAutoRange(true); // axis.setFixedAutoRange(60000.0); // 60 seconds axis2 = plot.getRangeAxis(); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setBackgroundPaint(Color.white); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, new Color(255, 0, 0)); renderer.setSeriesStroke(0, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f)); renderer.setLegendTextFont(0, font2); renderer.setSeriesPaint(1, new Color(2, 157, 116)); renderer.setSeriesStroke(1, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f)); renderer.setLegendTextFont(1, font2); renderer.setSeriesPaint(2, new Color(112, 147, 219)); renderer.setSeriesStroke(2, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f)); renderer.setLegendTextFont(2, font2); renderer.setSeriesPaint(3, new Color(140, 23, 23)); renderer.setSeriesStroke(3, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 6.0f }, 0.0f)); renderer.setLegendTextFont(3, font2); // axis.setRange(0.0, 200.0); return result; }
From source file:com.seniorproject.augmentedreality.chart.ChartCreator.java
private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart1 = ChartFactory.createXYLineChart(this.title[0], // chart title "Intensity", // x axis label "number of pixel", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );/* w w w .j a va2 s . c o m*/ chart1.setBackgroundPaint(Color.white); final XYPlot plot = chart1.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); // renderer.setSeriesLinesVisible(5, true); // renderer.setSeriesShapesVisible(1, false); // plot.setRenderer(renderer); // final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart1; }
From source file:de.fhffm.jad.demo.view.LineChartPanel.java
/** * Creates a sample chart./*from w ww.j a va2s . c om*/ * * @param dataset a dataset. * * @return The chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Realtime Anomaly Detection", // chart title "Time", // x axis label "Percent", // 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... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:gui.Grafico.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor./* ww w . jav a 2 s . c o m*/ */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new javax.swing.JPanel(); jPanel2 = new ChartPanel(ChartFactory.createXYLineChart("Grfico", "X", "Y", set, PlotOrientation.VERTICAL, true, true, false)); jPanel3 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); setTitle("Grfico"); jPanel1.setBackground(new java.awt.Color(252, 255, 252)); jPanel2.setBackground(new java.awt.Color(254, 255, 254)); jPanel2.setForeground(new java.awt.Color(0, 0, 0)); jPanel2.setFont(new java.awt.Font("Ubuntu Light", 0, 24)); // NOI18N jPanel2.setPreferredSize(new java.awt.Dimension(877, 338)); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 782, Short.MAX_VALUE)); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 0, Short.MAX_VALUE)); jPanel3.setBackground(new java.awt.Color(254, 255, 254)); jScrollPane1.setBackground(new java.awt.Color(255, 255, 255)); jScrollPane1.setForeground(new java.awt.Color(0, 0, 0)); jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); jScrollPane1.setFont(new java.awt.Font("Ubuntu Light", 0, 24)); // NOI18N jScrollPane1.setMaximumSize(new java.awt.Dimension(453, 324)); jScrollPane1.setMinimumSize(new java.awt.Dimension(453, 324)); jScrollPane1.setPreferredSize(new java.awt.Dimension(453, 324)); jTable1.setAutoCreateRowSorter(true); jTable1.setFont(new java.awt.Font("Ubuntu Light", 0, 24)); // NOI18N jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] { }, new String[] { "Mostrar", "Funcin" }) { Class[] types = new Class[] { java.lang.Boolean.class, java.lang.String.class }; boolean[] canEdit = new boolean[] { true, false }; public Class getColumnClass(int columnIndex) { return types[columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; } }); jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); jTable1.setCellSelectionEnabled(false); jTable1.setDragEnabled(true); jTable1.setFillsViewportHeight(true); jTable1.setIntercellSpacing(new java.awt.Dimension(4, 4)); jTable1.setRowHeight(44); jTable1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { botonDecidirMostrarFuncion(evt); } }); jScrollPane1.setViewportView(jTable1); jTable1.getColumnModel().getSelectionModel() .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); jTable1.getColumnModel().getColumn(0).setMinWidth(64); jTable1.getColumnModel().getColumn(0).setPreferredWidth(64); jTable1.getColumnModel().getColumn(0).setMaxWidth(64); jTable1.getColumnModel().getColumn(1).setPreferredWidth(256); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout .setHorizontalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 325, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 348, Short.MAX_VALUE)); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 782, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 348, Short.MAX_VALUE))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); pack(); }