List of usage examples for org.jfree.chart JFreeChart JFreeChart
public JFreeChart(Plot plot)
From source file:meter_rpm.Stackoverflow.java
private ChartPanel buildDialPlot(int minimumValue, int maximumValue, int majorTickGap) { DialPlot plot = new DialPlot(); plot.setView(0.0D, 0.0D, 1.0D, 1.0D); plot.setDataset(0, dataset0);/*from w ww. ja va 2 s.c om*/ plot.setDataset(1, dataset1); plot.setDialFrame(new StandardDialFrame()); DialTextAnnotation dialtextannotation = new DialTextAnnotation("RPM"); dialtextannotation.setFont(new Font("Dialog", 1, 12)); dialtextannotation.setRadius(0.69999999999999996D); plot.addLayer(dialtextannotation); // value indicator uses the real data set //plot.addLayer(new DialValueIndicator(0)); DialValueIndicator dialvalueindicator = new DialValueIndicator(0); dialvalueindicator.setFont(new Font("Dialog", Font.BOLD, 12)); dialvalueindicator.setOutlinePaint(Color.YELLOW); dialvalueindicator.setRadius(0.6D); dialvalueindicator.setAngle(-90D); dialvalueindicator.setTemplateValue(1000); plot.addLayer(dialvalueindicator); org.jfree.chart.plot.dial.DialPointer.Pin pin1 = new org.jfree.chart.plot.dial.DialPointer.Pin(1); pin1.setRadius(0.55000000000000004D); plot.addPointer(pin1); // needle uses constrained data set plot.addLayer(new DialPointer.Pointer(0)); StandardDialScale scale = new StandardDialScale(0d, 6000, -110, -320, majorTickGap, 4); scale.setTickRadius(0.88); scale.setTickLabelOffset(0.20); scale.setTickLabelFormatter(new DecimalFormat("####")); plot.addScale(0, scale); StandardDialScale standarddialscale1 = new StandardDialScale(0D, 30D, -120D, -300D, 5D, 4); standarddialscale1.setTickRadius(0.5D); standarddialscale1.setTickLabelOffset(0.14999999999999999D); standarddialscale1.setTickLabelFont(new Font("Dialog", 0, 10)); standarddialscale1.setMajorTickPaint(Color.RED); standarddialscale1.setMinorTickPaint(Color.RED); plot.addScale(1, standarddialscale1); plot.mapDatasetToScale(1, 1); JFreeChart jfreechart = new JFreeChart(plot); jfreechart.setTitle("ENGINE RPM & MANIFOLD PRESSURE"); ChartPanel chartpanel = new ChartPanel(jfreechart); chartpanel.setPreferredSize(new Dimension(400, 400)); return chartpanel; }
From source file:it.eng.spagobi.engines.kpi.bo.charttypes.dialcharts.SimpleDial.java
/** * Creates the chart .//from w w w . j av a 2 s . c o m * * @return A Simple Dial chart . */ public JFreeChart createChart() { logger.debug("IN"); if (dataset == null) { logger.debug("The dataset to be represented is null"); return null; } DialPlot plot = new DialPlot(); plot.setDataset((ValueDataset) dataset); logger.debug("Created the new Dial Plot"); ArcDialFrame dialFrame = null; plot.setView(0.21, 0.0, 0.58, 0.30); dialFrame = new ArcDialFrame(60.0, 60.0); dialFrame.setInnerRadius(0.65); dialFrame.setOuterRadius(0.90); dialFrame.setForegroundPaint(Color.darkGray); dialFrame.setStroke(new BasicStroke(3.0f)); plot.setDialFrame(dialFrame); GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(240, 240, 240)); DialBackground sdb = new DialBackground(gp); GradientPaintTransformType gradientPaintTransformType = GradientPaintTransformType.HORIZONTAL; sdb.setGradientPaintTransformer(new StandardGradientPaintTransformer(gradientPaintTransformType)); plot.addLayer(sdb); increment = (upper - lower) / 4; StandardDialScale scale = null; scale = new StandardDialScale(lower, upper, 115.0, -50.0, increment, minorTickCount); // sets intervals for (Iterator iterator = intervals.iterator(); iterator.hasNext();) { KpiInterval interval = (KpiInterval) iterator.next(); StandardDialRange range = new StandardDialRange(interval.getMin(), interval.getMax(), interval.getColor()); range.setInnerRadius(0.70); range.setOuterRadius(0.75); plot.addLayer(range); } scale.setTickRadius(0.88); scale.setTickLabelOffset(0.07); Font f = new Font("Arial", Font.PLAIN, 11); scale.setTickLabelFont(f); //scale.setMajorTickIncrement(25.0); plot.addScale(0, scale); DialPointer needle = new DialPointer.Pin(); needle.setRadius(0.82); plot.addLayer(needle); JFreeChart chart1 = new JFreeChart(plot); logger.debug("Created the chart"); chart1.setBackgroundPaint(color); logger.debug("Setted background color of the chart"); TextTitle title = setStyleTitle(name, styleTitle); chart1.setTitle(title); logger.debug("Setted the title of the chart"); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart1.addSubtitle(subTitle); logger.debug("Setted the subtitle of the chart"); } logger.debug("OUT"); return chart1; }
From source file:com.ivli.roim.controls.VOILUTPanel.java
public VOILUTPanel(LUTControl aP) { iCurveName = java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle").getString("VOILUTPANEL.VOI_LUT"); iLUT = LUTControl.create(aP);// w w w .ja v a2s . c o m aP.addWindowChangeListener(this); initComponents(); XYPlot plot = new XYPlot(); plot.setDataset(0, makeLUTCurve()); plot.setRenderer(0, new XYSplineRenderer()); ((XYSplineRenderer) plot.getRenderer()).setShapesVisible(false); plot.setRangeAxis(0, new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle") .getString("VOILUTPANEL.AXIS_LABEL_VOI_CURVE"))); XYSeriesCollection col2 = new XYSeriesCollection(); col2.addSeries(makeHistogram()); plot.setDataset(1, col2); plot.setRenderer(1, new XYBarRenderer()); plot.setRangeAxis(1, new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle") .getString("VOILUTPANEL.AXIS_LABEL_IMAGE_SPACE"))); plot.mapDatasetToRangeAxis(1, 1); plot.setDomainAxis(new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle") .getString("VOILUTPANEL.AXIS_LABEL_IMAGE_HISTOGRAM"))); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); // change the rendering order so the primary dataset appears "behind" the // other datasets... plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); JFreeChart jfc = new JFreeChart(plot); jfc.setBorderVisible(true); jfc.removeLegend(); iPanel = new ChartPanel(jfc); iPanel.setSize(jPanel1.getPreferredSize()); jPanel1.add(iPanel);//, java.awt.BorderLayout.CENTER); iLUT.setSize(jPanel2.getPreferredSize()); jPanel2.add(iLUT); iLabelMin.setText(String.format("%.0f", iLUT.getView().getMin())); iLabelMax.setText(String.format("%.0f", iLUT.getView().getMax())); validate(); }
From source file:openqcm.ChartDynamicData.java
public ChartDynamicData() { // add primary axis frequency TimeSeries seriesFrequency = new TimeSeries("Frequency (Hz)"); datasetFrequency = new TimeSeriesCollection(seriesFrequency); rangeAxisF = new NumberAxis("Frequency (Hz)"); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, new Color(0, 142, 192)); rangeAxisF.setAutoRangeIncludesZero(false); rangeAxisF.setAutoRange(true);/*from w ww . j a v a 2s . c o m*/ rangeAxisF.setAutoRangeMinimumSize(50); plot.setDataset(0, datasetFrequency); plot.setRangeAxis(0, rangeAxisF); plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT); plot.setRenderer(0, renderer); plot.mapDatasetToRangeAxis(0, 0); // add secondary axis temperature TimeSeries seriesTemperature = new TimeSeries("Temperature (C)"); datasetTemperature = new TimeSeriesCollection(seriesTemperature); plot.setDataset(1, datasetTemperature); NumberAxis rangeAxisT = new NumberAxis("Temperature (C)"); rangeAxisT.setAutoRangeIncludesZero(false); rangeAxisT.setAutoRange(true); rangeAxisT.setAutoRangeMinimumSize(5); plot.setRangeAxis(1, rangeAxisT); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); // custom renderer for dinamically changing temperaure rendererT.setSeriesPaint(0, new Color(255, 128, 0)); plot.setRenderer(1, rendererT); plot.mapDatasetToRangeAxis(1, 1); plotComb.add(plot); plotComb.setBackgroundPaint(Color.white); plotComb.setDomainGridlinePaint(Color.white); plotComb.setRangeGridlinePaint(Color.white); // enable panning for both axis plotComb.setRangePannable(true); plotComb.setDomainPannable(true); // set time axis properties // format time axis as hh:mm:ss SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss"); DateAxis axis = (DateAxis) plotComb.getDomainAxis(); axis.setDateFormatOverride(format); // default auto range domainAxis.setAutoRange(true); // init the JFreeChart JFreeChart chart = new JFreeChart(plotComb); chart.setBorderPaint(Color.lightGray); chart.setBorderVisible(true); chart.setBackgroundPaint(Color.white); // set legend properties LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.TOP); legend.setItemFont(new Font("Dialog", Font.PLAIN, 9)); // constructor for org.jfree.chart.ChartPanel // ChartPanel(JFreeChart chart, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips) ChartPanel chartPanel = new ChartPanel(chart, false, true, true, true, true); // enable mouse wheel support for the chart panel chartPanel.setMouseWheelEnabled(true); this.setLayout(new BorderLayout()); // add real time chart to the frame this.add(chartPanel); this.validate(); }
From source file:PlotsBuilding.PlotPanel.java
private JFreeChart createChart(XYDataset xyDataset, ArrayList<Integer> seriesCount, double y1, double y2) { NumberAxis domainAxis = new NumberAxis("x"); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setPositiveArrowVisible(true); NumberAxis rangeAxis = new NumberAxis("y"); rangeAxis.setRange(y1, y2);//w w w . jav a 2 s .co m rangeAxis.setPositiveArrowVisible(true); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); int start = 0; int color = 50; for (Object series : seriesCount) { for (int i = start; i < start + (int) series; i++) { Color s = new Color(color); renderer.setSeriesPaint(i, s); renderer.setSeriesVisibleInLegend(i, false); renderer.setSeriesVisibleInLegend(start, true); } start = start + (int) series; color *= 100; } renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); XYPlot plot = new XYPlot(xyDataset, domainAxis, rangeAxis, renderer); PlotOrientation orientation = PlotOrientation.VERTICAL; plot.setOrientation(orientation); plot.setBackgroundPaint(Color.white); chart = new JFreeChart(plot); chart.setBackgroundPaint(Color.white); chart.getLegend().setPosition(RectangleEdge.RIGHT); chart.getLegend().setVerticalAlignment(VerticalAlignment.TOP); return chart; }
From source file:edu.cuny.cat.ui.ClientStatePanel.java
public ClientStatePanel() { registry = GameController.getInstance().getRegistry(); clock = GameController.getInstance().getClock(); setTitledBorder("Client Status"); final CategoryAxis xAxis = new CategoryAxis(); yAxis = new NumberAxis(); yAxis.setTickUnit(new NumberTickUnit(1)); // TODO: to change the colors for different kinds of events final ValueListShapeRenderer eventRenderer = new ValueListShapeRenderer(); eventRenderer.setBaseOutlinePaint(Color.black); eventRenderer.setUseOutlinePaint(true); eventRenderer.setDrawOutlines(true); final IntervalListBarRenderer progressRenderer = new IntervalListBarRenderer(); categoryPlot = new CategoryPlot(); categoryPlot.setOrientation(PlotOrientation.HORIZONTAL); categoryPlot.setRenderer(0, eventRenderer); categoryPlot.setRenderer(1, progressRenderer); categoryPlot.setDomainAxis(xAxis);/*from w ww .j a v a 2 s .c om*/ categoryPlot.setRangeAxis(yAxis); final JFreeChart chart = new JFreeChart(categoryPlot); chart.setAntiAlias(false); chart.setBackgroundPaint(getBackground()); categoryPlot.setForegroundAlpha(0.5F); categoryPlot.getDomainAxis().setMaximumCategoryLabelWidthRatio(10.0f); categoryPlot.setBackgroundPaint(Color.lightGray); categoryPlot.setRangeGridlinePaint(Color.white); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setRangeZoomable(false); add(chartPanel, BorderLayout.CENTER); }
From source file:org.jfree.chart.demo.XYDrawableAnnotationDemo1.java
private static JFreeChart createPieChart() { DefaultPieDataset defaultpiedataset = new DefaultPieDataset(); defaultpiedataset.setValue("Engineering", 43.200000000000003D); defaultpiedataset.setValue("Research", 13.199999999999999D); defaultpiedataset.setValue("Advertising", 20.899999999999999D); PiePlot pieplot = new PiePlot(defaultpiedataset); pieplot.setBackgroundPaint(null);/*from ww w . jav a 2 s . c o m*/ pieplot.setOutlinePaint(null); pieplot.setBaseSectionOutlinePaint(Color.white); pieplot.setBaseSectionOutlineStroke(new BasicStroke(2.0F)); pieplot.setLabelFont(new Font("Dialog", 0, 18)); pieplot.setMaximumLabelWidth(0.25D); JFreeChart jfreechart = new JFreeChart(pieplot); jfreechart.setBackgroundPaint(null); jfreechart.removeLegend(); jfreechart.setPadding(RectangleInsets.ZERO_INSETS); return jfreechart; }
From source file:motordrivertxrx.View.MainView.java
/** * Creates new form MainView// w w w . j av a 2 s .c om */ public MainView() { initComponents(); this.dataset1 = new DefaultValueDataset(10.0); this.dataset2 = new DefaultValueDataset(50.0); // get data for diagrams DialPlot plot = new DialPlot(); plot.setView(0.0, 0.0, 1.0, 1.0); plot.setDataset(0, this.dataset1); plot.setDataset(1, this.dataset2); SimpleDialFrame dialFrame = new SimpleDialFrame(); dialFrame.setBackgroundPaint(Color.lightGray); dialFrame.setForegroundPaint(Color.DARK_GRAY); plot.setDialFrame(dialFrame); /* GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(170, 170, 220)); */ GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), Color.ORANGE); DialBackground db = new DialBackground(gp); db.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL)); plot.setBackground(db); DialTextAnnotation annotation1 = new DialTextAnnotation("Velocidad"); annotation1.setFont(new Font("Dialog", Font.BOLD, 14)); annotation1.setRadius(0.7); plot.addLayer(annotation1); DialValueIndicator dvi = new DialValueIndicator(0, "c"); dvi.setFont(new Font("Dialog", Font.PLAIN, 10)); dvi.setOutlinePaint(Color.darkGray); dvi.setRadius(0.60); dvi.setAngle(-103.0); plot.addLayer(dvi); DialValueIndicator dvi2 = new DialValueIndicator(1, "c"); dvi2.setFont(new Font("Dialog", Font.PLAIN, 10)); dvi2.setOutlinePaint(Color.red); dvi2.setRadius(0.60); dvi2.setAngle(-77.0); plot.addLayer(dvi2); StandardDialScale scale = new StandardDialScale(0, 127, -120, -300); scale.setTickRadius(0.88); scale.setTickLabelOffset(0.15); scale.setTickLabelFont(new Font("Dialog", Font.PLAIN, 14)); plot.addScale(0, scale); StandardDialScale scale2 = new StandardDialScale(0, 100, -120, -300); scale2.setTickRadius(0.50); scale2.setTickLabelOffset(0.15); scale2.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10)); scale2.setMajorTickPaint(Color.red); plot.addScale(1, scale2); plot.mapDatasetToScale(1, 1); DialPointer needle2 = new DialPointer.Pin(1); needle2.setRadius(0.55); plot.addLayer(needle2); DialPointer needle = new DialPointer.Pointer(0); plot.addLayer(needle); DialCap cap = new DialCap(); cap.setRadius(0.10); plot.setCap(cap); JFreeChart chart1 = new JFreeChart(plot); chart1.setTitle("Velocidad motor"); ChartPanel cp1 = new ChartPanel(chart1); cp1.setPreferredSize(new Dimension(400, 400)); /*JPanel sliderPanel = new JPanel(new GridLayout(2, 2)); sliderPanel.add(new JLabel("Outer Needle:")); sliderPanel.add(new JLabel("Inner Needle:")); this.slider1 = new JSlider(-40, 60); this.slider1.setMajorTickSpacing(20); this.slider1.setPaintTicks(true); this.slider1.setPaintLabels(true); this.slider1.addChangeListener(this); sliderPanel.add(this.slider1); sliderPanel.add(this.slider1); this.slider2 = new JSlider(0, 100); this.slider2.setMajorTickSpacing(20); this.slider2.setPaintTicks(true); this.slider2.setPaintLabels(true); this.slider2.addChangeListener(this); sliderPanel.add(this.slider2);*/ velocimetroPanel.add(cp1); }
From source file:com.insa.tp3g1.esbsimulator.view.OverlaidBarChart.java
/** * Default constructor./*from w ww.j a v a2s . c om*/ * * @param title the frame title. * @param result */ public OverlaidBarChart(final String title, Result result) { super(title); // create the first dataset... DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); LinkConsumerProvider[] linkConsProv = result.getLinksConsumerProvider(); for (LinkConsumerProvider linkConsProv1 : linkConsProv) { dataset1.addValue(Integer.parseInt(linkConsProv1.getAverageResponseTime()), average, link + linkConsProv1.getConsumerId()); } // create the first renderer... // final CategoryLabelGenerator generator = new StandardCategoryLabelGenerator(); final CategoryItemRenderer renderer = new BarRenderer(); // renderer.setLabelGenerator(generator); renderer.setItemLabelsVisible(true); final CategoryPlot plot = new CategoryPlot(); plot.setDataset(dataset1); plot.setRenderer(renderer); plot.setDomainAxis(new CategoryAxis("Category")); plot.setRangeAxis(new NumberAxis("Value (ms)")); plot.setOrientation(PlotOrientation.VERTICAL); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); // now create the second dataset and renderer... DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); for (LinkConsumerProvider linkConsProv1 : linkConsProv) { dataset2.addValue(Integer.parseInt(result.getTotalResult().getResponseTime().getMinResponseTime()), min, link + linkConsProv1.getConsumerId()); } final CategoryItemRenderer renderer2 = new LineAndShapeRenderer(); plot.setDataset(1, dataset2); plot.setRenderer(1, renderer2); // create the third dataset and renderer... final ValueAxis rangeAxis2 = new NumberAxis("value (ms)"); plot.setRangeAxis(1, rangeAxis2); DefaultCategoryDataset dataset3 = new DefaultCategoryDataset(); for (LinkConsumerProvider linkConsProv1 : linkConsProv) { dataset3.addValue(Integer.parseInt(result.getTotalResult().getResponseTime().getMaxResponseTime()), max, link + linkConsProv1.getConsumerId()); } plot.setDataset(2, dataset3); final CategoryItemRenderer renderer3 = new LineAndShapeRenderer(); plot.setRenderer(2, renderer3); plot.mapDatasetToRangeAxis(2, 1); // change the rendering order so the primary dataset appears "behind" the // other datasets... plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); final JFreeChart chart = new JFreeChart(plot); chart.setTitle("Response Time Chart"); // chart.setLegend(new StandardLegend()); // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:org.jax.haplotype.analysis.visualization.GenomicGraphFactory.java
/** * Creates a plot which contains multiple chromosome histograms * @param chromosomeHistograms// w ww. j a v a2 s .c om * the chromosome histograms * @param xAxisLabel * the X axis label * @param yAxisLabel * the Y axis label * @return * the object for the multiple chromosome plots */ public JFreeChart createMultiChromosomeHistogram( final List<? extends ChromosomeHistogramValues> chromosomeHistograms, final String xAxisLabel, final String yAxisLabel) { // create the y-axis that is shared by all of the chromosomes NumberAxis yAxis = new NumberAxis(); if (yAxisLabel != null) { yAxis.setLabel(yAxisLabel); } // the combined plot makes all of the chromosomes to share the same // y-axis but to have thier own x-axis CombinedRangeXYPlot combinedChromosomePlot = new CombinedRangeXYPlot(yAxis); combinedChromosomePlot.setGap(4.0); // iterate through the chromosomes adding a new plot for each one for (ChromosomeHistogramValues currChromHist : chromosomeHistograms) { // use a weight to ensure that the amount of space that the // subgraph gets on the x-axis is proportional to the chromosome's // extent final int currWeight = (int) (currChromHist.getExtentInBasePairs() / 1000 + 1); final NumberAxis currXAxis = new NumberAxis(); currXAxis.setAutoRangeIncludesZero(false); currXAxis.setTickLabelsVisible(false); currXAxis.setTickMarksVisible(false); currXAxis.setLabel(Integer.toString(currChromHist.getChromosomeNumber())); final XYPlot currPlot = this.createSnpIntervalHistogramPlot(currChromHist.getIntervals(), currChromHist.getVisualInterval(), currXAxis, null); combinedChromosomePlot.add(currPlot, currWeight); } JFreeChart multiChromosomeChart = new JFreeChart(combinedChromosomePlot); multiChromosomeChart.removeLegend(); return multiChromosomeChart; }