List of usage examples for org.jfree.chart JFreeChart setBorderVisible
public void setBorderVisible(boolean visible)
From source file:org.shredzone.bullshitcharts.servlet.ChartServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String pathInfo = req.getPathInfo(); PlotGenerator generator = null;// ww w .ja v a 2 s . c o m if ("/pie.png".equals(pathInfo)) { generator = new ChoicePieGenerator(); } else if ("/agree.png".equals(pathInfo)) { generator = new AgreementPieGenerator(); } else if ("/line.png".equals(pathInfo)) { generator = new LineChartGenerator(); } else if ("/bar.png".equals(pathInfo)) { generator = new BarChartGenerator(); } else { resp.setStatus(HttpServletResponse.SC_NOT_FOUND); return; } generator.configure(req); Plot plot = generator.generate(); // Generate the chart JFreeChart chart = new JFreeChart(plot); chart.setAntiAlias(true); chart.setTextAntiAlias(true); chart.setBorderVisible(false); chart.removeLegend(); String title = req.getParameter("title"); if (title != null) { chart.setTitle(title); } // Write the chart to a byte array. It is small enough so it won't load the // server's memory too much. try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { ChartUtilities.writeChartAsPNG(baos, chart, IMAGE_WIDTH, IMAGE_HEIGHT); byte[] data = baos.toByteArray(); // Stream the chart resp.setContentType("image/png"); resp.setContentLength(data.length); resp.setHeader("Cache-Control", "no-cache, must-revalidate"); resp.setHeader("Expires", "Sat, 01 Jan 2000 00:00:00 GMT"); resp.getOutputStream().write(data); } }
From source file:picocash.components.panel.statistic.AbstractPieStatisticComponent.java
private final void init() { this.title = getTitle(); this.dataset = new DefaultPieDataset(); this.chartPanel = new JXPanel(new MigLayout("fill, insets 0 0 0 0")); final JFreeChart piechart = ChartFactory.createPieChart(title, dataset, true, true, Locale.getDefault()); ((PiePlot) piechart.getPlot()).setLabelGenerator(null); piechart.setBorderVisible(false); piechart.setAntiAlias(true);//w ww .j a va2 s . c o m ChartPanel chart = new ChartPanel(piechart, 300, 300, 200, 200, 400, 400, false, false, false, false, false, true); chart.getChart().getPlot().setBackgroundAlpha(0); chart.getChart().getPlot().setOutlineVisible(false); this.chartPanel.setOpaque(false); this.chartPanel.add(chart, "growx, aligny top"); }
From source file:info.novatec.testit.livingdoc.confluence.macros.historic.LinearExecutionChartBuilder.java
@SuppressWarnings("deprecation") private void customizeChart(JFreeChart chart) { chart.setBackgroundPaint(Color.white); chart.setBorderVisible(settings.isBorder()); TextTitle chartTitle = chart.getTitle(); customizeTitle(chartTitle, DEFAULT_TITLE_FONT); addSubTitle(chart, settings.getSubTitle(), DEFAULT_SUBTITLE_FONT); addSubTitle(chart, settings.getSubTitle2(), DEFAULT_SUBTITLE2_FONT); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setNoDataMessage(ldUtil.getText("livingdoc.historic.nodata")); CategoryItemRenderer renderer = plot.getRenderer(); int index = 0; renderer.setSeriesPaint(index++, GREEN_COLOR); if (settings.isShowIgnored()) { renderer.setSeriesPaint(index++, Color.yellow); }/* ww w . j a v a2 s.c o m*/ renderer.setSeriesPaint(index, Color.red); renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator()); renderer.setItemURLGenerator(new CategoryURLGenerator() { @Override public String generateURL(CategoryDataset data, int series, int category) { Comparable<?> valueKey = data.getColumnKey(category); ChartLongValue value = (ChartLongValue) valueKey; return "javascript:" + settings.getExecutionUID() + "_showExecutionResult('" + value.getId() + "');"; } }); CategoryAxis domainAxis = plot.getDomainAxis(); customizeAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); ValueAxis rangeAxis = plot.getRangeAxis(); customizeAxis(rangeAxis); rangeAxis.setLowerBound(0); if (rangeAxis instanceof NumberAxis) { ((NumberAxis) rangeAxis).setTickUnit(new NumberTickUnit(1)); } plot.setForegroundAlpha(0.8f); }
From source file:picocash.components.panel.statistic.ExpenseByCategoryStatistic.java
private void init() { this.title = "Expense"; this.dataset = new DefaultPieDataset(); this.chartPanel = new JXPanel(new MigLayout("fill, insets 0 0 0 0")); final JFreeChart piechart = ChartFactory.createPieChart(title, dataset, true, true, Locale.getDefault()); ((PiePlot) piechart.getPlot()).setLabelGenerator(null); piechart.setBorderVisible(false); piechart.setAntiAlias(true);/* w w w . j a v a2s . co m*/ ChartPanel chart = new ChartPanel(piechart, 300, 300, 200, 200, 400, 400, false, false, false, false, false, true); chart.getChart().getPlot().setBackgroundAlpha(0); chart.getChart().getPlot().setOutlineVisible(false); this.chartPanel.setOpaque(false); this.chartPanel.add(chart, "growx, aligny top"); }
From source file:com.greenpepper.confluence.macros.historic.LinearExecutionChartBuilder.java
private void customizeChart(JFreeChart chart) throws IOException { chart.setBackgroundPaint(Color.white); chart.setBorderVisible(settings.isBorder()); TextTitle chartTitle = chart.getTitle(); customizeTitle(chartTitle, DEFAULT_TITLE_FONT); addSubTitle(chart, settings.getSubTitle(), DEFAULT_SUBTITLE_FONT); addSubTitle(chart, settings.getSubTitle2(), DEFAULT_SUBTITLE2_FONT); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setNoDataMessage(gpUtil.getText("greenpepper.historic.nodata")); CategoryItemRenderer renderer = plot.getRenderer(); int index = 0; renderer.setSeriesPaint(index++, GREEN_COLOR); if (settings.isShowIgnored()) renderer.setSeriesPaint(index++, Color.yellow); renderer.setSeriesPaint(index, Color.red); renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator()); renderer.setItemURLGenerator(new CategoryURLGenerator() { public String generateURL(CategoryDataset data, int series, int category) { Comparable valueKey = data.getColumnKey(category); ChartLongValue value = (ChartLongValue) valueKey; return "javascript:" + settings.getExecutionUID() + "_showExecutionResult('" + value.getId() + "');"; }//from w ww . j av a 2s .c om }); CategoryAxis domainAxis = plot.getDomainAxis(); customizeAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); ValueAxis rangeAxis = plot.getRangeAxis(); customizeAxis(rangeAxis); rangeAxis.setLowerBound(0); if (rangeAxis instanceof NumberAxis) { ((NumberAxis) rangeAxis).setTickUnit(new NumberTickUnit(1)); } plot.setForegroundAlpha(0.8f); }
From source file:org.adempiere.webui.apps.graph.WPerformanceIndicator.java
/** * Init Graph Display//from ww w .ja v a2 s . c om * Kinamo (pelgrim) */ private void init() { JFreeChart chart = createChart(); chart.setBackgroundPaint(Color.WHITE); chart.setBorderVisible(true); chart.setBorderPaint(Color.LIGHT_GRAY); chart.setAntiAlias(true); BufferedImage bi = chart.createBufferedImage(200, 120, BufferedImage.TRANSLUCENT, null); try { byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true); AImage image = new AImage("", bytes); Image myImage = new Image(); myImage.setContent(image); appendChild(myImage); } catch (Exception e) { // TODO: handle exception } invalidate(); }
From source file:net.pickapack.chart.LinePlotFrame.java
/** * Create a line plot frame.//from w w w . ja va 2 s. c o m * * @param linePlot the line plot * @param width the width * @param height the height */ public LinePlotFrame(LinePlot linePlot, int width, int height) { super(linePlot.getTitle()); this.linePlot = linePlot; this.numSubPlots = linePlot.getSubLinePlots().size(); CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time")); this.dataSets = new ArrayList<TimeSeriesCollection>(); this.dataSinks = new ArrayList<Map<SubLinePlotLine, Function<Double>>>(); for (SubLinePlot subLinePlot : linePlot.getSubLinePlots()) { TimeSeriesCollection dataSetsPerSubPlot = new TimeSeriesCollection(); this.dataSets.add(dataSetsPerSubPlot); HashMap<SubLinePlotLine, Function<Double>> dataSinksPerSubPlot = new HashMap<SubLinePlotLine, Function<Double>>(); this.dataSinks.add(dataSinksPerSubPlot); for (SubLinePlotLine subLinePlotLine : subLinePlot.getLines()) { TimeSeries timeSeries = new TimeSeries(subLinePlotLine.getTitle()); dataSetsPerSubPlot.addSeries(timeSeries); dataSinksPerSubPlot.put(subLinePlotLine, subLinePlotLine.getGetValueCallback()); } NumberAxis rangeAxis = new NumberAxis(subLinePlot.getTitleY()); rangeAxis.setAutoRangeIncludesZero(false); XYPlot subplot = new XYPlot(dataSetsPerSubPlot, null, rangeAxis, new StandardXYItemRenderer()); subplot.setBackgroundPaint(Color.lightGray); subplot.setDomainGridlinePaint(Color.white); subplot.setRangeGridlinePaint(Color.white); plot.add(subplot); } JFreeChart chart = new JFreeChart(linePlot.getTitle(), plot); chart.setBorderPaint(Color.black); chart.setBorderVisible(true); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(3600000.0); JPanel content = new JPanel(new BorderLayout()); ChartPanel chartPanel = new ChartPanel(chart); content.add(chartPanel); chartPanel.setPreferredSize(new java.awt.Dimension(width, height)); chartPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setContentPane(content); DataSink dataSink = new DataSink(); new Thread(dataSink).start(); }
From source file:org.sonar.server.charts.deprecated.BaseChart.java
protected void configureChart(JFreeChart chart, RectangleEdge legendPosition) { chart.setBackgroundPaint(new Color(255, 255, 255, 0)); chart.setBackgroundImageAlpha(0.0f); chart.setBorderVisible(false); chart.setAntiAlias(true);// ww w. j a v a 2 s . co m chart.setTextAntiAlias(true); chart.removeLegend(); if (legendPosition != null) { LegendTitle legend = new LegendTitle(chart.getPlot()); legend.setPosition(legendPosition); legend.setItemPaint(BASE_COLOR); chart.addSubtitle(legend); } }
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 a 2 s. 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:com.googlecode.jchav.chart.MinMeanMaxChart.java
/** * Construct a new chart to display the given data. * * @param title The page id, used for the title of the chart. * @param data the data to plot.// w ww . jav a 2 s .co m */ public MinMeanMaxChart(final String title, final SortedSet<Measurement> data) { // The renderer that does all the real work here: final MinMaxCategoryRenderer minMaxRenderer = new MinMaxCategoryRenderer(); minMaxRenderer.setObjectIcon(new FilledCircle()); // Munge the data into form JFreeChart can use: DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (Measurement m : data) { // This ordering gives max=red, min=green, mean=blue dataset.addValue(m.getMaximumTime(), "max", m.getBuildId().getBuildName()); dataset.addValue(m.getAverageTime(), "mean", m.getBuildId().getBuildName()); dataset.addValue(m.getMinimumTime(), "min", m.getBuildId().getBuildName()); } // Create the plot area: final CategoryPlot plot = new CategoryPlot(); plot.setDataset(dataset); plot.setRenderer(minMaxRenderer); plot.setDomainAxis(new CategoryAxis("Build")); // TO DO: i18n plot.setRangeAxis(new NumberAxis("RT")); // Build labels running diagonally under the bars of the chart. plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); plot.setOrientation(PlotOrientation.VERTICAL); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(false); // the legend here would be the "min", "max", "mean" strings used when created int category data set. boolean showLegend = true; // Render the chart: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, showLegend); chart.setTitle(title); chart.setBackgroundPaint(Color.WHITE); chart.setBorderVisible(false); if (showLegend) { chart.getLegend().setBorder(BlockBorder.NONE); } this.setChart(chart); }