List of usage examples for org.jfree.chart.plot XYPlot getRenderer
public XYItemRenderer getRenderer()
From source file:MSUmpire.LCMSPeakStructure.LCMSPeakMS1.java
public void GenerateMassCalibrationRTMap() throws IOException { String pngfile = FilenameUtils.getFullPath(ScanCollectionName) + "/" + FilenameUtils.getBaseName(ScanCollectionName) + "_masscaliRT.png"; XYSeries series = new XYSeries("PSM"); XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); LoessInterpolator loessInterpolator = new LoessInterpolator(0.75, //bandwidth, 2//robustnessIters );/* ww w. j a v a 2 s. c o m*/ for (PSM psm : this.IDsummary.PSMList.values()) { float ppm = InstrumentParameter.CalcSignedPPM(psm.ObserPrecursorMass, psm.NeutralPepMass); series.add(new XYDataItem(psm.RetentionTime, ppm)); } double x[] = new double[IDsummary.PSMList.size()]; double y[] = new double[x.length]; double currentmin = 0f; for (int i = 0; i < series.getItemCount(); i++) { x[i] = (double) series.getX(i); if (x[i] <= currentmin) { x[i] = currentmin + 0.0001f; } currentmin = x[i]; y[i] = (double) series.getY(i); } Masscalibrationfunction = loessInterpolator.interpolate(x, y); XYSeries smoothline = new XYSeries("Loess Regression"); double xvalue = x[0]; while (xvalue < x[x.length - 1]) { smoothline.add(xvalue, Masscalibrationfunction.value(xvalue)); xvalue += 0.05d; } xySeriesCollection.addSeries(smoothline); xySeriesCollection.addSeries(series); JFreeChart chart = ChartFactory.createScatterPlot("Mass calibration", "RT", "Mass error (ppm)", xySeriesCollection, PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) chart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesPaint(1, Color.blue); renderer.setSeriesPaint(0, Color.BLACK); renderer.setSeriesShape(1, new Ellipse2D.Double(0, 0, 3, 3)); renderer.setSeriesStroke(1, new BasicStroke(1.0f)); xyPlot.setBackgroundPaint(Color.white); ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600); }
From source file:org.jfree.chart.demo.CrosshairDemo1.java
/** * Creates a chart./*from w ww . j a va 2 s . co m*/ * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createXYLineChart("Crosshair Demo 1", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainCrosshairVisible(true); plot.setDomainCrosshairLockedOnData(true); plot.setRangeCrosshairVisible(true); plot.setRangeCrosshairLockedOnData(true); final StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer(); renderer.setPlotShapes(true); renderer.setShapesFilled(true); // 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:org.jfree.eastwood.ChartEngine.java
/** * Creates a scatter chart./*from ww w .j a v a 2 s.c o m*/ * * @return A scatter chart. */ private static JFreeChart createScatterChart() { JFreeChart chart = ChartFactory.createScatterPlot(null, null, null, null, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setOutlinePaint(null); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBasePaint(new Color(0x76A4FB)); renderer.setAutoPopulateSeriesPaint(false); GValueAxis xAxis = new GValueAxis(); xAxis.setTickLabelsVisible(false); xAxis.setTickMarksVisible(false); plot.setDomainAxis(xAxis); GValueAxis yAxis = new GValueAxis(); yAxis.setTickLabelsVisible(false); yAxis.setTickMarksVisible(false); plot.setRangeAxis(yAxis); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); return chart; }
From source file:CargarEntrenamiento.grafica2.java
public void grafica1() { s1.add(new Month(2, 2001), 181.8); //s1.add(new Week(1, 1), null); s1.add(new Month(3, 2001), 167.3); s1.add(new Month(4, 2001), 153.8); s1.add(new Month(5, 2001), 167.6); s1.add(new Month(6, 2001), 158.8); s1.add(new Month(7, 2001), 148.3); s1.add(new Month(8, 2001), 153.9); s1.add(new Month(9, 2001), 142.7); s1.add(new Month(10, 2001), 123.2); s1.add(new Month(11, 2001), 131.8); s1.add(new Month(12, 2001), 139.6); s1.add(new Month(1, 2002), 142.9); s1.add(new Month(2, 2002), 138.7); s1.add(new Month(3, 2002), 137.3); s1.add(new Month(4, 2002), 143.9); s1.add(new Month(5, 2002), 139.8); s1.add(new Month(6, 2002), 137.0); s1.add(new Month(7, 2002), 132.8); TimeSeries s2 = new TimeSeries("L&G UK Index Trust"); s2.add(new Month(2, 2001), 129.6); s2.add(new Month(3, 2001), 123.2); s2.add(new Month(4, 2001), 117.2); s2.add(new Month(5, 2001), 124.1); s2.add(new Month(6, 2001), 122.6); s2.add(new Month(7, 2001), 119.2); s2.add(new Month(8, 2001), 116.5); s2.add(new Month(9, 2001), 112.7); s2.add(new Month(10, 2001), 101.5); s2.add(new Month(11, 2001), 106.1); s2.add(new Month(12, 2001), 110.3); s2.add(new Month(1, 2002), 111.7); s2.add(new Month(2, 2002), 111.0); s2.add(new Month(3, 2002), 109.6); s2.add(new Month(4, 2002), 113.2); s2.add(new Month(5, 2002), 111.6); s2.add(new Month(6, 2002), 108.8); s2.add(new Month(7, 2002), 101.6); TimeSeries s3 = new TimeSeries("andres2255"); s3.add(new Month(2, 2001), 129.6); s3.add(new Month(10, 2001), 106.1); s3.add(new Month(1, 2002), 111.7); s3.add(new Month(2, 2002), 111.0); datos.addSeries(s1);/* ww w . ja v a 2 s . co m*/ datos.addSeries(s2); datos.addSeries(s3); grafica = ChartFactory.createTimeSeriesChart("titulo", "etiquetas X", "etiquetaY", datos, true, true, false); /// grafica.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) grafica.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); }
From source file:CargarEntrenamiento.grafica2.java
public void iejmplo() { s1.add(new Month(2, 2001), 181.8); //s1.add(new Week(1, 1), null); s1.add(new Month(3, 2001), 167.3); s1.add(new Month(4, 2001), 153.8); s1.add(new Month(5, 2001), 167.6); s1.add(new Month(6, 2001), 158.8); s1.add(new Month(7, 2001), 148.3); s1.add(new Month(8, 2001), 153.9); s1.add(new Month(9, 2001), 142.7); s1.add(new Month(10, 2001), 123.2); s1.add(new Month(11, 2001), 131.8); s1.add(new Month(12, 2001), 139.6); s1.add(new Month(1, 2002), 142.9); s1.add(new Month(2, 2002), 138.7); s1.add(new Month(3, 2002), 137.3); s1.add(new Month(4, 2002), 143.9); s1.add(new Month(5, 2002), 139.8); s1.add(new Month(6, 2002), 137.0); s1.add(new Month(7, 2002), 132.8); TimeSeries s2 = new TimeSeries("L&G UK Index Trust"); s2.add(new Month(2, 2001), 129.6); s2.add(new Month(3, 2001), 123.2); s2.add(new Month(4, 2001), 117.2); s2.add(new Month(5, 2001), 124.1); s2.add(new Month(6, 2001), 122.6); s2.add(new Month(7, 2001), 119.2); s2.add(new Month(8, 2001), 116.5); s2.add(new Month(9, 2001), 112.7); s2.add(new Month(10, 2001), 101.5); s2.add(new Month(11, 2001), 106.1); s2.add(new Month(12, 2001), 110.3); s2.add(new Month(1, 2002), 111.7); s2.add(new Month(2, 2002), 111.0); s2.add(new Month(3, 2002), 109.6); s2.add(new Month(4, 2002), 113.2); s2.add(new Month(5, 2002), 111.6); s2.add(new Month(6, 2002), 108.8); s2.add(new Month(7, 2002), 101.6); TimeSeries s3 = new TimeSeries("andres2255"); s3.add(new Month(2, 2001), 129.6); s3.add(new Month(10, 2001), 106.1); s3.add(new Month(1, 2002), 111.7); s3.add(new Month(2, 2002), 111.0); datos.addSeries(s1);//from w w w . ja va 2 s . com datos.addSeries(s2); datos.addSeries(s3); grafica = ChartFactory.createTimeSeriesChart("titulo", "etiquetas X", "etiquetaY", datos, true, true, false); /// grafica.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) grafica.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); }
From source file:org.jfree.chart.demo.LineChartDemo2.java
/** * Creates a chart./*from w ww . j a v a2 s . c om*/ * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Line Chart Demo 2", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.HORIZONTAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainCrosshairLockedOnData(true); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairLockedOnData(true); plot.setRangeCrosshairVisible(true); final StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer(); renderer.setPlotShapes(true); renderer.setShapesFilled(true); renderer.setItemLabelsVisible(true); final ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER, TextAnchor.CENTER, Math.PI / 4); renderer.setPositiveItemLabelPosition(p); // 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:slash.navigation.converter.gui.elevationview.ElevationView.java
private XYPlot createPlot(JFreeChart chart) { XYPlot plot = chart.getXYPlot(); plot.setForegroundAlpha(0.65F);/*from w w w . j ava2 s .com*/ NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); Font font = new JLabel().getFont(); rangeAxis.setLabelFont(font); NumberAxis valueAxis = (NumberAxis) plot.getDomainAxis(); valueAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); valueAxis.setLowerMargin(0.0); valueAxis.setUpperMargin(0.0); valueAxis.setLabelFont(font); XYItemRenderer renderer = plot.getRenderer(); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{2}m @ {1} Km", NumberFormat.getIntegerInstance(), NumberFormat.getIntegerInstance())); return plot; }
From source file:edu.unibonn.plotting.TimeSeriesPlotter_Sensors.java
private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart("Sensors", "Time", "Erlang", dataset, false, true, false);//from w w w . java 2 s . co m chart.setBackgroundPaint(Color.white); // final StandardLegend sl = (StandardLegend) chart.getLegend(); // sl.setDisplaySeriesShapes(true); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof StandardXYItemRenderer) { final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; //rr.setPlotShapes(true); rr.setShapesFilled(true); rr.setItemLabelsVisible(true); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("dd-MM-yyyy hh:mm")); return chart; }
From source file:mineria.UI.java
public UI() { this.setLayout(new GridBagLayout()); Label lblnodatos = new Label("NoDatos: "); Label label = new Label("BD: "); JTextField filename = new JTextField("/Users/eduardomartinez/Documents/mineria/representacion.txt"); JTextField nodatos = new JTextField(); nodatos.setText("500"); JTextField funcion = new JTextField("6"); JTextField individuos = new JTextField("200"); JTextField enteros = new JTextField("1"); JTextField decimales = new JTextField("40"); JTextField variables = new JTextField("6"); JTextField Pc = new JTextField("0.9"); JTextField Pm = new JTextField("0.01"); JTextField generaciones = new JTextField("100"); JTextField minimiza = new JTextField("0"); Label lblfuncion = new Label("funcion: "); Label lblindividuos = new Label("individuos: "); Label lblenteros = new Label("enteros: "); Label lbldecimales = new Label("decimales: "); Label lblvariables = new Label("variables: "); Label lblpc = new Label("Pc: "); Label lblpm = new Label("Pm: "); Label lblgeneraciones = new Label("generaciones: "); Label lblminimiza = new Label("[0 Min/1 Max] : "); /*/*w w w . j av a2s .c o m*/ FN=funcion; N =individuos; E =bits_enteros; D =bits_decimales; V =variables; Pc=porcentaje_cruza; Pm=porcentaje_muta; G =generaciones; MM=minimiza; */ JButton openBtn = new JButton("Open BD"); JButton ejecutarEGA = new JButton("Ejecutar EGA"); JTextField resultado = new JTextField(); Label fitness = new Label("fitness: "); XYSeriesCollection datosSerie = new XYSeriesCollection(); AGF agf = new AGF(2); EGA ega = new EGA(); JFreeChart chart = ChartFactory.createScatterPlot("Scatter Plot", // chart title "X", // x axis label "Y", // y axis label datosSerie, // data ***-----PROBLEM------*** PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // create and display a frame... ChartPanel panelChart = new ChartPanel(chart); //leer BD openBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { //datosSerie.removeAllSeries(); if (filename.getText().length() > 0) { agf.LeerDatos(filename.getText(), Integer.parseInt(nodatos.getText())); createDataset(datosSerie, agf.data, "Datos"); chart.fireChartChanged(); } else { JFileChooser openFile = new JFileChooser(); int rVal = openFile.showOpenDialog(null); if (rVal == JFileChooser.APPROVE_OPTION) { filename.setText(openFile.getSelectedFile().getAbsolutePath()); agf.LeerDatos(filename.getText(), Integer.parseInt(nodatos.getText())); //createDataset(datosSerie, agf.data, "Datos"); //chart.fireChartChanged(); } if (rVal == JFileChooser.CANCEL_OPTION) { filename.setText(""); //dir.setText(""); } } } }); ejecutarEGA.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { //datosSerie.removeAllSeries(); if (datosSerie.getSeriesCount() > 1) datosSerie.removeSeries(1); int fn = Integer.parseInt(funcion.getText()); int n = Integer.parseInt(individuos.getText()); int e = Integer.parseInt(enteros.getText()); int d = Integer.parseInt(decimales.getText()); int v = Integer.parseInt(variables.getText()); double pc = Double.parseDouble(Pc.getText()); double pm = Double.parseDouble(Pm.getText()); int g = Integer.parseInt(generaciones.getText()); int mm = Integer.parseInt(minimiza.getText()); ega.setParams(fn, n, e, d, v, pc, pm, g, mm); Resultado res = ega.ejecutarAlgoritmoGenetico(agf); resultado.setText(String.valueOf(res.getFitnessSemental())); res.creaArchivo(); createDataset(datosSerie, res.getFenotipoSemental(), "Centros"); Shape cross = ShapeUtilities.createDiagonalCross(5, 1); XYPlot xyPlot = (XYPlot) chart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesShape(1, cross); renderer.setSeriesPaint(1, Color.blue); chart.fireChartChanged(); } }); //ejecutar AG GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 0; gbc.weighty = 1; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(lblnodatos, gbc); gbc.gridx = 3; gbc.gridy = 0; gbc.weighty = 1; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(nodatos, gbc); gbc.gridx = 2; gbc.gridy = 1; gbc.weighty = 1; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(filename, gbc); gbc.gridx = 3; gbc.gridy = 1; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(openBtn, gbc); gbc.gridx = 2; gbc.gridy = 2; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(fitness, gbc); gbc.gridx = 3; gbc.gridy = 2; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(resultado, gbc); gbc.gridx = 2; gbc.gridy = 3; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(ejecutarEGA, gbc); //-----------------PARAMETROS gbc.gridx = 0; gbc.gridy = 0; gbc.weighty = 1; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(lblfuncion, gbc); gbc.gridx = 1; gbc.gridy = 0; gbc.weighty = 1; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(funcion, gbc); gbc.gridx = 0; gbc.gridy = 1; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(lblindividuos, gbc); gbc.gridx = 1; gbc.gridy = 1; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(individuos, gbc); gbc.gridx = 0; gbc.gridy = 2; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(lblenteros, gbc); gbc.gridx = 1; gbc.gridy = 2; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(enteros, gbc); gbc.gridx = 0; gbc.gridy = 3; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(lbldecimales, gbc); gbc.gridx = 1; gbc.gridy = 3; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(decimales, gbc); gbc.gridx = 0; gbc.gridy = 4; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(lblvariables, gbc); gbc.gridx = 1; gbc.gridy = 4; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(variables, gbc); gbc.gridx = 0; gbc.gridy = 5; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(lblpc, gbc); gbc.gridx = 1; gbc.gridy = 5; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(Pc, gbc); gbc.gridx = 0; gbc.gridy = 6; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(lblpm, gbc); gbc.gridx = 1; gbc.gridy = 6; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(Pm, gbc); gbc.gridx = 0; gbc.gridy = 7; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(lblgeneraciones, gbc); gbc.gridx = 1; gbc.gridy = 7; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(generaciones, gbc); gbc.gridx = 0; gbc.gridy = 8; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(lblminimiza, gbc); gbc.gridx = 1; gbc.gridy = 8; gbc.fill = GridBagConstraints.HORIZONTAL; this.add(minimiza, gbc); gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 0; gbc.gridy = 9; gbc.gridheight = 2; gbc.gridwidth = 4; this.add(panelChart, gbc); this.setTitle("File Chooser"); this.pack(); }
From source file:Perfil_Deportivo.graficaEntrenamientoCargado.java
public graficaEntrenamientoCargado() { datos.removeAllSeries();//from w ww . j a v a2 s. c o m //sxy.add(x[0], y[0]); pesos = new double[EntrenamientoCargado.pesoentreno.length]; fecha = new String[EntrenamientoCargado.fechaentreno.length]; pesos = EntrenamientoCargado.pesoentreno; fecha = EntrenamientoCargado.fechaentreno; ///////////////77 Date fechaDate = null; int n = pesos.length; Calendar calendar = Calendar.getInstance(); for (int i = 0; i < n; i++) { // JOptionPane.showMessageDialog(null, "fecha tio:"+fecha[i]); try { fechaDate = formato.parse(fecha[i]); calendar.setTime(fechaDate); } catch (ParseException ex) { } // JOptionPane.showMessageDialog(null, calendar.get(Calendar.DAY_OF_MONTH)+" "+calendar.get(Calendar.MONTH)+1+" "+ calendar.get(Calendar.YEAR)); s1.add(new Day(calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.YEAR)), pesos[i]); // System.out.print(x[i]+"-"+i+" "); } datos.addSeries(s1); grafica = ChartFactory.createTimeSeriesChart("Progreso de cargas", "Fecha", "Peso", datos, true, true, false); /// grafica.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) grafica.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); }