List of usage examples for java.awt Color Color
public Color(ColorSpace cspace, float[] components, float alpha)
From source file:com.mergano.core.AreaChart.java
private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createAreaChart("Order statistic", // chart title "Days", // domain axis label "Order Average", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend false, // tooltips false // urls );//from w w w . j av a 2s .com // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setAnchor(StandardLegend.SOUTH); chart.setBackgroundPaint(Color.white); chart.setAntiAlias(true); CategoryPlot plot = chart.getCategoryPlot(); plot.getRenderer().setSeriesPaint(0, new Color(0, 191, 165)); plot.setForegroundAlpha(0.75f); plot.setBackgroundPaint(Color.white); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); // disable this plot.setDomainGridlinesVisible(false); plot.setDomainGridlinePaint(new Color(240, 240, 240)); plot.setRangeGridlinesVisible(false); plot.setRangeGridlinePaint(new Color(240, 240, 240)); plot.setDomainCrosshairPaint(Color.MAGENTA); plot.setRangeCrosshairPaint(Color.CYAN); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.addCategoryLabelToolTip("Type 1", "The first type."); domainAxis.addCategoryLabelToolTip("Type 2", "The second type."); domainAxis.addCategoryLabelToolTip("Type 3", "The third type."); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLabelAngle(0 * Math.PI / 2.0); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:org.jfree.chart.demo.BarChartDemo10.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Bar Chart Demo", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setDomainGridlinePaint(Color.white); categoryplot.setDomainGridlinesVisible(true); categoryplot.setRangeGridlinePaint(Color.white); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64)); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0)); GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); barrenderer.setSeriesPaint(0, gradientpaint); barrenderer.setSeriesPaint(1, gradientpaint1); barrenderer.setSeriesPaint(2, gradientpaint2); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D)); return jfreechart; }
From source file:org.jfree.chart.demo.SubCategoryAxisDemo1.java
private static JFreeChart createChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart("SubCategoryAxis Demo 1", "Category", "Value", dataset, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); SubCategoryAxis subCategoryAxis = new SubCategoryAxis(null); subCategoryAxis.addSubCategory("S1"); subCategoryAxis.addSubCategory("S2"); subCategoryAxis.addSubCategory("S3"); plot.setDomainAxis(subCategoryAxis); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false);//from www . j av a 2 s . co m GradientPaint gradientpaint0 = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64)); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0)); GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); renderer.setSeriesPaint(0, gradientpaint0); renderer.setSeriesPaint(1, gradientpaint1); renderer.setSeriesPaint(2, gradientpaint2); return chart; }
From source file:atencionurgencia.evolucion.grafic_sVitales.java
private void graficar() { final TimeSeriesCollection dataset1 = axisTaFC.createDatasetTA(); final JFreeChart chart2 = ChartFactory.createTimeSeriesChart("", // chart title "HORA", // domain axis label "Tensin Arterial - TA (ppm)", // range axis label dataset1, // data true, // include legend true, // tooltips? false // URL generator? Not required... );//w ww . j ava2 s .c o m chart2.setBackgroundPaint(Color.white); final XYPlot plot = chart2.getXYPlot(); plot.setBackgroundPaint(new Color(0xEE, 0xEE, 0xFF)); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } // plot.set // //// final CategoryDataset dataset2 = axisTaFC.createDatasetFC(); //// plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 0); // // final DateAxis domainAxis = (DateAxis) plot.getDomainAxis(); // domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); //// final ValueAxis axis2 = new NumberAxis("Frecuencia Cardiaca - FC (ppm)"); //// plot.setRangeAxis(1, axis2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); // // // final ChartPanel chartPanel = new ChartPanel(chart2); chartPanel.setPreferredSize(new java.awt.Dimension(444, 358));//[598, 358][444, 358] jPanel4.removeAll(); jPanel4.setLayout(new BorderLayout()); jPanel4.add(chartPanel, BorderLayout.NORTH); jPanel4.repaint(); }
From source file:com.aw.swing.mvp.grid.GridManager.java
private void configureGridTitleColor() { JPanel pnlGrid = ipView.getPnlGrid(gridIndex); pnlGrid.setBorder(BorderFactory.createLineBorder(new Color(131, 172, 219))); JPanel pnlTitGrid = ipView.getPnlTitGrid(gridIndex); pnlTitGrid.setBackground(new Color(131, 172, 219)); pnlTitGrid.setLayout(/* ww w.j a v a 2 s . c om*/ new FormLayout("fill:16dlu:noGrow,left:4dlu:noGrow,fill:d:grow,left:4dlu:noGrow,right:pref:grow", "center:16dlu:noGrow")); JLabel lblTitGrid = ipView.getLblTitGrid(gridIndex); lblTitGrid.setFont(new Font(lblTitGrid.getFont().getName(), Font.BOLD, 14)); lblTitGrid.setForeground(Color.black); numRecords = new JLabel(""); numRecords.setFont(new Font(lblTitGrid.getFont().getName(), Font.BOLD, 14)); numRecords.setForeground(Color.black); numRecords.setVisible(showTotalRegistros); pnlTitGrid.remove(lblTitGrid); CellConstraints cc = new CellConstraints(); pnlTitGrid.add(lblTitGrid, cc.xy(3, 1)); pnlTitGrid.add(numRecords, cc.xy(5, 1)); }
From source file:ch.unibe.iam.scg.archie.ui.charts.ConsultationMoneyChart.java
/** * @see ch.unibe.iam.scg.archie.ui.charts.AbstractChartComposite# * initializeChart()/*from ww w . ja va2s . c o m*/ */ @Override protected JFreeChart initializeChart() { JFreeChart chart = ChartFactory.createTimeSeriesChart(ConsultationMoneyChart.CHART_TITLE, // title "", // x-axis label "Amount", // y-axis label (XYDataset) this.creator.getDataset(), // data true, // create legend? true, // generate tooltips? false // generate URLs? ); // Set chart background color to it's parents background chart.setBackgroundPaint(new Color(this.parent.getBackground().getRed(), this.parent.getBackground().getGreen(), this.parent.getBackground().getBlue())); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
From source file:org.jfree.chart.demo.XYBlockChartDemo1.java
private static JFreeChart createChart(XYZDataset xyzdataset) { NumberAxis numberaxis = new NumberAxis("X"); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setLowerMargin(0.0D);/*from w w w . ja v a2 s . c o m*/ numberaxis.setUpperMargin(0.0D); numberaxis.setAxisLinePaint(Color.white); numberaxis.setTickMarkPaint(Color.white); NumberAxis numberaxis1 = new NumberAxis("Y"); numberaxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis1.setLowerMargin(0.0D); numberaxis1.setUpperMargin(0.0D); numberaxis1.setAxisLinePaint(Color.white); numberaxis1.setTickMarkPaint(Color.white); XYBlockRenderer xyblockrenderer = new XYBlockRenderer(); GrayPaintScale graypaintscale = new GrayPaintScale(-2D, 1.0D); xyblockrenderer.setPaintScale(graypaintscale); XYPlot xyplot = new XYPlot(xyzdataset, numberaxis, numberaxis1, xyblockrenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinesVisible(false); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setOutlinePaint(Color.blue); JFreeChart jfreechart = new JFreeChart("XYBlockChartDemo1", xyplot); jfreechart.removeLegend(); NumberAxis numberaxis2 = new NumberAxis("Scale"); numberaxis2.setAxisLinePaint(Color.white); numberaxis2.setTickMarkPaint(Color.white); numberaxis2.setTickLabelFont(new Font("Dialog", 0, 7)); PaintScaleLegend paintscalelegend = new PaintScaleLegend(new GrayPaintScale(), numberaxis2); paintscalelegend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT); paintscalelegend.setAxisOffset(5D); paintscalelegend.setMargin(new RectangleInsets(5D, 5D, 5D, 5D)); paintscalelegend.setFrame(new BlockBorder(Color.red)); paintscalelegend.setPadding(new RectangleInsets(10D, 10D, 10D, 10D)); paintscalelegend.setStripWidth(10D); paintscalelegend.setPosition(RectangleEdge.RIGHT); paintscalelegend.setBackgroundPaint(new Color(120, 120, 180)); jfreechart.addSubtitle(paintscalelegend); jfreechart.setBackgroundPaint(new Color(180, 180, 250)); return jfreechart; }
From source file:web.diva.server.model.GroupColorUtil.java
/** * * @param colorStr e.g. "#FFFFFF"// w ww .ja va 2s . c om * @return */ private Color hex2Rgb(String colorStr) { return new Color(Integer.valueOf(colorStr.substring(1, 3), 16), Integer.valueOf(colorStr.substring(3, 5), 16), Integer.valueOf(colorStr.substring(5, 7), 16)); }
From source file:codeswarm.processing.ColorTest.java
public void loadProperty(String value) { String[] tokens;//from w ww.ja va 2 s .c om // should have the format "label", "regex", r1,g1,b1, r2,g2,b2 // get the stuff in quotes first int firstQ = value.indexOf('\"'); int lastQ = value.lastIndexOf('\"'); String firstpart = value.substring(firstQ + 1, lastQ); tokens = firstpart.split("\""); label = tokens[0]; if (tokens.length == 3) { expr = Pattern.compile(tokens[2]); } else { expr = Pattern.compile(tokens[0]); } // then the comma delimited colors String rest = value.substring(lastQ + 1); tokens = rest.split(","); int[] components = new int[6]; int j = 0; for (int i = 0; i < tokens.length; i++) { String tok = tokens[i].trim(); if (tok.length() > 0) { components[j++] = Integer.parseInt(tok); } } c1 = new Color(components[0], components[1], components[2]).getRGB(); c2 = new Color(components[3], components[4], components[5]).getRGB(); }
From source file:ch.zhaw.init.walj.projectmanagement.util.chart.PieChart.java
/** * creates the pie chart/*from w ww .java2 s . c o m*/ * @throws NumberFormatException * @throws IOException */ public void createChart() throws NumberFormatException, IOException { // create dataset with used and remaining budget DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("spent", con.getUsedBudget(project)); dataset.setValue("remaining", con.getRemainingBudget(project)); // create chart JFreeChart chart = ChartFactory.createPieChart("", dataset, false, false, false); // set color and style PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionPaint("remaining", new Color(0, 101, 166)); plot.setSectionPaint("spent", new Color(0, 62, 102)); plot.setLabelGenerator(null); plot.setBackgroundPaint(Color.WHITE); plot.setShadowXOffset(0); plot.setShadowYOffset(0); plot.setOutlineVisible(false); plot.setInteriorGap(0); // set size and save it as JPEG int width = 350; /* Width of the image */ int height = 350; /* Height of the image */ File pieChart = new File(path + "/Charts/BudgetProject" + project.getID() + ".jpg"); ChartUtilities.saveChartAsJPEG(pieChart, chart, width, height); }