List of usage examples for java.awt Color blue
Color blue
To view the source code for java.awt Color blue.
Click Source Link
From source file:net.sf.dynamicreports.test.jasper.chart.LayeredBarChartTest.java
@Override protected void configureReport(JasperReportBuilder rb) { TextColumnBuilder<String> column1; TextColumnBuilder<Integer> column2; Locale.setDefault(Locale.ENGLISH); rb.columns(column1 = col.column("Column1", "field1", String.class), column2 = col.column("Column2", "field2", Integer.class)) .summary(/* ww w.j a v a 2 s .c om*/ cht.layeredBarChart().customizers(new ChartCustomizer()).setCategory(column1) .series(cht.serie(column2)).setShowLabels(true).setShowTickLabels(false) .setShowTickMarks(false), cht.layeredBarChart().setCategory(column1).series(cht.serie(column2)) .setCategoryAxisFormat(cht.axisFormat().setLabel("category") .setLabelColor(Color.BLUE).setLabelFont(stl.fontArialBold()) .setTickLabelFont(stl.fontArial().setItalic(true)) .setTickLabelColor(Color.CYAN).setTickLabelRotation(45d) .setLineColor(Color.LIGHT_GRAY)), cht.layeredBarChart().setCategory(column1).series(cht.serie(column2)) .setValueAxisFormat(cht.axisFormat().setLabel("value").setLabelColor(Color.BLUE) .setLabelFont(stl.fontArialBold()) .setTickLabelFont(stl.fontArial().setItalic(true)) .setTickLabelColor(Color.CYAN).setTickLabelMask("#,##0.00") .setLineColor(Color.LIGHT_GRAY).setRangeMinValueExpression(1) .setRangeMaxValueExpression(15))); }
From source file:BubbleChartDemo.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { Connection conn = null;/* www . j av a 2 s.com*/ Statement stmt = null; ResultSet rs = null; ResultSetMetaData rsm = null; OutputStream out = response.getOutputStream(); try { DefaultXYZDataset dataset = new DefaultXYZDataset(); double[] x = { 2.1, 2.3, 2.3, 2.2, 2.2, 1.8, 1.8, 1.9, 2.3, 3.8 }; double[] y = { 14.1, 11.1, 10.0, 8.8, 8.7, 8.4, 5.4, 4.1, 4.1, 25 }; double[] z = { 2.4, 2.7, 2.7, 2.2, 2.2, 2.2, 2.1, 2.2, 1.6, 4 }; double[][] series = new double[][] { x, y, z }; dataset.addSeries("Series 1", series); JFreeChart chart = ChartFactory.createBubbleChart("Bubble Chart Demo 1", "X", "Y", dataset, PlotOrientation.HORIZONTAL, true, true, true); XYPlot plot = (XYPlot) chart.getPlot(); plot.setForegroundAlpha(0.65f); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); // increase the margins to account for the fact that the auto-range // doesn't take into account the bubble size... NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setLowerMargin(0.15); domainAxis.setUpperMargin(0.15); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLowerMargin(0.15); rangeAxis.setUpperMargin(0.15); response.setContentType("image/png"); int width = 800; int height = 600; ChartUtilities.writeChartAsPNG(out, chart, width, height); } catch (Exception e) { throw new ServletException(e); } }
From source file:org.jfree.chart.demo.BarChartDemo9.java
private static Paint[] createPaint() { Paint apaint[] = new Paint[5]; apaint[0] = new GradientPaint(0.0F, 0.0F, Color.white, 0.0F, 0.0F, Color.red); apaint[1] = new GradientPaint(0.0F, 0.0F, Color.white, 0.0F, 0.0F, Color.green); apaint[2] = new GradientPaint(0.0F, 0.0F, Color.white, 0.0F, 0.0F, Color.blue); apaint[3] = new GradientPaint(0.0F, 0.0F, Color.white, 0.0F, 0.0F, Color.orange); apaint[4] = new GradientPaint(0.0F, 0.0F, Color.white, 0.0F, 0.0F, Color.magenta); return apaint; }
From source file:ch.zhaw.parallelComputing.view.Plotter.java
/** * Generates a plot for comparing to datasets * @param title the name of the plot/*from w w w . j av a 2s . com*/ * @param dataset1 the first data set for plotting * @param dataset2 the second data set for plotting * @return a chart object for displaying or saving as picture */ public static JFreeChart plot(String title, XYDataset dataset1, XYDataset dataset2) { JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title "Date", // x-axis label "Input Value", // y-axis label dataset1, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); XYPlot plot = chart.getXYPlot(); Axis axis1 = plot.getRangeAxis(0); axis1.setLabelPaint(Color.red); NumberAxis axis2 = new NumberAxis("Twitter"); axis2.setLabelPaint(Color.blue); plot.setRangeAxis(1, axis2); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesPaint(0, Color.blue); renderer.setBaseShapesVisible(false); plot.setRenderer(1, renderer); return chart; }
From source file:org.jfree.graphics2d.demo.SVGPieChartDemo1.java
/** * Creates a chart.//from w w w . j ava2 s . c om * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Smart Phones Manufactured / Q3 2011", // chart title dataset); chart.removeLegend(); // set a custom background for the chart chart.setBackgroundPainter(new GradientPainter(new Color(20, 20, 20), RectangleAnchor.TOP_LEFT, Color.DARK_GRAY, RectangleAnchor.BOTTOM_RIGHT)); // customise the title position and font TextTitle t = chart.getTitle(); t.setHorizontalAlignment(HorizontalAlignment.LEFT); t.setPaint(new Color(240, 240, 240)); t.setFont(new Font("Arial", Font.BOLD, 26)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPainter(null); plot.setInteriorGap(0.04); plot.setBorderPainter(null); // use gradients and white borders for the section colours plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE)); plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED)); plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN)); plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW)); plot.setBaseSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f)); // customise the section label appearance plot.setLabelFont(new Font("Courier New", Font.BOLD, 20)); plot.setLabelLinkPaint(Color.WHITE); plot.setLabelLinkStroke(new BasicStroke(2.0f)); plot.setLabelOutlineStroke(null); plot.setLabelPaint(Color.WHITE); plot.setLabelBackgroundPaint(null); // add a subtitle giving the data source TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", new Font("Courier New", Font.PLAIN, 12)); source.setPaint(Color.WHITE); source.setPosition(RectangleEdge.BOTTOM); source.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(source); return chart; }
From source file:org.esa.beam.smos.visat.GridPointBtDataFlagmatrixToolView.java
@Override protected JComponent createGridPointComponent() { dataset = new DefaultXYZDataset(); final NumberAxis xAxis = new NumberAxis("Record #"); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setAutoRangeIncludesZero(false); xAxis.setLowerMargin(0.0);// w w w .j a v a 2s . co m xAxis.setUpperMargin(0.0); flagNames = createFlagNames(Dddb.getInstance().getFlagDescriptors(DEFAULT_FLAG_DESCRIPTOR_IDENTIFIER)); final NumberAxis yAxis = createRangeAxis(flagNames); final LookupPaintScale paintScale = new LookupPaintScale(0.0, 4.0, Color.WHITE); paintScale.add(0.0, Color.BLACK); paintScale.add(1.0, Color.RED); paintScale.add(2.0, Color.GREEN); paintScale.add(3.0, Color.BLUE); paintScale.add(4.0, Color.YELLOW); final XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setPaintScale(paintScale); renderer.setBaseToolTipGenerator(new FlagToolTipGenerator(flagNames)); plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.WHITE); plot.setForegroundAlpha(0.5f); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); plot.setNoDataMessage("No data"); chart = new JFreeChart(null, plot); chart.removeLegend(); chartPanel = new ChartPanel(chart); return chartPanel; }
From source file:de.tor.tribes.ui.algo.TimeFrameVisualizer.java
/** Creates new form TimeFrameVisualizer */ public TimeFrameVisualizer() { initComponents();//ww w . j a v a2s . co m try { STROKED = new BufferedImage(3, 3, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = STROKED.createGraphics(); g2d.setColor(Constants.DS_BACK_LIGHT); g2d.fillRect(0, 0, 3, 3); g2d.setColor(Constants.DS_BACK); g2d.drawLine(0, 2, 2, 0); g2d.dispose(); DAILY_START_FRAME_FILL = new BufferedImage(3, 3, BufferedImage.TYPE_INT_RGB); g2d = DAILY_START_FRAME_FILL.createGraphics(); g2d.setColor(Color.CYAN); g2d.fillRect(0, 0, 3, 3); g2d.setColor(Color.BLUE); g2d.drawLine(0, 2, 2, 0); g2d.dispose(); EXACT_START_FRAME_FILL = new BufferedImage(3, 3, BufferedImage.TYPE_INT_RGB); g2d = EXACT_START_FRAME_FILL.createGraphics(); g2d.setColor(Color.CYAN); g2d.fillRect(0, 0, 3, 3); g2d.dispose(); ONE_DAY_START_FRAME_FILL = new BufferedImage(3, 3, BufferedImage.TYPE_INT_RGB); g2d = ONE_DAY_START_FRAME_FILL.createGraphics(); g2d.setColor(Color.CYAN); g2d.fillRect(0, 0, 3, 3); g2d.setColor(Color.BLUE); g2d.drawLine(1, 0, 1, 2); g2d.dispose(); ARRIVE_FRAME_FILL = new BufferedImage(3, 3, BufferedImage.TYPE_INT_RGB); g2d = ARRIVE_FRAME_FILL.createGraphics(); g2d.setColor(Color.RED); g2d.fillRect(0, 0, 3, 3); g2d.setColor(Color.BLACK); g2d.drawLine(0, 2, 2, 0); g2d.dispose(); } catch (Exception e) { } popupInfo = new HashMap<String, Object>(); addMouseMotionListener(new MouseMotionListener() { @Override public void mouseDragged(MouseEvent e) { } @Override public void mouseMoved(MouseEvent e) { repaint(); } }); addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { fireClickEvent(e); } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } }); }
From source file:playground.anhorni.crossborder.verification.TGZMCompare.java
public JFreeChart createChart(String actType) { XYSeriesCollection dataset0 = new XYSeriesCollection(); XYSeries series0 = new XYSeries(actType + " Trips MATSim"); XYSeries series1 = new XYSeries(actType + " Trips TGZM"); for (int i = 0; i < 24; i++) { double realVal = this.aggregatedVolumePerHour[i]; int calcVal = this.xTripsPerHour[i]; series0.add(i, calcVal);//from w w w . j a va2s . c om series1.add(i, realVal); } dataset0.addSeries(series0); dataset0.addSeries(series1); String title = "Compare TGZM and MATSim volumes per hour"; this.chart = ChartFactory.createXYLineChart(title, "hour", // x axis label "Trips", // y axis label dataset0, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); XYPlot plot = this.chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setLinesVisible(true); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesShape(0, new Rectangle2D.Double(-1.5, -1.5, 3.0, 3.0)); renderer.setSeriesPaint(1, Color.black); renderer.setSeriesShape(1, new Rectangle2D.Double(-1.5, -1.5, 3.0, 3.0)); plot.setRenderer(0, renderer); return this.chart; }
From source file:net.sf.dynamicreports.test.jasper.chart.ThermometerChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//ww w.j ava2s .c o m JFreeChart chart = getChart("summary.chart1", 0); Plot plot = chart.getPlot(); Assert.assertEquals("renderer", ThermometerPlot.class, plot.getClass()); ThermometerPlot thermometerPlot = (ThermometerPlot) plot; Assert.assertEquals("value", 15, thermometerPlot.getDataset().getValue()); Assert.assertEquals("data range low", 3d, thermometerPlot.getLowerBound()); Assert.assertEquals("data range high", 30d, thermometerPlot.getUpperBound()); Assert.assertEquals("value color", Color.BLUE, thermometerPlot.getValuePaint()); try { Field field = thermometerPlot.getClass().getDeclaredField("valueFormat"); field.setAccessible(true); Assert.assertEquals("value mask", "15.0", ((NumberFormat) field.get(thermometerPlot)).format(15)); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } Assert.assertEquals("value font", new Font("Arial", Font.PLAIN, 10), thermometerPlot.getValueFont()); Assert.assertEquals("value location", ThermometerPlot.BULB, thermometerPlot.getValueLocation()); Assert.assertEquals("mercury color", Color.LIGHT_GRAY, thermometerPlot.getMercuryPaint()); try { Field field = thermometerPlot.getClass().getDeclaredField("subrangeInfo"); field.setAccessible(true); double[][] subrangeInfo = (double[][]) field.get(thermometerPlot); Assert.assertEquals("low data range low", 8d, subrangeInfo[2][0]); Assert.assertEquals("low data range high", 10d, subrangeInfo[2][1]); Assert.assertEquals("medium data range low", 18d, subrangeInfo[1][0]); Assert.assertEquals("medium data range high", 20d, subrangeInfo[1][1]); Assert.assertEquals("high data range low", 28d, subrangeInfo[0][0]); Assert.assertEquals("high data range high", 30d, subrangeInfo[0][1]); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } }
From source file:it.cnr.istc.utils.gui.ReverseGradientXYBarPainter.java
/** * Paints a single bar instance.// w ww .j a va 2 s . c o m * * @param g2 the graphics target. * @param renderer the renderer. * @param row the row index. * @param column the column index. * @param bar the bar * @param base indicates which side of the rectangle is the base of the bar. */ @Override public void paintBar(Graphics2D g2, XYBarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base) { Paint itemPaint = renderer.getItemPaint(row, column); Color c0, c1; if (itemPaint instanceof Color) { c0 = (Color) itemPaint; c1 = c0.brighter(); } else if (itemPaint instanceof GradientPaint) { GradientPaint gp = (GradientPaint) itemPaint; c0 = gp.getColor1(); c1 = gp.getColor2(); } else { c0 = Color.blue; c1 = Color.blue.brighter(); } // as a special case, if the bar colour has alpha == 0, we draw // nothing. if (c0.getAlpha() == 0) { return; } if (base == RectangleEdge.LEFT || base == RectangleEdge.RIGHT) { Rectangle2D[] regions = splitVerticalBar(bar, this.g1, this.g2, this.g3); GradientPaint gp = new GradientPaint((float) regions[0].getMinX(), 0.0f, c0, (float) regions[0].getMaxX(), 0.0f, Color.white); g2.setPaint(gp); g2.fill(regions[0]); gp = new GradientPaint((float) regions[1].getMinX(), 0.0f, Color.white, (float) regions[1].getMaxX(), 0.0f, c0); g2.setPaint(gp); g2.fill(regions[1]); gp = new GradientPaint((float) regions[2].getMinX(), 0.0f, c0, (float) regions[2].getMaxX(), 0.0f, c1); g2.setPaint(gp); g2.fill(regions[2]); gp = new GradientPaint((float) regions[3].getMinX(), 0.0f, c1, (float) regions[3].getMaxX(), 0.0f, c0); g2.setPaint(gp); g2.fill(regions[3]); } else if (base == RectangleEdge.TOP || base == RectangleEdge.BOTTOM) { Rectangle2D[] regions = splitHorizontalBar(bar, this.g1, this.g2, this.g3); GradientPaint gp = new GradientPaint(0.0f, (float) regions[0].getMinY(), c0, 0.0f, (float) regions[0].getMaxX(), Color.white); g2.setPaint(gp); g2.fill(regions[0]); gp = new GradientPaint(0.0f, (float) regions[1].getMinY(), Color.white, 0.0f, (float) regions[1].getMaxY(), c0); g2.setPaint(gp); g2.fill(regions[1]); gp = new GradientPaint(0.0f, (float) regions[2].getMinY(), c0, 0.0f, (float) regions[2].getMaxY(), c1); g2.setPaint(gp); g2.fill(regions[2]); gp = new GradientPaint(0.0f, (float) regions[3].getMinY(), c1, 0.0f, (float) regions[3].getMaxY(), c0); g2.setPaint(gp); g2.fill(regions[3]); } // draw the outline... if (renderer.isDrawBarOutline()) { Stroke stroke = renderer.getItemOutlineStroke(row, column); Paint paint = renderer.getItemOutlinePaint(row, column); if (stroke != null && paint != null) { g2.setStroke(stroke); g2.setPaint(paint); g2.draw(bar); } } }