List of usage examples for org.jfree.chart.plot XYPlot setDomainCrosshairVisible
public void setDomainCrosshairVisible(boolean flag)
From source file:edu.unibonn.plotting.TimeSeriesPlotter_Sensors.java
private JFreeChart createChart(final XYDataset dataset, final XYDataset dataset_centroids, ArrayList<Cluster_KMeans> clusters) { final JFreeChart chart = ChartFactory.createTimeSeriesChart("Sensors", "Time", "Erlang", dataset, false, //t true, //t false //f );/*from w ww . j a va2 s . c om*/ ChartUtilities.applyCurrentTheme(chart); //chart.setBackgroundPaint(Color.white); // final StandardLegend sl = (StandardLegend) chart.getLegend(); // sl.setDisplaySeriesShapes(true); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); 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); } int temp_count = 0; //for (int i = 0; i < clusters.size(); i++) for (int i = 0; (i < 11) && (i < clusters.size()); i++) { Cluster_KMeans current_cluster = clusters.get(i); ArrayList<Sensor> member_time_series = current_cluster.getMembership(); for (int j = 0; j < member_time_series.size(); j++) { renderer.setSeriesPaint(j + temp_count, getColor(i)); } temp_count = temp_count + member_time_series.size(); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm")); //final ValueAxis axis_y = plot.getRangeAxis(); //axis_y.setRange(0, 20); plot.setDataset(1, dataset_centroids); plot.setRenderer(1, new StandardXYItemRenderer()); for (int i = 0; (i < clusters.size()); i++) { //plot.getRenderer(1).setSeriesPaint(i, getColor(i)); plot.getRenderer(1).setSeriesPaint(i, Color.BLACK); plot.getRenderer(1).setSeriesStroke(i, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f)); } plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }
From source file:graficoComparacion.graficaCompa.java
public graficaCompa() { //sxy.add(x[0], y[0]); /////////////// /* 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); ////////////////////////////////////// datos.addSeries(s1);/*www . j a v a2 s.c o m*/ */ grafica = ChartFactory.createTimeSeriesChart("Progreso de cargas", "Fechas", "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")); }
From source file:org.jgrasstools.gears.ui.OmsMatrixCharter.java
@SuppressWarnings("deprecation") private JFreeChart doLineChart() { XYSeriesCollection collection = getSeriesCollection(); PlotOrientation orientation = PlotOrientation.VERTICAL; if (doHorizontal) { orientation = PlotOrientation.HORIZONTAL; }//from ww w. ja v a2 s . c om JFreeChart chart = ChartFactory.createXYLineChart(inTitle, inLabels[0], inLabels[1], collection, orientation, doLegend, true, false); XYPlot plot = (XYPlot) chart.getPlot(); // plot.setDomainGridlinePaint(Color.red); // plot.setRangeGridlinePaint(Color.cyan); // plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer plotRenderer = plot.getRenderer(); if (plotRenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plotRenderer; if (doPoints) { renderer.setShapesVisible(true); renderer.setShapesFilled(true); } if (inColors != null) { String[] colorSplit = inColors.split(";"); for (int i = 0; i < colorSplit.length; i++) { String[] split = colorSplit[i].split(","); int r = (int) Double.parseDouble(split[0]); int g = (int) Double.parseDouble(split[1]); int b = (int) Double.parseDouble(split[2]); renderer.setSeriesPaint(i, new Color(r, g, b)); } } } NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); double delta = (max - min) * 0.1; yAxis.setRange(min, max + delta); yAxis.setMinorTickCount(4); yAxis.setMinorTickMarksVisible(true); if (inFormats != null && inFormats.length > 1 && inFormats[1].trim().length() > 0) { yAxis.setNumberFormatOverride(new DecimalFormat(inFormats[1])); } if (inFormats != null && inFormats.length > 0 && inFormats[0].trim().length() > 0) { ValueAxis domainAxis = plot.getDomainAxis(); if (domainAxis instanceof NumberAxis) { NumberAxis xAxis = (NumberAxis) domainAxis; xAxis.setNumberFormatOverride(new DecimalFormat(inFormats[0])); } } return chart; }
From source file:imc.graficaIMC.java
public void iejmplo() { TimeSeries s1 = new TimeSeries("Entrenamiento Actual"); 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. j av a2 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:visualizer.projection.distance.view.DistanceHistogram.java
private JFreeChart createChart(IntervalXYDataset intervalxydataset) { JFreeChart chart = ChartFactory.createHistogram("Distance Histogram", "Distances Values", "Occurences", intervalxydataset, PlotOrientation.VERTICAL, true, true, false); // JFreeChart chart = ChartFactory.createHistogram("Histograma das Distncias", // "Valores", "Ocorrncias", intervalxydataset, // PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.WHITE); XYPlot xyplot = (XYPlot) chart.getPlot(); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); xyplot.setDomainGridlinePaint(Color.BLACK); xyplot.setRangeGridlinePaint(Color.BLACK); xyplot.setOutlinePaint(Color.BLACK); xyplot.setOutlineStroke(new BasicStroke(1.0f)); xyplot.setBackgroundPaint(Color.white); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setDrawBarOutline(false); return chart; }
From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.ClinicalPlot.java
private void createChart() { //String xLabel = factor1.toString(); String xLabel = factor1AxisLabel; //String yLabel = factor2.toString(); String yLabel = factor2AxisLabel; clinicalChart = ChartFactory.createScatterPlot("Clinical Plot", xLabel, yLabel, null, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) clinicalChart.getPlot(); buildLegend();//w ww. ja va2s . co m plot.setNoDataMessage(null); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setUseOutlinePaint(true); plot.setRangeCrosshairVisible(false); plot.setDomainCrosshairVisible(false); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); //should determine axis range using datapoints. domainAxis.setAutoRangeIncludesZero(false); //get domain and range of the axis. DataRange domainAxisLimits = getDataRange(dataPoints, factor1, true); DataRange rangeAxisLimits = getDataRange(dataPoints, factor2, true); //domainAxis.setRange(domainAxisLimits.getMinRange(), domainAxisLimits.getMaxRange()); //rangeAxis.setRange(rangeAxisLimits.getMinRange(), rangeAxisLimits.getMaxRange()); double domainMax = Math.max(100.0, domainAxisLimits.getMaxRange()) + 5.0; double rangeMax = Math.max(100.0, rangeAxisLimits.getMaxRange()) + 5.0; domainAxis.setRange(0.0, domainMax); rangeAxis.setRange(0.0, rangeMax); System.out.println("domainAxis=" + domainAxis.getLabel()); System.out.println("rangeAxis=" + rangeAxis.getLabel()); createGlyphsAndAddToPlot(plot); }
From source file:visualizer.datamining.dataanalysis.CreateLineGraph.java
private JFreeChart createChart(XYDataset xydataset, String title, String xtitle, String ytitle) { JFreeChart chart = ChartFactory.createXYLineChart(title, xtitle, ytitle, xydataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.WHITE); XYPlot xyplot = (XYPlot) chart.getPlot(); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); xyplot.setDomainGridlinePaint(Color.BLACK); xyplot.setRangeGridlinePaint(Color.BLACK); xyplot.setOutlinePaint(Color.BLACK); xyplot.setOutlineStroke(new BasicStroke(1.0f)); xyplot.setBackgroundPaint(Color.white); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); xyplot.setDrawingSupplier(new DefaultDrawingSupplier( new Paint[] { Color.RED, Color.BLUE, Color.GREEN, Color.MAGENTA, Color.CYAN, Color.ORANGE, Color.BLACK, Color.DARK_GRAY, Color.GRAY, Color.LIGHT_GRAY, Color.YELLOW }, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); xylineandshaperenderer.setDrawOutlines(true); return chart; }
From source file:org.limy.eclipse.qalab.task.DistanceGraphTask.java
/** * @param dataset /*from w ww . j a va 2 s . co m*/ * @throws IOException * */ private void drawGraph(XYDataset dataset) throws IOException { JFreeChart chart = ChartFactory.createScatterPlot("Distance from the Main Sequence", "Instability", "Abstractness", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = chart.getXYPlot(); plot.getRenderer().addAnnotation( new XYLineAnnotation(-0.1, 1.1, 1.1, -0.1, new BasicStroke(2), new Color(50, 220, 50)), Layer.BACKGROUND); plot.getRenderer().setShape(new Ellipse2D.Double(-4, -4, 8, 8)); plot.getRenderer().setPaint(new Color(0xec, 0x76, 0x37)); plot.getDomainAxis().setRangeWithMargins(0, 1); plot.getRangeAxis().setRangeWithMargins(0, 1); chart.getTitle().setPaint(Color.BLUE); plot.setDomainCrosshairVisible(true); plot.setDomainCrosshairPaint(Color.GRAY); plot.setRangeCrosshairVisible(true); plot.setRangeCrosshairPaint(Color.GRAY); LimyGraphUtils.writeImagePng(chart, out, 400, 380); }
From source file:org.tolven.web.ChartAction.java
/** * Create Growth Chart//w w w . j a v a2s . com * * @author Suja * added on 02/01/2011 * @param type - 1: Height & 2: Weight * @return */ public JFreeChart createChart(int type) { long patientId = Long.parseLong(getRequestParameter("element").toString().split(":")[1].split("-")[1]); MenuData patMD = getMenuLocal().findMenuDataItem(patientId); int age = 0; int gender = 1; Date dob = null; if (patMD != null) { DateFormat df = new SimpleDateFormat("yyyy"); dob = patMD.getDate01(); Date cur = new Date(); age = Integer.parseInt(df.format(cur)) - Integer.parseInt(df.format(dob)); if (patMD.getString04().equals("Male")) gender = 1; else gender = 2; } // create dataset XYDataset dataset = createDataset(type, gender, age, dob); String title = ""; if (type == 1 && age < 3) title = "Height birth to 36 Months Old " + (gender == 1 ? "Male" : "Female"); else if (type == 1 && age >= 3) title = "Height 2-20 Year Old " + (gender == 1 ? "Male" : "Female"); else if (type == 2 && age < 3) title = "Weight birth to 36 Months Old " + (gender == 1 ? "Male" : "Female"); else if (type == 2 && age >= 3) title = "Weight 2-20 Year Old " + (gender == 1 ? "Male" : "Female"); JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title "X-Value", // x-axis label "Y-Value", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.lightGray); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); for (int i = 1; i < 10; i++) { renderer.setSeriesLinesVisible(i, true); renderer.setSeriesShapesVisible(i, false); } renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, true); plot.setRenderer(renderer); plot.setDomainAxis(new NumberAxis("Age (Months)")); plot.setRangeAxis(new NumberAxis((type == 1 ? "Height (Centimeters)" : "Weight (Kilograms)"))); return chart; }
From source file:my.electrochem.ElectrochemUI.java
private ChartPanel createChartPanel() { //creates a line chart object //returns the chart panel String chartTitle = "i-E curve"; String xAxisLabel = "E (V)"; String yAxisLabel = "i (A)"; dataset1 = createEmptyDataset();/*ww w . j a va2s . c o m*/ JFreeChart chart = ChartFactory.createScatterPlot(chartTitle, xAxisLabel, yAxisLabel, dataset1); XYPlot plot = chart.getXYPlot(); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.setDomainCrosshairLockedOnData(false); plot.setRangeCrosshairLockedOnData(false); /*chart.addProgressListener(new ChartProgressListener() { @Override public void chartProgress(ChartProgressEvent cpe) { if (cpe.getType() == ChartProgressEvent.DRAWING_FINISHED) { //System.out.println("Click event!!"); XYPlot xyPlot2 = cpe.getChart().getXYPlot(); System.out.println("drawing finished"); System.out.println("Xreal:"+xyPlot2.getDomainCrosshairValue() +"Yreal:"+xyPlot2.getRangeCrosshairValue()); if (click) { System.out.println("click true"); if (x1 == -423.0) { x1 = 0.0; y1 = 0.0; } if (x1 == 0.0 && y1 == 0.0) { System.out.println("print 0,0"); click = true; x1 = xyPlot2.getDomainCrosshairValue(); y1 = xyPlot2.getRangeCrosshairValue(); //xyPlot2.clearAnnotations(); } else { xyPlot2.clearAnnotations(); System.out.println("true-false"); click = false; x1 = xyPlot2.getDomainCrosshairValue(); y1 = xyPlot2.getRangeCrosshairValue(); } } else { System.out.println("click false"); x2 = xyPlot2.getDomainCrosshairValue(); y2 = xyPlot2.getRangeCrosshairValue(); createLineAnn(xyPlot2, x1, y1, x2, y2); click = true; } } } });*/ XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); // sets paint color for each series //renderer.setSeriesPaint(0, Color.RED); // sets thickness for series (using strokes) //renderer.setSeriesStroke(0, new BasicStroke(5.0f)); renderer.setBaseLinesVisible(true); //renderer.setSeriesLinesVisible(0, true); //renderer.setBaseShapesFilled(true); renderer.setBaseShapesVisible(false); //srenderer.setDrawSeriesLineAsPath(false); 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); plot.setRenderer(renderer); return new ChartPanel(chart); }