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:org.jfree.chart.demo.LayeredBarChartDemo1.java
/** * Creates a chart for the specified dataset. * //from w ww. j av a 2 s. c o m * @param dataset the dataset. * * @return a chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final CategoryAxis categoryAxis = new CategoryAxis("Category"); //categoryAxis.setMaxCategoryLabelWidthRatio(10.0f); final ValueAxis valueAxis = new NumberAxis("Score (%)"); final CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, new LayeredBarRenderer()); plot.setOrientation(PlotOrientation.HORIZONTAL); final JFreeChart chart = new JFreeChart("Layered Bar Chart", 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.4); renderer.setItemMargin(0.01); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryMargin(0.25); domainAxis.setUpperMargin(0.05); domainAxis.setLowerMargin(0.05); return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.BarChartDemo4.java
/** * Creates a sample chart.// www .ja v a 2 s.c om * * @param dataset the dataset. * * @return The chart. */ protected JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(new Color(0xBBBBDD)); // get a reference to the plot for further customisation... CategoryPlot plot = chart.getCategoryPlot(); // 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.setMaximumBarWidth(0.10); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); // OPTIONAL CUSTOMISATION COMPLETED. renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator()); setCategorySummary(dataset); return chart; }
From source file:jmbench.plots.OperationsVersusSizePlot.java
public static Color getColor(int num) { switch (num) { case 0://from ww w .j a v a 2 s.c o m return new Color(0f, 0f, 1f, 0.6f); case 1: return new Color(0.5f, 0.7f, 0f, 0.6f); case 2: return Color.BLACK; case 3: return Color.RED; case 4: return Color.CYAN; case 5: return Color.ORANGE; case 6: return Color.GREEN; case 7: return Color.lightGray; case 8: return Color.blue; case 9: return new Color(255, 0, 255, 190); //magenta with translucent case 10: return new Color(230, 150, 0); // darker orange case 11: return new Color(255, 0, 255, 190); case 12: return new Color(120, 255, 0); default: throw new RuntimeException("add some more"); } }
From source file:edu.ucla.stat.SOCR.chart.demo.ScatterChartDemo1.java
/** * Creates a chart.// ww w . j av a 2 s . c o m * * @param dataset the data for the chart. * * @return a chart. */ protected JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title domainLabel, // x axis label rangeLabel, // y axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... 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); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setBaseLinesVisible(false); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setUpperMargin(0); rangeAxis.setLowerMargin(0); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setUpperMargin(0); domainAxis.setLowerMargin(0); // OPTIONAL CUSTOMISATION COMPLETED. setXSummary(dataset); return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.LineChartDemo6.java
/** * Creates a chart.// ww w .ja v a 2 s .c om * * @param dataset the data for the chart. * * @return a chart. */ protected JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title domainLabel, // x axis label rangeLabel, // y axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); // renderer.setSeriesLinesVisible(0, false); // renderer.setSeriesShapesVisible(1, false); renderer.setBaseLinesVisible(false); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:org.jls.toolbox.math.chart.XYBlockChart.java
/** * Permet de modifier l'chelle de couleur utilise par le graphique. Cela * va crer un gradient de couleur entre les deux couleurs spcifies, la * premire couleur correspondant aux valeurs les plus fortes de l'chelle * des donnes reprsenter. Les bornes infrieure et suprieure permettent * de prciser l'tendue des donnes reprsentes par cette chelle de * couleur.//www . j a va 2 s.c om * * @param colorMin * Couleur d'arrive du gradient reprsentant les plus faibles * valeurs de l'chelle. * @param colorMax * Couleur de dpart du gradient reprsentant les plus fortes * valeurs de l'chelle. * @param lowerBound * Borne infrieure de l'chelle des donnes reprsentes. * @param upperBound * Bornes suprieure de l'chelle des donnes reprsentes. */ public void setColorGradient(Color colorMin, Color colorMax, double lowerBound, double upperBound) { LookupPaintScale scale = new LookupPaintScale(lowerBound, upperBound, Color.lightGray); double r1, r2, dr, g1, g2, dg, b1, b2, db; int nbVal = (int) (upperBound - lowerBound + 0.5); // Acquisition des composantes r1 = colorMax.getRed(); g1 = colorMax.getGreen(); b1 = colorMax.getBlue(); r2 = colorMin.getRed(); g2 = colorMin.getGreen(); b2 = colorMin.getBlue(); // Calcul du delta entre les composantes dr = (r2 - r1) / nbVal; dg = (g2 - g1) / nbVal; db = (b2 - b1) / nbVal; // Cration du gradient for (int i = 0; i < nbVal; i++) { scale.add(lowerBound + i, new Color((int) r2, (int) g2, (int) b2)); r2 = r2 - dr; g2 = g2 - dg; b2 = b2 - db; } // Mise jour du graphique this.renderer.setPaintScale(scale); this.scaleLegend.setScale(scale); // Du fait que la lgende n'est pas lie aux modifications de la courbe, // il faut rcrer la lgende la main. this.chart.removeSubtitle(this.scaleLegend); createPaintScaleLegend(scale); }
From source file:edu.ucla.stat.SOCR.chart.demo.IndexChart.java
/** * Creates a chart.//from www .ja v a2s. c om * * @param dataset the data for the chart. * * @return a chart. */ protected JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title domainLabel, // x axis label rangeLabel, // y axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); // renderer.setSeriesShape(0, java.awt.Shape.round); renderer.setBaseShapesVisible(false); renderer.setBaseShapesFilled(false); renderer.setBaseLinesVisible(true); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); //change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setUpperMargin(0.05); rangeAxis.setLowerMargin(0.05); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setAutoRangeIncludesZero(false); // domainAxis.setTickLabelsVisible(false); // domainAxis.setTickMarksVisible(false); domainAxis.setUpperMargin(0.05); domainAxis.setLowerMargin(0.05); // OPTIONAL CUSTOMISATION COMPLETED. setYSummary(dataset); return chart; }
From source file:demos.TreeCollapse.java
@SuppressWarnings("unchecked") public TreeCollapse() { // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree();//from w w w . j a va 2 s . c om layout = new TreeLayout<String, Integer>(graph); collapser = new TreeCollapser(); radialLayout = new RadialTreeLayout<String, Integer>(graph); radialLayout.setSize(new Dimension(600, 600)); vv = new VisualizationViewer<String, Integer>(layout, new Dimension(600, 600)); vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.getRenderContext().setVertexShapeTransformer(new ClusterVertexShapeFunction()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); rings = new Rings(); 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) { // layout.setRadial(true); vv.setGraphLayout(radialLayout); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.addPreRenderPaintable(rings); } else { // layout.setRadial(false); vv.setGraphLayout(layout); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.removePreRenderPaintable(rings); } vv.repaint(); } }); JButton collapse = new JButton("Collapse"); collapse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Collection<?> picked = new HashSet<Object>(vv.getPickedVertexState().getPicked()); if (picked.size() == 1) { Object root = picked.iterator().next(); Forest<?, ?> inGraph = (Forest<?, ?>) layout.getGraph(); try { collapser.collapse(vv.getGraphLayout(), inGraph, root); } catch (InstantiationException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IllegalAccessException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } vv.getPickedVertexState().clear(); vv.repaint(); } } }); JButton expand = new JButton("Expand"); expand.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Collection picked = vv.getPickedVertexState().getPicked(); for (Object v : picked) { if (v instanceof Forest) { Forest inGraph = (Forest) layout.getGraph(); collapser.expand(inGraph, (Forest) v); } vv.getPickedVertexState().clear(); 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); controls.add(collapse); controls.add(expand); content.add(controls, BorderLayout.SOUTH); }
From source file:arduinouno.TimeChartGenerator.java
/** * Creates a sample chart./*from ww w . j av a 2s.c o m*/ * * @param dataset the dataset. * * @return A sample chart. */ private JFreeChart createChart(final XYDataset dataset, final XYDataset dataset0, final XYDataset dataset1, final XYDataset dataset2, final XYDataset dataset3, final XYDataset dataset4, final XYDataset dataset5) { final JFreeChart result = ChartFactory.createTimeSeriesChart("Arduino Serial Reader", "Time", "Value", dataset, true, true, false); plot = result.getXYPlot(); //Set Graph Parameters plot.setBackgroundPaint(new Color(0xffffe0)); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.lightGray); ValueAxis xaxis = plot.getDomainAxis(); xaxis.setAutoRange(true); xaxis.setTickLabelsVisible(false); //Domain axis would show data of 30 seconds for a time xaxis.setFixedAutoRange(30000.0); // 30 seconds xaxis.setVerticalTickLabels(false); ValueAxis yaxis = plot.getRangeAxis(); yaxis.setRange(0.0, 6.0); if (dataset0 != null) { plot.setDataset(1, dataset0); plot.setRenderer(1, new StandardXYItemRenderer()); } if (dataset1 != null) { plot.setDataset(2, dataset1); plot.setRenderer(2, new StandardXYItemRenderer()); } if (dataset2 != null) { plot.setDataset(3, dataset2); plot.setRenderer(3, new StandardXYItemRenderer()); } if (dataset3 != null) { plot.setDataset(4, dataset3); plot.setRenderer(4, new StandardXYItemRenderer()); } if (dataset4 != null) { plot.setDataset(5, dataset4); plot.setRenderer(5, new StandardXYItemRenderer()); } if (dataset5 != null) { plot.setDataset(6, dataset5); plot.setRenderer(6, new StandardXYItemRenderer()); } return result; }
From source file:org.jfree.chart.demo.CategoryStepChartDemo.java
/** * Creates a chart.//from w w w . ja v a 2s .c o m * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final CategoryItemRenderer renderer = new CategoryStepRenderer(true); final CategoryAxis domainAxis = new CategoryAxis("Category"); final ValueAxis rangeAxis = new NumberAxis("Value"); final CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); final JFreeChart chart = new JFreeChart("Category Step Chart", plot); // 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); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); 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."); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLabelAngle(0 * Math.PI / 2.0); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }