List of usage examples for org.jfree.chart JFreeChart DEFAULT_TITLE_FONT
Font DEFAULT_TITLE_FONT
To view the source code for org.jfree.chart JFreeChart DEFAULT_TITLE_FONT.
Click Source Link
From source file:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.Thermometer.java
/** * Creates a chart of type thermometer.//w w w . ja va2 s . c o m * * @param chartTitle the chart title. * @param dataset the dataset. * * @return A chart thermometer. */ public JFreeChart createChart(DatasetMap datasets) { logger.debug("IN"); Dataset dataset = (Dataset) datasets.getDatasets().get("1"); ThermometerPlot plot = new ThermometerPlot((ValueDataset) dataset); JFreeChart chart = new JFreeChart(name, JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(color); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setPadding(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); plot.setThermometerStroke(new BasicStroke(2.0f)); plot.setThermometerPaint(Color.lightGray); plot.setGap(3); plot.setValueLocation(3); plot.setValuePaint(labelsValueStyle.getColor()); plot.setValueFont(new Font(labelsValueStyle.getFontName(), Font.PLAIN, labelsValueStyle.getSize())); plot.setRange(lower, upper); if (units.equalsIgnoreCase(FAHRENHEIT)) plot.setUnits(ThermometerPlot.UNITS_FAHRENHEIT); else if (units.equalsIgnoreCase(CELCIUS)) plot.setUnits(ThermometerPlot.UNITS_CELCIUS); else if (units.equalsIgnoreCase(KELVIN)) plot.setUnits(ThermometerPlot.UNITS_KELVIN); else plot.setUnits(ThermometerPlot.UNITS_NONE); // set subranges for (Iterator iterator = intervals.iterator(); iterator.hasNext();) { KpiInterval subrange = (KpiInterval) iterator.next(); int range = 0; if (subrange.getLabel().equalsIgnoreCase(NORMAL)) range = (ThermometerPlot.NORMAL); else if (subrange.getLabel().equalsIgnoreCase(WARNING)) range = (ThermometerPlot.WARNING); else if (subrange.getLabel().equalsIgnoreCase(CRITICAL)) range = (ThermometerPlot.CRITICAL); plot.setSubrange(range, subrange.getMin(), subrange.getMax()); if (subrange.getColor() != null) { plot.setSubrangePaint(range, subrange.getColor()); } //plot.setDisplayRange(subrange.getRange(), subrange.getLower(), subrange.getUpper()); } //plot.setFollowDataInSubranges(true); logger.debug("OUT"); return chart; }
From source file:biz.ixnay.pivot.charts.skin.jfree.SpiderWebViewSkin.java
@Override protected JFreeChart createChart() { ChartView chartView = (ChartView) getComponent(); String title = chartView.getTitle(); boolean showLegend = chartView.getShowLegend(); String seriesNameKey = chartView.getSeriesNameKey(); List<?> chartData = chartView.getChartData(); JFreeChart chart;/*from w w w . ja v a 2s . c o m*/ ChartView.CategorySequence categories = chartView.getCategories(); CategorySeriesDataset dataset = new CategorySeriesDataset(categories, seriesNameKey, chartData); // JFree ChartFactory is missing factory method for SpiderWebPlot SpiderWebPlot plot = new SpiderWebPlot(dataset); chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, showLegend); STANDARD_THEME.apply(chart); return chart; }
From source file:wsattacker.plugin.intelligentdos.ui.helper.ChartHelper.java
public static JFreeChart createOverlaidChart(SuccessfulAttack sa) { // create subplot 1... final XYSeries data1 = createDatasetResponseTime(RequestType.UNTAMPERED, sa.getUntamperedMetrics()); final XYSeries data2 = createDatasetResponseTime(RequestType.TAMPERED, sa.getTamperedMetrics()); final XYSeries data3 = createDatasetResponseTime(RequestType.TESTPROBES, sa.getTestProbes()); final XYSeriesCollection collection = new XYSeriesCollection(); collection.addSeries(data1);/*from w w w .jav a 2 s . com*/ collection.addSeries(data2); collection.addSeries(data3); final XYItemRenderer renderer = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis("duration in ms"); final XYPlot plot = new XYPlot(collection, new NumberAxis(""), rangeAxis1, renderer); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); renderer.setSeriesPaint(0, Color.GREEN); renderer.setSeriesPaint(1, Color.RED); renderer.setSeriesPaint(2, Color.BLUE); // return a new chart containing the overlaid plot... return new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.jfree.chart.demo.ChartTiming4.java
/** * Runs the test.//from w w w .j a v a 2 s .c o m */ public void run() { this.finished = false; // create a dataset... populateData(); // create a fast scatter chart... final Plot plot = new FastScatterPlot(this.data, new NumberAxis("X"), new NumberAxis("Y")); final JFreeChart chart = new JFreeChart("Fast Scatter Plot Timing", JFreeChart.DEFAULT_TITLE_FONT, plot, true); final BufferedImage image = new BufferedImage(400, 300, BufferedImage.TYPE_INT_RGB); final Graphics2D g2 = image.createGraphics(); final Rectangle2D chartArea = new Rectangle2D.Double(0, 0, 400, 300); // set up the timer... final Timer timer = new Timer(10000, this); timer.setRepeats(false); int count = 0; timer.start(); while (!this.finished) { chart.draw(g2, chartArea, null, null); System.out.println("Charts drawn..." + count); if (!this.finished) { count++; } } System.out.println("DONE"); }
From source file:org.cyberoam.iview.charts.MeterChart.java
/** * This method generates JFreeChart instance for Meter chart with dial port and iView customization. * @param reportID// w ww .ja v a 2s.c o m * @param rsw * @param request * @return */ public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) { ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID); JFreeChart chart = null; ReportColumnBean reportColumnBean = null; GraphBean graphBean = null; try { DefaultValueDataset data = null; graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId()); reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getYColumnId()); String yColumnDBname = reportColumnBean.getDbColumnName(); rsw.first(); double used = Double.parseDouble(rsw.getString(yColumnDBname)); data = new DefaultValueDataset(100 - used); DialPlot plot = new DialPlot(data); chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBackgroundPaint(Color.white); int imgWidth = graphBean.getWidth(); int imgHeight = graphBean.getHeight(); if (request != null && request.getParameter("imgwidth") != null && !"".equalsIgnoreCase(request.getParameter("imgwidth")) && !"null".equalsIgnoreCase(request.getParameter("imgwidth"))) { imgWidth = Integer.parseInt(request.getParameter("imgwidth")); } if (request != null && request.getParameter("imgheight") != null && !"".equalsIgnoreCase(request.getParameter("imgheight")) && !"null".equalsIgnoreCase(request.getParameter("imgheight"))) { imgHeight = Integer.parseInt(request.getParameter("imgheight")); } plot.setView((1 - ((double) imgWidth / (double) imgHeight)) / 2, plot.getViewY(), ((double) imgWidth / (double) imgHeight), plot.getViewHeight()); StandardDialFrame dialFrame = new StandardDialFrame(); dialFrame.setBackgroundPaint(new Color(54, 73, 109)); dialFrame.setRadius(0.8); dialFrame.setStroke(new BasicStroke(0)); plot.setDialFrame(dialFrame); GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(196, 210, 219)); DialBackground db = new DialBackground(gp); db.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL)); plot.setBackground(db); DialValueIndicator dvi = new DialValueIndicator(0); dvi.setRadius(0.55); dvi.setBackgroundPaint(gp); dvi.setNumberFormat(new DecimalFormat("###")); dvi.setFont(new Font("Vandara", Font.CENTER_BASELINE, 10)); dvi.setOutlinePaint(Color.lightGray); plot.addLayer(dvi); StandardDialScale scale = new StandardDialScale(0, 100, -120, -300, 10, 4); scale.setTickRadius(0.75); scale.setTickLabelOffset(0.15); scale.setTickLabelFont(new Font("Vandara", Font.CENTER_BASELINE, 9)); plot.addScale(0, scale); StandardDialRange range = new StandardDialRange(0.0, 50.0, Color.green); range.setInnerRadius(0.35); range.setOuterRadius(0.38); plot.addLayer(range); StandardDialRange range2 = new StandardDialRange(50.0, 75.0, Color.yellow); range2.setInnerRadius(0.35); range2.setOuterRadius(0.38); plot.addLayer(range2); StandardDialRange range3 = new StandardDialRange(75.0, 100.0, Color.red); range3.setInnerRadius(0.35); range3.setOuterRadius(0.38); plot.addLayer(range3); DialPointer needle = new DialPointer.Pointer(); needle.setRadius(0.55); plot.addLayer(needle); DialCap cap = new DialCap(); cap.setRadius(0.05); plot.setCap(cap); } catch (Exception e) { CyberoamLogger.appLog.debug("MeterChart=>Exception : " + e, e); } return chart; }
From source file:org.kurento.test.latency.ChartWriter.java
public void drawChart(String filename, int width, int height) throws IOException { // Create plot NumberAxis xAxis = new NumberAxis(xAxisLabel); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYSplineRenderer renderer = new XYSplineRenderer(); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4)); // Create chart JFreeChart chart = new JFreeChart(chartTitle, JFreeChart.DEFAULT_TITLE_FONT, plot, true); ChartUtilities.applyCurrentTheme(chart); ChartPanel chartPanel = new ChartPanel(chart, false); // Draw png//w w w . ja v a 2 s . c o m BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR); Graphics graphics = bi.getGraphics(); chartPanel.setBounds(0, 0, width, height); chartPanel.paint(graphics); ImageIO.write(bi, "png", new File(filename)); }
From source file:playground.yu.utils.charts.DoubleBarChart.java
public void saveAsPng(final String filename, final String title, final int width, final int height) { for (int i = 0; i < subCharts.length; i++) plot.add((CategoryPlot) subCharts[i].getChart().getPlot(), 1); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); // add MATSim logo Image image = MatsimResource.getAsImage("matsim_logo_transparent_small.png"); Title subtitle = new ImageTitle(image, RectangleEdge.BOTTOM, HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM);/*from w w w . j av a 2 s . c o m*/ chart.addSubtitle(subtitle); // add default Formatting chart.setBackgroundPaint(new Color(1.0f, 1.0f, 1.0f, 1.0f)); chart.getLegend().setBorder(0.0, 0.0, 0.0, 0.0); try { ChartUtilities.saveChartAsPNG(new File(filename), chart, width, height, null, true, 9); } catch (IOException e) { e.printStackTrace(); } }
From source file:graph.jfreecharts.GraphFunction.java
/** * A custom xyerror renderer because jfreecharts does not * have it supported in the api.//from w w w .j av a 2s .c o m * @param title the graph title * @param xAxisLabel the xaxis title * @param yAxisLabel the yaxis title * @param dataset the xydataset * @param orientation the plot orientation * @param legend true to turn on legend * @param tooltips true to turn on tooltips (the pop up when right click) * @param urls // no idea what this is for * @return */ private static JFreeChart createXYIntervalChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYErrorRenderer renderer = new XYErrorRenderer(); renderer.setDrawXError(true); renderer.setDrawYError(true); xAxis.setNumberFormatOverride(new DecimalFormat("0.######E0")); yAxis.setNumberFormatOverride(new DecimalFormat("0.######E0")); xAxis.setAutoRangeIncludesZero(false); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(orientation); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
From source file:ste.travian.world.WorldChart.java
/** * Create the JFreeChart world chart// w w w . ja v a 2 s . com * * @param title world title * @param dataset world data set * */ private void createWorldPlot(String title, XYDataset dataset) { NumberAxis xAxis = new NumberAxis(LABEL_X_AXIS); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(LABEL_Y_AXIS); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); TileRenderer renderer = new TileRenderer(3, 3); renderer.setBaseToolTipGenerator(new TileToolTipGenerator()); plot.setRenderer(renderer); plot.setOrientation(PlotOrientation.VERTICAL); chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.jfree.chart.demo.SymbolicXYPlotDemo.java
/** * Creates a XY graph with symbolic value on X and Y axis. * /*from w ww.j av a 2s . c o m*/ * @param title * the title. * @param xAxisLabel * the x axis label. * @param yAxisLabel * the y axis label. * @param data * the dataset. * @param legend * create a legend? * @return a chart. */ public static JFreeChart createXYSymbolicPlot(final String title, final String xAxisLabel, final String yAxisLabel, final XYDataset data, final boolean legend) { final SymbolicAxis xSymbolicAxis = new SymbolicAxis(xAxisLabel, ((XisSymbolic) data).getXSymbolicValues()); final SymbolicAxis ySymbolicAxis = new SymbolicAxis(yAxisLabel, ((YisSymbolic) data).getYSymbolicValues()); final XYPlot plot = new XYPlot(data, xSymbolicAxis, ySymbolicAxis, null); final XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, new SymbolicXYItemLabelGenerator()); plot.setRenderer(renderer); final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }