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:edu.ucla.stat.SOCR.chart.demo.PolarChartDemo1.java
/** * Creates a sample chart./* w w w. j ava 2 s.c o m*/ * * @param dataset the dataset. * * @return The chart. */ protected JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createPolarChart(chartTitle, dataset, true, false, false); chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... PolarPlot plot = (PolarPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); if (isDemo) { plot.addCornerTextItem("Corner Item 1"); plot.addCornerTextItem("Corner Item 2"); } plot.setRenderer(new SOCRPolarItemRenderer()); //PolarItemRenderer renderer = plot.getRenderer(); //renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); setXSummary(dataset); if (legendPanelOn) chart.removeLegend(); return chart; }
From source file:graphs.LimitsGraphs.java
/** * Creates a sample chart.//from w w w . j a v a2 s . co m * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Limits ..", // chart title "Metric", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:com.google.code.facebook.graph.sna.applet.AnimatingAddNodeDemo.java
@Override public void init() { //create a graph Graph<Number, Number> ig = Graphs .<Number, Number>synchronizedDirectedGraph(new DirectedSparseMultigraph<Number, Number>()); ObservableGraph<Number, Number> og = new ObservableGraph<Number, Number>(ig); og.addGraphEventListener(new GraphEventListener<Number, Number>() { public void handleGraphEvent(GraphEvent<Number, Number> evt) { System.err.println("got " + evt); }//from w ww . j a v a2 s.c om }); this.g = og; //create a graphdraw layout = new FRLayout<Number, Number>(g); layout.setSize(new Dimension(600, 600)); Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); Layout<Number, Number> staticLayout = new StaticLayout<Number, Number>(g, layout); vv = new VisualizationViewer<Number, Number>(staticLayout, new Dimension(600, 600)); JRootPane rp = this.getRootPane(); rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE); getContentPane().setLayout(new BorderLayout()); getContentPane().setBackground(java.awt.Color.lightGray); getContentPane().setFont(new Font("Serif", Font.PLAIN, 12)); vv.setGraphMouse(new DefaultModalGraphMouse<Number, Number>()); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Number>()); vv.setForeground(Color.white); vv.addComponentListener(new ComponentAdapter() { /** * @see java.awt.event.ComponentAdapter#componentResized(java.awt.event.ComponentEvent) */ @Override public void componentResized(ComponentEvent arg0) { super.componentResized(arg0); System.err.println("resized"); layout.setSize(arg0.getComponent().getSize()); } }); getContentPane().add(vv); switchLayout = new JButton("Switch to SpringLayout"); switchLayout.addActionListener(new ActionListener() { @SuppressWarnings("unchecked") public void actionPerformed(ActionEvent ae) { Dimension d = vv.getSize();//new Dimension(600,600); if (switchLayout.getText().indexOf("Spring") > 0) { switchLayout.setText("Switch to FRLayout"); layout = new SpringLayout<Number, Number>(g, new ConstantTransformer(EDGE_LENGTH)); layout.setSize(d); Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); StaticLayout<Number, Number> staticLayout = new StaticLayout<Number, Number>(g, layout); LayoutTransition<Number, Number> lt = new LayoutTransition<Number, Number>(vv, vv.getGraphLayout(), staticLayout); Animator animator = new Animator(lt); animator.start(); // vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.repaint(); } else { switchLayout.setText("Switch to SpringLayout"); layout = new FRLayout<Number, Number>(g, d); layout.setSize(d); Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); StaticLayout<Number, Number> staticLayout = new StaticLayout<Number, Number>(g, layout); LayoutTransition<Number, Number> lt = new LayoutTransition<Number, Number>(vv, vv.getGraphLayout(), staticLayout); Animator animator = new Animator(lt); animator.start(); // vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.repaint(); } } }); getContentPane().add(switchLayout, BorderLayout.SOUTH); timer = new Timer(); }
From source file:SortItem.java
/** * Paint the array of numbers as a list of horizontal lines of varying * lenghts./*from w w w . java2s. c om*/ */ public void paint(Graphics g) { int[] a = arr; int y = size().height - 1; // Erase old lines g.setColor(Color.lightGray); for (int i = a.length; --i >= 0; y -= 2) { g.drawLine(arr[i], y, size().width, y); } // Draw new lines g.setColor(Color.black); y = size().height - 1; for (int i = a.length; --i >= 0; y -= 2) { g.drawLine(0, y, arr[i], y); } if (h1 >= 0) { g.setColor(Color.red); y = h1 * 2 + 1; g.drawLine(0, y, size().width, y); } if (h2 >= 0) { g.setColor(Color.blue); y = h2 * 2 + 1; g.drawLine(0, y, size().width, y); } }
From source file:net.sourceforge.subsonic.controller.UserChartController.java
private JFreeChart createChart(CategoryDataset dataset, HttpServletRequest request) { JFreeChart chart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false);/*from ww w . j a v a2 s .co m*/ CategoryPlot plot = chart.getCategoryPlot(); Paint background = new GradientPaint(0, 0, Color.lightGray, 0, IMAGE_MIN_HEIGHT, Color.white); plot.setBackgroundPaint(background); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); LogarithmicAxis rangeAxis = new LogarithmicAxis(null); rangeAxis.setStrictValuesFlag(false); rangeAxis.setAllowNegativesFlag(true); plot.setRangeAxis(rangeAxis); // Disable bar outlines. BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // Set up gradient paint for series. GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); renderer.setSeriesPaint(0, gp0); // Rotate labels. CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); // Set theme-specific colors. Color bgColor = getBackground(request); Color fgColor = getForeground(request); chart.setBackgroundPaint(bgColor); domainAxis.setTickLabelPaint(fgColor); domainAxis.setTickMarkPaint(fgColor); domainAxis.setAxisLinePaint(fgColor); rangeAxis.setTickLabelPaint(fgColor); rangeAxis.setTickMarkPaint(fgColor); rangeAxis.setAxisLinePaint(fgColor); return chart; }
From source file:org.jfree.chart.demo.TimeSeriesDemo.java
/** * Creates a chart./*from w w w .jav a 2 s.c o m*/ * * @param dataset a dataset. * * @return A chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", "Date", "Price Per Unit", dataset, true, true, false); chart.setBackgroundPaint(Color.white); // final StandardLegend sl = (StandardLegend) chart.getLegend(); // sl.setDisplaySeriesShapes(true); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof StandardXYItemRenderer) { final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; rr.setPlotShapes(true); rr.setShapesFilled(true); rr.setItemLabelsVisible(true); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
From source file:osh.comdriver.simulation.cruisecontrol.AbstractDrawer.java
/** * Creates a chart./*from w ww . j a va 2s. com*/ * * @param dataset1 a dataset. * * @return A chart. */ private JFreeChart createChart(XYDataset dataset, long lastentry) { JFreeChart chart = ChartFactory.createTimeSeriesChart(name, // title "time", // x-axis label "temperature", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis axis1 = new NumberAxis(getAxisName()); axis1.setAutoRangeIncludesZero(isIncludeZero()); plot.setRangeAxis(0, axis1); plot.setDataset(0, dataset); plot.mapDatasetToRangeAxis(1, 0); 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); //TODO: SHADOWS OFF final StandardXYItemRenderer r1 = new StandardXYItemRenderer(); plot.setRenderer(0, r1); r1.setSeriesPaint(0, Color.BLUE); r1.setSeriesPaint(1, Color.RED); r1.setSeriesPaint(2, Color.GREEN); //plot.setDomainAxis(new NumberAxis("time")); plot.setDomainAxis(new DateAxis()); plot.getDomainAxis().setAutoRange(false); long begin = getRangeBegin(lastentry); long end = getRangeEnd(lastentry); plot.getDomainAxis().setRange(begin, end); return chart; }
From source file:main.AddNodeDemo.java
@Override public void init() { //create a graph Graph<String, Number> ig = Graphs .<String, Number>synchronizedDirectedGraph(new DirectedSparseMultigraph<String, Number>()); ObservableGraph<String, Number> og = new ObservableGraph<String, Number>(ig); og.addGraphEventListener(new GraphEventListener<String, Number>() { public void handleGraphEvent(GraphEvent<String, Number> evt) { System.err.println("got " + evt); }//from w ww.j av a 2 s .co m }); this.g = og; //create a graphdraw // layout = new FRLayout2<String,Number>(g); // layout = new SpringLayout<String,Number>(g); // ((FRLayout)layout).setMaxIterations(200); layout = new KKLayout<String, Number>(g); vv = new VisualizationViewer<String, Number>(layout, new Dimension(600, 600)); JRootPane rp = this.getRootPane(); rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE); getContentPane().setLayout(new BorderLayout()); getContentPane().setBackground(java.awt.Color.lightGray); getContentPane().setFont(new Font("Serif", Font.PLAIN, 12)); vv.getModel().getRelaxer().setSleepTime(500); vv.setGraphMouse(new DefaultModalGraphMouse<Number, Number>()); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>()); vv.setForeground(Color.white); FontMetrics fm = vv.getFontMetrics(vv.getFont()); int width = fm.stringWidth(g.toString()); Transformer<String, Shape> vertexSize = new Transformer<String, Shape>() { public Shape transform(String i) { Ellipse2D circle = new Ellipse2D.Double(-20, -20, 40, 40); // in this case, the vertex is twice as large return circle; } }; // vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller() { // @Override // public String transform(Object v) { // // return ((VertexTopology)v).screenName; // }}); vv.getRenderContext().setVertexShapeTransformer(vertexSize); getContentPane().setPreferredSize(new Dimension(1400, 900)); getContentPane().add(vv); switchLayout = new JButton("Switch to SpringLayout"); // switchLayout.addActionListener(new ActionListener() { // // @SuppressWarnings("unchecked") // public void actionPerformed(ActionEvent ae) { // Dimension d = new Dimension(600,600); // if (switchLayout.getText().indexOf("Spring") > 0) { // switchLayout.setText("Switch to FRLayout"); // layout = new SpringLayout<String,Number>(g, // new ConstantTransformer(EDGE_LENGTH)); // layout.setSize(d); // vv.getModel().setGraphLayout(layout, d); // } else { // switchLayout.setText("Switch to SpringLayout"); // layout = new FRLayout<String,Number>(g, d); // vv.getModel().setGraphLayout(layout, d); // } // } // }); getContentPane().add(switchLayout, BorderLayout.SOUTH); timer = new Timer(); }
From source file:org.jfree.chart.demo.MultipleAxisDemo1.java
/** * Creates the demo chart.//from w w w.j ava2 s .com * * @return The chart. */ private JFreeChart createChart() { final XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200); final JFreeChart chart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 1", "Time of Day", "Primary Range Axis", dataset1, true, true, false); chart.setBackgroundPaint(Color.white); chart.addSubtitle(new TextTitle("Four datasets and four range axes.")); final XYPlot plot = chart.getXYPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); final StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer(); renderer.setPaint(Color.black); // AXIS 2 final 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); final 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 final NumberAxis axis3 = new NumberAxis("Range Axis 3"); axis3.setLabelPaint(Color.blue); axis3.setTickLabelPaint(Color.blue); plot.setRangeAxis(2, axis3); final 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 final NumberAxis axis4 = new NumberAxis("Range Axis 4"); axis4.setLabelPaint(Color.green); axis4.setTickLabelPaint(Color.green); plot.setRangeAxis(3, axis4); final 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:com.modeln.build.ctrl.charts.CMnPatchCountChart.java
/** * Create a chart representing the number patches grouped by time interval. * The data passed in the hashtable is a list of the time intervals and * the value is the number of patch requests for each interval. * * @param data Hashtable cnotaining the time intervals and corresponding counts * @param label Count label/* www. ja va 2s . co m*/ * * @return Bar chart representing the interval and count information */ public static final JFreeChart getPatchesByIntervalChart(Hashtable<CMnTimeInterval, Integer> data, String label) { JFreeChart chart = null; String title = "Patches per " + label; String nameLabel = label; String valueLabel = "Patches"; // Sort the data by date Vector<CMnTimeInterval> intervals = new Vector<CMnTimeInterval>(); Enumeration intervalList = data.keys(); while (intervalList.hasMoreElements()) { intervals.add((CMnTimeInterval) intervalList.nextElement()); } Collections.sort(intervals); // Populate the dataset with data DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Iterator keyIter = intervals.iterator(); while (keyIter.hasNext()) { CMnTimeInterval interval = (CMnTimeInterval) keyIter.next(); Integer value = data.get(interval); dataset.addValue(value, valueLabel, interval.getName()); } // Create the chart chart = ChartFactory.createBarChart(title, /*title*/ nameLabel, /*categoryAxisLabel*/ valueLabel, /*valueAxisLabel*/ dataset, /*dataset*/ PlotOrientation.VERTICAL, /*orientation*/ false, /*legend*/ false, /*tooltips*/ false /*urls*/ ); // get a reference to the plot for further customization... CategoryPlot plot = (CategoryPlot) chart.getPlot(); //chartFormatter.formatMetricChart(plot, "min"); // Set the chart colors plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setShadowVisible(false); final GradientPaint gp = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.blue); renderer.setSeriesPaint(0, gp); // Set the label orientation CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); return chart; }