List of usage examples for java.awt Color lightGray
Color lightGray
To view the source code for java.awt Color lightGray.
Click Source Link
From source file:com.mxgraph.examples.swing.chart.TimeSeriesChartDemo1.java
/** * Creates a chart.//from ww w . j av a 2s. c o m * * @param dataset a dataset. * * @return A chart. */ public static JFreeChart createChart(XYDataset dataset, String name) { JFreeChart chart = ChartFactory.createTimeSeriesChart(name, // title "Date", // x-axis label "Value", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); 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); renderer.setItemLabelGenerator(new StandardXYItemLabelGenerator()); renderer.setBaseItemLabelsVisible(true); // renderer.setItemLabelsVisible(true); // renderer.setBaseShapesVisible(true); // renderer.setBaseShapesFilled(true); // renderer.setLegendItemLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})")); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"/*"yyyy-MM-dd HH:mm:ss"*/)); chart.getTitle().setFont(new Font("", Font.BOLD, 15)); chart.getLegend().setItemFont(new Font("", Font.BOLD, 15)); // plot.getRangeAxis().setLabelFont(new Font("", Font.BOLD, 15)); // chart.getLegend().setItemFont(new Font("", Font.ITALIC, 15)); // plot.getDomainAxis().setTickLabelFont(new Font("", 1, 15)); // plot.getDomainAxis().setLabelFont(new Font("", 1, 12)); return chart; }
From source file:eu.choreos.vv.chart.YIntervalChart.java
private static JFreeChart createChart(XYDataset dataset, String chartTitle, String xLabel, String yLabel) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title xLabel, // domain axis label yLabel, // range axis label dataset, // initial series PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? );/*w ww . ja v a 2s.com*/ // set chart background chart.setBackgroundPaint(Color.white); // set a few custom plot features XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(0xffffe0)); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); // set the plot's axes to display integers TickUnitSource ticks = NumberAxis.createIntegerTickUnits(); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setStandardTickUnits(ticks); domain.resizeRange(1.1); domain.setLowerBound(0.5); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setStandardTickUnits(ticks); range.setUpperBound(range.getUpperBound() * 1.1); // render shapes and lines DeviationRenderer renderer = new DeviationRenderer(true, true); plot.setRenderer(renderer); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); // set the renderer's stroke Stroke stroke = new BasicStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL); renderer.setBaseOutlineStroke(stroke); //TODO: render the deviation with the same color as the line // renderer.setBaseFillPaint(new Color(255, 200, 200)); // renderer.setUseOutlinePaint(flag); // renderer.setUseFillPaint(flag); // label the points NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(2); XYItemLabelGenerator generator = new StandardXYItemLabelGenerator( StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, format, format); renderer.setBaseItemLabelGenerator(generator); renderer.setBaseItemLabelsVisible(true); //TODO: fix the visible area to show the deviation return chart; }
From source file:org.ow2.clif.jenkins.chart.CallChart.java
@Override protected JFreeChart createChart() { XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(this.eventSerie); JFreeChart chart;//from ww w. ja va 2s . c om if (this.scatterPlot) { chart = ChartFactory.createScatterPlot(getBasicTitle(), // chart title Messages.CallChart_Time(), // x axis label Messages.CallChart_ResponseTime(), // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); } else { chart = ChartFactory.createXYLineChart(getBasicTitle(), // chart title Messages.CallChart_Time(), // x axis label this.chartId.getEvent(), // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); } chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); Shape cross = ShapeUtilities.createDiamond(3); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseShape(cross); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShape(0, cross); plot.setRenderer(renderer); // Force the 0 on vertical axis NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(true); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // Force the 0 on horizontal axis NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(true); return chart; }
From source file:mediamatrix.gui.JVMMemoryProfilerPanel.java
public JVMMemoryProfilerPanel() { initComponents();//from w w w. j av a 2s .c o m profiler = new JVMMemoryProfiler(frequency); profiler.addListener(new JVMMemoryProfilerListener() { @Override public void addScore(long t, long f) { total.add(new Millisecond(), t); free.add(new Millisecond(), f); } }); total = new TimeSeries("Total Memory"); total.setMaximumItemCount(historyCount); free = new TimeSeries("Free Memory"); free.setMaximumItemCount(historyCount); final TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(total); dataset.addSeries(free); final DateAxis domain = new DateAxis("Time"); final NumberAxis range = new NumberAxis("Memory"); domain.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); domain.setLabelFont(new Font("SansSerif", Font.PLAIN, 14)); range.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); range.setLabelFont(new Font("SansSerif", Font.PLAIN, 14)); range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); final XYItemRenderer renderer = new DefaultXYItemRenderer(); renderer.setSeriesPaint(0, Color.red); renderer.setSeriesPaint(1, Color.green); renderer.setBaseStroke(new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); final XYPlot plot = new XYPlot(dataset, domain, range, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); domain.setAutoRange(true); domain.setLowerMargin(0.0); domain.setUpperMargin(0.0); domain.setTickLabelsVisible(true); final JFreeChart chart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", Font.BOLD, 24), plot, true); chart.setBackgroundPaint(Color.white); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder(Color.black))); chart.getLegend().setItemFont(new Font("SansSerif", Font.PLAIN, 12)); add(chartPanel, BorderLayout.CENTER); }
From source file:org.jfree.chart.demo.LayeredBarChartDemo2.java
/** * Creates a new demo instance./* w w w . ja v a 2 s . c om*/ * * @param title the frame title. */ public LayeredBarChartDemo2(final String title) { super(title); // create a dataset... final double[][] data = new double[][] { { 41.0, 33.0, 22.0, 64.0, 42.0, 62.0, 22.0, 14.0 }, { 55.0, 63.0, 55.0, 48.0, 54.0, 37.0, 41.0, 39.0 }, { 57.0, 75.0, 43.0, 33.0, 63.0, 46.0, 57.0, 33.0 } }; final CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Series ", "Factor ", data); // create the chart... final CategoryAxis categoryAxis = new CategoryAxis("Category"); final ValueAxis valueAxis = new NumberAxis("Score (%)"); final CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, new LayeredBarRenderer()); plot.setOrientation(PlotOrientation.VERTICAL); final JFreeChart chart = new JFreeChart("Layered Bar Chart Demo 2", JFreeChart.DEFAULT_TITLE_FONT, plot, true); // set the background color for the chart... chart.setBackgroundPaint(Color.lightGray); final LayeredBarRenderer renderer = (LayeredBarRenderer) plot.getRenderer(); // we can set each series bar width individually or let the renderer manage a standard view. // the width is set in percentage, where 1.0 is the maximum (100%). renderer.setSeriesBarWidth(0, 1.0); renderer.setSeriesBarWidth(1, 0.7); renderer.setSeriesBarWidth(2, 0.5); renderer.setItemMargin(0.01); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryMargin(0.25); domainAxis.setUpperMargin(0.05); domainAxis.setLowerMargin(0.05); // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:ws.moor.bt.gui.charts.OpenConnections.java
private JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Open Connections", "Time", "Connections", dataset, true, false, false);//from ww w .ja v a 2 s . co m chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); return chart; }
From source file:gui.grafica.estadisticas.PanelGrafica.java
/** * Crea un objeto JFreechart con el titulo pasado por parametro con * leyenda en el eje X siendo el tiempo y la leyenda de eje Y la velocidad. * La grafica creada es vaca./* w w w. j av a2 s . c om*/ * * @param title. Titulo de la grafica. * * @return A chart. */ private JFreeChart createChart() { JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title LEYENDA_X, // x-axis label LEYENDA_Y, // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); 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("h:mm")); chartSet = chart; return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.CrosshairDemo3.java
protected JFreeChart createChart(XYDataset dataset) { JFreeChart c = ChartFactory.createTimeSeriesChart(chartTitle, // "Legal & General Unit Trust Prices", domainLabel, rangeLabel, // "Date", "Price Per Unit", dataset, !legendPanelOn, true, false); c.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) c.getPlot();//from w w w . j a v a 2s . co m plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer rr = (XYLineAndShapeRenderer) renderer; rr.setBaseShapesVisible(true); rr.setBaseShapesFilled(true); } renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); //setXSummary(dataset) X is time; return c; }
From source file:org.agmip.ui.afsirs.frames.GraphOutput.java
public void addGraph() { JFreeChart chart = ChartFactory.createBarChart("IRRIGATION REQUIREMENTS(INCHES)", "MONTH", "IRR", createDataset(0), PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(600, 270)); jTabbedPane1.addTab("Irrigation Requirement", chartPanel); if (utils.getICODE() >= 0) { //JFreeChart chart1 = ChartFactory.createBarChart("IRRIGATION REQUIREMENTS(INCHES)", "BI-WEEK", "IRR", createDataset(1), PlotOrientation.VERTICAL, true, true, false); //JFreeChart chart2 = ChartFactory.createBarChart("IRRIGATION REQUIREMENTS(INCHES)", "WEEK", "IRR", createDataset(2), PlotOrientation.VERTICAL, true, true, false); JFreeChart chart1 = ChartFactory.createBarChart("IRRIGATION REQUIREMENTS(INCHES)", "1-In-10", "IRR", createDataset(1), PlotOrientation.VERTICAL, true, true, false); JFreeChart chart2 = ChartFactory.createBarChart("IRRIGATION REQUIREMENTS(INCHES)", "2-In-10", "IRR", createDataset(2), PlotOrientation.VERTICAL, true, true, false); chart1.setBackgroundPaint(Color.white); chart2.setBackgroundPaint(Color.white); plot = chart1.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot = chart2.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); ChartPanel chartPanel1 = new ChartPanel(chart1); chartPanel1.setPreferredSize(new java.awt.Dimension(600, 270)); //jTabbedPane1.addTab("Bi-Week Graph", chartPanel1); jTabbedPane1.addTab("1-In-10", chartPanel1); ChartPanel chartPanel2 = new ChartPanel(chart2); chartPanel2.setPreferredSize(new java.awt.Dimension(600, 270)); //jTabbedPane1.addTab("Weekly Graph", chartPanel2); jTabbedPane1.addTab("2-In-10", chartPanel2); }//from w w w. j a va2 s .c om }
From source file:v800_trainer.JHistogram.java
public JPanel StartHistoHf(JCicloTronic JTronicHandle) { boolean Summenhisto; int von = 0;//from ww w .j a v a2 s.com int bis = 0; int num = 0; int selected; int single; int Gruppen = 0; int i = 100; int j = 10; int m = 0; int n = 0; int Linecount = 0; int Anzahl = 1; JFreeChart chart; double DummyData[] = new double[1]; selected = JTronicHandle.Auswahl_Histogramm.getSelectedIndex(); Summenhisto = JTronicHandle.Summenhistogramm_Check.isSelected(); chart = ChartFactory.createHistogram("", "Herzfrequenz [p/min]", "Hufigkeit", new HistogramDataset(), PlotOrientation.HORIZONTAL, true, true, true); chart.setBackgroundPaint(Color.white); JTronicHandle.applyChartTheme(chart); XYPlot plot = chart.getXYPlot(); 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)); plot.getRangeAxis().setFixedDimension(15.0); ArrayList Bufferarray = new ArrayList(); double Buffer; if (selected == 0) { single = 1; } else { single = 0; Summenhisto = false; } //einzelne Tour oder alle Touren von = Integer.parseInt(JTronicHandle.Properties.getProperty("HistovonHf", "100")); bis = Integer.parseInt(JTronicHandle.Properties.getProperty("HistobisHf", "200")); Gruppen = Integer.parseInt(JTronicHandle.Properties.getProperty("HistostepHf", "10")); Anzahl = (JTronicHandle.Auswahl_Histogramm.getItemCount() - 2) * single + 1; //komische Mathe; //wenn nur eine Tour ausgewhlt ist single = 0 und damit Anzahl =1 // sonst single gleich 1 und die Anzahl ist ItemCont - 1 for (j = 0; j < Anzahl; j++) { if (single == 1) { selected = j + 1; // single = 1 => Summe ist ausgewhlt und selected muss ein hher gesetz werden } if (!Summenhisto) { num = JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte; } else { num += JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte; } n = 0; if (!Summenhisto) { create_Start_Stop(JTronicHandle, selected); //die limits einer gezoomten Graphik ermitteln for (i = start; i < stop; i++) { //hier wird nun ber alle Daten gezhlt Buffer = (double) JTronicHandle.Statistikhandle.TourData[selected].Hf_gesZeit[i]; //aktueller Wert zwischengespeichert if (Buffer >= von && Buffer <= bis) { Bufferarray.add(Buffer); //wenn im ges. Intervall dann in das Bufferarray } } } else { //Summenhist ist ausgewhlt for (i = 0; i < j + 1; i++) { //schlechte Schleifensteuerung i=1;i<j htte es auch getan create_Start_Stop(JTronicHandle, i + 1); for (m = start; m < stop; m++) { // Schleife ber alle Datenpunkte Buffer = (double) JTronicHandle.Statistikhandle.TourData[i + 1].Hf_gesZeit[m]; if (Buffer >= von && Buffer <= bis) { Bufferarray.add(Buffer); } } } } DummyData = new double[Bufferarray.size()]; for (i = 0; i < Bufferarray.size(); i++) { DummyData[i] = new Double(Bufferarray.get(i).toString()); } if (!Summenhisto) { HistogramDataset histoHF = new HistogramDataset(); histoHF.addSeries( "" + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr, DummyData, Gruppen, (double) von, (double) bis); histoHF.setType(HistogramType.RELATIVE_FREQUENCY); plot.setDataset(Linecount, histoHF); plot.mapDatasetToRangeAxis(Linecount, 0); XYBarRenderer renderer = new XYBarRenderer(); renderer.setDrawBarOutline(true); // renderer.setShadowVisible(false); renderer.setSeriesPaint(0, getColour(Linecount, (int) 255 / Anzahl)); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); } Linecount++; } if (Summenhisto) { HistogramDataset histoHF = new HistogramDataset(); histoHF.addSeries("Summenhistogram", DummyData, Gruppen, (double) von, (double) bis); histoHF.setType(HistogramType.RELATIVE_FREQUENCY); plot.setDataset(0, histoHF); plot.mapDatasetToRangeAxis(0, 0); XYItemRenderer renderer = new XYBarRenderer(); renderer.setSeriesPaint(0, Color.blue); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(0, renderer); } chart.setPadding(padding); ChartPanel Panel = new ChartPanel(chart); return Panel; }