List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer XYLineAndShapeRenderer
public XYLineAndShapeRenderer()
From source file:EHRAppointment.ChartPanelDraw.java
private ChartPanel createChart(XYDataset dataset, String type) { final JFreeChart chart = ChartFactory.createTimeSeriesChart(type, "Date", getValueAxis(), dataset); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); plot.setRenderer(renderer);/* w w w . j a va 2 s . com*/ final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return new ChartPanel(chart); }
From source file:org.jcryptool.visual.verifiablesecretsharing.views.ReconstructionChartComposite.java
/** * Creates a chart.//from w w w . java 2 s . c o m * * @param dataset * the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("", // chart // title "", // x axis label "", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend false, // tooltips false // urls ); // XYSplineRenderer -- show data points XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); // show no line renderer.setSeriesLinesVisible(0, false); renderer.setSeriesLinesVisible(3, false); // show no points renderer.setSeriesShapesVisible(1, false); // set range of axis NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setRange(-0.1, playerID[playerID.length - 1] + 0.1); domain.setTickUnit(new NumberTickUnit(1)); domain.setVerticalTickLabels(false); // display value NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(0); XYItemLabelGenerator generator = new StandardXYItemLabelGenerator( StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, format, format); renderer.setBaseItemLabelGenerator(generator); renderer.setBaseItemLabelsVisible(true); plot.setRenderer(renderer); return chart; }
From source file:org.fhcrc.cpl.viewer.commandline.modules.MassAccuracyCommandLineModule.java
/** * do the actual work/*from ww w . j ava2s .c o m*/ */ public void execute() throws CommandLineModuleExecutionException { int NUM_TICKS = 50; float[][] plotData = new float[3][NUM_TICKS]; deltaMassType = FeatureSetMatcher.DELTA_MASS_TYPE_ABSOLUTE; //This block is for plotting curves of mass accuracy over changes in parameters for (int i = 0; i < NUM_TICKS; i++) { deltaMass = (float) .04 * i; ClusteringFeatureSetMatcher featureSetMatcher = new ClusteringFeatureSetMatcher(); featureSetMatcher.init(deltaMass, deltaMassType, (float) deltaHydrophobicity); FeatureSetMatcher.FeatureMatchingResult featureMatchingResult = featureSetMatcher .matchFeatures(ms1Features, ms2Features); double[] massDiffRatios = new double[featureMatchingResult.size()]; int j = 0; for (Feature ms1Feature : featureMatchingResult.getMasterSetFeatures()) { Feature ms2Feature = featureMatchingResult.getBestMatch(ms1Feature); massDiffRatios[j++] = 1000000 * ((Math.abs(ms1Feature.getMass() - ms2Feature.getMass())) / ms2Feature.getMass()); } plotData[0][i] = deltaMass; plotData[1][i] = (float) BasicStatistics.median(massDiffRatios); plotData[2][i] = (float) BasicStatistics.mean(massDiffRatios); } XYSeries xySeries = new XYSeries("median"); XYSeries xySeries1 = new XYSeries("mean"); for (int i = 0; i < plotData[0].length; i++) { xySeries.add(plotData[0][i], plotData[1][i]); xySeries1.add(plotData[0][i], plotData[2][i]); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(xySeries); dataset.addSeries(xySeries1); XYPlot plot = new XYPlot(dataset, new NumberAxis(), new NumberAxis(), new XYLineAndShapeRenderer()); ChartDialog cd0 = new ChartDialog(plot); cd0.setTitle("Mean and median deviation, for various mass match tolerances"); cd0.setVisible(true); }
From source file:net.nosleep.superanalyzer.analysis.views.YearView.java
private void createChart() { NumberAxis xAxis = new NumberAxis(Misc.getString("RELEASE_YEAR")); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(Misc.getString("SONG_COUNT")); yAxis.setAutoRangeIncludesZero(true); xAxis.setNumberFormatOverride(new DecimalFormat("0")); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); XYPlot plot = new XYPlot(_dataset, xAxis, yAxis, renderer); // create and return the chart panel... _chart = new JFreeChart(Misc.getString("RELEASE_YEAR"), JFreeChart.DEFAULT_TITLE_FONT, plot, true); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4)); LegendTitle legend = _chart.getLegend(); legend.setFrame(BlockBorder.NONE);/*ww w . java 2s . c o m*/ _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("RELEASE_YEAR_TOOLTIP"))); XYToolTipGenerator generator = new StandardXYToolTipGenerator("{2}", new DecimalFormat("0.00"), new DecimalFormat("0.00")); renderer.setToolTipGenerator(generator); ChartUtilities.applyCurrentTheme(_chart); // format the lines after applying the theme renderer.setBaseShapesVisible(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setBaseFillPaint(Color.white); renderer.setSeriesStroke(0, new BasicStroke(3.0f)); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0)); renderer.setSeriesStroke(1, new BasicStroke(3.0f)); renderer.setSeriesOutlineStroke(1, new BasicStroke(2.0f)); renderer.setSeriesShape(1, new Rectangle2D.Double(-3.0, -3.0, 6.0, 6.0)); _chart.setPadding(new RectangleInsets(10, 10, 10, 10)); Misc.formatChart(plot); }
From source file:org.agmip.ui.afsirs.frames.GraphOutput.java
public void addEvaporationAndTranspiration() { XYSeries etSeries = new XYSeries("ET"); double[][] ET = utils.getET(); for (int i = 0; i < 10/*ET.length*/; i++) { for (int j = 0; j < 10/*ET[0].length*/; j++) { etSeries.add(i * ET[0].length + j, ET[i][j]); }//from w w w.j ava2 s . c o m } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(etSeries); JFreeChart chart = ChartFactory.createXYLineChart("Evaporation Transpiration", "Days", "Inches", dataset/*, PlotOrientation.VERTICAL, true, true, false*/); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartPanel panel = new ChartPanel(chart); jTabbedPane1.addTab("Evaporation Transpiration", panel); }
From source file:com.javafxpert.neuralnetviz.scenario.PlotUtil.java
private static JFreeChart createChart(XYZDataset dataset, double[] mins, double[] maxs, int nPoints, XYDataset xyData) {//from w w w.j a v a 2 s. com NumberAxis xAxis = new NumberAxis("X"); xAxis.setRange(mins[0], maxs[0]); NumberAxis yAxis = new NumberAxis("Y"); yAxis.setRange(mins[1], maxs[1]); XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setBlockWidth((maxs[0] - mins[0]) / (nPoints - 1)); renderer.setBlockHeight((maxs[1] - mins[1]) / (nPoints - 1)); PaintScale scale = new GrayPaintScale(0, 1.0); renderer.setPaintScale(scale); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); JFreeChart chart = new JFreeChart("", plot); chart.getXYPlot().getRenderer().setSeriesVisibleInLegend(0, false); NumberAxis scaleAxis = new NumberAxis("Probability (class 0)"); scaleAxis.setAxisLinePaint(Color.white); scaleAxis.setTickMarkPaint(Color.white); scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 7)); PaintScaleLegend legend = new PaintScaleLegend(new GrayPaintScale(), scaleAxis); legend.setStripOutlineVisible(false); legend.setSubdivisionCount(20); legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT); legend.setAxisOffset(5.0); legend.setMargin(new RectangleInsets(5, 5, 5, 5)); legend.setFrame(new BlockBorder(Color.red)); legend.setPadding(new RectangleInsets(10, 10, 10, 10)); legend.setStripWidth(10); legend.setPosition(RectangleEdge.LEFT); chart.addSubtitle(legend); ChartUtilities.applyCurrentTheme(chart); plot.setDataset(1, xyData); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); renderer2.setBaseLinesVisible(false); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }
From source file:UserInterface.DoctorRole.ViewPatientReport.java
private void LineGraphButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LineGraphButtonActionPerformed // TODO add your handling code here: //dataset = new DefaultCategoryDataset(); XYSeriesCollection dataset = new XYSeriesCollection(); if (!(patient.getTestDir().getTestdir().isEmpty())) { for (Test vs : patient.getTestDir().getTestdir()) { XYSeries series1 = new XYSeries(vs.getBloodPressure()); series1.add(10, Float.parseFloat(vs.getBloodPressure())); series1.add(20, Float.parseFloat(vs.getBloodPlatlets())); series1.add(30, Float.parseFloat(vs.getHemoglobinLevel())); series1.add(40, Float.parseFloat(vs.getBloodPlatlets())); dataset.addSeries(series1);//from w ww . j av a 2 s . c o m // dataset.addValue(Integer.parseInt(vs.getBloodPressure()), "Blood Pressure", vs.getTimestamp()); // dataset.addValue(Integer.parseInt(vs.getBloodPlatlets()), "Blood Platelets", vs.getTimestamp()); // //dataset.addValue(Integer.parseInt(vs.getHemoglobinLevel()), "Hemoglobin Level", vs.getTimestamp()); // //dataset.addValue(vs.getWeight(), "Weight", vs.getTimestamp()); // } JFreeChart chartFactory = ChartFactory.createXYLineChart("GRAPHICAL REPRESENTATION OF SENSOR DATA", "X-Axis", "SIGN", (XYDataset) dataset); XYLineAndShapeRenderer renderer = null; // XYPlot plot = chartFactory.getXYPlot(); renderer = new XYLineAndShapeRenderer(); ChartFrame frame = new ChartFrame("Line Chart Of Sensor Data", chartFactory); frame.setVisible(true); frame.setSize(700, 320); } //GEN-LAST:event_LineGraphButtonActionPerformed else { JOptionPane.showMessageDialog(this, "No Vital Signs To Display On Graph!!!"); } }
From source file:projects.hip.exec.HrDiagram.java
/** * Plot the distribution of distance of all objects. * @param d_hist//w ww . java 2 s .co m * The array containing the distance distribution histogram. * @return * A {@link JFreeChart} containing the plot. */ private static JFreeChart getDistanceChart(double[] d_hist) { XYSeries series = new XYSeries("Distance distribution"); for (int i = 0; i < d_hist.length; i++) { // Centre of this distance bin double d = d_min + i * d_step + d_step / 2.0; series.add(d, d_hist[i]); } XYSeriesCollection data = new XYSeriesCollection(); data.addSeries(series); // Set up the renderer XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, false); // Configure axes NumberAxis xAxis = new NumberAxis("Distance [pc]"); xAxis.setRange(d_min, d_max); NumberAxis yAxis = new NumberAxis("Number of objects"); yAxis.setAutoRangeIncludesZero(true); // Configure plot XYPlot xyplot = new XYPlot(data, xAxis, yAxis, renderer); xyplot.setBackgroundPaint(Color.white); JFreeChart dChart = new JFreeChart("Distance distribution of Hipparcos stars", xyplot); dChart.removeLegend(); dChart.setBackgroundPaint(Color.white); return dChart; }
From source file:org.activequant.util.charting.Chart.java
/** * method to add a dot chart./*w w w . j a v a 2 s . c om*/ * @param title * @param dateAndValues */ public void addDotSeriesChart(String title, List<Tuple<TimeStamp, Double>> dateAndValues) { if (chart != null) { // final TimeSeries ts = new TimeSeries(title, Millisecond.class); for (Tuple<TimeStamp, Double> tuple : dateAndValues) { // TimeSeriesDataItem item = new TimeSeriesDataItem(new Millisecond(tuple.getObject1().getDate()), tuple.getObject2()); ts.addOrUpdate(item.getPeriod(), item.getValue()); } datasets.add(ts); final TimeSeriesCollection dataset = new TimeSeriesCollection(ts); final XYPlot plot1 = chart.getXYPlot(); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setShapesVisible(true); renderer.setLinesVisible(false); plot1.setDataset(datasets.size(), dataset); plot1.setRenderer(datasets.size(), renderer); } }
From source file:eu.hydrologis.jgrass.charting.impl.JGrassXYTimeLineChart.java
public JFreeChart getChart(String title, String xLabel, String yLabel, PlotOrientation porient, boolean withLegend, boolean withTooltips, boolean withUrls) { if (porient == null) { porient = PlotOrientation.VERTICAL; }//from w ww .j av a2 s . c o m theChart = ChartFactory.createTimeSeriesChart(title, xLabel, yLabel, lineDataset, withLegend, withTooltips, withUrls); // also create the plot obj for customizations thePlot = theChart.getXYPlot(); ((XYPlot) thePlot).setRenderer(new XYLineAndShapeRenderer()); renderer = ((XYPlot) thePlot).getRenderer(); if (timeFormat != null) { // PeriodAxis domainAxis = new PeriodAxis(""); // PeriodAxisLabelInfo[] info = new PeriodAxisLabelInfo[1]; // // PeriodAxisLabelInfo[] info = new PeriodAxisLabelInfo[infos.length]; // // // for( int i = 0; i < infos.length; i++ ) { // // info[infos.length - i - 1] = new PeriodAxisLabelInfo(timeClasses[i], // // new SimpleDateFormat(infos[i])); // // // // } // info[0] = new PeriodAxisLabelInfo(Minute.class, // new SimpleDateFormat("yyyy-MM-dd HH:mm")); // // // domainAxis.setAutoRangeTimePeriodClass(Minute.class); // // domainAxis.setMajorTickTimePeriodClass(Hour.class); // // domainAxis.setMinorTickTimePeriodClass(Minute.class); // domainAxis.setLabelAngle(Math.PI); // // domainAxis.setLabelInfo(info); // ((XYPlot) thePlot).setDomainAxis(domainAxis); DateAxis axis = (DateAxis) ((XYPlot) thePlot).getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat(timeFormat)); } for (int i = 0; i < chartSeries.length; i++) { ((XYLineAndShapeRenderer) renderer).setSeriesLinesVisible(i, showLines); ((XYLineAndShapeRenderer) renderer).setSeriesShapesVisible(i, showShapes); } return theChart; }