List of usage examples for org.jfree.util ShapeUtilities createDiagonalCross
public static Shape createDiagonalCross(final float l, final float t)
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 ww .jav a2 s . com*/ 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:org.cerberus.crud.service.impl.TestCaseExecutionwwwDetService.java
private BufferedImage bi(TimeSeriesCollection timeseriescollection, String xname, String name, int count) { BufferedImage bi = null;/* ww w.ja v a 2s . c o m*/ boolean fc = false; XYDataset xydataset = timeseriescollection; JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(name, xname, name, xydataset, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(false); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { Shape point = ShapeUtilities.createDiagonalCross(1, 1); String[] seriesColors = { "#FF0000", "#D7D6F6", "#0F07F3", "#EEFFBD", "#75C53E", "#FED7BA", "#FE6F01" }; String[] seriesColors2 = { "#D7D6F6", "#0F07F3", "#EEFFBD", "#75C53E", "#FED7BA", "#FE6F01" }; XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); for (int a = 0; a < count; a++) { xylineandshaperenderer.setSeriesShape(a, point); xyitemrenderer.setSeriesStroke(a, new BasicStroke(1.0F)); //TODO check this - fc is always false if (fc) { xylineandshaperenderer.setSeriesPaint(a, Color.decode(seriesColors[count - a - 1])); } else { xylineandshaperenderer.setSeriesPaint(a, Color.decode(seriesColors2[count - a - 1])); } } } DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("hh:mm")); bi = jfreechart.createBufferedImage(500, 270); return bi; }
From source file:GeMSE.GS.Analysis.Stats.OneSamplePCAPanel.java
private void Plot() { double[][] data = _principalComponents.getData(); if (data[0].length < 2) { JOptionPane.showMessageDialog(this, "An error occured when computing principal components. " + "\nRequire at least two principal components, but calculated " + String.valueOf(data[0].length) + "\n", "Not enough data", JOptionPane.ERROR_MESSAGE); return;//from w w w. ja va 2 s. co m } float[] yAxisColor = new float[3]; Color.RGBtoHSB(255, 255, 255, yAxisColor); float[] hsbValues = new float[3]; Color.RGBtoHSB(16, 23, 67, hsbValues); float[] pcColor = new float[3]; Color.RGBtoHSB(255, 255, 0, pcColor); XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries series = new XYSeries("PC"); for (double[] d : data) series.add(d[0], d[1]); dataset.addSeries(series); JFreeChart chart = ChartFactory.createScatterPlot(null, "Principal component 1", "Principal component 2", (XYDataset) dataset); chart.setBackgroundPaint(Color.getHSBColor(hsbValues[0], hsbValues[1], hsbValues[2])); chart.removeLegend(); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.getHSBColor(hsbValues[0], hsbValues[1], hsbValues[2])); Font axisLabelFont = new Font("Dialog", Font.PLAIN, 14); Font axisTickLabelFont = new Font("Dialog", Font.PLAIN, 12); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.getDomainAxis().setTickLabelPaint(Color.white); plot.getDomainAxis().setLabelPaint(Color.white); plot.getDomainAxis().setLabelFont(axisLabelFont); plot.getDomainAxis().setTickLabelFont(axisTickLabelFont); plot.getRangeAxis().setTickLabelPaint(Color.getHSBColor(yAxisColor[0], yAxisColor[1], yAxisColor[2])); plot.getRangeAxis().setLabelPaint(Color.getHSBColor(yAxisColor[0], yAxisColor[1], yAxisColor[2])); plot.getRangeAxis().setLabelFont(axisLabelFont); plot.getRangeAxis().setTickLabelFont(axisTickLabelFont); Shape shape = ShapeUtilities.createDiagonalCross(4, 0.5f); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); renderer.setSeriesShape(0, shape); renderer.setSeriesPaint(0, Color.getHSBColor(pcColor[0], pcColor[1], pcColor[2])); ChartPanel panel = new ChartPanel(chart); Dimension plotDim = plotPanel.getSize(); plotDim.height -= (plotDim.height * 10) / 100; plotDim.width -= (plotDim.width * 10) / 100; panel.setPreferredSize(plotDim); plotPanel.setViewportView(panel); revalidate(); repaint(); }
From source file:jhplot.HChart.java
/** * Get shape depending on the marker index. * //w ww .j a v a 2 s.c o m * @param index * @return */ private Shape getShape(int index, float size) { // Shape s = ShapeUtilities.createDiamond(4F); double x = -0.5 * size; if (index == 0) return new java.awt.geom.Ellipse2D.Double(x, x, size, size); if (index == 1) return new java.awt.geom.Rectangle2D.Double(x, x, size, size); if (index == 2) return ShapeUtilities.createDiamond(size); if (index == 3) return ShapeUtilities.createDownTriangle(size); if (index == 4) return new java.awt.geom.Ellipse2D.Double(x, x, size, size); if (index == 5) return new java.awt.geom.Rectangle2D.Double(x, x, size, size); if (index == 6) return ShapeUtilities.createDiamond(size); if (index == 7) return ShapeUtilities.createDownTriangle(size); if (index == 7) return ShapeUtilities.createRegularCross(0, size); if (index == 8) return ShapeUtilities.createDiagonalCross(0, size); if (index == 9) return ShapeUtilities.createDiagonalCross(0, size); if (index == 10) return ShapeUtilities.createDiagonalCross(0, size); if (index == 11) new java.awt.geom.Ellipse2D.Double(0.5, 0.5, 1, 1); if (index == 12) return ShapeUtilities.createDiagonalCross(0, size); return new java.awt.geom.Ellipse2D.Double(x, x, size, size); }