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.AxisOffsetsDemo1.java
private static JFreeChart createChart(String s, CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart(s, "Category", "Value", categorydataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setDomainGridlinesVisible(true); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64)); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0)); GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); barrenderer.setSeriesPaint(0, gradientpaint); barrenderer.setSeriesPaint(1, gradientpaint1); barrenderer.setSeriesPaint(2, gradientpaint2); return jfreechart; }
From source file:org.jfree.chart.demo.ClusteredXYBarRendererDemo1.java
public static JPanel createDemoPanel() { JPanel jpanel = new JPanel(new GridLayout(2, 2)); jpanel.setPreferredSize(new Dimension(800, 600)); IntervalXYDataset intervalxydataset = createDataset(); JFreeChart jfreechart = createChart("Vertical", intervalxydataset); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setDrawBarOutline(false); xybarrenderer.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow)); xybarrenderer.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green)); xybarrenderer.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL)); ChartPanel chartpanel = new ChartPanel(jfreechart); jpanel.add(chartpanel);/*from w ww . j a va2 s . co m*/ JFreeChart jfreechart1 = createChart("Vertical / Inverted Axis", intervalxydataset); XYPlot xyplot1 = (XYPlot) jfreechart1.getPlot(); XYBarRenderer xybarrenderer1 = (XYBarRenderer) xyplot1.getRenderer(); xybarrenderer1.setDrawBarOutline(false); xybarrenderer1.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow)); xybarrenderer1.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green)); xybarrenderer1.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)); xyplot1.getDomainAxis().setInverted(true); ChartPanel chartpanel1 = new ChartPanel(jfreechart1); jpanel.add(chartpanel1); JFreeChart jfreechart2 = createChart("Horizontal", intervalxydataset); XYPlot xyplot2 = (XYPlot) jfreechart2.getPlot(); xyplot2.setOrientation(PlotOrientation.HORIZONTAL); XYBarRenderer xybarrenderer2 = (XYBarRenderer) xyplot2.getRenderer(); xybarrenderer2.setDrawBarOutline(false); xybarrenderer2.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow)); xybarrenderer2.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green)); xybarrenderer2.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)); ChartPanel chartpanel2 = new ChartPanel(jfreechart2); jpanel.add(chartpanel2); JFreeChart jfreechart3 = createChart("Horizontal / Inverted Axis", intervalxydataset); XYPlot xyplot3 = (XYPlot) jfreechart3.getPlot(); xyplot3.setOrientation(PlotOrientation.HORIZONTAL); XYBarRenderer xybarrenderer3 = (XYBarRenderer) xyplot3.getRenderer(); xybarrenderer3.setDrawBarOutline(false); xybarrenderer3.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow)); xybarrenderer3.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green)); xybarrenderer3.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL)); xyplot3.getDomainAxis().setInverted(true); ChartPanel chartpanel3 = new ChartPanel(jfreechart3); jpanel.add(chartpanel3); return jpanel; }
From source file:gui.MainForm.java
private static JFreeChart create_AMS_DATA_Chart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("AMS??", "", "??", categorydataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setDomainGridlinesVisible(true); categoryplot.setRangeCrosshairVisible(true); categoryplot.setRangeCrosshairPaint(Color.blue); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64)); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0)); GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); barrenderer.setSeriesPaint(0, gradientpaint); barrenderer.setSeriesPaint(1, gradientpaint1); barrenderer.setSeriesPaint(2, gradientpaint2); barrenderer.setLegendItemToolTipGenerator(new StandardCategorySeriesLabelGenerator("Tooltip: {0}")); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D)); return jfreechart; }
From source file:org.jfree.chart.demo.BarChartDemo10.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Bar Chart Demo", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setDomainGridlinePaint(Color.white); categoryplot.setDomainGridlinesVisible(true); categoryplot.setRangeGridlinePaint(Color.white); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64)); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0)); GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); barrenderer.setSeriesPaint(0, gradientpaint); barrenderer.setSeriesPaint(1, gradientpaint1); barrenderer.setSeriesPaint(2, gradientpaint2); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D)); return jfreechart; }
From source file:org.jfree.chart.demo.SubCategoryAxisDemo1.java
private static JFreeChart createChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart("SubCategoryAxis Demo 1", "Category", "Value", dataset, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); SubCategoryAxis subCategoryAxis = new SubCategoryAxis(null); subCategoryAxis.addSubCategory("S1"); subCategoryAxis.addSubCategory("S2"); subCategoryAxis.addSubCategory("S3"); plot.setDomainAxis(subCategoryAxis); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false);/*from w ww . ja v a2s . c o m*/ GradientPaint gradientpaint0 = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64)); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0)); GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); renderer.setSeriesPaint(0, gradientpaint0); renderer.setSeriesPaint(1, gradientpaint1); renderer.setSeriesPaint(2, gradientpaint2); return chart; }
From source file:userInterface.cdcRole.OverviewJPanel.java
private static JFreeChart createChart1(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Distribution of Vaccines", "Vaccine", "Quantity", categorydataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setDomainGridlinesVisible(true); categoryplot.setRangeCrosshairVisible(true); categoryplot.setRangeCrosshairPaint(Color.green); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 0, 64)); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0)); GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); barrenderer.setSeriesPaint(0, gradientpaint); barrenderer.setSeriesPaint(1, gradientpaint1); barrenderer.setSeriesPaint(2, gradientpaint2); barrenderer.setLegendItemToolTipGenerator(new StandardCategorySeriesLabelGenerator("Tooltip: {0}")); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D)); return jfreechart; }
From source file:savant.view.variation.swing.VariantMap.java
@Override public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Paint a gradient from top to bottom int h = getHeight(); int w = getWidth(); GradientPaint gp0 = new GradientPaint(0, 0, ColourSettings.getColor(ColourKey.GRAPH_PANE_BACKGROUND_TOP), 0, h, ColourSettings.getColor(ColourKey.GRAPH_PANE_BACKGROUND_BOTTOM)); g2.setPaint(gp0);//from www . j a v a 2 s . co m g2.fillRect(0, 0, w, h); List<VariantRecord> data = controller.getData(); if (data != null && !data.isEmpty()) { double boxTop = Double.NaN; double boxBottom = Double.NaN; Range browseRange = LocationController.getInstance().getRange(); int participantCount = controller.getParticipantCount(); unitHeight = (double) h / data.size(); unitWidth = (double) w / participantCount; boolean gappable = unitHeight > GAP_HEIGHT * 2.0; ColourScheme cs = new ColourScheme(ColourKey.A, ColourKey.C, ColourKey.G, ColourKey.T, ColourKey.INSERTED_BASE, ColourKey.DELETED_BASE, ColourKey.N); ColourAccumulator accumulator = new ColourAccumulator(cs); double y = 0.0; double topGap = 0.0; for (int i = 0; i < data.size(); i++) { VariantRecord varRec = data.get(i); double bottomGap = 0.0; if (gappable && i + 1 < data.size()) { VariantRecord nextRec = data.get(i + 1); if (nextRec.getPosition() - varRec.getPosition() > 1) { bottomGap = GAP_HEIGHT * 0.5; } } if (Double.isNaN(boxTop) && browseRange.getFrom() <= varRec.getPosition() && browseRange.getTo() >= varRec.getPosition()) { boxTop = y + topGap; boxBottom = boxTop + unitHeight; } else if (varRec.getPosition() <= browseRange.getTo()) { boxBottom = y + unitHeight - bottomGap; } double x = 0.0; for (int j = 0; j < participantCount; j++) { VariantTrackRenderer.accumulateZygoteShapes(varRec.getVariantsForParticipant(j), accumulator, new Rectangle2D.Double(x, y + topGap, unitWidth, unitHeight - topGap - bottomGap)); x += unitWidth; } topGap = bottomGap; y += unitHeight; } accumulator.fill(g2); if (gappable) { drawGapSizes(g2); } else { // Not enough room to draw gaps, so just label the axes. labelVerticalAxis(g2); } g2.setClip(null); g2.setColor(Color.BLUE); g2.draw(new Rectangle2D.Double(0.0, boxTop, w - 1.0, boxBottom - boxTop - 1.0)); } }
From source file:no.met.jtimeseries.marinogram.MarinogramWrapper.java
public static void main(String args[]) throws Exception { MarinogramTemperaturePlot mp = new MarinogramTemperaturePlot(800, 200, "UTC", "en"); mp.setDescription("Temperature"); MarinogramTemperaturePlot mp1 = new MarinogramTemperaturePlot(800, 200, "UTC", "en"); mp1.setDescription("Temperature1"); MarinogramPlot marinogram = new MarinogramWrapper(900, 200, "UTC", "en"); marinogram.setDescription("marinogram"); MarinogramWrapper marinogram1 = new MarinogramWrapper(940, 200, "UTC", "en"); // /* w w w.j a v a2 s .c om*/ // 30.95, 71.5 // 58.9653, 5.7180 //41.8947&longitude=12.4839 //41.0138 //5.04092, 58.89468 //16.66, 68.56 //10.72938, 71.50000 ChartPlottingInfo cpi = new ChartPlottingInfo.Builder(5.32905, 74.39825).width(mp1.getWidth()) .showAirTemperature(true).showWaterTemperature(true).showDewpointTemperature(true) .showPressure(true).showWaveDirection(true).showWaveHeight(true).showCurrentDirection(true) .showCurrentSpeed(true).showWindDirection(true).showWindSpeed(true).timezone("UTC").language("en") .build(); JFreeChart jchart = marinogram1.createMarinogram(cpi); jchart.setBorderVisible(false); Paint paint = new GradientPaint(0, 0, Color.WHITE, marinogram1.getWidth(), 0, Color.WHITE); jchart.setBackgroundPaint(paint); jchart.removeLegend(); ChartFrame frame = new ChartFrame(jchart, new java.awt.Dimension(900, 400)); frame.pack(); frame.setVisible(true); }
From source file:org.jfree.chart.demo.XYBarChartDemo4.java
/** * Constructs the demo application.//from www. j a v a 2 s . c o m * * @param title the frame title. */ public XYBarChartDemo4(final String title) { super(title); final IntervalXYDataset dataset = createDataset(); final JFreeChart chart = ChartFactory.createXYBarChart(title, "X", false, "Y", dataset, PlotOrientation.VERTICAL, true, false, false); // then customise it a little... chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 1000, 0, Color.blue)); final XYPlot plot = (XYPlot) chart.getPlot(); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 300)); setContentPane(chartPanel); }
From source file:demo.BarChartDemo11.java
/** * Creates a sample chart.// w ww .j av a 2s .co m * * @param dataset the dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createBarChart("Open Source Projects By License", "License", "Percent", dataset); chart.removeLegend(); TextTitle source = new TextTitle( "Source: http://www.blackducksoftware.com/resources/data/top-20-licenses (as at 30 Aug 2013)", new Font("Dialog", Font.PLAIN, 9)); source.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(source); // get a reference to the plot for further customisation... CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setOrientation(PlotOrientation.HORIZONTAL); plot.setDomainGridlinesVisible(true); plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(0.8f); // 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); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator("{1}: {2} percent", new DecimalFormat("0")); renderer.setBaseToolTipGenerator(tt); // 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)); renderer.setSeriesPaint(0, gp0); return chart; }