List of usage examples for org.jfree.chart.plot XYPlot setOutlinePaint
public void setOutlinePaint(Paint paint)
From source file:com.romraider.logger.ecu.ui.handler.graph.GraphUpdateHandler.java
private JFreeChart createXYLineChart(LoggerData loggerData, XYDataset dataset, boolean combined) { String title = combined ? "Combined Data" : loggerData.getName(); String rangeAxisTitle = combined ? "Data" : buildRangeAxisTitle(loggerData); JFreeChart chart = ChartFactory.createXYLineChart(title, "Time (sec)", rangeAxisTitle, dataset, VERTICAL, false, true, false);/*www. jav a2 s. c om*/ chart.setBackgroundPaint(BLACK); chart.getTitle().setPaint(WHITE); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(BLACK); plot.getDomainAxis().setLabelPaint(WHITE); plot.getRangeAxis().setLabelPaint(WHITE); plot.getDomainAxis().setTickLabelPaint(LIGHT_GREY); plot.getRangeAxis().setTickLabelPaint(LIGHT_GREY); plot.setDomainGridlinePaint(DARK_GREY); plot.setRangeGridlinePaint(DARK_GREY); plot.setOutlinePaint(DARK_GREY); return chart; }
From source file:IHM.NewClass.java
/** * * @param title/* ww w . j a va2 s. c om*/ */ public NewClass(String title /*,*JInternalFrame jp*/) { super(title); // jp = new JInternalFrame("courbes"); JFreeChart chart = createChart(createDataset()); ChartPanel panel = new ChartPanel(chart); panel.setPreferredSize(new Dimension(500, 300)); setContentPane(panel); // jp.add(panel, BorderLayout.EAST); // jp.setVisible(true); panel.setVisible(true); XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); plot.setRenderer(renderer); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.GREEN); renderer.setSeriesPaint(2, Color.YELLOW); // sets thickness for series (using strokes) renderer.setSeriesStroke(0, new BasicStroke(4.0f)); renderer.setSeriesStroke(1, new BasicStroke(3.0f)); renderer.setSeriesStroke(2, new BasicStroke(2.0f)); plot.setRenderer(renderer); plot.setOutlinePaint(Color.BLUE); plot.setOutlineStroke(new BasicStroke(2.0f)); plot.setBackgroundPaint(Color.DARK_GRAY); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.BLACK); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.BLACK); }
From source file:com.intel.stl.ui.common.view.ComponentFactory.java
public static JFreeChart createStackedXYBarChart(XYDataset dataset, String title, String domainAxisLabel, String rangeAxisLabel, boolean legend) { DateAxis dateaxis = new DateAxis(domainAxisLabel); NumberAxis numberaxis = new NumberAxis(rangeAxisLabel); StackedXYBarRenderer stackedxybarrenderer = new StackedXYBarRenderer(0.10000000000000001D); XYPlot xyplot = new XYPlot(dataset, dateaxis, numberaxis, stackedxybarrenderer); JFreeChart jfreechart = new JFreeChart(title, UIConstants.H5_FONT, xyplot, legend); ChartUtilities.applyCurrentTheme(jfreechart); stackedxybarrenderer.setShadowVisible(false); stackedxybarrenderer.setDrawBarOutline(false); stackedxybarrenderer.setBarPainter(new StandardXYBarPainter()); stackedxybarrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator( "<html><b>{0}</b><br> Time: {1}<br> Data: {2}</html>", Util.getHHMMSS(), new DecimalFormat("###"))); xyplot.setBackgroundPaint(null);// ww w . j av a2 s . c o m xyplot.setOutlinePaint(null); xyplot.setRangeGridlinePaint(UIConstants.INTEL_BORDER_GRAY); dateaxis.setLabelFont(UIConstants.H5_FONT); dateaxis.setLowerMargin(0.0D); dateaxis.setUpperMargin(0.0D); numberaxis.setRangeType(RangeType.POSITIVE); numberaxis.setLabelFont(UIConstants.H5_FONT); numberaxis.setLabelInsets(new RectangleInsets(0, 0, 0, 0)); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
From source file:financepro.XYLineChartExample.java
License:asdf
private JPanel createChartPanel() { // creates a line chart object // returns the chart panel String chartTitle = "Various Financial Ratios"; String xAxisLabel = "Years"; String yAxisLabel = "Ratio Values"; XYDataset dataset = createDataset(); JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, xAxisLabel, yAxisLabel, dataset); XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); plot.setRenderer(renderer);//from www . j a v a2 s . c om renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.GREEN); renderer.setSeriesPaint(2, Color.YELLOW); renderer.setSeriesPaint(3, Color.CYAN); renderer.setSeriesPaint(4, Color.BLACK); renderer.setSeriesStroke(0, new BasicStroke(4.0f)); renderer.setSeriesStroke(1, new BasicStroke(4.0f)); renderer.setSeriesStroke(2, new BasicStroke(4.0f)); renderer.setSeriesStroke(3, new BasicStroke(4.0f)); renderer.setSeriesStroke(4, new BasicStroke(4.0f)); plot.setRenderer(renderer); plot.setOutlinePaint(Color.BLUE); plot.setOutlineStroke(new BasicStroke(4.0f)); plot.setBackgroundPaint(Color.DARK_GRAY); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.BLACK); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.BLACK); return new ChartPanel(chart); }
From source file:csds60analyzer.csds60analyzerGUI.java
public BufferedImage creaImagen() { BufferedImage imagen = null;/*from www . j a v a 2s. c o m*/ try { SAXBuilder builder = new SAXBuilder(false); Document doc = null; TimeSeriesCollection datos = new TimeSeriesCollection(); if (fichero != null) { doc = builder.build(fichero); Element raiz = doc.getRootElement(); List<Element> dias = raiz.getChildren("dia"); Iterator<Element> diasIT = dias.iterator(); TimeSeries desayunoAntes = new TimeSeries("Desayuno antes"); TimeSeries desayunoDespues = new TimeSeries("Desayuno despus"); TimeSeries almuerzoAntes = new TimeSeries("Almuerzo antes"); TimeSeries almuerzoDespues = new TimeSeries("Almuerzo despus"); TimeSeries cenaAntes = new TimeSeries("Cena antes"); TimeSeries cenaDespues = new TimeSeries("Cena despus"); pdesayuno = 0; pdesant = 0; pdesdes = 0; palmuerzo = 0; palmant = 0; palmdes = 0; pcena = 0; pcenant = 0; pcendes = 0; contdesant = 0; contdesdes = 0; contalmant = 0; contalmdes = 0; contcenant = 0; contcendes = 0; while (diasIT.hasNext()) { Element diaActual = diasIT.next(); Integer fechaActual = Integer.parseInt(diaActual.getChildText("fecha").substring(0, 10)); Calendar fad = GregorianCalendar.getInstance(); fad.setTimeInMillis(fechaActual.longValue() * 1000); int dia = fad.get(Calendar.DAY_OF_MONTH); int mes = fad.get(Calendar.MONTH) + 1; int ano = fad.get(Calendar.YEAR); if (diaActual.getChildren().toString().contains("desayunoantes")) { int desayunoAntesActual = Integer.parseInt(diaActual.getChildText("desayunoantes")); desayunoAntes.add(new Day(dia, mes, ano), desayunoAntesActual); pdesant = pdesant + desayunoAntesActual; contdesant++; } if (diaActual.getChildren().toString().contains("desayunodespues")) { int desayunoDespuesActual = Integer.parseInt(diaActual.getChildText("desayunodespues")); desayunoDespues.add(new Day(dia, mes, ano), desayunoDespuesActual); pdesdes = pdesdes + desayunoDespuesActual; contdesdes++; } if (diaActual.getChildren().toString().contains("almuerzoantes")) { int almuerzoAntesActual = Integer.parseInt(diaActual.getChildText("almuerzoantes")); almuerzoAntes.add(new Day(dia, mes, ano), almuerzoAntesActual); palmant = palmant + almuerzoAntesActual; contalmant++; } if (diaActual.getChildren().toString().contains("almuerzodespues")) { int almuerzoDespuesActual = Integer.parseInt(diaActual.getChildText("almuerzodespues")); almuerzoDespues.add(new Day(dia, mes, ano), almuerzoDespuesActual); palmdes = palmdes + almuerzoDespuesActual; contalmdes++; } if (diaActual.getChildren().toString().contains("cenaantes")) { int cenaAntesActual = Integer.parseInt(diaActual.getChildText("cenaantes")); cenaAntes.add(new Day(dia, mes, ano), cenaAntesActual); pcenant = pcenant + cenaAntesActual; contcenant++; } if (diaActual.getChildren().toString().contains("cenadespues")) { int cenaDespuesActual = Integer.parseInt(diaActual.getChildText("cenadespues")); cenaDespues.add(new Day(dia, mes, ano), cenaDespuesActual); pcendes = pcendes + cenaDespuesActual; contcendes++; } } //controlar la division por cero if ((contdesant + contdesdes) > 0) pdesayuno = (pdesant + pdesdes) / (contdesant + contdesdes); if (contdesant > 0) pdesant = pdesant / contdesant; if (contdesdes > 0) pdesdes = pdesdes / contdesdes; if ((contalmant + contalmdes) > 0) palmuerzo = (palmant + palmdes) / (contalmant + contalmdes); if (contalmant > 0) palmant = palmant / contalmant; if (contalmdes > 0) palmdes = palmdes / contalmdes; if ((contcenant + contcendes) > 0) pcena = (pcenant + pcendes) / (contcenant + contcendes); if (contcenant > 0) pcenant = pcenant / contcenant; if (contcendes > 0) pcendes = pcendes / contcendes; datos.addSeries(desayunoAntes); datos.addSeries(desayunoDespues); datos.addSeries(almuerzoAntes); datos.addSeries(almuerzoDespues); datos.addSeries(cenaAntes); datos.addSeries(cenaDespues); } JFreeChart graficaJfree = ChartFactory.createTimeSeriesChart("Anlisis", " ", "Glucosa (mg)", datos, true, true, false); XYPlot plot = (XYPlot) graficaJfree.getPlot(); plot.setBackgroundPaint(Color.getHSBColor(0f, 0f, .88f)); plot.setDomainGridlinePaint(Color.getHSBColor(0f, 0f, .35f)); plot.setDomainTickBandPaint(Color.getHSBColor(0f, 0f, .93f)); plot.setOutlinePaint(Color.getHSBColor(0f, 0f, 0.35f)); plot.setRangeGridlinePaint(Color.getHSBColor(0f, 0f, 0.35f)); XYLineAndShapeRenderer plot2 = (XYLineAndShapeRenderer) plot.getRenderer(); if (!CBdesayunoantes.getState()) plot2.setSeriesLinesVisible(0, false); plot2.setSeriesPaint(0, Color.getHSBColor(.3f, 1f, .5f)); //plot2.setSeriesStroke(0,new BasicStroke(2.0f,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND,1.0f)); if (!CBdesayunodespues.getState()) plot2.setSeriesLinesVisible(1, false); plot2.setSeriesPaint(1, Color.getHSBColor(.2f, 1f, .9f)); if (!CBalmuerzoantes.getState()) plot2.setSeriesLinesVisible(2, false); plot2.setSeriesPaint(2, Color.getHSBColor(.0f, 1f, .6f)); if (!CBalmuerzodespues.getState()) plot2.setSeriesLinesVisible(3, false); plot2.setSeriesPaint(3, Color.getHSBColor(.0f, 1f, .9f)); if (!CBcenaantes.getState()) plot2.setSeriesLinesVisible(4, false); plot2.setSeriesPaint(4, Color.getHSBColor(.6f, 1f, .4f)); if (!CBcenadespues.getState()) plot2.setSeriesLinesVisible(5, false); plot2.setSeriesPaint(5, Color.getHSBColor(.6f, 1f, 1f)); imagen = graficaJfree.createBufferedImage(800, 600); } catch (Exception e) { e.printStackTrace(); } return imagen; }
From source file:edu.jhuapl.graphs.jfreechart.JFreeChartTimeSeriesGraphSource.java
/** * Initializes the graph. This method generates the backing {@link JFreeChart} from the time series and graph * parameter data.//from w w w.j av a 2s. c o m * * @throws GraphException if the initialization fails */ public void initialize() throws GraphException { String title = getParam(GraphSource.GRAPH_TITLE, String.class, DEFAULT_TITLE); String xLabel = getParam(GraphSource.GRAPH_X_LABEL, String.class, DEFAULT_DOMAIN_LABEL); String yLabel = getParam(GraphSource.GRAPH_Y_LABEL, String.class, DEFAULT_RANGE_LABEL); Shape graphShape = getParam(GraphSource.GRAPH_SHAPE, Shape.class, DEFAULT_GRAPH_SHAPE); Paint graphColor = getParam(GraphSource.GRAPH_COLOR, Paint.class, DEFAULT_GRAPH_COLOR); boolean legend = getParam(GraphSource.GRAPH_LEGEND, Boolean.class, DEFAULT_GRAPH_LEGEND); boolean graphToolTip = getParam(GraphSource.GRAPH_TOOL_TIP, Boolean.class, DEFAULT_GRAPH_TOOL_TIP); Stroke graphStroke = getParam(GraphSource.GRAPH_STROKE, Stroke.class, DEFAULT_GRAPH_STROKE); Font titleFont = getParam(GraphSource.GRAPH_FONT, Font.class, DEFAULT_GRAPH_TITLE_FONT); boolean graphBorder = getParam(GraphSource.GRAPH_BORDER, Boolean.class, DEFAULT_GRAPH_BORDER); boolean legendBorder = getParam(GraphSource.LEGEND_BORDER, Boolean.class, DEFAULT_LEGEND_BORDER); Double offset = getParam(GraphSource.AXIS_OFFSET, Double.class, DEFAULT_AXIS_OFFSET); checkSeriesType(data); @SuppressWarnings("unchecked") List<? extends TimeSeriesInterface> timeData = (List<? extends TimeSeriesInterface>) data; TimeSeriesCollection dataset = new TimeSeriesCollection(); int seriesCount = 1; for (TimeSeriesInterface series : timeData) { dataset.addSeries(buildTimeSeries(series, seriesCount)); seriesCount += 1; } // actually create the chart this.chart = ChartFactory.createTimeSeriesChart(title, xLabel, yLabel, dataset, false, graphToolTip, false); // start customizing it Paint backgroundColor = getParam(GraphSource.BACKGROUND_COLOR, Paint.class, DEFAULT_BACKGROUND_COLOR); Paint plotColor = getParam(JFreeChartTimeSeriesGraphSource.PLOT_COLOR, Paint.class, backgroundColor); Paint graphDomainGridlinePaint = getParam(GraphSource.GRAPH_DOMAIN_GRIDLINE_PAINT, Paint.class, backgroundColor); Paint graphRangeGridlinePaint = getParam(GraphSource.GRAPH_RANGE_GRIDLINE_PAINT, Paint.class, backgroundColor); this.chart.setBackgroundPaint(backgroundColor); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(plotColor); plot.setAxisOffset(new RectangleInsets(offset, offset, offset, offset)); plot.setDomainGridlinePaint(graphDomainGridlinePaint); plot.setRangeGridlinePaint(graphRangeGridlinePaint); if (graphBorder) { } else { plot.setOutlinePaint(null); } //Use a TextTitle to change the font of the graph title TextTitle title1 = new TextTitle(); title1.setText(title); title1.setFont(titleFont); chart.setTitle(title1); //Makes a wrapper for the legend to remove the border around it if (legend) { LegendTitle legend1 = new LegendTitle(chart.getPlot()); BlockContainer wrapper = new BlockContainer(new BorderArrangement()); if (legendBorder) { wrapper.setFrame(new BlockBorder(1, 1, 1, 1)); } else { wrapper.setFrame(new BlockBorder(0, 0, 0, 0)); } BlockContainer items = legend1.getItemContainer(); items.setPadding(2, 10, 5, 2); wrapper.add(items); legend1.setWrapper(wrapper); legend1.setPosition(RectangleEdge.BOTTOM); legend1.setHorizontalAlignment(HorizontalAlignment.CENTER); if (params.get(GraphSource.LEGEND_FONT) instanceof Font) { legend1.setItemFont(((Font) params.get(GraphSource.LEGEND_FONT))); } chart.addSubtitle(legend1); } boolean include0 = getParam(GraphSource.GRAPH_RANGE_INCLUDE_0, Boolean.class, true); NumberAxis numAxis = (NumberAxis) plot.getRangeAxis(); double rangeLower = getParam(GraphSource.GRAPH_RANGE_LOWER_BOUND, Double.class, numAxis.getLowerBound()); double rangeUpper = getParam(GraphSource.GRAPH_RANGE_UPPER_BOUND, Double.class, numAxis.getUpperBound()); boolean graphRangeIntegerTick = getParam(GraphSource.GRAPH_RANGE_INTEGER_TICK, Boolean.class, false); boolean graphRangeMinorTickVisible = getParam(GraphSource.GRAPH_RANGE_MINOR_TICK_VISIBLE, Boolean.class, true); if (include0) { rangeLower = 0; } numAxis.setRange(rangeLower, rangeUpper); if (graphRangeIntegerTick) { numAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } numAxis.setMinorTickMarksVisible(graphRangeMinorTickVisible); setupFont(numAxis, GraphSource.GRAPH_Y_AXIS_FONT); if (params.get(GraphSource.GRAPH_Y_AXIS_LABEL_FONT) instanceof Font) { numAxis.setLabelFont(((Font) params.get(GraphSource.GRAPH_Y_AXIS_LABEL_FONT))); } TimeResolution minimumResolution = getMinimumResolution(timeData); DateFormat dateFormat = getParam(GraphSource.GRAPH_DATE_FORMATTER, DateFormat.class, new DefaultDateFormatFactory().getFormat(minimumResolution)); if (params.get(DATE_AXIS) instanceof DateAxis) { DateAxis dateAxis = (DateAxis) params.get(DATE_AXIS); dateAxis.setLabel(xLabel); plot.setDomainAxis(dateAxis); } DateAxis dateAxis = ((DateAxis) plot.getDomainAxis()); dateAxis.setDateFormatOverride(dateFormat); if (params.get(GraphSource.GRAPH_X_AXIS_LABEL_FONT) instanceof Font) { dateAxis.setLabelFont(((Font) params.get(GraphSource.GRAPH_X_AXIS_LABEL_FONT))); } int minTick = getParam(GraphSource.GRAPH_MIN_DOMAIN_TICK, Integer.class, 1); if (minTick <= 0) { minTick = 1; } dateAxis.setTickUnit(getDateTickUnit(minimumResolution, minTick), false, false); //dateAxis.setMinorTickMarksVisible(true); //dateAxis.setMinorTickCount(7); dateAxis.setMinorTickMarkOutsideLength(2); Integer minorTick = getParam(GraphSource.GRAPH_MINOR_TICKS, Integer.class, null); if (minorTick != null) { int minorVal = minorTick; if (minorVal > 0) { dateAxis.setMinorTickCount(minorVal); } } setupFont(dateAxis, GraphSource.GRAPH_X_AXIS_FONT); //double lowerMargin = getParam(DOMAIN_AXIS_LOWER_MARGIN, Double.class, DEFAULT_DOMAIN_AXIS_LOWER_MARGIN); double lowerMargin = getParam(DOMAIN_AXIS_LOWER_MARGIN, Double.class, DEFAULT_DOMAIN_AXIS_LOWER_MARGIN); dateAxis.setLowerMargin(lowerMargin); //double upperMargin = getParam(DOMAIN_AXIS_UPPER_MARGIN, Double.class, DEFAULT_DOMAIN_AXIS_UPPER_MARGIN); double upperMargin = getParam(DOMAIN_AXIS_UPPER_MARGIN, Double.class, DEFAULT_DOMAIN_AXIS_UPPER_MARGIN); dateAxis.setUpperMargin(upperMargin); Date domainLower = getParam(GraphSource.GRAPH_DOMAIN_LOWER_BOUND, Date.class, dateAxis.getMinimumDate()); Date domainUpper = getParam(GraphSource.GRAPH_DOMAIN_UPPER_BOUND, Date.class, dateAxis.getMaximumDate()); dateAxis.setRange(domainLower, domainUpper); // depending on the domain axis range, display either 1 tick per day, week, month or year TickUnits standardUnits = new TickUnits(); standardUnits.add(new DateTickUnit(DateTickUnitType.DAY, 1)); standardUnits.add(new DateTickUnit(DateTickUnitType.DAY, 7)); standardUnits.add(new DateTickUnit(DateTickUnitType.MONTH, 1)); standardUnits.add(new DateTickUnit(DateTickUnitType.YEAR, 1)); dateAxis.setStandardTickUnits(standardUnits); TimeSeriesRenderer renderer = new TimeSeriesRenderer(dataset); setupRenderer(renderer, graphColor, graphShape, graphStroke); renderer.setBaseFillPaint(Color.BLACK); renderer.setSeriesOutlinePaint(0, Color.WHITE); //renderer.setUseOutlinePaint(true); plot.setRenderer(renderer); this.initialized = true; }
From source file:IHM.compargraph.java
/** * * @param title/* w w w. j a v a 2 s. c o m*/ * @param c1 * @param c2 * @param comp * */ public compargraph(String title, ArrayList<ReleveMeteo> c1, ArrayList<ReleveMeteo> c2, String comp) { super(title); t1 = c1; t2 = c2; c = comp; // jp = new JInternalFrame("courbes"); JFreeChart chart = createChart(createDataset()); ChartPanel panel = new ChartPanel(chart); panel.setPreferredSize(new Dimension(500, 300)); setContentPane(panel); // jp.add(panel, BorderLayout.EAST); // jp.setVisible(true); panel.setVisible(true); XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); plot.setRenderer(renderer); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.GREEN); renderer.setSeriesPaint(2, Color.YELLOW); // sets thickness for series (using strokes) renderer.setSeriesStroke(0, new BasicStroke(4.0f)); renderer.setSeriesStroke(1, new BasicStroke(3.0f)); renderer.setSeriesStroke(2, new BasicStroke(2.0f)); plot.setRenderer(renderer); plot.setOutlinePaint(Color.BLUE); plot.setOutlineStroke(new BasicStroke(2.0f)); plot.setBackgroundPaint(Color.DARK_GRAY); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.BLACK); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.BLACK); }
From source file:juicebox.windowui.QCDialog.java
public QCDialog(MainWindow mainWindow, HiC hic, String title) { super(mainWindow); Dataset dataset = hic.getDataset();//from w w w .j a va2 s .co m String text = dataset.getStatistics(); String textDescription = null; String textStatistics = null; String graphs = dataset.getGraphs(); JTextPane description = null; JTabbedPane tabbedPane = new JTabbedPane(); HTMLEditorKit kit = new HTMLEditorKit(); StyleSheet styleSheet = kit.getStyleSheet(); styleSheet.addRule("table { border-collapse: collapse;}"); styleSheet.addRule("body {font-family: Sans-Serif; font-size: 12;}"); styleSheet.addRule("td { padding: 2px; }"); styleSheet.addRule( "th {border-bottom: 1px solid #000; text-align: left; background-color: #D8D8D8; font-weight: normal;}"); if (text != null) { int split = text.indexOf("</table>") + 8; textDescription = text.substring(0, split); textStatistics = text.substring(split); description = new JTextPane(); description.setEditable(false); description.setContentType("text/html"); description.setEditorKit(kit); description.setText(textDescription); tabbedPane.addTab("About Library", description); JTextPane textPane = new JTextPane(); textPane.setEditable(false); textPane.setContentType("text/html"); textPane.setEditorKit(kit); textPane.setText(textStatistics); JScrollPane pane = new JScrollPane(textPane); tabbedPane.addTab("Statistics", pane); } boolean success = true; if (graphs != null) { long[] A = new long[2000]; long sumA = 0; long[] mapq1 = new long[201]; long[] mapq2 = new long[201]; long[] mapq3 = new long[201]; long[] intraCount = new long[100]; final XYSeries intra = new XYSeries("Intra Count"); final XYSeries leftRead = new XYSeries("Left"); final XYSeries rightRead = new XYSeries("Right"); final XYSeries innerRead = new XYSeries("Inner"); final XYSeries outerRead = new XYSeries("Outer"); final XYSeries allMapq = new XYSeries("All MapQ"); final XYSeries intraMapq = new XYSeries("Intra MapQ"); final XYSeries interMapq = new XYSeries("Inter MapQ"); Scanner scanner = new Scanner(graphs); try { while (!scanner.next().equals("[")) ; for (int idx = 0; idx < 2000; idx++) { A[idx] = scanner.nextLong(); sumA += A[idx]; } while (!scanner.next().equals("[")) ; for (int idx = 0; idx < 201; idx++) { mapq1[idx] = scanner.nextInt(); mapq2[idx] = scanner.nextInt(); mapq3[idx] = scanner.nextInt(); } for (int idx = 199; idx >= 0; idx--) { mapq1[idx] = mapq1[idx] + mapq1[idx + 1]; mapq2[idx] = mapq2[idx] + mapq2[idx + 1]; mapq3[idx] = mapq3[idx] + mapq3[idx + 1]; allMapq.add(idx, mapq1[idx]); intraMapq.add(idx, mapq2[idx]); interMapq.add(idx, mapq3[idx]); } while (!scanner.next().equals("[")) ; for (int idx = 0; idx < 100; idx++) { int tmp = scanner.nextInt(); if (tmp != 0) innerRead.add(logXAxis[idx], tmp); intraCount[idx] = tmp; tmp = scanner.nextInt(); if (tmp != 0) outerRead.add(logXAxis[idx], tmp); intraCount[idx] += tmp; tmp = scanner.nextInt(); if (tmp != 0) rightRead.add(logXAxis[idx], tmp); intraCount[idx] += tmp; tmp = scanner.nextInt(); if (tmp != 0) leftRead.add(logXAxis[idx], tmp); intraCount[idx] += tmp; if (idx > 0) intraCount[idx] += intraCount[idx - 1]; if (intraCount[idx] != 0) intra.add(logXAxis[idx], intraCount[idx]); } } catch (NoSuchElementException exception) { JOptionPane.showMessageDialog(getParent(), "Graphing file improperly formatted", "Error", JOptionPane.ERROR_MESSAGE); success = false; } if (success) { final XYSeriesCollection readTypeCollection = new XYSeriesCollection(); readTypeCollection.addSeries(innerRead); readTypeCollection.addSeries(outerRead); readTypeCollection.addSeries(leftRead); readTypeCollection.addSeries(rightRead); final JFreeChart readTypeChart = ChartFactory.createXYLineChart("Types of reads vs distance", // chart title "Distance (log)", // domain axis label "Binned Reads (log)", // range axis label readTypeCollection, // data PlotOrientation.VERTICAL, true, // include legend true, false); final XYPlot readTypePlot = readTypeChart.getXYPlot(); readTypePlot.setDomainAxis(new LogarithmicAxis("Distance (log)")); readTypePlot.setRangeAxis(new LogarithmicAxis("Binned Reads (log)")); readTypePlot.setBackgroundPaint(Color.white); readTypePlot.setRangeGridlinePaint(Color.lightGray); readTypePlot.setDomainGridlinePaint(Color.lightGray); readTypeChart.setBackgroundPaint(Color.white); readTypePlot.setOutlinePaint(Color.black); final ChartPanel chartPanel = new ChartPanel(readTypeChart); final XYSeriesCollection reCollection = new XYSeriesCollection(); final XYSeries reDistance = new XYSeries("Distance"); for (int i = 0; i < A.length; i++) { if (A[i] != 0) reDistance.add(i, A[i] / (float) sumA); } reCollection.addSeries(reDistance); final JFreeChart reChart = ChartFactory.createXYLineChart( "Distance from closest restriction enzyme site", // chart title "Distance (bp)", // domain axis label "Fraction of Reads (log)", // range axis label reCollection, // data PlotOrientation.VERTICAL, true, // include legend true, false); final XYPlot rePlot = reChart.getXYPlot(); rePlot.setDomainAxis(new NumberAxis("Distance (bp)")); rePlot.setRangeAxis(new LogarithmicAxis("Fraction of Reads (log)")); rePlot.setBackgroundPaint(Color.white); rePlot.setRangeGridlinePaint(Color.lightGray); rePlot.setDomainGridlinePaint(Color.lightGray); reChart.setBackgroundPaint(Color.white); rePlot.setOutlinePaint(Color.black); final ChartPanel chartPanel2 = new ChartPanel(reChart); final XYSeriesCollection intraCollection = new XYSeriesCollection(); intraCollection.addSeries(intra); final JFreeChart intraChart = ChartFactory.createXYLineChart("Intra reads vs distance", // chart title "Distance (log)", // domain axis label "Cumulative Sum of Binned Reads (log)", // range axis label intraCollection, // data PlotOrientation.VERTICAL, true, // include legend true, false); final XYPlot intraPlot = intraChart.getXYPlot(); intraPlot.setDomainAxis(new LogarithmicAxis("Distance (log)")); intraPlot.setRangeAxis(new NumberAxis("Cumulative Sum of Binned Reads (log)")); intraPlot.setBackgroundPaint(Color.white); intraPlot.setRangeGridlinePaint(Color.lightGray); intraPlot.setDomainGridlinePaint(Color.lightGray); intraChart.setBackgroundPaint(Color.white); intraPlot.setOutlinePaint(Color.black); final ChartPanel chartPanel3 = new ChartPanel(intraChart); final XYSeriesCollection mapqCollection = new XYSeriesCollection(); mapqCollection.addSeries(allMapq); mapqCollection.addSeries(intraMapq); mapqCollection.addSeries(interMapq); final JFreeChart mapqChart = ChartFactory.createXYLineChart("MapQ Threshold Count", // chart title "MapQ threshold", // domain axis label "Count", // range axis label mapqCollection, // data PlotOrientation.VERTICAL, true, // include legend true, // include tooltips false); final XYPlot mapqPlot = mapqChart.getXYPlot(); mapqPlot.setBackgroundPaint(Color.white); mapqPlot.setRangeGridlinePaint(Color.lightGray); mapqPlot.setDomainGridlinePaint(Color.lightGray); mapqChart.setBackgroundPaint(Color.white); mapqPlot.setOutlinePaint(Color.black); final ChartPanel chartPanel4 = new ChartPanel(mapqChart); tabbedPane.addTab("Pair Type", chartPanel); tabbedPane.addTab("Restriction", chartPanel2); tabbedPane.addTab("Intra vs Distance", chartPanel3); tabbedPane.addTab("MapQ", chartPanel4); } } final ExpectedValueFunction df = hic.getDataset().getExpectedValues(hic.getZoom(), hic.getNormalizationType()); if (df != null) { double[] expected = df.getExpectedValues(); final XYSeriesCollection collection = new XYSeriesCollection(); final XYSeries expectedValues = new XYSeries("Expected"); for (int i = 0; i < expected.length; i++) { if (expected[i] > 0) expectedValues.add(i + 1, expected[i]); } collection.addSeries(expectedValues); String title1 = "Expected at " + hic.getZoom() + " norm " + hic.getNormalizationType(); final JFreeChart readTypeChart = ChartFactory.createXYLineChart(title1, // chart title "Distance between reads (log)", // domain axis label "Genome-wide expected (log)", // range axis label collection, // data PlotOrientation.VERTICAL, false, // include legend true, false); final XYPlot readTypePlot = readTypeChart.getXYPlot(); readTypePlot.setDomainAxis(new LogarithmicAxis("Distance between reads (log)")); readTypePlot.setRangeAxis(new LogarithmicAxis("Genome-wide expected (log)")); readTypePlot.setBackgroundPaint(Color.white); readTypePlot.setRangeGridlinePaint(Color.lightGray); readTypePlot.setDomainGridlinePaint(Color.lightGray); readTypeChart.setBackgroundPaint(Color.white); readTypePlot.setOutlinePaint(Color.black); final ChartPanel chartPanel5 = new ChartPanel(readTypeChart); tabbedPane.addTab("Expected", chartPanel5); } if (text == null && graphs == null) { JOptionPane.showMessageDialog(this, "Sorry, no metrics are available for this dataset", "Error", JOptionPane.ERROR_MESSAGE); setVisible(false); dispose(); } else { getContentPane().add(tabbedPane); pack(); setModal(false); setLocation(100, 100); setTitle(title); setVisible(true); } }
From source file:org.jstockchart.plot.TimeseriesPlot.java
private XYPlot createPricePlot() { Font axisFont = new Font("Arial", 0, 12); Stroke stroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f, new float[] { 1.0f, 1.0f }, 1.0f); PriceArea priceArea = timeseriesArea.getPriceArea(); Color averageColor = new Color(243, 182, 117); priceArea.setAverageColor(averageColor); priceArea.setPriceColor(Color.BLUE); TimeSeriesCollection priceDataset = new TimeSeriesCollection(); priceDataset.addSeries(dataset.getPriceTimeSeries().getTimeSeries()); if (priceArea.isAverageVisible()) { priceDataset.addSeries(dataset.getAverageTimeSeries().getTimeSeries()); }/*from w w w. j a va 2s . co m*/ CentralValueAxis logicPriceAxis = priceArea.getLogicPriceAxis(); logicPriceAxis.setTickCount(7); CFXNumberAxis priceAxis = new CFXNumberAxis(logicPriceAxis.getLogicTicks()); priceAxis.setShowUD(true); priceAxis.setOpenPrice(logicPriceAxis.getCentralValue().doubleValue()); priceAxis.setTickMarksVisible(false); XYLineAndShapeRenderer priceRenderer = new XYLineAndShapeRenderer(true, false); priceAxis.setUpperBound(logicPriceAxis.getUpperBound()); priceAxis.setLowerBound(logicPriceAxis.getLowerBound()); priceAxis.setAxisLineVisible(false); priceAxis.setTickLabelFont(axisFont); priceRenderer.setSeriesPaint(0, priceArea.getPriceColor()); priceRenderer.setSeriesPaint(1, priceArea.getAverageColor()); CFXNumberAxis rateAxis = new CFXNumberAxis(logicPriceAxis.getRatelogicTicks()); rateAxis.setShowUD(true); rateAxis.setOpenPrice(logicPriceAxis.getCentralValue().doubleValue()); rateAxis.setTickMarksVisible(false); ; rateAxis.setTickLabelFont(axisFont); rateAxis.setAxisLineVisible(false); rateAxis.setUpperBound(logicPriceAxis.getUpperBound()); rateAxis.setLowerBound(logicPriceAxis.getLowerBound()); XYPlot plot = new XYPlot(priceDataset, null, priceAxis, priceRenderer); plot.setBackgroundPaint(priceArea.getBackgroudColor()); plot.setOrientation(priceArea.getOrientation()); plot.setRangeAxisLocation(priceArea.getPriceAxisLocation()); plot.setRangeMinorGridlinesVisible(false); Stroke outLineStroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f, new float[] { 1.0f, 1.0f }, 1.0f); Stroke gridLineStroke = new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, new float[] { 2.0f, 2.0f }, 1.0f); plot.setRangeGridlineStroke(gridLineStroke); plot.setDomainGridlineStroke(gridLineStroke); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); plot.setOutlineVisible(true); plot.setOutlineStroke(outLineStroke); plot.setOutlinePaint(Color.BLACK); if (priceArea.isRateVisible()) { plot.setRangeAxis(1, rateAxis); plot.setRangeAxisLocation(1, priceArea.getRateAxisLocation()); plot.setDataset(1, null); plot.mapDatasetToRangeAxis(1, 1); } if (priceArea.isMarkCentralValue()) { Number centralPrice = logicPriceAxis.getCentralValue(); if (centralPrice != null) { plot.addRangeMarker(new ValueMarker(centralPrice.doubleValue(), priceArea.getCentralPriceColor(), new BasicStroke())); } } return plot; }
From source file:org.jstockchart.plot.TimeseriesPlot.java
private XYPlot createVolumePlot() { Font axisFont = new Font("Arial", 0, 12); Stroke stroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f, new float[] { 1.0f, 1.0f }, 1.0f); VolumeArea volumeArea = timeseriesArea.getVolumeArea(); LogicNumberAxis logicVolumeAxis = volumeArea.getLogicVolumeAxis(); Color volumeColor = new Color(86, 126, 160); volumeArea.setVolumeColor(volumeColor); CFXNumberAxis volumeAxis = new CFXNumberAxis(logicVolumeAxis.getLogicTicks()); volumeAxis.setAxisLineVisible(false); volumeAxis.setCustomTickCount(2);//from w w w .j a v a 2 s .c o m volumeAxis.setTickLabelPaint(volumeColor); volumeAxis.setUpperBound(logicVolumeAxis.getUpperBound()); volumeAxis.setTickLabelFont(axisFont); volumeAxis.setTickMarkStroke(stroke); volumeAxis.setLowerBound(logicVolumeAxis.getLowerBound()); volumeAxis.setAutoRangeIncludesZero(true); XYAreaRenderer2 volumeRenderer = new XYAreaRenderer2(); volumeRenderer.setSeriesPaint(0, volumeArea.getVolumeColor()); //volumeRenderer.setShadowVisible(false); volumeRenderer.setSeriesStroke(0, stroke); volumeRenderer.setBaseStroke(stroke); XYPlot plot = new XYPlot(new TimeSeriesCollection(dataset.getVolumeTimeSeries()), null, volumeAxis, volumeRenderer); plot.setBackgroundPaint(volumeArea.getBackgroudColor()); plot.setOrientation(volumeArea.getOrientation()); plot.setRangeAxisLocation(volumeArea.getVolumeAxisLocation()); plot.setRangeMinorGridlinesVisible(false); Stroke outLineStroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f, new float[] { 1.0f, 1.0f }, 1.0f); Stroke gridLineStroke = new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, new float[] { 2.0f, 2.0f }, 1.0f); // plot.setBackgroundPaint(Color.RED); plot.setRangeGridlineStroke(gridLineStroke); plot.setDomainGridlineStroke(gridLineStroke); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); plot.setOutlineVisible(true); plot.setOutlineStroke(outLineStroke); plot.setOutlinePaint(Color.black); plot.setRangeZeroBaselineVisible(true); return plot; }