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.JFreeChartDemoBase.java
/** * Creates and returns a sample wind plot. * * @return a sample wind plot.// w ww . j a v a 2s .co m */ public JFreeChart createWindPlot() { // create a default chart based on some sample data... final String title = this.resources.getString("other.wind.title"); final String domain = this.resources.getString("other.wind.domain"); final String range = this.resources.getString("other.wind.range"); final WindDataset data = DemoDatasetFactory.createWindDataset1(); final JFreeChart chart = ChartFactory.createWindPlot(title, domain, range, data, true, false, false); // then customise it a little... chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 1000, 0, Color.green)); return chart; }
From source file:org.jfree.chart.demo.JFreeChartDemoBase.java
/** * Creates and returns a sample scatter plot. * * @return a sample scatter plot./*from w ww . j a v a 2 s . co m*/ */ public JFreeChart createScatterPlot() { // create a default chart based on some sample data... final String title = this.resources.getString("other.scatter.title"); final String domain = this.resources.getString("other.scatter.domain"); final String range = this.resources.getString("other.scatter.range"); final XYDataset data = new SampleXYDataset2(); final JFreeChart chart = ChartFactory.createScatterPlot(title, domain, range, data, PlotOrientation.VERTICAL, true, true, // tooltips false // urls ); // then customise it a little... chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 1000, 0, Color.green)); final XYPlot plot = chart.getXYPlot(); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(false); return chart; }
From source file:org.jfree.chart.demo.JFreeChartDemoBase.java
/** * Creates and returns a sample line chart. * * @return a line chart.//from ww w. j a v a 2 s . c o m */ public JFreeChart createLineChart() { // create a default chart based on some sample data... final String title = this.resources.getString("other.line.title"); final String domain = this.resources.getString("other.line.domain"); final String range = this.resources.getString("other.line.range"); final CategoryDataset data = DemoDatasetFactory.createCategoryDataset(); final JFreeChart chart = ChartFactory.createLineChart(title, domain, range, data, PlotOrientation.VERTICAL, true, true, false); // then customise it a little... chart.setBackgroundImage(JFreeChart.INFO.getLogo()); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.green)); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundAlpha(0.65f); return chart; }
From source file:org.jfree.chart.demo.JFreeChartDemoBase.java
/** * Creates and returns a sample vertical XY bar chart. * * @return a sample vertical XY bar chart. *///from w w w. j a v a 2 s . co m public JFreeChart createVerticalXYBarChart() { // create a default chart based on some sample data... final String title = this.resources.getString("other.xybar.title"); final String domain = this.resources.getString("other.xybar.domain"); final String range = this.resources.getString("other.xybar.range"); final TimeSeriesCollection data = DemoDatasetFactory.createTimeSeriesCollection1(); data.setDomainIsPointsInTime(false); final JFreeChart chart = ChartFactory.createXYBarChart(title, domain, true, range, data, PlotOrientation.VERTICAL, true, false, false); // then customise it a little... chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 1000, 0, Color.blue)); final XYItemRenderer renderer = chart.getXYPlot().getRenderer(); renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); return chart; }
From source file:org.jfree.chart.demo.JFreeChartDemoBase.java
/** * Creates and returns a sample XY chart with null data. * * @return a chart.//from ww w .j a v a 2 s .c om */ public JFreeChart createNullXYPlot() { // create a default chart based on some sample data... final String title = this.resources.getString("test.null.title"); final String domain = this.resources.getString("test.null.domain"); final String range = this.resources.getString("test.null.range"); final XYDataset data = null; final JFreeChart chart = ChartFactory.createXYLineChart(title, domain, range, data, PlotOrientation.VERTICAL, true, true, false); // then customise it a little... chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 1000, 0, Color.red)); return chart; }
From source file:org.jfree.chart.demo.JFreeChartDemoBase.java
/** * Creates a sample XY plot with an empty dataset. * * @return a sample XY plot with an empty dataset. *//*from www . j a va2 s.com*/ public JFreeChart createXYPlotZeroData() { // create a default chart based on some sample data... final String title = this.resources.getString("test.zero.title"); final String domain = this.resources.getString("test.zero.domain"); final String range = this.resources.getString("test.zero.range"); final XYDataset data = new EmptyXYDataset(); final JFreeChart chart = ChartFactory.createXYLineChart(title, domain, range, data, PlotOrientation.VERTICAL, true, true, false); // then customise it a little... chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 1000, 0, Color.red)); return chart; }
From source file:com.jtstand.swing.StatsPanel.java
public JFreeChart getChartDistribution(boolean horizontal) { // System.out.println("Min: " + minValue()); // System.out.println("Max: " + maxValue()); XYIntervalSeriesCollection datasetDistribution = createIntervalXYDatasetDistribution(horizontal); XYSeriesCollection dataset2 = createXYDatasetGauss(horizontal); // create the chart... NumberAxis xAxis = new NumberAxis(getValueString()); xAxis.setAutoRangeIncludesZero(false); // NumberAxis yAxis = new NumberAxis("Distribution"); NumberAxis yAxis = new NumberAxis(); yAxis.setAutoRangeIncludesZero(true); //XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer = new MyBarRenderer(); XYPlot plot = new XYPlot(datasetDistribution, xAxis, yAxis, renderer); plot.setOrientation(horizontal ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, isGrouping()); chart.setBackgroundPaint((Paint) UIManager.get("Panel.background")); // plot.setBackgroundPaint(Color.white); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); StandardXYItemLabelGenerator itemlabels = new StandardXYItemLabelGenerator(); renderer.setBaseItemLabelGenerator(itemlabels); renderer.setBaseItemLabelsVisible(true); plot.setDataset(1, dataset2);/*from ww w . j a v a 2 s .co m*/ plot.mapDatasetToRangeAxis(1, 1); // ValueAxis domainAxis = plot.getDomainAxis(); //domainAxis.setCategoryLabelPositions(horizontal?CategoryLabelPositions.STANDARD:CategoryLabelPositions.UP_90); ValueAxis axis2 = new NumberAxis("Gaussian"); plot.setRangeAxis(1, axis2); axis2.setVisible(false); final XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); //renderer2.setShapesVisible(false); //renderer2.setSeriesVisibleInLegend(false); renderer2.setBaseSeriesVisibleInLegend(false); //renderer2.setToolTipGenerator(new StandardCategoryToolTipGenerator()); plot.setRenderer(1, renderer2); renderer.setUseYInterval(true); renderer.setBaseSeriesVisibleInLegend(false); /* coloring */ Color c; if (isMultipleCategorization()) { // TreeMap<String, Color> cmap = new TreeMap<String, Color>(); int i = 0; for (Iterator<String> it = catstats.keySet().iterator(); it.hasNext(); i++) { String groupName = it.next(); c = ChartCategories.getColor(i); for (int j = 0; j < datasetDistribution.getSeriesCount(); j++) { XYIntervalSeries s = datasetDistribution.getSeries(j); if (s.getKey().equals(groupName)) { GradientPaint gp = new GradientPaint(0.0f, 0.0f, c, 0.0f, 0.0f, c.darker().darker()); renderer.setSeriesPaint(j, gp); } } for (int j = 0; j < dataset2.getSeriesCount(); j++) { XYSeries s = dataset2.getSeries(j); if (s.getKey().equals(groupName)) { renderer2.setSeriesPaint(j, c); renderer2.setSeriesShapesVisible(j, false); renderer2.setSeriesStroke(j, myStroke); } } } c = Color.black; } else { c = ChartCategories.getColor(0); GradientPaint gp = new GradientPaint(0.0f, 0.0f, c, 0.0f, 0.0f, c.darker().darker()); renderer.setSeriesPaint(0, gp); } renderer2.setSeriesPaint(0, c); renderer2.setSeriesShapesVisible(0, false); renderer2.setSeriesStroke(0, myStroke); placeLimitMarkers(plot, false); // renderer.setAutoPopulateSeriesOutlinePaint(true); // renderer.setBaseOutlinePaint(Color.black); // renderer.setSeriesOutlinePaint(0, Color.black, true); // renderer.setDrawBarOutline(true); renderer.setHighlightedItem(0, 0); yAxis.setAutoRange(false); yAxis.setAutoRange(true); xAxis.setRange(leftValue(0), rightValue(numberOfCategories - 1)); chart.setTextAntiAlias(false); return chart; }
From source file:org.jfree.chart.demo.JFreeChartDemoBase.java
/** * Creates and returns a sample time series chart that will be displayed in a scroll pane. * * @return a sample time series chart.//from w ww .j a v a 2 s . com */ public JFreeChart createTimeSeriesChartInScrollPane() { // create a default chart based on some sample data... final String title = this.resources.getString("test.scroll.title"); final String domain = this.resources.getString("test.scroll.domain"); final String range = this.resources.getString("test.scroll.range"); final String subtitleStr = this.resources.getString("test.scroll.subtitle"); final XYDataset data = DemoDatasetFactory.createTimeSeriesCollection2(); final JFreeChart chart = ChartFactory.createTimeSeriesChart(title, domain, range, data, true, true, false); // then customise it a little... final TextTitle subtitle = new TextTitle(subtitleStr, new Font("SansSerif", Font.BOLD, 12)); chart.addSubtitle(subtitle); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.gray)); return chart; }
From source file:com.rapidminer.gui.viewer.metadata.AttributeStatisticsPanel.java
@Override public void paintComponent(final Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int x = 0;/*from w ww .j a v a2 s . c o m*/ int y = 0; int width = (int) getSize().getWidth(); int height = (int) getSize().getHeight(); // draw background depending special roles and hovering if (getModel() != null && getModel().isSpecialAtt()) { if (Attributes.LABEL_NAME.equals(getModel().getSpecialAttName())) { // label special attributes have a distinct color g2.setPaint( new GradientPaint(x, y, getColorForSpecialAttribute(Attributes.LABEL_NAME, true, hovered), x, height, getColorForSpecialAttribute(Attributes.LABEL_NAME, false, hovered))); } else if (Attributes.WEIGHT_NAME.equals(getModel().getSpecialAttName())) { // weight special attributes have another distinct color g2.setPaint( new GradientPaint(x, y, getColorForSpecialAttribute(Attributes.WEIGHT_NAME, true, hovered), x, height, getColorForSpecialAttribute(Attributes.WEIGHT_NAME, false, hovered))); } else if (Attributes.PREDICTION_NAME.equals(getModel().getSpecialAttName())) { // prediction special attributes have another distinct color g2.setPaint(new GradientPaint(x, y, getColorForSpecialAttribute(Attributes.PREDICTION_NAME, true, hovered), x, height, getColorForSpecialAttribute(Attributes.PREDICTION_NAME, false, hovered))); } else if (getModel().getSpecialAttName().startsWith(Attributes.CONFIDENCE_NAME + "_")) { // confidence special attributes have another distinct color g2.setPaint(new GradientPaint(x, y, getColorForSpecialAttribute(Attributes.CONFIDENCE_NAME, true, hovered), x, height, getColorForSpecialAttribute(Attributes.CONFIDENCE_NAME, false, hovered))); } else if (Attributes.ID_NAME.equals(getModel().getSpecialAttName())) { // id special attributes have another distinct color g2.setPaint(new GradientPaint(x, y, getColorForSpecialAttribute(Attributes.ID_NAME, true, hovered), x, height, getColorForSpecialAttribute(Attributes.ID_NAME, false, hovered))); } else { // other special attributes have another color g2.setPaint( new GradientPaint(x, y, getColorForSpecialAttribute(GENERIC_SPECIAL_NAME, true, hovered), x, height, getColorForSpecialAttribute(GENERIC_SPECIAL_NAME, false, hovered))); } } else { // regular attributes g2.setPaint( new GradientPaint(x, y, getColorForSpecialAttribute(Attributes.ATTRIBUTE_NAME, true, hovered), x, height, getColorForSpecialAttribute(Attributes.ATTRIBUTE_NAME, false, hovered))); } g2.fillRoundRect(x, y, width, height, CORNER_ARC_WIDTH, CORNER_ARC_WIDTH); // draw border g2.setPaint(new GradientPaint(x, y, COLOR_BORDER_GRADIENT_FIRST, x, height, COLOR_BORDER_GRADIENT_SECOND)); if (hovered) { g2.setStroke(new BasicStroke(1.0f)); } else { g2.setStroke(new BasicStroke(0.5f)); } g2.drawRoundRect(x, y, width - 1, height - 1, CORNER_ARC_WIDTH, CORNER_ARC_WIDTH); // let Swing draw its components super.paintComponent(g2); }
From source file:org.jfree.chart.demo.JFreeChartDemoBase.java
/** * Creates and returns a sample bar chart with just one series. * * @return a sample bar chart.//from w ww . j a va 2s . c o m */ public JFreeChart createSingleSeriesBarChart() { // create a default chart based on some sample data... final String title = this.resources.getString("test.single.title"); final String domain = this.resources.getString("test.single.domain"); final String range = this.resources.getString("test.single.range"); final String subtitle1Str = this.resources.getString("test.single.subtitle1"); final String subtitle2Str = this.resources.getString("test.single.subtitle2"); final CategoryDataset data = DemoDatasetFactory.createSingleSeriesCategoryDataset(); final JFreeChart chart = ChartFactory.createBarChart(title, domain, range, data, PlotOrientation.HORIZONTAL, true, true, false); chart.addSubtitle(new TextTitle(subtitle1Str)); chart.addSubtitle(new TextTitle(subtitle2Str)); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 1000, 0, Color.red)); return chart; }