List of usage examples for org.jfree.chart JFreeChart setAntiAlias
public void setAntiAlias(boolean flag)
From source file:org.adempiere.webui.apps.graph.jfreegraph.ChartRendererServiceImpl.java
@Override public boolean renderPerformanceIndicator(Component parent, int chartWidth, int chartHeight, IndicatorModel model) {//from w w w . j av a 2s . c om PerformanceGraphBuilder builder = new PerformanceGraphBuilder(); JFreeChart chart = builder.createIndicatorChart(model); chart.setBackgroundPaint(model.chartBackground); chart.setAntiAlias(true); BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null); try { byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true); AImage image = new AImage("", bytes); Image myImage = new Image(); myImage.setContent(image); parent.appendChild(myImage); } catch (Exception e) { e.printStackTrace(); return false; } return true; }
From source file:com.manydesigns.portofino.chart.Chart1DGenerator.java
public JFreeChart generate(ChartDefinition chartDefinition, Persistence persistence, Locale locale) { DefaultPieDataset dataset = new DefaultPieDataset(); java.util.List<Object[]> result; String query = chartDefinition.getQuery(); logger.info(query);//from w w w .ja v a2 s .c om Session session = persistence.getSession(chartDefinition.getDatabase()); result = QueryUtils.runSql(session, query); for (Object[] current : result) { ComparableWrapper key = new ComparableWrapper((Comparable) current[0]); dataset.setValue(key, (Number) current[1]); if (current.length > 2) { key.setLabel(current[2].toString()); } } JFreeChart chart = createChart(chartDefinition, dataset); chart.setAntiAlias(isAntiAlias()); // impostiamo il bordo invisibile // eventualmente e' il css a fornirne uno // eventualmente e' il css a fornirne uno chart.setBorderVisible(isBorderVisible()); // impostiamo il titolo TextTitle title = chart.getTitle(); title.setFont(titleFont); title.setMargin(10.0, 0.0, 0.0, 0.0); // ottieni il Plot PiePlot plot = (PiePlot) chart.getPlot(); String urlExpression = chartDefinition.getUrlExpression(); if (!StringUtils.isBlank(urlExpression)) { PieURLGenerator urlGenerator = new ChartPieUrlGenerator(urlExpression); plot.setURLGenerator(urlGenerator); } else { plot.setURLGenerator(null); } // il plot ha sfondo e bordo trasparente // (quindi si vede il colore del chart) plot.setBackgroundPaint(transparentColor); plot.setOutlinePaint(transparentColor); // Modifico il toolTip // hongliangpan add // :?{0} {1} {2} ? ,??? plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})", NumberFormat.getNumberInstance(), new DecimalFormat("0.00%"))); // {0}={1}({2}) plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}")); // ?(0.0-1.0) // plot.setForegroundAlpha(1.0f); // imposta la distanza delle etichette dal plot plot.setLabelGap(0.03); // plot.setLabelGenerator(new MyPieSectionLabelGenerator()); // imposta il messaggio se non ci sono dati plot.setNoDataMessage(ElementsThreadLocals.getText("no.data.available")); plot.setCircular(true); plot.setBaseSectionOutlinePaint(Color.BLACK); DrawingSupplier supplier = new DesaturatedDrawingSupplier(plot.getDrawingSupplier()); plot.setDrawingSupplier(supplier); // ? plot.setForegroundAlpha(1.0f); // impostiamo il titolo della legenda String legendString = chartDefinition.getLegend(); Title subtitle = new TextTitle(legendString, legendFont, Color.BLACK, RectangleEdge.BOTTOM, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, new RectangleInsets(0, 0, 0, 0)); subtitle.setMargin(0, 0, 5, 0); chart.addSubtitle(subtitle); // impostiamo la legenda LegendTitle legend = chart.getLegend(); legend.setBorder(0, 0, 0, 0); legend.setItemFont(legendItemFont); int legendMargin = 10; legend.setMargin(0.0, legendMargin, legendMargin, legendMargin); legend.setBackgroundPaint(transparentColor); // impostiamo un gradiente orizzontale Paint chartBgPaint = new GradientPaint(0, 0, new Color(255, 253, 240), 0, getHeight(), Color.WHITE); chart.setBackgroundPaint(chartBgPaint); return chart; }
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);//from w w w . j a va 2 s. com piechart.setAntiAlias(true); 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:daylightchart.options.chart.ChartOptions.java
/** * {@inheritDoc}//w ww .j a va 2 s . c o m * * @see BaseChartOptions#updateChart(org.jfree.chart.JFreeChart) */ @Override public void updateChart(final JFreeChart chart) { if (chart instanceof ChartOptionsListener) { ((ChartOptionsListener) chart).beforeSettingChartOptions(this); } // chart.setAntiAlias(antiAlias); chart.setBackgroundPaint(backgroundPaint); // plotOptions.updateChart(chart); titleOptions.updateChart(chart); // if (chart instanceof ChartOptionsListener) { ((ChartOptionsListener) chart).afterSettingChartOptions(this); } }
From source file:CorrelationLambdaTest.java
@Test public void crossCorrelationGraphicTest() { CategoryTableXYDataset serie = new CategoryTableXYDataset(); serie.setNotify(false);//from w w w. j av a 2 s .co m double step = 1.0 / discretization; double startPosition = step * framePosition; //100 ? - 100 , 50 ? - 50 , 25 ?- 25 Transform t = new Transform(new FastWaveletTransform(new Haar1())); double[] signal = testData.get1DSimpleSignal(1.5, 500, 32768, 5000); double[] data = crossCorrelationCoefficient(signal, window); // double[] data = math.convolve(testData.get1DSignal(100, 200, frameWidth, discretization), math.lpf(70, step, 128)); // double[] data = math.convolve(testData.get1DSignal(100, 200, 32768, 10000), math.lpf(70, 1./10000, 32)); // double[] data = testData.get1DSignal(100, 200, frameWidth, discretization); // double[] data = math.lpf(70, step,128); for (int i = 0; i < data.length; i++) { serie.add(startPosition, data[i], ""); startPosition += step; } JFreeChart chart = ChartFactory.createXYLineChart("", "t,c", "wave", serie); chart.removeLegend(); chart.setAntiAlias(false); XYPlot plot = chart.getXYPlot(); //plot.setRangeGridlinePaint(Color.BLACK); org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis(); org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis(); double start = framePosition * 1.0 / discretization; double max = start + frameWidth * 1.0 / discretization; xAxis.setRange(start, max); ChartPanel chartPanel = new ChartPanel(chart); JPanel p = new JPanel(new BorderLayout()); p.removeAll(); p.add(chartPanel); p.validate(); //1. Create the frame. JFrame frame = new JFrame("FrameDemo"); //2. Optional: What happens when the frame closes? frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //3. Create components and put them in the frame. //...create emptyLabel... frame.getContentPane().add(new Label("olol"), BorderLayout.CENTER); frame.getContentPane().add(p, BorderLayout.CENTER); //4. Size the frame. frame.pack(); //5. Show it. frame.setVisible(true); }
From source file:gda.plots.DataMagnifierWindow.java
/** * Sets the SimplePlot to be magnified.// ww w . j a va 2 s .co m * * @param simplePlot * the SimplePlot which the magnifier will be Magnifying * @param collection */ @Override public void setSimplePlot(SimplePlot simplePlot, XYSeriesCollection collection) { this.simplePlot = simplePlot; setTitle("Data Magnifier"); // The magnifiedPlot is effectively just another view of the data of the // simplePlot. By creating a JFreeChart and extracting its plot we get // all // the tediouse work done elsewhere. JFreeChart magnifiedChart = ChartFactory.createXYLineChart(simplePlot.getTitle(), null, null, collection, PlotOrientation.VERTICAL, false, false, false); magnifiedChart.setAntiAlias(false); magnifiedPlot = magnifiedChart.getXYPlot(); magnifiedPlot.setRenderer(simplePlot.getChart().getXYPlot().getRenderer()); if (simplePlot.isShowToolTip()) magnifiedPlot.getRenderer().setToolTipGenerator(new SimpleXYToolTipGenerator()); add(new DataMagnifierPanel()); }
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);/*from w ww .j a v a2 s. c o m*/ piechart.setAntiAlias(true); 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: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);/* www.java 2s . c o m*/ chart.setAntiAlias(true); 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:org.yccheok.jstock.gui.charting.DynamicChart.java
public void showNewJDialog(java.awt.Frame parent, String title) { TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(this.price); JFreeChart freeChart = ChartFactory.createTimeSeriesChart(title, GUIBundle.getString("DynamicChart_Date"), GUIBundle.getString("DynamicChart_Price"), dataset, true, true, false); freeChart.setAntiAlias(true); XYPlot plot = freeChart.getXYPlot(); NumberAxis rangeAxis1 = (NumberAxis) plot.getRangeAxis(); DecimalFormat format = new DecimalFormat("00.00"); rangeAxis1.setNumberFormatOverride(format); XYItemRenderer renderer1 = plot.getRenderer(); renderer1.setBaseToolTipGenerator(/*w ww . j ava 2 s .c o m*/ new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("h:mm:ss a"), new DecimalFormat("0.00#"))); org.yccheok.jstock.charting.Utils.applyChartTheme(freeChart); ChartPanel _chartPanel = new ChartPanel(freeChart, true, true, true, true, true); JDialog dialog = new JDialog(parent, title, false); dialog.getContentPane().add(_chartPanel, java.awt.BorderLayout.CENTER); dialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); final java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); dialog.setBounds((screenSize.width - 750) >> 1, (screenSize.height - 600) >> 1, 750, 600); dialog.setVisible(true); }
From source file:org.adempiere.webui.apps.graph.WPerformanceIndicator.java
/** * Init Graph Display//from w w w . jav a 2 s .com * 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(); }