List of usage examples for java.awt GradientPaint GradientPaint
public GradientPaint(float x1, float y1, Color color1, float x2, float y2, Color color2, boolean cyclic)
From source file:com.bdb.weather.display.current.Thermometer.java
private ChartViewer createChartElements() { thermometerPlot/*from ww w.j a v a2 s . com*/ .setMercuryPaint(new GradientPaint(0.0f, 0.0f, Color.RED.darker(), 5.0f, 5.0f, Color.RED, true)); thermometerPlot.setUseSubrangePaint(false); thermometerPlot.setBulbRadius(15); thermometerPlot.setColumnRadius(10); thermometerPlot.setValueLocation(ThermometerPlot.RIGHT); thermometerPlot.setValuePaint(Color.BLACK); thermometerPlot.setSubrange(0, 80.0, 80.0); thermometerPlot.setSubrangePaint(0, Color.BLUE); thermometerPlot.setSubrangePaint(1, Color.RED); thermometerPlot.setSubrange(1, 1000.0, 1000.0); thermometerPlot.setSubrange(2, 1000.0, 1000.0); thermometerPlot.setBackgroundPaint(Color.GRAY); thermometerPlot.setOutlineVisible(false); thermometerPlot.setValueFont(thermometerPlot.getValueFont().deriveFont(14.0F).deriveFont(Font.PLAIN)); chart = new JFreeChart(thermometerPlot); chart.setTitle(titleProperty.getValue()); chart.setBackgroundPaint(Color.GRAY); ChartViewer chartViewer = new ChartViewer(chart); chartViewer.setMinHeight(75); chartViewer.setMinWidth(25); return chartViewer; }
From source file:PaintUtils.java
/** * Paints a top to bottom gradient fill over the component bounds * from color1 to color2./* w w w . j av a2s . c o m*/ */ public static void paintGradient(Graphics g, JComponent comp, Color color1, Color color2) { GradientPaint paint = new GradientPaint(0, 0, color1, 0, comp.getHeight(), color2, true); Graphics2D g2 = (Graphics2D) g; Paint oldPaint = g2.getPaint(); g2.setPaint(paint); g2.fillRect(0, 0, comp.getWidth(), comp.getHeight()); g2.setPaint(oldPaint); }
From source file:be.vds.jtbdive.client.view.core.dive.profile.DiveProfileChartPanelEditor.java
private Component createChartPanel() { depthSerie = new XYSeries("depth"); XYSeriesCollection depthCollection = new XYSeriesCollection(); depthCollection.addSeries(depthSerie); JFreeChart chart = ChartFactory.createXYLineChart("", I18nResourceManager.sharedInstance().getString("time"), I18nResourceManager.sharedInstance().getString("depth"), depthCollection, PlotOrientation.VERTICAL, true, true, false);//from w ww.j av a 2 s. c o m plot = chart.getXYPlot(); Paint p = new GradientPaint(0f, 0f, UIAgent.getInstance().getColorWaterBottom(), 200f, 200f, UIAgent.getInstance().getColorWaterSurface(), false); plot.setBackgroundPaint(p); XYAreaRenderer renderer0 = new XYAreaRenderer(); renderer0.setOutline(true); renderer0.setBaseOutlinePaint(UIAgent.getInstance().getColorProfileEdition()); Color baseColor = UIAgent.getInstance().getColorBaseBackground(); renderer0.setSeriesPaint(0, new Color(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), 50)); plot.setRenderer(0, renderer0); dAxis = new NumberAxis(); rAxis = new NumberAxis(); // dAxis.setAutoRange(false); // rAxis.setAutoRange(false); // dAxis.setRange(0, maxTime); // rAxis.setRange(lowestDepth, 0); plot.setDomainAxis(dAxis); plot.setRangeAxis(rAxis); // plot.setRangeCrosshairLockedOnData(false); // plot.setDomainCrosshairLockedOnData(false); ((NumberAxis) plot.getDomainAxis()).setNumberFormatOverride(new MinutesNumberFormat()); panel = new ChartPanel(chart); // panel.addChartMouseListener(new ChartMouseListener() { // // @Override // public void chartMouseMoved(ChartMouseEvent arg0) { // // TODO Auto-generated method stub // // } // // @Override // public void chartMouseClicked(ChartMouseEvent evt) { // // double x = plot.getDomainAxis().java2DToValue( // panel.translateScreenToJava2D( // evt.getTrigger().getPoint()).getX(), // panel.getChartRenderingInfo().getPlotInfo() // .getDataArea(), plot.getDomainAxisEdge()); // // double y = plot.getRangeAxis().java2DToValue( // panel.translateScreenToJava2D( // evt.getTrigger().getPoint()).getY(), // panel.getChartRenderingInfo().getPlotInfo() // .getDataArea(), plot.getRangeAxisEdge()); // // diveProfileEditor.addEntry(x, y, this); // } // }); createDecoWarningCollection(); createAscentTooFastCollection(); createRemainBottomTimeCollection(); createDecoEntriesCollection(); return panel; }
From source file:edu.ucla.stat.SOCR.chart.demo.BarChartDemo9.java
/** * Creates a sample chart.//from w ww. j a v a 2 s .c o m * * @param dataset the dataset. * * @return a sample chart. */ protected JFreeChart createChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation !legendPanelOn, // include legend true, false); TextTitle title = chart.getTitle(); title.setBorder(0, 0, 1, 0); title.setBackgroundPaint(new GradientPaint(0f, 0f, Color.red, 350f, 0f, Color.white, true)); title.setExpandToFitSpace(true); chart.setBackgroundPaint(new GradientPaint(0f, 0f, Color.yellow, 350f, 0f, Color.white, true)); // get a reference to the plot for further customisation... CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setNoDataMessage("NO DATA!"); plot.setBackgroundPaint(null); plot.setInsets(new RectangleInsets(10, 5, 5, 5)); plot.setOutlinePaint(Color.black); plot.setRangeGridlinePaint(Color.gray); plot.setRangeGridlineStroke(new BasicStroke(1.0f)); Paint[] colors = createPaint(); CustomBarRenderer renderer = new CustomBarRenderer(colors); renderer.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL)); plot.setRenderer(renderer); renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator()); // change the margin at the top of the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // rangeAxis.setRange(0.0, 800.0); rangeAxis.setTickMarkPaint(Color.black); setCategorySummary(dataset); return chart; }
From source file:org.zephyrsoft.sdb2.presenter.SongView.java
@Override public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D) g; int topBorderHeight = topMargin; int bottomBorderHeight = bottomMargin; // gradient upper border as overlay Area areaUpper = new Area(new Rectangle2D.Double(0, 0, getWidth(), topBorderHeight)); g2d.setPaint(new GradientPaint(0, 0, new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue(), 255), 0, topBorderHeight,//from w w w .j av a2 s. com new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue(), 0), false)); g2d.fill(areaUpper); // gradient lower border as overlay Area areaLower = new Area( new Rectangle2D.Double(0, getHeight() - bottomBorderHeight, getWidth(), getHeight())); g2d.setPaint(new GradientPaint(0, getHeight() - bottomBorderHeight, new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue(), 0), 0, getHeight(), new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue(), 255), false)); g2d.fill(areaLower); }
From source file:net.sf.fspdfs.chartthemes.spring.EyeCandySixtiesChartTheme.java
/** * *//* w ww . ja v a2 s. com*/ protected void configureChart(JFreeChart jfreeChart, JRChartPlot jrPlot) throws JRException { super.configureChart(jfreeChart, jrPlot); TextTitle title = jfreeChart.getTitle(); if (title != null) { RectangleInsets padding = title.getPadding(); double bottomPadding = Math.max(padding.getBottom(), 15d); title.setPadding(padding.getTop(), padding.getLeft(), bottomPadding, padding.getRight()); } GradientPaint gp = (GradientPaint) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BACKGROUND_PAINT); jfreeChart.setBackgroundPaint(new GradientPaint(0f, 0f, gp.getColor1(), 0f, getChart().getHeight() * 0.7f, gp.getColor2(), false)); }
From source file:net.sf.jasperreports.chartthemes.spring.EyeCandySixtiesChartTheme.java
@Override protected void configureChart(JFreeChart jfreeChart, JRChartPlot jrPlot) throws JRException { super.configureChart(jfreeChart, jrPlot); TextTitle title = jfreeChart.getTitle(); if (title != null) { RectangleInsets padding = title.getPadding(); double bottomPadding = Math.max(padding.getBottom(), 15d); title.setPadding(padding.getTop(), padding.getLeft(), bottomPadding, padding.getRight()); }/* ww w . j av a 2 s. c o m*/ GradientPaint gp = (GradientPaint) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BACKGROUND_PAINT); jfreeChart.setBackgroundPaint(new GradientPaint(0f, 0f, gp.getColor1(), 0f, getChart().getHeight() * 0.7f, gp.getColor2(), false)); }
From source file:Bouncer.java
protected void setPaint(Graphics2D g2) { if (mGradient) { GradientPaint gp = new GradientPaint(0, 0, Color.yellow, 50, 25, Color.red, true); g2.setPaint(gp);/*from w ww . j a va2 s . c om*/ } else g2.setPaint(Color.orange); }
From source file:TextBouncer.java
protected void setPaint(Graphics2D g2) { if (mGradient) { GradientPaint gp = new GradientPaint(0, 0, Color.blue, 50, 25, Color.green, true); g2.setPaint(gp);//from w w w . j a v a 2s.co m } else g2.setPaint(Color.orange); }
From source file:org.openfaces.component.chart.impl.renderers.XYLineFillRenderer.java
private Paint getAreaFillPaint(XYPlot plot, Double plotWidth, Double plotHeight, Color mainColor, Color secondaryColor) {/*from w ww .j a va 2 s . co m*/ return (plot.getOrientation() == PlotOrientation.VERTICAL) ? new GradientPaint(0.0f, 0.0f, mainColor, 0.0f, plotHeight.floatValue(), secondaryColor, true) : new GradientPaint(plotWidth.floatValue(), 0.0f, mainColor, 0.0f, 0.0f, secondaryColor, true); }