List of usage examples for org.jfree.chart JFreeChart setTitle
public void setTitle(String text)
From source file:no.met.jtimeseries.netcdf.NetcdfChartProvider.java
/** * Convert {@link Phenomenon} list to a {@link JFreeChart} * // ww w. j a v a 2 s .co m * @param dataList The data to convert * @return A complete chart, ready to display */ private JFreeChart getChart(List<NumberPhenomenon> dataList) { JFreeChart chart = new JFreeChart(getPlotProvider().getPlot(dataList)); if (header != null) chart.setTitle(header); return chart; }
From source file:AsymptoticFreedom.GraphViewPanel.java
public JFreeChart getResultChart() { // XY ?//w ww .j a v a 2 s . c o m int quark_size = ViewPanel.quark_list.size(); if (quark_size < 2) return new JFreeChart(new XYPlot()); // XY Dataset XYSeriesCollection data = new XYSeriesCollection(); //System.out.println(series.get(0).getY(30)); for (XYSeries s : series) { data.addSeries(s); } final JFreeChart chart = ChartFactory.createXYLineChart("Potential", "Distance", "Potential", data, PlotOrientation.VERTICAL, true, true, false); chart.setTitle("Potential of quarks"); // ? XYPlot plot = (XYPlot) chart.getPlot(); //plot.addRangeMarker(new ValueMarker(15,Color.RED,new BasicStroke(2.0f))); for (int i = 0; i < quark_size; i++) { for (int j = i + 1; j < quark_size; j++) { Quark quark1 = ViewPanel.quark_list.get(i); Quark quark2 = ViewPanel.quark_list.get(j); double distance = quark1.pos.distance(quark2.pos); double value = quark1.calculatePotential(quark2); String anno_title = String.format("V_ %c-%c", quark1.color.charAt(0), quark2.color.charAt(0)); //System.out.println(anno_title); XYPointerAnnotation pointer = new XYPointerAnnotation(anno_title, distance, value, 3.0 * Math.PI / 4.0); plot.addAnnotation(pointer); } } plot.getRangeAxis().setRange(-500, 4000); return chart; }
From source file:com.thecoderscorner.groovychart.chart.BaseChart.java
public JFreeChart setExtraProperties(JFreeChart chart) { if (this.getTextTitle() != null) chart.setTitle(this.getTextTitle()); if (chartProperties.size() > 0) { try {/*from w w w . ja va2 s .co m*/ bb.setProperties(chart, chartProperties); } catch (InvocationTargetException ex) { ex.printStackTrace(); } catch (IllegalAccessException ex) { ex.printStackTrace(); } } return chart; }
From source file:com.ohalo.cn.awt.JFreeChartTest.java
public List<JFreeChart> printHardDiskCharts() throws SigarException { Sigar sigar = new Sigar(); FileSystem fslist[] = sigar.getFileSystemList(); ArrayList<JFreeChart> charts = new ArrayList<JFreeChart>(); for (int i = 0; i < fslist.length; i++) { FileSystem fs = fslist[i]; String diskName = fs.getDevName(); FileSystemUsage usage = null;// ww w . j a va2s . com try { usage = sigar.getFileSystemUsage(fs.getDirName()); } catch (SigarException e) { if (fs.getType() == 2) throw e; continue; } DefaultPieDataset dpd = new DefaultPieDataset(); // if (fs.getType() == 2) { dpd.setValue("??(" + usage.getAvail() / 1024 / 1024 + "GB)", usage.getAvail()); dpd.setValue("?(" + usage.getUsed() / 1024 / 1024 + "GB)", usage.getUsed()); } JFreeChart chart = ChartFactory.createPieChart("???", dpd, true, true, false); chart.setTitle(":" + diskName); Font font2 = new Font("", Font.BOLD, 12); chart.getTitle().setFont(font2); PiePlot pieplot = (PiePlot) chart.getPlot(); pieplot.setLabelFont(font2); chart.getLegend().setItemFont(font2); charts.add(chart); } return charts; }
From source file:lu.lippmann.cdb.lab.mds.MDSViewBuilder.java
/** * // w ww . j a va 2s .com */ public static JXPanel buildMDSViewFromDataSet(final Instances instances, final MDSResult mdsResult, final int maxInstances, final Listener<Instances> listener, final String... attrNameToUseAsPointTitle) throws Exception { final XYSeriesCollection dataset = new XYSeriesCollection(); final JFreeChart chart = ChartFactory.createScatterPlot("", // title "X", "Y", // axis labels dataset, // dataset PlotOrientation.VERTICAL, attrNameToUseAsPointTitle.length == 0, // legend? true, // tooltips? yes false // URLs? no ); final XYPlot xyPlot = (XYPlot) chart.getPlot(); xyPlot.setBackgroundPaint(Color.WHITE); xyPlot.getDomainAxis().setTickLabelsVisible(false); xyPlot.getRangeAxis().setTickLabelsVisible(false); //FIXME : should be different for Shih if (!mdsResult.isNormalized()) { String stress = FormatterUtil.DECIMAL_FORMAT .format(ClassicMDS.getKruskalStressFromMDSResult(mdsResult)); chart.setTitle(mdsResult.getCInstances().isCollapsed() ? "Collapsed MDS(Instances=" + maxInstances + ",Stress=" + stress + ")" : "MDS(Stress=" + stress + ")"); } else { chart.setTitle(mdsResult.getCInstances().isCollapsed() ? "Collapsed MDS(Instances=" + maxInstances + ")" : "MDS"); } final SimpleMatrix coordinates = mdsResult.getCoordinates(); buildFilteredSeries(mdsResult, xyPlot, attrNameToUseAsPointTitle); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setMouseWheelEnabled(true); chartPanel.setPreferredSize(new Dimension(1200, 900)); chartPanel.setBorder(new TitledBorder("MDS Projection")); chartPanel.setBackground(Color.WHITE); final JButton selectionButton = new JButton("Select data"); selectionButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final org.jfree.data.Range XDomainRange = xyPlot.getDomainAxis().getRange(); final org.jfree.data.Range YDomainRange = xyPlot.getRangeAxis().getRange(); final Instances cInstances = mdsResult.getCollapsedInstances(); final Instances selectedInstances = new Instances(cInstances, 0); List<Instances> clusters = null; if (mdsResult.getCInstances().isCollapsed()) { clusters = mdsResult.getCInstances().getCentroidMap().getClusters(); } for (int i = 0; i < cInstances.numInstances(); i++) { final Instance centroid = instances.instance(i); if (XDomainRange.contains(coordinates.get(i, 0)) && YDomainRange.contains(coordinates.get(i, 1))) { if (mdsResult.getCInstances().isCollapsed()) { if (clusters != null) { final Instances elementsOfCluster = clusters.get(i); final int nbElements = elementsOfCluster.numInstances(); for (int k = 0; k < nbElements; k++) { selectedInstances.add(elementsOfCluster.get(k)); } } } else { selectedInstances.add(centroid); } } } if (listener != null) { listener.onAction(selectedInstances); } } }); final JXPanel allPanel = new JXPanel(); allPanel.setLayout(new BorderLayout()); allPanel.add(chartPanel, BorderLayout.CENTER); final JXPanel southPanel = new JXPanel(); southPanel.add(selectionButton); allPanel.add(southPanel, BorderLayout.SOUTH); return allPanel; }
From source file:com.romraider.logger.ecu.ui.handler.dash.DialGaugeStyle.java
protected JFreeChart buildChart() { DialPlot plot = new DialPlot(); plot.setView(0.0, 0.0, 1.0, 1.0);//from w w w. j a v a 2s . c o m plot.setDataset(0, current); plot.setDataset(1, max); plot.setDataset(2, min); DialFrame dialFrame = new StandardDialFrame(); plot.setDialFrame(dialFrame); GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(170, 170, 220)); DialBackground db = new DialBackground(gp); db.setGradientPaintTransformer(new StandardGradientPaintTransformer(VERTICAL)); plot.setBackground(db); unitsLabel.setFont(new Font(Font.DIALOG, BOLD, 15)); unitsLabel.setRadius(0.7); unitsLabel.setLabel(loggerData.getSelectedConvertor().getUnits()); plot.addLayer(unitsLabel); DecimalFormat format = new DecimalFormat(loggerData.getSelectedConvertor().getFormat()); DialValueIndicator dvi = new DialValueIndicator(0); dvi.setNumberFormat(format); plot.addLayer(dvi); EcuDataConvertor convertor = loggerData.getSelectedConvertor(); GaugeMinMax minMax = convertor.getGaugeMinMax(); StandardDialScale scale = new StandardDialScale(minMax.min, minMax.max, 225.0, -270.0, minMax.step, 5); scale.setTickRadius(0.88); scale.setTickLabelOffset(0.15); scale.setTickLabelFont(new Font(Font.DIALOG, PLAIN, 12)); scale.setTickLabelFormatter(format); plot.addScale(0, scale); plot.addScale(1, scale); plot.addScale(2, scale); StandardDialRange range = new StandardDialRange(rangeLimit(minMax, 0.75), minMax.max, RED); range.setInnerRadius(0.52); range.setOuterRadius(0.55); plot.addLayer(range); StandardDialRange range2 = new StandardDialRange(rangeLimit(minMax, 0.5), rangeLimit(minMax, 0.75), ORANGE); range2.setInnerRadius(0.52); range2.setOuterRadius(0.55); plot.addLayer(range2); StandardDialRange range3 = new StandardDialRange(minMax.min, rangeLimit(minMax, 0.5), GREEN); range3.setInnerRadius(0.52); range3.setOuterRadius(0.55); plot.addLayer(range3); DialPointer needleCurrent = new DialPointer.Pointer(0); plot.addLayer(needleCurrent); DialPointer needleMax = new DialPointer.Pin(1); needleMax.setRadius(0.84); ((DialPointer.Pin) needleMax).setPaint(RED); ((DialPointer.Pin) needleMax).setStroke(new BasicStroke(1.5F)); plot.addLayer(needleMax); DialPointer needleMin = new DialPointer.Pin(2); needleMin.setRadius(0.84); ((DialPointer.Pin) needleMin).setPaint(BLUE); ((DialPointer.Pin) needleMin).setStroke(new BasicStroke(1.5F)); plot.addLayer(needleMin); DialCap cap = new DialCap(); cap.setRadius(0.10); plot.setCap(cap); JFreeChart chart = new JFreeChart(plot); chart.setTitle(loggerData.getName()); return chart; }
From source file:hudson.plugins.codeviation.JavaFileIterableView.java
public void doGraph(StaplerRequest req, StaplerResponse rsp) throws IOException { Lookup lookup = Lookup.getDefault(); ChartConfProvider provider = null;// ww w . java 2 s . c o m ChartConf conf = getChartConf(req); if (lookup != null) { for (ChartConfProvider prov : lookup.lookupAll(ChartConfProvider.class)) { for (ChartConf c : prov.getChartConfs()) { if (c.equals(conf)) { provider = prov; } } } } if (provider == null) { provider = new CountsStatHandler(); conf = provider.getChartConfs()[0]; } Graph graph = conf.createGraph(); if (graph == null) { getLogger().info("Date:" + getMinDate() + "," + getMaxDate()); graph = new Statistics(getMinDate(), getMaxDate()); } JavaFileHandler handler = conf.getStatHandler(); graph.setJavaFileHandler(handler); graph.setItemsCount(100); handler.init(graph); graph.addJavaFiles(getJavaFiles()); handler.initGraphPaint(conf); JFreeChart chart = graph.getChart(conf, true); chart.setBackgroundPaint(Color.WHITE); chart.setTitle((String) null); XYPlot plot = (XYPlot) chart.getPlot(); // plot.setDomainGridlinePaint(Color.BLACK); // plot.setRangeGridlinePaint(Color.BLACK); // // 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.setUseFillPaint(true); // // // renderer.setSeriesItemLabelsVisible(1, true); // renderer.setUseOutlinePaint(true); renderer.setStroke(new BasicStroke(2.0f)); //// renderer.getPlot().setRenderer(1, r)getRenderer(1).setStroke(); //// renderer.setStroke(); // // // renderer.setS } // ChartUtil.generateGraph(req, rsp, chart, 400, 400); }
From source file:se.backede.jeconomix.forms.budget.BudgetOutcomePanel.java
private void setChart(JPanel panel, BudgetOutcomeModel model, CategoryTypeEnum category) { JFreeChart barChart = ChartFactory.createBarChart(category.name() + " budget vs outcome", "", "", createDataset(model), PlotOrientation.HORIZONTAL, true, true, false); barChart.setTitle(new org.jfree.chart.title.TextTitle( WordUtils.capitalizeFully(category.name()) + " budget vs outcome", new java.awt.Font("Courier New", java.awt.Font.PLAIN, 12))); ChartPanel chartPanel = new ChartPanel(barChart); chartPanel.setPreferredSize(new java.awt.Dimension(panel.getWidth(), panel.getHeight())); panel.setLayout(new BorderLayout()); panel.add(chartPanel, BorderLayout.NORTH); }
From source file:uk.ac.ed.epcc.webapp.charts.jfreechart.JFreeChartData.java
private JFreeChart getCustomisedJFreeChart() { JFreeChart chart = getJFreeChart(); chart.getPlot().setBackgroundPaint(/*from www . j a v a 2 s.c o m*/ new GradientPaint(0.0f, 0.0F, new Color(0.75F, 0.75F, 1.0F), 0.0F, 100.0F, Color.white, false)); if (title != null && title.trim().length() > 0) { chart.setTitle(title); } return chart; }
From source file:signalviewer.SignalViewer.java
private void getPlot() { update_data();//from www .ja va 2s .c om // ChartPanel[] panels = new ChartPanel[max_plots]; for (int j = 0; j < max_plots; j++) { XYSeries series = new XYSeries("Planned"); for (int i = 0; i < max_bins; i++) { series.add((double) i, D[j][i]); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createXYLineChart("Line Chart Demo", "X", "Y", dataset); chart.setTitle(""); chart.removeLegend(); XYPlot plot = (XYPlot) chart.getPlot(); // draw a horizontal line across the chart at y == 0 // plot.addRangeMarker(new Marker(0, Color.red, new BasicStroke(1), Color.red, 1f)); // ChartPanel panel = new ChartPanel(chart); if (panels[j] == null) { panels[j] = new ChartPanel(chart); } else { panels[j].setChart(chart); // panels[j].setMaximumDrawHeight(200); panels[j].revalidate(); panels[j].repaint(); } // panels[j] = panel; } // return panels; }