List of usage examples for java.awt Color BLACK
Color BLACK
To view the source code for java.awt Color BLACK.
Click Source Link
From source file:com.charts.OneMonthChart.java
public OneMonthChart(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);// ww w. j a v a 2 s. co m rangeAxis.setAutoRangeIncludesZero(false); domainAxis.setVerticalTickLabels(true); 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(600, 300)); 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(); Date now = new Date(); SegmentedTimeline segmentedTimeline = SegmentedTimeline.newMondayThroughFridayTimeline(); Calendar[][] holidays = DayRange.getHolidayDates(); int len = holidays.length; for (int i = 0; i < holidays[0].length; i++) { Calendar day = Calendar.getInstance(TimeZone.getTimeZone("EST")); day.set(Calendar.YEAR, holidays[0][i].get(Calendar.YEAR)); day.set(Calendar.MONTH, holidays[0][i].get(Calendar.MONTH)); day.set(Calendar.DAY_OF_MONTH, holidays[0][i].get(Calendar.DAY_OF_MONTH)); day.set(Calendar.HOUR_OF_DAY, 9); segmentedTimeline.addException(day.getTime()); } xAxis.setTimeline(segmentedTimeline); //xAxis.setVerticalTickLabels(true); xAxis.setDateFormatOverride(new SimpleDateFormat("MMM-dd")); xAxis.setAutoTickUnitSelection(false); xAxis.setAutoRange(false); 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:com.charts.ThreeMonthChart.java
public ThreeMonthChart(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);/*www .j a v a2s . 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(600, 300)); 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(); Date now = new Date(); SegmentedTimeline segmentedTimeline = SegmentedTimeline.newMondayThroughFridayTimeline(); Calendar[][] holidays = DayRange.getHolidayDates(); int len = holidays.length; for (int i = 0; i < holidays[0].length; i++) { Calendar day = Calendar.getInstance(TimeZone.getTimeZone("EST")); day.set(Calendar.YEAR, holidays[0][i].get(Calendar.YEAR)); day.set(Calendar.MONTH, holidays[0][i].get(Calendar.MONTH)); day.set(Calendar.DAY_OF_MONTH, holidays[0][i].get(Calendar.DAY_OF_MONTH)); day.set(Calendar.HOUR_OF_DAY, 9); segmentedTimeline.addException(day.getTime()); } xAxis.setTimeline(segmentedTimeline); //xAxis.setVerticalTickLabels(true); 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:com.thalesgroup.hudson.plugins.sourcemonitor.SourceMonitorChartBuilder.java
public static JFreeChart buildChart(SourceMonitorBuildAction action) { JFreeChart chart = ChartFactory.createStackedAreaChart(null, null, "Number of errors", buildDataset(action), PlotOrientation.VERTICAL, true, false, true); chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null);// w w w . j av a2 s . c o m plot.setForegroundAlpha(0.8f); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // crop extra space around the graph plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); CategoryItemRenderer firstRender = new DefaultCategoryItemRenderer(); SourceMonitorRenderer renderer = new SourceMonitorRenderer(action.getUrlName()); plot.setRenderer(firstRender); return chart; }
From source file:JavaWorldPrintExample1.java
/** * Method: print//from w ww. j a va 2 s .co m * <p> * * This class is responsible for rendering a page using the provided * parameters. The result will be a grid where each cell will be half an * inch by half an inch. * * @param g * a value of type Graphics * @param pageFormat * a value of type PageFormat * @param page * a value of type int * @return a value of type int */ public int print(Graphics g, PageFormat pageFormat, int page) { int i; Graphics2D g2d; Line2D.Double line = new Line2D.Double(); //--- Validate the page number, we only print the first page if (page == 0) { //--- Create a graphic2D object a set the default parameters g2d = (Graphics2D) g; g2d.setColor(Color.black); //--- Translate the origin to be (0,0) g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY()); //--- Print the vertical lines for (i = 0; i < pageFormat.getWidth(); i += INCH / 2) { line.setLine(i, 0, i, pageFormat.getHeight()); g2d.draw(line); } //--- Print the horizontal lines for (i = 0; i < pageFormat.getHeight(); i += INCH / 2) { line.setLine(0, i, pageFormat.getWidth(), i); g2d.draw(line); } return (PAGE_EXISTS); } else return (NO_SUCH_PAGE); }
From source file:name.dlazerka.gm.shell.store.GraphmlStorerTest.java
@Before public void setUp() { graph = new BasicGraph(false); BasicVertex vertex1 = graph.createVertex(); vertex1.getVisual().setColor(Color.RED); BasicVertex vertex2 = graph.createVertex(); vertex2.getVisual().setColor(Color.WHITE); BasicVertex vertex3 = graph.createVertex(); vertex3.getVisual().setColor(Color.RED); BasicEdge edge1 = graph.createEdge(vertex1, vertex2); edge1.getVisual().setColor(Color.BLACK); BasicEdge edge2 = graph.createEdge(vertex1, vertex3, true); edge2.getVisual().setColor(Color.GREEN); }
From source file:GraphUI.java
/** * Creates new form GraphUI// w w w . j a v a 2 s .c o m */ public GraphUI() { try { //graphPane is the jPanel in the jFrame //cp is the ChartPanel that needs to be held inside jPanel1 initComponents(); data = Pinwheel.getData(); this.batch = data[0]; //jPanel1 = createChartPanel(); cp = createChartPanel(); //cp = new ChartPanel(chart); cp.setMouseWheelEnabled(true); jPanel1.add(cp); XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesStroke(0, new BasicStroke(3.0f)); renderer.setSeriesStroke(1, new BasicStroke(3.0f)); plot.setBackgroundPaint(Color.DARK_GRAY); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.BLACK); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.BLACK); plot.setRenderer(renderer); this.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent windowEvent) { backBtn.doClick(); } }); } catch (SQLException ex) { Logger.getLogger(GraphUI.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.edgenius.wiki.security.service.SimpleListImageCaptchaEngine.java
@Override protected void buildInitialFactories() { TextPaster textPaster = new RandomTextPaster(Integer.valueOf(6), Integer.valueOf(7), Color.black); BackgroundGenerator backgroundGenerator = new UniColorBackgroundGenerator(Integer.valueOf(140), Integer.valueOf(50), Color.white); FontGenerator fontGenerator = new TwistedAndShearedRandomFontGenerator(Integer.valueOf(20), Integer.valueOf(25)); WordToImage wordToImage = new ComposedWordToImage(fontGenerator, backgroundGenerator, textPaster); this.addFactory(new GimpyFactory(new RandomWordGenerator(), wordToImage)); }
From source file:com.charts.SixMonthChart.java
public SixMonthChart(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 w w. j ava2 s. com*/ 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(600, 300)); 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(); Date now = new Date(); SegmentedTimeline segmentedTimeline = SegmentedTimeline.newMondayThroughFridayTimeline(); Calendar[][] holidays = DayRange.getHolidayDates(); int len = holidays.length; for (int i = 0; i < holidays[0].length; i++) { Calendar day = Calendar.getInstance(TimeZone.getTimeZone("EST")); day.set(Calendar.YEAR, holidays[0][i].get(Calendar.YEAR)); day.set(Calendar.MONTH, holidays[0][i].get(Calendar.MONTH)); day.set(Calendar.DAY_OF_MONTH, holidays[0][i].get(Calendar.DAY_OF_MONTH)); day.set(Calendar.HOUR_OF_DAY, 9); segmentedTimeline.addException(day.getTime()); } xAxis.setTimeline(segmentedTimeline); //xAxis.setVerticalTickLabels(true); 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.jfree.chart.swt.demo.SWTMultipleAxisDemo1.java
/** * Creates the demo chart./*from w ww. j ava2 s.co m*/ * * @return The chart. */ private static JFreeChart createChart() { XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200); JFreeChart chart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 3", "Time of Day", "Primary Range Axis", dataset1, true, true, false); chart.setBackgroundPaint(Color.white); chart.setBorderVisible(true); chart.setBorderPaint(Color.BLACK); TextTitle subtitle = new TextTitle("Four datasets and four range axes."); chart.addSubtitle(subtitle); XYPlot plot = (XYPlot) chart.getPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.black); // AXIS 2 NumberAxis axis2 = new NumberAxis("Range Axis 2"); axis2.setAutoRangeIncludesZero(false); axis2.setLabelPaint(Color.red); axis2.setTickLabelPaint(Color.red); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); XYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // AXIS 3 NumberAxis axis3 = new NumberAxis("Range Axis 3"); axis3.setLabelPaint(Color.blue); axis3.setTickLabelPaint(Color.blue); //axis3.setPositiveArrowVisible(true); plot.setRangeAxis(2, axis3); XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), 170); plot.setDataset(2, dataset3); plot.mapDatasetToRangeAxis(2, 2); XYItemRenderer renderer3 = new StandardXYItemRenderer(); renderer3.setSeriesPaint(0, Color.blue); plot.setRenderer(2, renderer3); // AXIS 4 NumberAxis axis4 = new NumberAxis("Range Axis 4"); axis4.setLabelPaint(Color.green); axis4.setTickLabelPaint(Color.green); plot.setRangeAxis(3, axis4); XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200); plot.setDataset(3, dataset4); plot.mapDatasetToRangeAxis(3, 3); XYItemRenderer renderer4 = new StandardXYItemRenderer(); renderer4.setSeriesPaint(0, Color.green); plot.setRenderer(3, renderer4); return chart; }
From source file:org.jfree.chart.demo.XYAreaChartDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYAreaChart("XY Area Chart Demo", "Domain (X)", "Range (Y)", xydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setForegroundAlpha(0.65F);// ww w .java2 s. c om xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); ValueAxis valueaxis = xyplot.getDomainAxis(); valueaxis.setTickMarkPaint(Color.black); valueaxis.setLowerMargin(0.0D); valueaxis.setUpperMargin(0.0D); ValueAxis valueaxis1 = xyplot.getRangeAxis(); valueaxis1.setTickMarkPaint(Color.black); XYPointerAnnotation xypointerannotation = new XYPointerAnnotation("Test", 5D, -500D, 2.3561944901923448D); xypointerannotation.setTipRadius(0.0D); xypointerannotation.setBaseRadius(35D); xypointerannotation.setFont(new Font("SansSerif", 0, 9)); xypointerannotation.setPaint(Color.blue); xypointerannotation.setTextAnchor(TextAnchor.HALF_ASCENT_RIGHT); xyplot.addAnnotation(xypointerannotation); return jfreechart; }