List of usage examples for java.awt Color green
Color green
To view the source code for java.awt Color green.
Click Source Link
From source file:com.charts.OneYearChart.java
public OneYearChart(YStockQuote currentStock) throws ParseException { DateAxis domainAxis = new DateAxis("Date"); NumberAxis rangeAxis = new NumberAxis("Price"); CandlestickRenderer renderer = new CandlestickRenderer(); XYDataset dataset = getDataSet(currentStock); XYPlot mainPlot = new XYPlot(dataset, domainAxis, rangeAxis, renderer); //Do some setting up, see the API Doc renderer.setSeriesPaint(0, Color.BLACK); renderer.setDrawVolume(false);/* w ww. ja va 2s . co m*/ rangeAxis.setAutoRangeIncludesZero(false); domainAxis.setDateFormatOverride(new SimpleDateFormat("dd-MM-yy")); domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); //Now create the chart and chart panel JFreeChart chart = new JFreeChart(currentStock.get_name(), null, mainPlot, false); chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(900, 400)); XYPlot plot = (XYPlot) chart.getPlot(); LegendTitle legend = new LegendTitle(plot); chart.addLegend(legend); chart.getLegend().setVisible(true); chart.getLegend().setPosition(RectangleEdge.BOTTOM); ValueAxis yAxis = (ValueAxis) plot.getRangeAxis(); DateAxis xAxis = (DateAxis) plot.getDomainAxis(); xAxis.setDateFormatOverride(new SimpleDateFormat("MMM y")); xAxis.setAutoTickUnitSelection(true); xAxis.setAutoRange(true); renderer.setAutoWidthFactor(0.5); renderer.setUpPaint(Color.green); renderer.setDownPaint(new Color(0xc0, 0x00, 0x00)); renderer.setSeriesPaint(0, Color.black); StandardXYItemRenderer renderer1 = new StandardXYItemRenderer(); renderer1.setSeriesPaint(0, Color.BLUE); TimeSeries movingAverage30 = MovingAverage.createMovingAverage(close, "MA(30)", 30, 0); Double currMA30 = (Double) movingAverage30.getDataItem(movingAverage30.getItemCount() - 1).getValue(); currMA30 = Math.round(currMA30 * 100.0) / 100.0; movingAverage30.setKey("MA(30): " + currMA30); TimeSeriesCollection collection = new TimeSeriesCollection(); collection.addSeries(movingAverage30); plot.setDataset(1, collection); plot.setRenderer(1, renderer1); chartPanel.revalidate(); chartPanel.repaint(); chartPanel.revalidate(); chartPanel.repaint(); }
From source file:org.trade.ui.chart.renderer.CandleRenderer.java
/** * Constructor for CandleRenderer.//from w ww. j av a 2 s . c o m * * @param nightMode * boolean */ public CandleRenderer(boolean nightMode) { this.nightMode = nightMode; configureToolTips(); if (nightMode) { upPaint = Color.green; downPaint = Color.red; } else { upPaint = Color.green; downPaint = Color.red; } }
From source file:org.gvsig.gui.beans.graphic.GraphicChartPanel.java
/** * Creates a chart./*from w w w. j a va 2s . co m*/ * @param dataset the dataset. * @return A chart. */ private void createChart() { chart = ChartFactory.createXYLineChart(null, null, null, dataset, PlotOrientation.VERTICAL, false, true, true); // Definir la lista de colores XYPlot plot = chart.getXYPlot(); plot.getRenderer().setSeriesPaint(0, Color.red); plot.getRenderer().setSeriesPaint(1, Color.green); plot.getRenderer().setSeriesPaint(2, Color.blue); plot.getRenderer().setSeriesPaint(3, Color.cyan); plot.getRenderer().setSeriesPaint(4, Color.black); plot.getRenderer().setSeriesPaint(5, Color.darkGray); plot.getRenderer().setSeriesPaint(6, Color.gray); plot.getRenderer().setSeriesPaint(7, Color.magenta); plot.getRenderer().setSeriesPaint(8, Color.yellow); plot.getRenderer().setSeriesPaint(9, Color.orange); Image img = new ImageIcon(getClass().getResource("images/splash.png")).getImage(); plot.setBackgroundPaint(null); plot.setBackgroundImageAlpha(0.18f); plot.setBackgroundImage(img); }
From source file:gov.llnl.lc.infiniband.opensm.plugin.graph.decorators.IB_VertexDrawTransformer.java
public Paint transform(IB_Vertex v) { return Color.GREEN; }
From source file:ScaleTest_2008.java
/** * Paints the test image that will be downscaled and timed by the various * scaling methods. A different image is rendered into each of the four * quadrants of this image: RGB stripes, a picture, vector art, and * a black and white grid./*from w ww .j a va 2 s .com*/ */ private void paintOriginalImage() { Graphics g = originalImage.getGraphics(); // Erase to black g.setColor(Color.BLACK); g.fillRect(0, 0, FULL_SIZE, FULL_SIZE); // RGB quadrant for (int i = 0; i < QUAD_SIZE; i += 3) { int x = i; g.setColor(Color.RED); g.drawLine(x, 0, x, QUAD_SIZE); x++; g.setColor(Color.GREEN); g.drawLine(x, 0, x, QUAD_SIZE); x++; g.setColor(Color.BLUE); g.drawLine(x, 0, x, QUAD_SIZE); } // Picture quadrant try { URL url = getClass().getResource("BBGrayscale.png"); BufferedImage picture = ImageIO.read(url); // Center picture in quadrant area int xDiff = QUAD_SIZE - picture.getWidth(); int yDiff = QUAD_SIZE - picture.getHeight(); g.drawImage(picture, QUAD_SIZE + xDiff / 2, yDiff / 2, null); } catch (Exception e) { System.out.println("Problem reading image file: " + e); } // Vector drawing quadrant g.setColor(Color.WHITE); g.fillRect(0, QUAD_SIZE, QUAD_SIZE, QUAD_SIZE); g.setColor(Color.BLACK); g.drawOval(2, QUAD_SIZE + 2, QUAD_SIZE - 4, QUAD_SIZE - 4); g.drawArc(20, QUAD_SIZE + 20, (QUAD_SIZE - 40), QUAD_SIZE - 40, 190, 160); int eyeSize = 7; int eyePos = 30 - (eyeSize / 2); g.fillOval(eyePos, QUAD_SIZE + eyePos, eyeSize, eyeSize); g.fillOval(QUAD_SIZE - eyePos - eyeSize, QUAD_SIZE + eyePos, eyeSize, eyeSize); // B&W grid g.setColor(Color.WHITE); g.fillRect(QUAD_SIZE + 1, QUAD_SIZE + 1, QUAD_SIZE, QUAD_SIZE); g.setColor(Color.BLACK); for (int i = 0; i < QUAD_SIZE; i += 4) { int pos = QUAD_SIZE + i; g.drawLine(pos, QUAD_SIZE + 1, pos, FULL_SIZE); g.drawLine(QUAD_SIZE + 1, pos, FULL_SIZE, pos); } originalImagePainted = true; }
From source file:com.view.TimeSeriesChartView.java
public JFreeChart getVendorTimeSeriesChart(Excel theExcel, String vendor) { int vendorCode = Integer.parseInt(vendor); ArrayList<Receiving> theReceiving = theExcel.getSheetReceiving(); // HashMap<Month, Integer> item1Map = new HashMap<>(); // HashMap<Month, Integer> item2Map = new HashMap<>(); // HashMap<Month, Integer> item3Map = new HashMap<>(); Set vendorItem = new HashSet(); for (int i = 0; i < theReceiving.size(); i++) { vendorItem.add(theReceiving.get(i).getItem()); }/* w ww. j a v a2s . co m*/ TimeSeries data[] = new TimeSeries[vendorItem.size()]; HashMap<Month, Integer> itemMap[] = new HashMap[vendorItem.size()]; for (int i = 0; i < vendorItem.size(); i++) { String itemName = "item" + i; data[i] = new TimeSeries(itemName); itemMap[i] = new HashMap<>(); } Calendar cal = Calendar.getInstance(); for (int i = 0; i < theReceiving.size(); i++) { cal.setTime(theReceiving.get(i).getDate()); int month = cal.get(Calendar.MONTH) + 1; int year = cal.get(Calendar.YEAR); int quantity = 0; if (theReceiving.get(i).getVendor() == vendorCode) { quantity = theReceiving.get(i).getQuantity(); Month theMonth = new Month(month, year); int itemNum = theReceiving.get(i).getItem() - 1; itemMap[itemNum].put(theMonth, updateItemMap(itemMap[itemNum], theMonth, quantity)); } } TimeSeriesCollection my_data_series = new TimeSeriesCollection(); for (int i = 0; i < vendorItem.size(); i++) { for (Map.Entry<Month, Integer> entry : itemMap[i].entrySet()) { data[i].add(entry.getKey(), entry.getValue()); } my_data_series.addSeries(data[i]); } JFreeChart chart = ChartFactory.createTimeSeriesChart("Receiving", "Month", "Quantity", my_data_series, true, true, false); chart.setBackgroundPaint(Color.YELLOW); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.GREEN); plot.setRangeGridlinePaint(Color.orange); plot.setAxisOffset(new RectangleInsets(50, 0, 20, 5)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MM.yyyy")); return chart; }
From source file:net.sf.jsfcomp.chartcreator.utils.ChartUtils.java
public static Color getColor(String color) { // HTML colors (#FFFFFF format) if (color.startsWith("#")) { return new Color(Integer.parseInt(color.substring(1), 16)); } else {/*from w w w. j a va2 s.c o m*/ // Colors by name if (color.equalsIgnoreCase("black")) return Color.black; if (color.equalsIgnoreCase("gray")) return Color.gray; if (color.equalsIgnoreCase("yellow")) return Color.yellow; if (color.equalsIgnoreCase("green")) return Color.green; if (color.equalsIgnoreCase("blue")) return Color.blue; if (color.equalsIgnoreCase("red")) return Color.red; if (color.equalsIgnoreCase("orange")) return Color.orange; if (color.equalsIgnoreCase("cyan")) return Color.cyan; if (color.equalsIgnoreCase("magenta")) return Color.magenta; if (color.equalsIgnoreCase("darkgray")) return Color.darkGray; if (color.equalsIgnoreCase("lightgray")) return Color.lightGray; if (color.equalsIgnoreCase("pink")) return Color.pink; if (color.equalsIgnoreCase("white")) return Color.white; throw new RuntimeException("Unsupported chart color:" + color); } }
From source file:org.jfree.graphics2d.demo.SVGPieChartDemo1.java
/** * Creates a chart.//from w ww .j ava2s .c o m * * @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:de.bund.bfr.jung.JungUtils.java
public static <V, E> Transformer<E, Paint> newEdgeFillTransformer(RenderContext<V, E> renderContext, Map<E, Paint> edgeColors) { return edge -> { Paint color = edgeColors != null && edgeColors.containsKey(edge) ? edgeColors.get(edge) : Color.BLACK; return renderContext.getPickedEdgeState().isPicked(edge) ? mixWith(color, Color.GREEN) : color; };/*from www .jav a 2 s. c o m*/ }
From source file:org.jfree.chart.demo.selection.SelectionDemo3.java
private static JFreeChart createChart(XYDataset dataset, DatasetSelectionExtension<XYCursor> ext) { JFreeChart chart = ChartFactory.createScatterPlot("SelectionDemo3", "X", "Y", dataset); XYPlot plot = (XYPlot) chart.getPlot(); plot.setNoDataMessage("NO DATA"); plot.setDomainPannable(true);/* ww w .j a v a 2 s . c o m*/ plot.setRangePannable(true); plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); plot.setDomainGridlineStroke(new BasicStroke(0.0f)); plot.setRangeGridlineStroke(new BasicStroke(0.0f)); plot.setDomainMinorGridlinesVisible(true); plot.setRangeMinorGridlinesVisible(true); //XYItemRenderer r = plot.getRenderer(); XYDotRenderer r = new XYDotRenderer(); r.setDotHeight(2); r.setDotWidth(2); r.setSeriesPaint(0, Color.blue); r.setSeriesPaint(1, Color.green); r.setSeriesPaint(2, Color.yellow); r.setSeriesPaint(3, Color.orange); plot.setRenderer(r); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setTickMarkInsideLength(2.0f); domainAxis.setTickMarkOutsideLength(2.0f); domainAxis.setMinorTickMarksVisible(true); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setTickMarkInsideLength(2.0f); rangeAxis.setTickMarkOutsideLength(2.0f); rangeAxis.setMinorTickMarksVisible(true); //add selection specific rendering IRSUtilities.setSelectedItemPaint(r, ext, Color.red); //register plot as selection change listener ext.addChangeListener(plot); return chart; }