List of usage examples for java.awt GradientPaint GradientPaint
public GradientPaint(float x1, float y1, Color color1, float x2, float y2, Color color2)
From source file:org.jfree.chart.demo.SymbolicYPlotDemo.java
/** * Create and display a multi XY plot with horizontal layout. * /*w w w. jav a 2s . c o m*/ * @param frameTitle * the frame title. * @param data1 * dataset1. * @param data2 * dataset2. */ private static void displayYSymbolicCombinedHorizontally(final String frameTitle, final SampleYSymbolicDataset data1, final SampleYSymbolicDataset data2) { final String title = "Animals Horizontally Combined"; final String xAxisLabel = "Miles"; final String yAxisLabel = null; // combine the y symbolic values of the two data sets final String[] combinedYSymbolicValues = SampleYSymbolicDataset.combineYSymbolicDataset(data1, data2); // make master dataset... final CombinedDataset data = new CombinedDataset(); data.add(data1); data.add(data2); // decompose data... final XYDataset series0 = new SubSeriesDataset(data, 0); final XYDataset series1 = new SubSeriesDataset(data, 1); final XYDataset series2 = new SubSeriesDataset(data, 2); final XYDataset series3 = new SubSeriesDataset(data, 3); final XYDataset series4 = new SubSeriesDataset(data, 4); final XYDataset series5 = new SubSeriesDataset(data, 5); final XYDataset series6 = new SubSeriesDataset(data, 6); final XYDataset series7 = new SubSeriesDataset(data, 7); // create axes... final ValueAxis valueAxis0 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis1 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis2 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis3 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis4 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis5 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis6 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis7 = new NumberAxis(xAxisLabel); final SymbolicAxis symbolicAxis = new SymbolicAxis(yAxisLabel, combinedYSymbolicValues); // make a combined plot final CombinedRangeXYPlot mainPlot = new CombinedRangeXYPlot(symbolicAxis); // add the sub-plots final XYItemRenderer renderer0 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot0 = new XYPlot(series0, valueAxis0, null, renderer0); final XYItemRenderer renderer1 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot1 = new XYPlot(series1, valueAxis1, null, renderer1); final XYItemRenderer renderer2 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot2 = new XYPlot(series2, valueAxis2, null, renderer2); final XYItemRenderer renderer3 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot3 = new XYPlot(series3, valueAxis3, null, renderer3); final XYItemRenderer renderer4 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot4 = new XYPlot(series4, valueAxis4, null, renderer4); final XYItemRenderer renderer5 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot5 = new XYPlot(series5, valueAxis5, null, renderer5); final XYItemRenderer renderer6 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot6 = new XYPlot(series6, valueAxis6, null, renderer6); final XYItemRenderer renderer7 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot7 = new XYPlot(series7, valueAxis7, null, renderer7); mainPlot.add(subplot0, 1); mainPlot.add(subplot1, 1); mainPlot.add(subplot2, 1); mainPlot.add(subplot3, 1); mainPlot.add(subplot4, 1); mainPlot.add(subplot5, 1); mainPlot.add(subplot6, 1); mainPlot.add(subplot7, 1); // make the top level JFreeChart object final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, mainPlot, true); // then customise it a little... chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue)); // and present it in a frame... final JFrame ySymbolicFrame = new ChartFrame(frameTitle, chart); ySymbolicFrame.pack(); RefineryUtilities.positionFrameRandomly(ySymbolicFrame); ySymbolicFrame.show(); }
From source file:net.sourceforge.atunes.kernel.controllers.stats.StatsDialogController.java
private void setAlbumsChart() { DefaultCategoryDataset dataset = getDataSet(HandlerProxy.getRepositoryHandler().getMostPlayedAlbums(10)); JFreeChart chart = ChartFactory.createStackedBarChart3D(LanguageTool.getString("ALBUM_MOST_PLAYED"), null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false); chart.getTitle().setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); chart.setBackgroundPaint(new GradientPaint(0, 0, ColorDefinitions.GENERAL_NON_PANEL_TOP_GRADIENT_COLOR, 0, 200, ColorDefinitions.GENERAL_NON_PANEL_BOTTOM_GRADIENT_COLOR)); chart.setPadding(new RectangleInsets(5, 0, 0, 0)); NumberAxis axis = new NumberAxis(); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); axis.setTickLabelFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10)); chart.getCategoryPlot().setRangeAxis(axis); chart.getCategoryPlot().setForegroundAlpha(0.6f); chart.getCategoryPlot().getRenderer().setPaint(Color.GREEN); ((StatsDialog) frameControlled).getAlbumsChart() .setIcon(new ImageIcon(chart.createBufferedImage(710, 250))); }
From source file:edu.ucla.stat.SOCR.chart.demo.StackedBarChartDemo4.java
protected JFreeChart createLegend(CategoryDataset dataset) { // JFreeChart chart = ChartFactory.createAreaChart( JFreeChart chart = ChartFactory.createStackedBarChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation true, // legend true, // tooltips false // urls );/* www . ja va 2 s . c o m*/ // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... GroupedStackedBarRenderer renderer = new GroupedStackedBarRenderer(); KeyToGroupMap map = new KeyToGroupMap("G1"); map.mapKeyToGroup("Product 1 (US)", "G1"); map.mapKeyToGroup("Product 1 (Europe)", "G1"); map.mapKeyToGroup("Product 1 (Asia)", "G1"); map.mapKeyToGroup("Product 1 (Middle East)", "G1"); map.mapKeyToGroup("Product 2 (US)", "G2"); map.mapKeyToGroup("Product 2 (Europe)", "G2"); map.mapKeyToGroup("Product 2 (Asia)", "G2"); map.mapKeyToGroup("Product 2 (Middle East)", "G2"); map.mapKeyToGroup("Product 3 (US)", "G3"); map.mapKeyToGroup("Product 3 (Europe)", "G3"); map.mapKeyToGroup("Product 3 (Asia)", "G3"); map.mapKeyToGroup("Product 3 (Middle East)", "G3"); renderer.setSeriesToGroupMap(map); renderer.setItemMargin(0.10); renderer.setDrawBarOutline(false); Paint p1 = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0x22, 0xFF), 0.0f, 0.0f, new Color(0x88, 0x88, 0xFF)); renderer.setSeriesPaint(0, p1); renderer.setSeriesPaint(4, p1); renderer.setSeriesPaint(8, p1); Paint p2 = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x88, 0xFF, 0x88)); renderer.setSeriesPaint(1, p2); renderer.setSeriesPaint(5, p2); renderer.setSeriesPaint(9, p2); Paint p3 = new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0x22, 0x22), 0.0f, 0.0f, new Color(0xFF, 0x88, 0x88)); renderer.setSeriesPaint(2, p3); renderer.setSeriesPaint(6, p3); renderer.setSeriesPaint(10, p3); Paint p4 = new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0xFF, 0x22), 0.0f, 0.0f, new Color(0xFF, 0xFF, 0x88)); renderer.setSeriesPaint(3, p4); renderer.setSeriesPaint(7, p4); renderer.setSeriesPaint(11, p4); renderer.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)); renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator()); SubCategoryAxis domainAxis = new SubCategoryAxis("Product / Month"); domainAxis.setCategoryMargin(0.05); domainAxis.addSubCategory("Product 1"); domainAxis.addSubCategory("Product 2"); domainAxis.addSubCategory("Product 3"); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDomainAxis(domainAxis); //plot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT); plot.setRenderer(renderer); return chart; }
From source file:piilSource.BarChart.java
private JFreeChart createChart(String title, final CategoryDataset dataset, String metaLabel) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart( "Barplot of the " + metaLabel + " values for all samples - " + title, // chart title "Samples", // domain axis label metaLabel + " values", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? );// w w w . ja v a2 s . c o m // 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.red); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (metaLabel.equals("beta")) { rangeAxis.setRange(0, 1); rangeAxis.setTickUnit(new NumberTickUnit(0.2)); } // 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.blue); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.green); final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.red); final GradientPaint gp3 = new GradientPaint(0.0f, 0.0f, Color.yellow, 0.0f, 0.0f, Color.yellow); final GradientPaint gp4 = new GradientPaint(0.0f, 0.0f, Color.cyan, 0.0f, 0.0f, Color.cyan); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); renderer.setSeriesPaint(3, gp3); renderer.setSeriesPaint(4, gp4); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); if (dataset.getColumnCount() > 40) { domainAxis.setTickLabelFont(new Font("Serif", Font.PLAIN, 10)); domainAxis .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2)); } return chart; }
From source file:edu.ucla.stat.SOCR.chart.SuperCategoryChart_vertical.java
/** * Creates a chart.//from w w w . j av a2s . c o m * * @param dataset the dataset. * * @return a chart. */ protected JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation !legendPanelOn, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:com.hmsinc.epicenter.webapp.chart.ChartService.java
/** * @param chart/*from w w w . ja v a2 s . c om*/ * @return */ private static CategoryItemRenderer getBarRenderer(final AbstractChart chart) { final BarRenderer renderer = new BarRenderer(); renderer.setMaximumBarWidth(0.3); for (int i = 0; i < chart.getColors().size(); i++) { final Color c = chart.getColors().get(i); renderer.setSeriesPaint(i, new GradientPaint(0f, 0f, c, 0f, 0f, c.brighter().brighter())); renderer.setSeriesOutlinePaint(i, c); } return renderer; }
From source file:org.jfree.chart.demo.JFreeChartDemoBase.java
/** * Create a horizontal bar chart./*from ww w.j ava 2 s . c om*/ * * @return a horizontal bar chart. */ public JFreeChart createHorizontalBarChart() { // create a default chart based on some sample data... final String title = this.resources.getString("bar.horizontal.title"); final String domain = this.resources.getString("bar.horizontal.domain"); final String range = this.resources.getString("bar.horizontal.range"); final CategoryDataset data = DemoDatasetFactory.createCategoryDataset(); final JFreeChart chart = ChartFactory.createBarChart(title, domain, range, data, PlotOrientation.HORIZONTAL, true, true, false); // then customise it a little... // chart.getLegend().setAnchor(Legend.EAST); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.orange)); final CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeCrosshairVisible(false); final NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); axis.setInverted(true); return chart; }
From source file:org.jfree.chart.demo.SymbolicXYPlotDemo.java
/** * Displays an horizontally combined XYPlot with X and Y symbolic data. * /*w ww. j a v a 2s .com*/ * @param frameTitle * the frame title. * @param data1 * the dataset 1. * @param data2 * the dataset 2. */ private static void displayXYSymbolicCombinedHorizontally(final String frameTitle, final XYDataset data1, final XYDataset data2) { final String title = "Pollutant Horizontally Combined"; final String x1AxisLabel = "Contamination"; final String x2AxisLabel = "Type"; final String yAxisLabel = "Pollutant"; // combine the y symbolic values of the two data sets final String[] combinedYSymbolicValues = SampleXYSymbolicDataset .combineYSymbolicDataset((YisSymbolic) data1, (YisSymbolic) data2); // make master dataset... final CombinedDataset data = new CombinedDataset(); data.add(data1); data.add(data2); // decompose data... final XYDataset series0 = new SubSeriesDataset(data, 0); final XYDataset series1 = new SubSeriesDataset(data, 1); JFreeChart chart = null; // common horizontal and vertical axes final SymbolicAxis hsymbolicAxis0 = new SymbolicAxis(x1AxisLabel, ((XisSymbolic) data1).getXSymbolicValues()); final SymbolicAxis hsymbolicAxis1 = new SymbolicAxis(x2AxisLabel, ((XisSymbolic) data2).getXSymbolicValues()); final SymbolicAxis symbolicAxis = new SymbolicAxis(yAxisLabel, combinedYSymbolicValues); // create main plot... final CombinedRangeXYPlot mainPlot = new CombinedRangeXYPlot(symbolicAxis); // add subplots... final XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot0 = new XYPlot(series0, hsymbolicAxis0, null, renderer); final XYPlot subplot1 = new XYPlot(series1, hsymbolicAxis1, null, renderer); mainPlot.add(subplot0, 1); mainPlot.add(subplot1, 1); // make the top level JFreeChart object chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, mainPlot, true); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue)); // and present it in a frame... final JFrame frame = new ChartFrame(frameTitle, chart); frame.pack(); RefineryUtilities.positionFrameRandomly(frame); frame.show(); }
From source file:edu.uara.gui.tableeditor.ChartGenerationFrame.java
public ChartGenerationFrame()//dummy constructor for testing { initComponents();/*from w w w . j a v a2s . c om*/ this.addRadioButtonGroup(); // create a baseDataset... DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(20.3, "Product 1 (US)", "Jan 04"); dataset.addValue(27.2, "Product 1 (US)", "Feb 04"); dataset.addValue(19.7, "Product 1 (US)", "Mar 04"); dataset.addValue(19.4, "Product 1 (Europe)", "Jan 04"); dataset.addValue(10.9, "Product 1 (Europe)", "Feb 04"); dataset.addValue(18.4, "Product 1 (Europe)", "Mar 04"); dataset.addValue(16.5, "Product 1 (Asia)", "Jan 04"); dataset.addValue(15.9, "Product 1 (Asia)", "Feb 04"); dataset.addValue(16.1, "Product 1 (Asia)", "Mar 04"); dataset.addValue(13.2, "Product 1 (Middle East)", "Jan 04"); dataset.addValue(14.4, "Product 1 (Middle East)", "Feb 04"); dataset.addValue(13.7, "Product 1 (Middle East)", "Mar 04"); dataset.addValue(23.3, "Product 2 (US)", "Jan 04"); dataset.addValue(16.2, "Product 2 (US)", "Feb 04"); dataset.addValue(28.7, "Product 2 (US)", "Mar 04"); dataset.addValue(12.7, "Product 2 (Europe)", "Jan 04"); dataset.addValue(17.9, "Product 2 (Europe)", "Feb 04"); dataset.addValue(12.6, "Product 2 (Europe)", "Mar 04"); dataset.addValue(15.4, "Product 2 (Asia)", "Jan 04"); dataset.addValue(21.0, "Product 2 (Asia)", "Feb 04"); dataset.addValue(11.1, "Product 2 (Asia)", "Mar 04"); dataset.addValue(23.8, "Product 2 (Middle East)", "Jan 04"); dataset.addValue(23.4, "Product 2 (Middle East)", "Feb 04"); dataset.addValue(19.3, "Product 2 (Middle East)", "Mar 04"); dataset.addValue(11.9, "Product 3 (US)", "Jan 04"); dataset.addValue(31.0, "Product 3 (US)", "Feb 04"); dataset.addValue(22.7, "Product 3 (US)", "Mar 04"); dataset.addValue(15.3, "Product 3 (Europe)", "Jan 04"); dataset.addValue(14.4, "Product 3 (Europe)", "Feb 04"); dataset.addValue(25.3, "Product 3 (Europe)", "Mar 04"); dataset.addValue(23.9, "Product 3 (Asia)", "Jan 04"); dataset.addValue(19.0, "Product 3 (Asia)", "Feb 04"); dataset.addValue(10.1, "Product 3 (Asia)", "Mar 04"); dataset.addValue(13.2, "Product 3 (Middle East)", "Jan 04"); dataset.addValue(15.5, "Product 3 (Middle East)", "Feb 04"); dataset.addValue(10.1, "Product 3 (Middle East)", "Mar 04"); // create a chart... IBarChart c = new CustomBarChart("Test barchart", "Domain", "Range", PlotOrientation.VERTICAL, true); c.generate3DStackedBarChart(dataset); GroupedStackedBarRenderer renderer = new GroupedStackedBarRenderer(); KeyToGroupMap map = new KeyToGroupMap("G1"); map.mapKeyToGroup("Product 1 (US)", "G1"); map.mapKeyToGroup("Product 1 (Europe)", "G1"); map.mapKeyToGroup("Product 1 (Asia)", "G1"); map.mapKeyToGroup("Product 1 (Middle East)", "G1"); map.mapKeyToGroup("Product 2 (US)", "G2"); map.mapKeyToGroup("Product 2 (Europe)", "G2"); map.mapKeyToGroup("Product 2 (Asia)", "G2"); map.mapKeyToGroup("Product 2 (Middle East)", "G2"); map.mapKeyToGroup("Product 3 (US)", "G3"); map.mapKeyToGroup("Product 3 (Europe)", "G3"); map.mapKeyToGroup("Product 3 (Asia)", "G3"); map.mapKeyToGroup("Product 3 (Middle East)", "G3"); renderer.setSeriesToGroupMap(map); renderer.setItemMargin(0.0); Paint p1 = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0x22, 0xFF), 0.0f, 0.0f, new Color(0x88, 0x88, 0xFF)); renderer.setSeriesPaint(0, p1); renderer.setSeriesPaint(4, p1); renderer.setSeriesPaint(8, p1); Paint p2 = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x88, 0xFF, 0x88)); renderer.setSeriesPaint(1, p2); renderer.setSeriesPaint(5, p2); renderer.setSeriesPaint(9, p2); Paint p3 = new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0x22, 0x22), 0.0f, 0.0f, new Color(0xFF, 0x88, 0x88)); renderer.setSeriesPaint(2, p3); renderer.setSeriesPaint(6, p3); renderer.setSeriesPaint(10, p3); Paint p4 = new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0xFF, 0x22), 0.0f, 0.0f, new Color(0xFF, 0xFF, 0x88)); renderer.setSeriesPaint(3, p4); renderer.setSeriesPaint(7, p4); renderer.setSeriesPaint(11, p4); renderer.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)); SubCategoryAxis domainAxis = new SubCategoryAxis("Product / Month"); domainAxis.setCategoryMargin(0.05); domainAxis.addSubCategory("Product 1"); domainAxis.addSubCategory("Product 2"); domainAxis.addSubCategory("Product 3"); CategoryPlot plot = (CategoryPlot) ((CustomJFreeChart) c).getPlot(); plot.setDomainAxis(domainAxis); //plot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT); plot.setRenderer(renderer); //plot.setFixedLegendItems(createLegendItems()); ChartPanel panel = c.drawChart("Chart Editor").getChartPanel(); ChartPanel.add(panel); //ChartPanel.setSize(panel.getWidth(), panel.getHeight()); splitPane.setDividerLocation(panel.getHeight()); //test table //H4_2 t = new H4_2(); //CustomJTable temp = (CustomJTable) t.generateTable(); //temp.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); //JScrollPane tableScrollPane = new JScrollPane(temp); //tableScrollPane.add(temp); //splitPane.setBottomComponent(tableScrollPane); //temp.setCellSelectionEnabled(true); //this.getContentPane().add(TablePanel) }
From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo.java
private static JFreeChart createLineChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createLineChart("Line Chart Demo 1", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? );//from ww w . j a v a 2 s . co m chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setUseOutlinePaint(true); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); return chart; }