List of usage examples for java.awt Color blue
Color blue
To view the source code for java.awt Color blue.
Click Source Link
From source file:com.googlecode.logVisualizer.chart.HorizontalIntervallBarChartBuilder.java
private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createBarChart(getTitle(), xLable, yLable, dataset, PlotOrientation.HORIZONTAL, isIncludeLegend(), true, false); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); final CategoryAxis categoryAxis = plot.getDomainAxis(); final LayeredBarRenderer renderer = new LayeredBarRenderer(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinePaint(Color.black); setBarShadowVisible(chart, false);/* w ww . j av a 2s. co m*/ plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.getRangeAxis().setLowerBound(-35); plot.getRangeAxis().setUpperBound(35); renderer.setDrawBarOutline(false); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesPaint(1, Color.green); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER)); renderer.setSeriesPositiveItemLabelPosition(1, new ItemLabelPosition(ItemLabelAnchor.OUTSIDE2, TextAnchor.CENTER)); renderer.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER)); renderer.setSeriesNegativeItemLabelPosition(1, new ItemLabelPosition(ItemLabelAnchor.OUTSIDE10, TextAnchor.CENTER)); renderer.setItemLabelAnchorOffset(9.0); renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("{1}, {2}", NumberFormat.getInstance())); plot.setRenderer(renderer); plot.setRowRenderingOrder(SortOrder.DESCENDING); categoryAxis.setCategoryMargin(0.15); categoryAxis.setUpperMargin(0.0175); categoryAxis.setLowerMargin(0.0175); return chart; }
From source file:loadmaprenderer.ResultDisplayChart.java
private JFreeChart makeChart(XYDataset dataset, String chartTitle, String dataTitle) { JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, "Year", dataTitle, dataset, PlotOrientation.VERTICAL, false, true, false); XYPlot plot = chart.getXYPlot();/*ww w .j av a 2s. c o m*/ plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.BLUE); plot.setRangeGridlinePaint(Color.BLUE); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRange(true); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRange(true); Double range = dataLine.getMaxY() - dataLine.getMinY(); if (Math.abs(range) < 0.1) range = dataLine.getMaxY(); rangeAxis.setRange(dataLine.getMinY() - range * 0.1, dataLine.getMaxY() + range * 0.1); return chart; }
From source file:com.google.code.facebook.graph.sna.applet.GraphFromGraphMLDemo.java
/** * create an instance of a simple graph with controls to * demo the zoom features.//from ww w . j ava2 s .c o m * @throws SAXException * @throws ParserConfigurationException * @throws IOException * */ public GraphFromGraphMLDemo(String filename) throws ParserConfigurationException, SAXException, IOException { Factory<Number> vertexFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; } }; Factory<Number> edgeFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; } }; GraphMLReader<DirectedGraph<Number, Number>, Number, Number> gmlr = new GraphMLReader<DirectedGraph<Number, Number>, Number, Number>( vertexFactory, edgeFactory); final DirectedGraph<Number, Number> graph = new DirectedSparseMultigraph<Number, Number>(); gmlr.load(filename, graph); // create a simple graph for the demo vv = new VisualizationViewer<Number, Number>(new FRLayout<Number, Number>(graph)); vv.addGraphMouseListener(new TestGraphMouseListener<Number>()); vv.getRenderer().setVertexRenderer(new GradientVertexRenderer<Number, Number>(Color.white, Color.red, Color.white, Color.blue, vv.getPickedVertexState(), false)); // add my listeners for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Number>()); vv.setEdgeToolTipTransformer(new Transformer<Number, String>() { public String transform(Number edge) { return "E" + graph.getEndpoints(edge).toString(); } }); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Number>()); vv.getRenderer().getVertexLabelRenderer().setPositioner(new InsidePositioner()); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.AUTO); // create a frome to hold the graph final JFrame frame = new JFrame(); Container content = frame.getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final AbstractModalGraphMouse graphMouse = new DefaultModalGraphMouse<Number, Number>(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); JMenuBar menubar = new JMenuBar(); menubar.add(graphMouse.getModeMenu()); panel.setCorner(menubar); vv.addKeyListener(graphMouse.getModeKeyListener()); vv.setToolTipText("<html><center>Type 'p' for Pick mode<p>Type 't' for Transform mode"); 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()); } }); JPanel controls = new JPanel(); controls.add(plus); controls.add(minus); content.add(controls, BorderLayout.SOUTH); frame.pack(); frame.setVisible(true); }
From source file:org.jax.bham.infer.PlotPhylogeneticTreeAction.java
/** * {@inheritDoc}//from w w w . ja va2s . co m */ public void actionPerformed(ActionEvent e) { final PhylogenyTreeNode phylogenyTree; final PhylogenyTreeImageFactory treeImageFactory; if (this.test == null) { phylogenyTree = this.phylogenyTree; treeImageFactory = new SimplePhylogenyTreeImageFactory(); } else { Map<String, List<Double>> phenoData = this.test.getPhenotypeDataSource().getPhenotypeData(); phenoData.keySet().retainAll(this.test.getCommonStrains()); PhylogenyTreeNode preTransformPhylogenyTree = this.test.getPhylogenyTester() .testMultipleResponseSignificance(this.phylogenyTree, phenoData); // do a -log10 transform phylogenyTree = PhylogenyTreeEdgeWithRealValue.transform(preTransformPhylogenyTree, new NegativeLog10()); PhylogenyTreeEdgeWithRealValue maxEdge = PhylogenyTreeEdgeWithRealValue .getEdgeWithMaximumValue(phylogenyTree); PaintScale paintScale = new SmoothPaintScale(0.0, maxEdge.getRealValue(), Color.BLUE, Color.RED); treeImageFactory = new SimplePhylogenyTreeImageFactory(paintScale); } PhylogenyTreeImagePanel phyloPanel = new PhylogenyTreeImagePanel(treeImageFactory, phylogenyTree); Desktop desktop = BhamApplication.getInstance().getBhamFrame().getDesktop(); desktop.createInternalFrame(phyloPanel, "Phylogeny Tree Graph", null, "phylo tree graph: " + this.phylogenyTree.toNewickFormat()); }
From source file:org.mili.jmibs.jfree.JFreeChartBarIterationIntervalBenchmarkSuiteResultRenderer.java
private JFreeChart createChart(String title, CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart(title, "Benchmark (Iteration/Interval)", "Time in ns", dataset, PlotOrientation.HORIZONTAL, true, true, false); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false);//from ww w . j av a2s . c o m GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); return chart; }
From source file:com.midas.classify.gui.DecisionTreeViewer.java
public DecisionTreeViewer(DelegateTree<TreeNode, TreeEdge> tr, String[] cls) { setLayout(new BorderLayout()); // ---------------------------------------------- // // INICIALIZACION DE COMPONENTES DE VISUALIZACION // // ---------------------------------------------- // tree = tr;//ww w .j a v a 2 s.c o m classNames = cls; classColors = new TreeMap(); nodeColor = Color.BLUE; for (int i = 0; i < cls.length; ++i) { classColors.put(cls[i], Color.RED); } leafNodes = new TreeSet(); for (TreeNode n : tr.getVertices()) { if (tr.isLeaf(n)) { for (String s : cls) { if (n.toString().startsWith(s)) { leafNodes.add(s); break; } } } } TreeLayout<TreeNode, TreeEdge> layout = new TreeLayout(tr); vv = new VisualizationViewer(layout); vv.setBackground(Color.white); vv.getRenderContext().setEdgeFontTransformer(new EdgeFontTransformer()); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<TreeNode, TreeEdge>()); PickedState<TreeNode> picked_state = vv.getPickedVertexState(); vv.getRenderContext().setVertexFillPaintTransformer(new VertexFillColorTransformer<TreeNode>(picked_state)); vv.getRenderContext().setVertexDrawPaintTransformer(new VertexDrawColorTransformer<TreeNode>(picked_state)); vv.getRenderContext().setVertexFontTransformer(new VertexFontTransformer()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller()); GraphZoomScrollPane scrollPane = new GraphZoomScrollPane(vv); gm = new DefaultModalGraphMouse(); vv.setGraphMouse(gm); final ScalingControl scaler = new CrossoverScalingControl(); // ---------------------------------------- // // INICIALIZACION DE COMPONENTES DE CONTROL // // ---------------------------------------- // fontChooser = new JFontChooser(); JPanel pControl = new JPanel(new GridLayout(7, 1, 4, 2)); JPanel pZoom = new JPanel(new GridLayout(1, 2, 2, 2)); pZoom.setBorder(new TitledBorder("Zoom")); bZoomIn = new JButton("+"); bZoomIn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); bZoomOut = new JButton("-"); bZoomOut.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); pZoom.add(bZoomIn); pZoom.add(bZoomOut); JPanel pFont = new JPanel(new GridLayout(1, 2, 2, 2)); pFont.setBorder(new TitledBorder("Fonts")); bNodeFont = new JButton("Node Font"); bNodeFont.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int r = fontChooser.showDialog(null); if (r == JFontChooser.OK_OPTION) { nodeFont = fontChooser.getSelectedFont(); vv.repaint(); } } }); bEdgeFont = new JButton("Edge Font"); bEdgeFont.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int r = fontChooser.showDialog(null); if (r == JFontChooser.OK_OPTION) { edgeFont = fontChooser.getSelectedFont(); vv.repaint(); } } }); pFont.add(bNodeFont); pFont.add(bEdgeFont); bNodeColor = new JButton("Node Color"); bNodeColor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { nodeColor = JColorChooser.showDialog(null, "Select color for intern nodes", Color.RED); vv.repaint(); } }); JPanel pMode = new JPanel(); pMode.setBorder(new TitledBorder("Mode")); cbMode = new JComboBox(); cbMode.addItem(ModalGraphMouse.Mode.TRANSFORMING); cbMode.addItem(ModalGraphMouse.Mode.PICKING); cbMode.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { gm.setMode((ModalGraphMouse.Mode) e.getItem()); } }); pMode.add(cbMode); JPanel pColors = new JPanel(new GridLayout(1, 2, 2, 2)); pColors.setBorder(new TitledBorder("Node Colors")); cbClasses = new JComboBox(classNames); cbClasses.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color c = JColorChooser.showDialog(null, "Select class color for " + cbClasses.getSelectedItem(), Color.RED); classColors.put(cbClasses.getSelectedItem().toString(), c); vv.repaint(); } }); pColors.add(cbClasses); pColors.add(bNodeColor); JPanel pLabelPosition = new JPanel(); pLabelPosition.setBorder(new TitledBorder("Label Position")); cbLabelPosition = new JComboBox(); cbLabelPosition.addItem(Renderer.VertexLabel.Position.N); cbLabelPosition.addItem(Renderer.VertexLabel.Position.NE); cbLabelPosition.addItem(Renderer.VertexLabel.Position.E); cbLabelPosition.addItem(Renderer.VertexLabel.Position.SE); cbLabelPosition.addItem(Renderer.VertexLabel.Position.S); cbLabelPosition.addItem(Renderer.VertexLabel.Position.SW); cbLabelPosition.addItem(Renderer.VertexLabel.Position.W); cbLabelPosition.addItem(Renderer.VertexLabel.Position.NW); cbLabelPosition.addItem(Renderer.VertexLabel.Position.N); cbLabelPosition.addItem(Renderer.VertexLabel.Position.CNTR); cbLabelPosition.addItem(Renderer.VertexLabel.Position.AUTO); cbLabelPosition.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { Renderer.VertexLabel.Position position = (Renderer.VertexLabel.Position) e.getItem(); vv.getRenderer().getVertexLabelRenderer().setPosition(position); vv.repaint(); } }); cbLabelPosition.setSelectedItem(Renderer.VertexLabel.Position.SE); pLabelPosition.add(cbLabelPosition); chkShowEdgeNames = new JCheckBox("Show Edge Name"); chkShowEdgeNames.addActionListener(new ActionListener() { ToStringLabeller strLabeller = new ToStringLabeller(); ConstantTransformer none = new ConstantTransformer(null); @Override public void actionPerformed(ActionEvent e) { AbstractButton src = (AbstractButton) e.getSource(); if (src.isSelected()) { vv.getRenderContext().setEdgeLabelTransformer(strLabeller); } else { vv.getRenderContext().setEdgeLabelTransformer(none); } vv.repaint(); } }); chkShowEdgeNames.setSelected(true); chkShowNodeNames = new JCheckBox("Show Node Name"); chkShowNodeNames.addActionListener(new ActionListener() { ToStringLabeller strLabeller = new ToStringLabeller(); ConstantTransformer none = new ConstantTransformer(null); @Override public void actionPerformed(ActionEvent e) { AbstractButton src = (AbstractButton) e.getSource(); if (src.isSelected()) { vv.getRenderContext().setVertexLabelTransformer(strLabeller); } else { vv.getRenderContext().setVertexLabelTransformer(none); } vv.repaint(); } }); chkShowNodeNames.setSelected(true); pControl.add(pZoom); pControl.add(pFont); pControl.add(pMode); pControl.add(pLabelPosition); pControl.add(pColors); pControl.add(chkShowNodeNames); pControl.add(chkShowEdgeNames); // Agregar componentes al panel add(scrollPane); JPanel p = new JPanel(new FlowLayout()); p.add(pControl); add(p, BorderLayout.EAST); }
From source file:org.jfree.chart.swt.demo.SWTMultipleAxisDemo1.java
/** * Creates the demo chart./*from ww w. j a v a 2s. c o m*/ * * @return The chart. */ private static JFreeChart createChart() { XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200); JFreeChart chart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 3", "Time of Day", "Primary Range Axis", dataset1, true, true, false); chart.setBackgroundPaint(Color.white); chart.setBorderVisible(true); chart.setBorderPaint(Color.BLACK); TextTitle subtitle = new TextTitle("Four datasets and four range axes."); chart.addSubtitle(subtitle); XYPlot plot = (XYPlot) chart.getPlot(); 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)); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.black); // AXIS 2 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); 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 NumberAxis axis3 = new NumberAxis("Range Axis 3"); axis3.setLabelPaint(Color.blue); axis3.setTickLabelPaint(Color.blue); //axis3.setPositiveArrowVisible(true); plot.setRangeAxis(2, axis3); 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 NumberAxis axis4 = new NumberAxis("Range Axis 4"); axis4.setLabelPaint(Color.green); axis4.setTickLabelPaint(Color.green); plot.setRangeAxis(3, axis4); 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:cn.edu.thss.iise.bpmdemo.charts.SWTMultipleAxisDemo1.java
/** * Creates the demo chart.// w w w .j a v a2 s . co m * * @return The chart. */ private static JFreeChart createChart() { XYDataset dataset1 = createDataset("Series 1", 100.0, new Day(), 200); JFreeChart chart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 3", "Time of Day", "Primary Range Axis", dataset1, true, true, false); chart.setBackgroundPaint(Color.white); chart.setBorderVisible(true); chart.setBorderPaint(Color.BLACK); TextTitle subtitle = new TextTitle("Four datasets and four range axes."); chart.addSubtitle(subtitle); XYPlot plot = (XYPlot) chart.getPlot(); 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)); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.black); // AXIS 2 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); XYDataset dataset2 = createDataset("Series 2", 1000.0, new Day(), 170); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); XYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // AXIS 3 NumberAxis axis3 = new NumberAxis("Range Axis 3"); axis3.setLabelPaint(Color.blue); axis3.setTickLabelPaint(Color.blue); // axis3.setPositiveArrowVisible(true); plot.setRangeAxis(2, axis3); XYDataset dataset3 = createDataset("Series 3", 10000.0, new Day(), 170); plot.setDataset(2, dataset3); plot.mapDatasetToRangeAxis(2, 2); XYItemRenderer renderer3 = new StandardXYItemRenderer(); renderer3.setSeriesPaint(0, Color.blue); plot.setRenderer(2, renderer3); // AXIS 4 NumberAxis axis4 = new NumberAxis("Range Axis 4"); axis4.setLabelPaint(Color.green); axis4.setTickLabelPaint(Color.green); plot.setRangeAxis(3, axis4); XYDataset dataset4 = createDataset("Series 4", 25.0, new Day(), 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.csc.GUI.ProfileGUIPanel.java
private JFreeChart createBarChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Expenses Statistics", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? );/*from w w w .ja v a 2 s . c o m*/ // 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:net.sf.dynamicreports.test.jasper.chart.MeterChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);/* w ww . java2 s . c o m*/ JFreeChart chart = getChart("summary.chart1", 0); Plot plot = chart.getPlot(); Assert.assertEquals("renderer", MeterPlot.class, plot.getClass()); MeterPlot meterPlot = (MeterPlot) plot; Assert.assertEquals("value", 15, meterPlot.getDataset().getValue()); Assert.assertEquals("data range low", 3d, meterPlot.getRange().getLowerBound()); Assert.assertEquals("data range high", 30d, meterPlot.getRange().getUpperBound()); Assert.assertEquals("value color", Color.BLUE, meterPlot.getValuePaint()); Assert.assertEquals("value mask", "15.0", meterPlot.getTickLabelFormat().format(15)); Assert.assertEquals("value font", new Font("Arial", Font.PLAIN, 10), meterPlot.getValueFont()); Assert.assertEquals("shape", DialShape.CIRCLE, meterPlot.getDialShape()); Assert.assertEquals("meter angle", 270, meterPlot.getMeterAngle()); Assert.assertEquals("units", "units", meterPlot.getUnits()); Assert.assertEquals("tick interval", 3d, meterPlot.getTickSize()); Assert.assertEquals("background color", Color.LIGHT_GRAY, meterPlot.getDialBackgroundPaint()); Assert.assertEquals("needle color", Color.CYAN, meterPlot.getNeedlePaint()); Assert.assertEquals("tick color", Color.MAGENTA, meterPlot.getTickPaint()); Assert.assertEquals("tick label font", new Font("Courier New", Font.PLAIN, 10), meterPlot.getTickLabelFont()); Assert.assertEquals("intervals size", 2, meterPlot.getIntervals().size()); intervalTest((MeterInterval) meterPlot.getIntervals().get(0), "red", new Color(1f, 0f, 0f, 0.8f), 25d, 30d); intervalTest((MeterInterval) meterPlot.getIntervals().get(1), "yellow", new Color(1f, 1f, 0f, 0.5f), 20d, 25d); }