List of usage examples for java.awt Color lightGray
Color lightGray
To view the source code for java.awt Color lightGray.
Click Source Link
From source file:org.jfree.chart.demo.OverlaidCategoryChartDemo.java
/** * Creates a new demo./*from w ww . j a v a2s . c o m*/ * * @param title the frame title. */ public OverlaidCategoryChartDemo(String title) { super(title); DefaultIntervalCategoryDataset barData = null; double[][] lows = { { -.0315, .0159, .0306, .0453, .0557 } }; double[][] highs = { { .1931, .1457, .1310, .1163, .1059 } }; barData = new DefaultIntervalCategoryDataset(lows, highs); double[][] vals = { { 0.0808, 0.0808, 0.0808, 0.0808, 0.0808 } }; CategoryDataset dotData = DatasetUtilities.createCategoryDataset("Series ", "Category ", vals); double[][] lineVals = new double[4][5]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 5; j++) { lineVals[i][j] = (Math.random() * 0.56) - 0.18; } } CategoryDataset lineData = DatasetUtilities.createCategoryDataset("Series ", "Category ", lineVals); String ctitle = "Strategie Sicherheit"; String xTitle = "Zeitraum (in Jahren)"; String yTitle = "Performance"; CategoryAxis xAxis = new CategoryAxis(xTitle); xAxis.setLabelFont(titleFont); xAxis.setTickLabelFont(labelFont); xAxis.setTickMarksVisible(false); NumberAxis yAxis = new NumberAxis(yTitle); yAxis.setLabelFont(titleFont); yAxis.setTickLabelFont(labelFont); yAxis.setRange(-0.2, 0.4); DecimalFormat formatter = new DecimalFormat("0.##%"); yAxis.setTickUnit(new NumberTickUnit(0.05, formatter)); IntervalBarRenderer barRenderer = new IntervalBarRenderer(); barRenderer.setItemLabelsVisible(Boolean.TRUE); CategoryPlot plot = new CategoryPlot(barData, xAxis, yAxis, barRenderer); plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); plot.setBackgroundPaint(Color.lightGray); plot.setOutlinePaint(Color.black); LineAndShapeRenderer dotRenderer = new LineAndShapeRenderer(LineAndShapeRenderer.SHAPES); dotRenderer.setItemLabelsVisible(Boolean.TRUE); plot.setSecondaryDataset(0, dotData); plot.setSecondaryRenderer(0, dotRenderer); LineAndShapeRenderer lineRenderer = new LineAndShapeRenderer(LineAndShapeRenderer.SHAPES_AND_LINES); plot.setSecondaryDataset(1, lineData); plot.setSecondaryRenderer(1, lineRenderer); this.chart = new JFreeChart(ctitle, titleFont, plot, false); this.chart.setBackgroundPaint(Color.white); ChartPanel chartPanel = new ChartPanel(this.chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:org.owasp.benchmark.score.report.ScatterScores.java
private JFreeChart display(String title, int height, int width, List<Report> toolResults) { JFrame f = new JFrame(title); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries series = new XYSeries("Scores"); for (int i = 0; i < toolResults.size(); i++) { Report toolReport = toolResults.get(i); OverallResults overallResults = toolReport.getOverallResults(); series.add(overallResults.getFalsePositiveRate() * 100, overallResults.getTruePositiveRate() * 100); }/*ww w .j av a 2 s . co m*/ dataset.addSeries(series); chart = ChartFactory.createScatterPlot(title, "False Positive Rate", "True Positive Rate", dataset, PlotOrientation.VERTICAL, true, true, false); String fontName = "Arial"; DecimalFormat pctFormat = new DecimalFormat("0'%'"); theme = (StandardChartTheme) org.jfree.chart.StandardChartTheme.createJFreeTheme(); theme.setExtraLargeFont(new Font(fontName, Font.PLAIN, 24)); // title theme.setLargeFont(new Font(fontName, Font.PLAIN, 20)); // axis-title theme.setRegularFont(new Font(fontName, Font.PLAIN, 16)); theme.setSmallFont(new Font(fontName, Font.PLAIN, 12)); theme.setRangeGridlinePaint(Color.decode("#C0C0C0")); theme.setPlotBackgroundPaint(Color.white); theme.setChartBackgroundPaint(Color.white); theme.setGridBandPaint(Color.red); theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); theme.setBarPainter(new StandardBarPainter()); theme.setAxisLabelPaint(Color.decode("#666666")); theme.apply(chart); XYPlot xyplot = chart.getXYPlot(); NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis(); NumberAxis domainAxis = (NumberAxis) xyplot.getDomainAxis(); xyplot.setOutlineVisible(true); rangeAxis.setRange(-5, 109.99); rangeAxis.setNumberFormatOverride(pctFormat); rangeAxis.setTickLabelPaint(Color.decode("#666666")); rangeAxis.setMinorTickCount(5); rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setAxisLineVisible(true); rangeAxis.setMinorTickMarksVisible(true); rangeAxis.setTickMarksVisible(true); rangeAxis.setLowerMargin(10); rangeAxis.setUpperMargin(10); xyplot.setRangeGridlineStroke(new BasicStroke()); xyplot.setRangeGridlinePaint(Color.lightGray); xyplot.setRangeMinorGridlinePaint(Color.decode("#DDDDDD")); xyplot.setRangeMinorGridlinesVisible(true); domainAxis.setRange(-5, 105); domainAxis.setNumberFormatOverride(pctFormat); domainAxis.setTickLabelPaint(Color.decode("#666666")); domainAxis.setMinorTickCount(5); domainAxis.setTickUnit(new NumberTickUnit(10)); domainAxis.setAxisLineVisible(true); domainAxis.setTickMarksVisible(true); domainAxis.setMinorTickMarksVisible(true); domainAxis.setLowerMargin(10); domainAxis.setUpperMargin(10); xyplot.setDomainGridlineStroke(new BasicStroke()); xyplot.setDomainGridlinePaint(Color.lightGray); xyplot.setDomainMinorGridlinePaint(Color.decode("#DDDDDD")); xyplot.setDomainMinorGridlinesVisible(true); chart.setTextAntiAlias(true); chart.setAntiAlias(true); chart.removeLegend(); chart.setPadding(new RectangleInsets(20, 20, 20, 20)); xyplot.getRenderer().setSeriesPaint(0, Color.decode("#4572a7")); // // setup item labels // XYItemRenderer renderer = xyplot.getRenderer(); // Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 7.0f, 7.0f); // for ( int i = 0; i < dataset.getSeriesCount(); i++ ) { // renderer.setSeriesShape(i, circle); // renderer.setSeriesPaint(i, Color.blue); // String label = ""+((String)dataset.getSeries(i).getKey()); // int idx = label.indexOf( ':'); // label = label.substring( 0, idx ); // StandardXYItemLabelGenerator generator = new StandardXYItemLabelGenerator(label); // renderer.setSeriesItemLabelGenerator(i, generator); // renderer.setSeriesItemLabelsVisible(i, true); // ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER ); // renderer.setSeriesPositiveItemLabelPosition(i, position); // } makeDataLabels(toolResults, xyplot); makeLegend(toolResults, 57, 48, dataset, xyplot); Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 6, 3 }, 0); for (XYDataItem item : (List<XYDataItem>) series.getItems()) { double x = item.getX().doubleValue(); double y = item.getY().doubleValue(); double z = (x + y) / 2; XYLineAnnotation score = new XYLineAnnotation(x, y, z, z, dashed, Color.blue); xyplot.addAnnotation(score); } // // put legend inside plot // LegendTitle lt = new LegendTitle(xyplot); // lt.setItemFont(theme.getSmallFont()); // lt.setPosition(RectangleEdge.RIGHT); // lt.setItemFont(theme.getSmallFont()); // XYTitleAnnotation ta = new XYTitleAnnotation(.7, .55, lt, RectangleAnchor.TOP_LEFT); // ta.setMaxWidth(0.48); // xyplot.addAnnotation(ta); // draw guessing line XYLineAnnotation guessing = new XYLineAnnotation(-5, -5, 105, 105, dashed, Color.red); xyplot.addAnnotation(guessing); XYPointerAnnotation worse = makePointer(75, 5, "Worse than guessing", TextAnchor.TOP_CENTER, 90); xyplot.addAnnotation(worse); XYPointerAnnotation better = makePointer(25, 100, "Better than guessing", TextAnchor.BOTTOM_CENTER, 270); xyplot.addAnnotation(better); XYTextAnnotation stroketext = new XYTextAnnotation(" Random Guess", 88, 107); stroketext.setTextAnchor(TextAnchor.CENTER_RIGHT); stroketext.setBackgroundPaint(Color.white); stroketext.setPaint(Color.red); stroketext.setFont(theme.getRegularFont()); xyplot.addAnnotation(stroketext); XYLineAnnotation strokekey = new XYLineAnnotation(58, 107, 68, 107, dashed, Color.red); xyplot.setBackgroundPaint(Color.white); xyplot.addAnnotation(strokekey); ChartPanel cp = new ChartPanel(chart, height, width, 400, 400, 1200, 1200, false, false, false, false, false, false); f.add(cp); f.pack(); f.setLocationRelativeTo(null); // f.setVisible(true); return chart; }
From source file:Client.Gui.TeamBarChart.java
/** * Creates a sample chart./* www .j a v a 2 s .com*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Distribution of Trainging", // chart title "", // domain axis label "", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); return chart; }
From source file:org.jfree.chart.demo.BarChartDemo4.java
/** * Creates a sample chart./*w ww . j a va2s . com*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(new Color(0xBBBBDD)); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setMaxBarWidth(0.10); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:j2se.jfreechart.barchart.BarChartDemo4.java
/** * Creates a sample chart./*from ww w.ja va2 s . com*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(new Color(0xBBBBDD)); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setMaximumBarWidth(0.10); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:org.micromanager.saim.plot.PlotUtils.java
/** * Create a frame with a plot of the data given in XYSeries overwrite any * previously created frame with the same title * /* ww w. j av a 2s. co m*/ * @param title shown in the top of the plot * @param data array with data series to be plotted * @param xTitle Title of the X axis * @param yTitle Title of the Y axis * @param showShapes whether or not to draw shapes at the data points * @param annotation to be shown in plot * @return Frame that displays the data */ public Frame plotDataN(String title, XYSeries[] data, String xTitle, String yTitle, boolean[] showShapes, String annotation) { //Close existing frames Frame[] gfs = ChartFrame.getFrames(); for (Frame f : gfs) { if (f.getTitle().equals(title)) { f.dispose(); } } // JFreeChart code XYSeriesCollection dataset = new XYSeriesCollection(); // calculate min and max to scale the graph double minX, minY, maxX, maxY; minX = data[0].getMinX(); minY = data[0].getMinY(); maxX = data[0].getMaxX(); maxY = data[0].getMaxY(); for (XYSeries d : data) { dataset.addSeries(d); if (d.getMinX() < minX) { minX = d.getMinX(); } if (d.getMaxX() > maxX) { maxX = d.getMaxX(); } if (d.getMinY() < minY) { minY = d.getMinY(); } if (d.getMaxY() > maxY) { maxY = d.getMaxY(); } } JFreeChart chart = ChartFactory.createScatterPlot(title, // Title xTitle, // x-axis Label yTitle, // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation true, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); for (int i = 0; i < data.length; i++) { renderer.setSeriesFillPaint(i, Color.white); renderer.setSeriesLinesVisible(i, true); } renderer.setSeriesPaint(0, Color.blue); Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f); renderer.setSeriesShape(0, circle, false); if (data.length > 1) { renderer.setSeriesPaint(1, Color.red); Shape square = new Rectangle2D.Float(-2.0f, -2.0f, 4.0f, 4.0f); renderer.setSeriesShape(1, square, false); } if (data.length > 2) { renderer.setSeriesPaint(2, Color.darkGray); Shape rect = new Rectangle2D.Float(-2.0f, -1.0f, 4.0f, 2.0f); renderer.setSeriesShape(2, rect, false); } if (data.length > 3) { renderer.setSeriesPaint(3, Color.magenta); Shape rect = new Rectangle2D.Float(-1.0f, -2.0f, 2.0f, 4.0f); renderer.setSeriesShape(3, rect, false); } for (int i = 0; i < data.length; i++) { if (showShapes.length > i && !showShapes[i]) { renderer.setSeriesShapesVisible(i, false); } } // place annotation at 80 % of max X, maxY XYAnnotation an = new XYTextAnnotation(annotation, maxX - 0.2 * (maxX - minX), maxY); plot.addAnnotation(an); renderer.setUseFillPaint(true); final MyChartFrame graphFrame = new MyChartFrame(title, chart); graphFrame.getChartPanel().setMouseWheelEnabled(true); graphFrame.pack(); graphFrame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent arg0) { graphFrame.dispose(); } }); graphFrame.setVisible(true); return graphFrame; }
From source file:edu.ucsf.valelab.saim.plot.PlotUtils.java
/** * Create a frame with a plot of the data given in XYSeries overwrite any * previously created frame with the same title * // ww w.j a v a 2 s . c o m * @param title shown in the top of the plot * @param data array with data series to be plotted * @param xTitle Title of the X axis * @param yTitle Title of the Y axis * @param showShapes whether or not to draw shapes at the data points * @param annotation to be shown in plot * @return Frame that displays the data */ public Frame plotDataN(String title, XYSeries[] data, String xTitle, String yTitle, boolean[] showShapes, String annotation) { // Close existing frames // Frame[] gfs = ChartFrame.getFrames(); // for (Frame f : gfs) { //if (f.getTitle().equals(title)) { // f.dispose(); //} // } // JFreeChart code XYSeriesCollection dataset = new XYSeriesCollection(); // calculate min and max to scale the graph double minX, minY, maxX, maxY; minX = data[0].getMinX(); minY = data[0].getMinY(); maxX = data[0].getMaxX(); maxY = data[0].getMaxY(); for (XYSeries d : data) { dataset.addSeries(d); if (d.getMinX() < minX) { minX = d.getMinX(); } if (d.getMaxX() > maxX) { maxX = d.getMaxX(); } if (d.getMinY() < minY) { minY = d.getMinY(); } if (d.getMaxY() > maxY) { maxY = d.getMaxY(); } } JFreeChart chart = ChartFactory.createScatterPlot(title, // Title xTitle, // x-axis Label yTitle, // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation true, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); for (int i = 0; i < data.length; i++) { renderer.setSeriesFillPaint(i, Color.white); renderer.setSeriesLinesVisible(i, true); } renderer.setSeriesPaint(0, Color.blue); Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f); renderer.setSeriesShape(0, circle, false); if (data.length > 1) { renderer.setSeriesPaint(1, Color.red); Shape square = new Rectangle2D.Float(-2.0f, -2.0f, 4.0f, 4.0f); renderer.setSeriesShape(1, square, false); } if (data.length > 2) { renderer.setSeriesPaint(2, Color.darkGray); Shape rect = new Rectangle2D.Float(-2.0f, -1.0f, 4.0f, 2.0f); renderer.setSeriesShape(2, rect, false); } if (data.length > 3) { renderer.setSeriesPaint(3, Color.magenta); Shape rect = new Rectangle2D.Float(-1.0f, -2.0f, 2.0f, 4.0f); renderer.setSeriesShape(3, rect, false); } for (int i = 0; i < data.length; i++) { if (showShapes.length > i && !showShapes[i]) { renderer.setSeriesShapesVisible(i, false); } } // place annotation at 80 % of max X, maxY XYAnnotation an = new XYTextAnnotation(annotation, maxX - 0.2 * (maxX - minX), maxY); plot.addAnnotation(an); renderer.setUseFillPaint(true); final MyChartFrame graphFrame = new MyChartFrame(title, chart); graphFrame.getChartPanel().setMouseWheelEnabled(true); graphFrame.pack(); graphFrame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent arg0) { graphFrame.dispose(); } }); graphFrame.setVisible(true); return graphFrame; }
From source file:com.al.cellplugin.LineChart.java
/** * Creates a chart.//from w ww. j a va2s . c o m * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Line Chart of Product SVD [V]", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setRangeGridlinesVisible(true); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); //rangeAxis.setTickLabelsVisible(true); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:com.epiq.bitshark.ui.TimeDomainPanel.java
/** * Initializes the graph/*from w w w .j a v a 2 s.c om*/ */ private void initGraph() { dataset = new XYSeriesCollection(); realSeries = new BasicSeries("Real"); imaginarySeries = new BasicSeries("Imaginary"); dataset.addSeries(realSeries); dataset.addSeries(imaginarySeries); graph = ChartFactory.createXYLineChart(null, // no title "", // no x-axis label "", // no y-axis label dataset, // data PlotOrientation.VERTICAL, false, // no legend false, // no tooltips false // no URLs ); graph.setBorderVisible(false); graph.setPadding(new RectangleInsets(-5, -5, 0, -7)); graph.setBackgroundPaint(null); graph.setAntiAlias(true); plot = (XYPlot) graph.getPlot(); plot.setBackgroundAlpha(0.0f); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setBaseShapesFilled(true); renderer.setSeriesPaint(0, I_COLOR); renderer.setSeriesPaint(1, Q_COLOR); } // X-axis setup plot.getDomainAxis().setAutoRange(false); plot.getDomainAxis().setVisible(true); plot.getDomainAxis().setRange(0, FMCUartClient.BLOCK_SIZE - 1); // Y-axis setup plot.getRangeAxis().setAutoRange(false); plot.getRangeAxis().setVisible(true); plot.getRangeAxis().setUpperBound(Math.pow(2, 13)); plot.getRangeAxis().setLowerBound(-Math.pow(2, 13)); // setup chart panel chartPanel = new ChartPanel(graph, false); chartPanel.setMouseZoomable(false); chartPanel.setOpaque(false); chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); chartPanel.setMinimumDrawWidth(0); chartPanel.setMinimumDrawHeight(0); chartPanel.setDomainZoomable(true); // mouse wheel zooming chartPanel.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { int clicks = e.getWheelRotation(); plot.getRangeAxis().setUpperBound(plot.getRangeAxis().getUpperBound() - (clicks * 100)); plot.getRangeAxis().setLowerBound(plot.getRangeAxis().getLowerBound() + (clicks * 100)); } }); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.others.CumulativeCurveChart.java
public JFreeChart createChart(DatasetMap datasetMap) { CategoryDataset datasetValue = (CategoryDataset) datasetMap.getDatasets().get("1"); CategoryDataset datasetCumulative = (CategoryDataset) datasetMap.getDatasets().get("2"); JFreeChart chart = ChartFactory.createBarChart(name, // chart title xLabel, // domain axis label yLabel, // range axis label datasetValue, // data PlotOrientation.VERTICAL, true, // include legend true, false);//from w ww .jav a 2 s.co m chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(0.02); domainAxis.setUpperMargin(0.02); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LineAndShapeRenderer renderer2 = new LineAndShapeRenderer(); NumberAxis axis2 = new NumberAxis("Percent"); axis2.setNumberFormatOverride(NumberFormat.getPercentInstance()); plot.setRangeAxis(1, axis2); plot.setDataset(1, datasetCumulative); plot.setRenderer(1, renderer2); plot.mapDatasetToRangeAxis(1, 1); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }