List of usage examples for org.jfree.chart.plot XYPlot getRenderer
public XYItemRenderer getRenderer()
From source file:ec.nbdemetra.chainlinking.outlineview.ChainLinkingChart.java
@Override protected void onColorSchemeChange() { XYPlot plot = chartPanel.getChart().getXYPlot(); if (plot.getDataset() != null) { for (int i = 0; i < plot.getDataset().getSeriesCount(); i++) { plot.getRenderer().setSeriesPaint(i, themeSupport.getLineColor(i)); }//from w w w .j a v a 2s . co m } plot.setBackgroundPaint(themeSupport.getPlotColor()); plot.setDomainGridlinePaint(themeSupport.getGridColor()); plot.setRangeGridlinePaint(themeSupport.getGridColor()); chartPanel.getChart().setBackgroundPaint(themeSupport.getBackColor()); }
From source file:org.codehaus.mojo.chronos.chart.SummaryThroughputChartSource.java
private XYPlot createThroughputPlot(ResourceBundle bundle, ReportConfig config) { TimeSeriesCollection dataset1 = createThroughputDataset(bundle, config); XYPlot throughputPlot = ChartUtil.newPlot(dataset1, bundle.getString("chronos.label.throughput.requests"), true);/*from w w w . j av a2s . c o m*/ throughputPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); throughputPlot.getRenderer().setSeriesPaint(0, Color.GREEN); throughputPlot.getRenderer().setSeriesPaint(1, Color.BLUE); throughputPlot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); double maxAvgThroughput = samples.getMaxAverageThroughput(config.getAverageduration(), config.getResponsetimedivider()); String maxThroughputLabel = bundle.getString("chronos.label.maxaveragethroughput"); ChartUtil.addRangeMarker(throughputPlot, maxThroughputLabel, maxAvgThroughput); return throughputPlot; }
From source file:carfuzzy.Operations.java
public JFreeChart setToChart(double input, double membership, XYSeries series, XYSeriesCollection collection, String x_axis) { // kurallari cizdirdikten sonra cizdir. series.add(input, membership);/* ww w . ja v a2 s . c o m*/ series.add(input, 0); series.add(0, membership); collection.addSeries(series); JFreeChart chart = XYGraph.drawChart(collection, x_axis, "Membership"); XYPlot plot = chart.getXYPlot(); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesStroke(collection.getSeriesCount() - 1, new BasicStroke(3.5f)); renderer.setSeriesStroke(collection.getSeriesCount() - 1, new BasicStroke(3.5f)); plot.setRenderer(renderer); return chart; }
From source file:ch.zhaw.ias.dito.ui.AnalysisPanel.java
private JPanel createDecompositionPanel(String title, double[][] mdsValues) { JFreeChart chart = ChartFactory.createScatterPlot(title, null, null, new MdsXYDataset(mdsValues), PlotOrientation.VERTICAL, false, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.getRenderer().setBaseToolTipGenerator(new XYToolTipGenerator() { @Override/*from ww w . j av a 2 s . c o m*/ public String generateToolTip(XYDataset dataset, int series, int item) { return "item #" + (item + 1); } }); JPanel mdsPanel = new JPanel(new BorderLayout(0, 10)); mdsPanel.add(new ChartPanel(chart), BorderLayout.CENTER); dimensionsCombo = new JComboBox(new Integer[] { 2, 3 }); JButton exportButton = new JButton(Translation.INSTANCE.get("s4.bu.exportDecomposition")); exportButton.addActionListener(this); JPanel mdsInputPanel = new JPanel(); mdsInputPanel.setLayout(new BoxLayout(mdsInputPanel, BoxLayout.LINE_AXIS)); mdsInputPanel.add(Box.createHorizontalGlue()); mdsInputPanel.add(Box.createHorizontalGlue()); mdsInputPanel.add(new JLabel(Translation.INSTANCE.get("s4.lb.dimension"))); mdsInputPanel.add(Box.createHorizontalStrut(10)); mdsInputPanel.add(dimensionsCombo); mdsInputPanel.add(Box.createHorizontalStrut(10)); mdsInputPanel.add(exportButton); mdsPanel.add(mdsInputPanel, BorderLayout.SOUTH); return mdsPanel; }
From source file:org.yccheok.jstock.gui.charting.DynamicChart.java
/** Creates new form DynamicChart */ public DynamicChart() { this.price = new TimeSeries("Price"); // Sets the maximumItemAge attribute, which specifies the maximum age of data items in the series // (in terms of the RegularTimePeriod type used by this series). Whenever a new data value is // added, any data items that are older than the limit specified by maximumItemAge are automatically // discarded//w ww.j a v a2 s. c o m // Maximum 2 hours. this.price.setMaximumItemAge(2 * 60 * 60); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(this.price); JFreeChart freeChart = ChartFactory.createTimeSeriesChart(null, null, null, dataset, false, true, false); freeChart.setAntiAlias(true); while (freeChart.getSubtitleCount() > 0) { freeChart.removeSubtitle(freeChart.getSubtitle(0)); } // Due to limited spacing, we remove all information regarding x and y axis // as well. XYPlot plot = freeChart.getXYPlot(); plot.getRangeAxis().setVisible(false); plot.getDomainAxis().setVisible(false); XYItemRenderer renderer1 = plot.getRenderer(); renderer1.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("h:mm:ss a"), new DecimalFormat("0.00#"))); org.yccheok.jstock.charting.Utils.applyChartTheme(freeChart); // Disable zoom. chartPanel = new ChartPanel(freeChart, true, true, true, false, true); chartPanel.setMouseZoomable(false); }
From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.PortHeatMapWorker.java
protected Void doInBackground() throws Exception { // this is a SwingWorker thread from its pool, give it a recognizable name Thread.currentThread().setName("PortHeatMapWorker"); JFreeChart Chart = PlotPanel.getHeatChart(); logger.info("Worker Building HeatMapPlot"); MessageManager.getInstance()/* w ww . j a va2s.c om*/ .postMessage(new SmtMessage(SmtMessageType.SMT_MSG_INFO, "Worker Building HeatMapPlot")); PortHeatMapDataSet pHeatMap = null; if (UseService) { SMT_UpdateService updateService = SMT_UpdateService.getInstance(); History = updateService.getCollection(); if (IncludedNodes != null) pHeatMap = new PortHeatMapDataSet(History, IncludedNodes); else pHeatMap = new PortHeatMapDataSet(History, IncludedDepths); } else if (History != null) { if (IncludedNodes != null) pHeatMap = new PortHeatMapDataSet(History, IncludedNodes); else pHeatMap = new PortHeatMapDataSet(History, IncludedDepths); } else { // FIXME - eliminate this, for test purposes only if (IncludedNodes != null) pHeatMap = new PortHeatMapDataSet("%h/scripts/OsmScripts/SmtScripts/sierra3H.his", IncludedNodes); else pHeatMap = new PortHeatMapDataSet("%h/scripts/OsmScripts/SmtScripts/sierra3H.his", IncludedDepths); } // logger.fine("Finished creating dataset"); // logger.fine("Max X: " + pHeatMap.getMaximumXValue()); // logger.fine("Max Y: " + pHeatMap.getMaximumYValue()); // logger.fine("Max Z: " + pHeatMap.getMaximumZValue()); // // if any of these "maximum" values are illegal, stop here and return null if (!pHeatMap.isValid()) { logger.severe("Invalid HeatMap, check OMS Collection or Depth filter (empty or null)"); MessageManager.getInstance().postMessage(new SmtMessage(SmtMessageType.SMT_MSG_SEVERE, "Invalid HeatMap, check OMS Collection or Depth filter (empty or null)")); PlotPanel.setHeatMapDataSet(null); return null; } PlotPanel.setHeatMapDataSet(pHeatMap); Range fixedXRange = new Range(0, pHeatMap.getMaximumXValue()); // time # Range fixedYRange = new Range(0, pHeatMap.getMaximumYValue()); // port # Range fixedZRange = new Range(0, pHeatMap.getMaximumZValue()); // % Util // there are 3 valid paint scales, 0, 1, & 2 LookupPaintScale paintScale = PaintScaleFactory.getLookupPaintScale(1, 0, fixedZRange.getUpperBound(), fixedZRange.getUpperBound()); ValueAxis paintAxis = PaintScaleFactory.getPaintScaleAxis(0, fixedZRange.getUpperBound(), PortHeatMapPlotPanel.UtilizationAxisLabel); BufferedImage image = HeatMapUtilities.createHeatMapImage(pHeatMap, paintScale); XYDataImageAnnotation ann = new XYDataImageAnnotation(image, fixedXRange.getLowerBound(), fixedYRange.getLowerBound(), fixedXRange.getUpperBound(), fixedYRange.getUpperBound(), true); XYPlot plot = (XYPlot) Chart.getPlot(); plot.getRenderer().addAnnotation(ann, Layer.BACKGROUND); // finally, show the heatmap PaintScaleLegend psLegend = new PaintScaleLegend(paintScale, paintAxis); psLegend.setMargin(new RectangleInsets(3, 40, 3, 10)); psLegend.setPosition(RectangleEdge.TOP); // location (within NORTH) of // heatmap legend psLegend.setAxisOffset(4.0); psLegend.setFrame(new BlockBorder(Color.GRAY)); Chart.addSubtitle(psLegend); // fix the sliders ranges, and set them for the middle if ((pHeatMap != null) && (PlotPanel != null)) { PlotPanel.getTimeSlider().setMinimum((int) fixedXRange.getLowerBound()); PlotPanel.getTimeSlider().setMaximum((int) fixedXRange.getUpperBound()); PlotPanel.getTimeSlider().setValue((int) fixedXRange.getCentralValue()); PlotPanel.getPortSlider().setMinimum((int) fixedYRange.getLowerBound()); PlotPanel.getPortSlider().setMaximum((int) fixedYRange.getUpperBound()); PlotPanel.getPortSlider().setValue((int) fixedYRange.getCentralValue()); HeatMapDepthPanel hmdp = new HeatMapDepthPanel(pHeatMap); PlotPanel.replaceDepthPanel(hmdp); } return null; }
From source file:edu.ucla.stat.SOCR.chart.demo.HistogramChartDemo3.java
protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, true, rangeLabel, dataset, PlotOrientation.VERTICAL, false, // !legendPanelOn, true, false);// w ww . j a v a2s . c o m // then customise it a little... // chart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do")); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setRenderer(new ClusteredXYBarRenderer()); XYItemRenderer renderer = plot.getRenderer(); StandardXYToolTipGenerator generator = new StandardXYToolTipGenerator("{1} = {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0")); renderer.setBaseToolTipGenerator(generator); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setLowerMargin(0.01); axis.setUpperMargin(0.01); // setXSummary(dataset); X is time return chart; }
From source file:org.jfree.chart.demo.XYStepAreaChartDemo.java
/** * Change options according to settings. * /*from w ww. ja v a 2 s. c o m*/ * @param evt the event. */ public void actionPerformed(final ActionEvent evt) { final Object source = evt.getSource(); if (source == this.nullValuesCheckBox) { final boolean withNulls = this.nullValuesCheckBox.isSelected(); for (int i = 0; i < TEST_DATA.length; i++) { Integer yVal = (Integer) TEST_DATA[i][1]; if (withNulls && TEST_DATA[i].length > 2) { yVal = null; } this.xySeries.getDataItem(i).setY(yVal); } } else if (source == this.outlineCheckBox) { final XYPlot plot = (XYPlot) this.chartPanel.getChart().getPlot(); ((XYStepAreaRenderer) plot.getRenderer()).setOutline(this.outlineCheckBox.isSelected()); } else if (source == this.rangeBaseTextField) { final double val = Double.parseDouble(this.rangeBaseTextField.getText()); final XYPlot plot = (XYPlot) this.chartPanel.getChart().getPlot(); final XYStepAreaRenderer rend = (XYStepAreaRenderer) plot.getRenderer(); rend.setRangeBase(val); } else if (source == this.orientationComboBox) { final XYPlot plot = (XYPlot) this.chartPanel.getChart().getPlot(); if (this.orientationComboBox.getSelectedItem() == ORIENT_HORIZ) { plot.setOrientation(PlotOrientation.HORIZONTAL); } else if (this.orientationComboBox.getSelectedItem() == ORIENT_VERT) { plot.setOrientation(PlotOrientation.VERTICAL); } } this.chartPanel.repaint(); }
From source file:com.att.aro.ui.view.diagnostictab.plot.AttenuatorPlot.java
/** * @param plot/*from w w w . j a v a 2 s . co m*/ * @param seriesDL * @param seriesUP */ private void setDataPlot(XYPlot plot, XYSeries seriesDL, XYSeries seriesUP) { XYSeriesCollection sercollection = new XYSeriesCollection(); sercollection.addSeries(seriesDL); sercollection.addSeries(seriesUP); XYStepRenderer renderer = new XYStepRenderer(); XYPlot plot1 = (XYPlot) plot; plot1.getRangeAxis().setAutoRangeMinimumSize(2.0);//for the data set is constant value(ex. 0) renderer = (XYStepRenderer) plot1.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); renderer.setSeriesStroke(1, new BasicStroke(4.0f)); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setDefaultEntityRadius(6); renderer.setBaseToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { StringBuffer displayInfo = new StringBuffer(); java.lang.Number tempx = dataset.getX(series, item); java.lang.Number tempy = dataset.getY(series, item); // series 0 -> downstream , stries 1 -> upstream String streamInfo = ""; if (series == 0) { streamInfo = "Downlink Delay"; } else { streamInfo = "Uplink Delay"; } return displayInfo.append("Time: " + tempx + " , " + streamInfo + " : " + tempy + "ms").toString(); } }); plot.setRenderer(renderer); plot.setDataset(sercollection); }
From source file:com.intel.stl.ui.main.view.HealthHistoryView.java
public void setDataset(final IntervalXYDataset dataset) { JFreeChart chart = ComponentFactory.createStepAreaChart(dataset, new XYItemLabelGenerator() { @Override// ww w . j a v a 2 s . c o m public String generateLabel(XYDataset dataset, int series, int item) { Number val = dataset.getY(series, item); return UIConstants.INTEGER.format(val.intValue()); } }); chart.addProgressListener(new ChartProgressListener() { @Override public void chartProgress(ChartProgressEvent event) { if (event.getType() == ChartProgressEvent.DRAWING_STARTED && currentValue != null) { currentValue.setText(scoreString); currentValue.setPaint(scoreColor); currentValue.setToolTipText(scoreTip); } } }); XYPlot plot = chart.getXYPlot(); plot.getRangeAxis().setRange(0, 105); plot.getRenderer().setSeriesPaint(0, UIConstants.INTEL_BLUE); currentValue = new TextTitle(scoreString, scoreFont); currentValue.setPaint(scoreColor); currentValue.setToolTipText(scoreTip); // currentValue.setBackgroundPaint(new Color(255, 255, 255, 128)); currentValue.setPosition(RectangleEdge.BOTTOM); XYTitleAnnotation xytitleannotation = new XYTitleAnnotation(0.49999999999999998D, 0.49999999999999998D, currentValue, RectangleAnchor.CENTER); // xytitleannotation.setMaxWidth(0.47999999999999998D); plot.addAnnotation(xytitleannotation); chartPanel.setChart(chart); }