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:Main.Chart.java
/** * Creates a chart.//w ww .ja v a 2 s . co m * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Weather Forecast", // chart title "Time", // x axis label "Temperature", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:grafici.StatisticheLineChart.java
/** * Creates a sample chart./* ww w.j av a 2s. c o m*/ * * @param dataset * the dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset, Table results, int variabile, int valore) { // create the chart... JFreeChart chart = ChartFactory.createLineChart(titolo, "", // domain axis label results.getColumn(valore).getText().toUpperCase(), // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); // customise the range axis... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // customise the renderer... final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); // renderer.setDrawShapes(true); renderer.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f)); renderer.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 6.0f }, 0.0f)); renderer.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 6.0f }, 0.0f)); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:service.chart.TimeSeriesChart.java
/** * Utworz wykres szeregu czasowego na podstawie zestawu danych * //from w ww.j a v a2s .c om * @param dataset Zestaw danych * @return Wykres szeregu czasowego */ private JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Time series", // 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 = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); 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); plot.setRenderer(renderer); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setBaseShapesFilled(false); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
From source file:edu.uci.ics.jung.samples.L2RTreeLayoutDemo.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public L2RTreeLayoutDemo() { // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree();/*from www. j a v a2 s. c o m*/ treeLayout = new TreeLayout<String, Integer>(graph); radialLayout = new RadialTreeLayout<String, Integer>(graph); radialLayout.setSize(new Dimension(600, 600)); vv = new VisualizationViewer<String, Integer>(treeLayout, new Dimension(600, 600)); vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); rings = new Rings(); setLtoR(vv); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(graphMouse.getModeListener()); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JToggleButton radial = new JToggleButton("Radial"); radial.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, treeLayout, radialLayout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.addPreRenderPaintable(rings); } else { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, radialLayout, treeLayout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); setLtoR(vv); vv.removePreRenderPaintable(rings); } vv.repaint(); } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(radial); controls.add(scaleGrid); controls.add(modeBox); content.add(controls, BorderLayout.SOUTH); }
From source file:org.jfree.chart.demo.CrosshairDemo1.java
/** * Creates a chart./* www . ja v a2 s . c o m*/ * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createXYLineChart("Crosshair Demo 1", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainCrosshairVisible(true); plot.setDomainCrosshairLockedOnData(true); plot.setRangeCrosshairVisible(true); plot.setRangeCrosshairLockedOnData(true); final StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer(); renderer.setPlotShapes(true); renderer.setShapesFilled(true); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:org.cyberoam.iview.charts.MeterChart.java
/** * This method generates JFreeChart instance for Meter chart with dial port and iView customization. * @param reportID//from w ww .j a v a2s . co m * @param rsw * @param request * @return */ public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) { ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID); JFreeChart chart = null; ReportColumnBean reportColumnBean = null; GraphBean graphBean = null; try { DefaultValueDataset data = null; graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId()); reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getYColumnId()); String yColumnDBname = reportColumnBean.getDbColumnName(); rsw.first(); double used = Double.parseDouble(rsw.getString(yColumnDBname)); data = new DefaultValueDataset(100 - used); DialPlot plot = new DialPlot(data); chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBackgroundPaint(Color.white); int imgWidth = graphBean.getWidth(); int imgHeight = graphBean.getHeight(); if (request != null && request.getParameter("imgwidth") != null && !"".equalsIgnoreCase(request.getParameter("imgwidth")) && !"null".equalsIgnoreCase(request.getParameter("imgwidth"))) { imgWidth = Integer.parseInt(request.getParameter("imgwidth")); } if (request != null && request.getParameter("imgheight") != null && !"".equalsIgnoreCase(request.getParameter("imgheight")) && !"null".equalsIgnoreCase(request.getParameter("imgheight"))) { imgHeight = Integer.parseInt(request.getParameter("imgheight")); } plot.setView((1 - ((double) imgWidth / (double) imgHeight)) / 2, plot.getViewY(), ((double) imgWidth / (double) imgHeight), plot.getViewHeight()); StandardDialFrame dialFrame = new StandardDialFrame(); dialFrame.setBackgroundPaint(new Color(54, 73, 109)); dialFrame.setRadius(0.8); dialFrame.setStroke(new BasicStroke(0)); plot.setDialFrame(dialFrame); GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(196, 210, 219)); DialBackground db = new DialBackground(gp); db.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL)); plot.setBackground(db); DialValueIndicator dvi = new DialValueIndicator(0); dvi.setRadius(0.55); dvi.setBackgroundPaint(gp); dvi.setNumberFormat(new DecimalFormat("###")); dvi.setFont(new Font("Vandara", Font.CENTER_BASELINE, 10)); dvi.setOutlinePaint(Color.lightGray); plot.addLayer(dvi); StandardDialScale scale = new StandardDialScale(0, 100, -120, -300, 10, 4); scale.setTickRadius(0.75); scale.setTickLabelOffset(0.15); scale.setTickLabelFont(new Font("Vandara", Font.CENTER_BASELINE, 9)); plot.addScale(0, scale); StandardDialRange range = new StandardDialRange(0.0, 50.0, Color.green); range.setInnerRadius(0.35); range.setOuterRadius(0.38); plot.addLayer(range); StandardDialRange range2 = new StandardDialRange(50.0, 75.0, Color.yellow); range2.setInnerRadius(0.35); range2.setOuterRadius(0.38); plot.addLayer(range2); StandardDialRange range3 = new StandardDialRange(75.0, 100.0, Color.red); range3.setInnerRadius(0.35); range3.setOuterRadius(0.38); plot.addLayer(range3); DialPointer needle = new DialPointer.Pointer(); needle.setRadius(0.55); plot.addLayer(needle); DialCap cap = new DialCap(); cap.setRadius(0.05); plot.setCap(cap); } catch (Exception e) { CyberoamLogger.appLog.debug("MeterChart=>Exception : " + e, e); } return chart; }
From source file:de.suse.swamp.modules.scheduledjobs.Statistics.java
/** * Generating the graphs that show the amount of running finished wfs over the time. *//*w w w.j av a 2 s. c om*/ protected void generateWorkflowGraph(String templateName, Date startDate, Date endDate) throws Exception { List stats = StatisticStorage.loadStats(templateName, startDate, endDate); // only generate if we have stats: if (stats != null && stats.size() > 0) { TimeSeriesCollection dataset = new TimeSeriesCollection(); TimeSeriesCollection avgdataset = new TimeSeriesCollection(); TimeSeries serie = new TimeSeries("running workflows", Day.class); TimeSeries avgserie = new TimeSeries("average age", Day.class); for (Iterator datait = stats.iterator(); datait.hasNext();) { Dbstatistics statisticItem = (Dbstatistics) datait.next(); serie.addOrUpdate(new Day(statisticItem.getDate()), statisticItem.getRunningcount()); avgserie.addOrUpdate(new Day(statisticItem.getDate()), statisticItem.getAvgage() / (3600 * 24)); } dataset.addSeries(serie); avgdataset.addSeries(avgserie); JFreeChart chart = ChartFactory.createTimeSeriesChart("Running " + templateName + " workflows", "Date", "running workflows", dataset, false, false, false); // modify chart appearance chart.setBackgroundImageAlpha(0.5f); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.getRangeAxis().setLabelPaint(Color.blue); // add the second line: final NumberAxis axis2 = new NumberAxis("Avg. age in days"); axis2.setLabelPaint(Color.red); plot.setRangeAxis(1, axis2); plot.setDataset(1, avgdataset); plot.mapDatasetToRangeAxis(1, 1); final XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); renderer2.setDrawOutlines(false); renderer2.setDrawSeriesLineAsPath(true); renderer2.setBaseShapesVisible(false); plot.setRenderer(1, renderer2); File image = new File(statPath + fs + templateName + ".png"); if (image.exists()) image.delete(); try { ChartUtilities.saveChartAsPNG(image, chart, 750, 200); } catch (Exception e) { Logger.ERROR("Error generating graph for " + templateName + ", e: " + e.getMessage()); e.printStackTrace(); throw e; } } }
From source file:gov.sandia.umf.platform.ui.jobs.Raster.java
public JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createScatterPlot(null, // chart title null, // x axis label null, // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls );/*from w w w. j a v a 2s .co m*/ chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); plot.setDomainPannable(true); plot.setRangePannable(true); plot.setRenderer(new XYDotRenderer() { public void drawItem(java.awt.Graphics2D g2, XYItemRendererState state, java.awt.geom.Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // Copied from org.jfree.chart.renderer.xy.XYDotRenderer.java and modified. // This would only need to be a couple of lines if they authors of jfreechart had not made dotWidth and dotHeight private members. // Yet another example of textbook OO programming gone awry. (Can anyone hear me scream?) if (!getItemVisible(series, item)) return; int dotWidth = 1; double rasterLines = rangeAxis.getRange().getLength(); int pixels = g2.getClipBounds().height; double height = pixels / rasterLines; if (height > 10) height -= 2; else if (height > 2) height -= 1; int dotHeight = (int) Math.min(20, Math.max(1, Math.floor(height))); double x = dataset.getXValue(series, item); double y = dataset.getYValue(series, item); if (Double.isNaN(y)) return; double adjx = (dotWidth - 1) / 2.0; double adjy = (dotHeight - 1) / 2.0; RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double transX = domainAxis.valueToJava2D(x, dataArea, xAxisLocation) - adjx; double transY = rangeAxis.valueToJava2D(y, dataArea, yAxisLocation) - adjy; g2.setPaint(Color.black); PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) g2.fillRect((int) transY, (int) transX, dotHeight, dotWidth); else g2.fillRect((int) transX, (int) transY, dotWidth, dotHeight); int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); updateCrosshairValues(crosshairState, x, y, domainAxisIndex, rangeAxisIndex, transX, transY, orientation); } }); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // Integer units only return chart; }
From source file:org.jfree.chart.demo.WaterfallChartDemo.java
/** * Returns the chart.// w ww .j a v a2 s. c o m * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createWaterfallChart("Product Cost Breakdown", "Expense Category", "Cost Per Unit", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); plot.setRangeGridlinesVisible(true); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); final ValueAxis rangeAxis = plot.getRangeAxis(); // create a custom tick unit collection... final DecimalFormat formatter = new DecimalFormat("##,###"); formatter.setNegativePrefix("("); formatter.setNegativeSuffix(")"); final TickUnits standardUnits = new TickUnits(); standardUnits.add(new NumberTickUnit(5, formatter)); standardUnits.add(new NumberTickUnit(10, formatter)); standardUnits.add(new NumberTickUnit(20, formatter)); standardUnits.add(new NumberTickUnit(50, formatter)); standardUnits.add(new NumberTickUnit(100, formatter)); standardUnits.add(new NumberTickUnit(200, formatter)); standardUnits.add(new NumberTickUnit(500, formatter)); standardUnits.add(new NumberTickUnit(1000, formatter)); standardUnits.add(new NumberTickUnit(2000, formatter)); standardUnits.add(new NumberTickUnit(5000, formatter)); rangeAxis.setStandardTickUnits(standardUnits); final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); final DecimalFormat labelFormatter = new DecimalFormat("$##,###.00"); labelFormatter.setNegativePrefix("("); labelFormatter.setNegativeSuffix(")"); // renderer.setLabelGenerator( // new StandardCategoryLabelGenerator("{2}", labelFormatter) // ); renderer.setItemLabelsVisible(true); return chart; }
From source file:msi.gama.hpc.gui.perspective.chart.HeadlessChart.java
private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Line Chart from XML output file", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );//from w w w. ja v a 2 s . c om // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }