List of usage examples for java.awt Color DARK_GRAY
Color DARK_GRAY
To view the source code for java.awt Color DARK_GRAY.
Click Source Link
From source file:ChartPanelMaker.java
public static ChartPanel createChart(ArrayList<Voter> voters, ArrayList<Candidate> candidates, ArrayList<Candidate> committee, String title) { XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries comitteeDataset = new XYSeries("Committee"); for (Candidate c : committee) { comitteeDataset.add(c.getX(), c.getY()); }//from ww w .java 2 s . c o m dataset.addSeries(comitteeDataset); int n = voters.size(); int m = candidates.size(); int skipN = n / 150; if (skipN < 1) { skipN = 1; } int skipM = m / 150; if (skipM < 1) { skipM = 1; } Collections.sort(voters, Election.VoterNameComparator); Collections.sort(candidates, Election.CandidateNameComparator); XYSeries voterDataset = new XYSeries("Voters"); for (int i = 0; i < n; i++) { Voter v = voters.get(i); if (i % skipN == 0) { voterDataset.add(v.getX(), v.getY()); } } dataset.addSeries(voterDataset); XYSeries candidateDataset = new XYSeries("Candidates"); for (int i = 0; i < m; i++) { Candidate c = candidates.get(i); if (i % skipM == 0) { candidateDataset.add(c.getX(), c.getY()); } } dataset.addSeries(candidateDataset); Shape committeeShape = ShapeUtilities.createDiamond(5); Shape voterShape = ShapeUtilities.createDownTriangle(3); Shape candidateShape = ShapeUtilities.createUpTriangle(3); Color committeeColor = Color.DARK_GRAY; Color voterColor = Color.ORANGE; Color candidateColor = Color.LIGHT_GRAY; JFreeChart chart = ChartFactory.createScatterPlot(title, "", "", dataset, PlotOrientation.VERTICAL, true, true, true); XYPlot plot = chart.getXYPlot(); XYItemRenderer r = plot.getRenderer(); r.setSeriesShape(0, committeeShape); r.setSeriesPaint(0, committeeColor); r.setSeriesShape(1, voterShape); r.setSeriesPaint(1, voterColor); r.setSeriesShape(2, candidateShape); r.setSeriesPaint(2, candidateColor); ChartPanel chartPanel = new ChartPanel(chart); return chartPanel; }
From source file:cl.apr.pdf.chart.BarChartAviso.java
public static BufferedImage crearBarchart(List<BarChartItem> barChartItems) { BufferedImage bi = null;/*from ww w .j a va 2 s. c o m*/ try { ChartFactory.setChartTheme(StandardChartTheme.createJFreeTheme()); //ChartFactory.setChartTheme(StandardChartTheme.createDarknessTheme()); /* Step - 1: Define the data for the bar chart */ DefaultCategoryDataset my_bar_chart_dataset = new DefaultCategoryDataset(); int i = 0; for (BarChartItem barChartItem : barChartItems) { if (barChartItem.getNombre().equals("-")) { my_bar_chart_dataset.addValue(barChartItem.getValor(), "serie", (++i) + ""); } else my_bar_chart_dataset.addValue(barChartItem.getValor(), "serie", barChartItem.getNombre()); } // my_bar_chart_dataset.addValue(34, "mes", "Ene"); // my_bar_chart_dataset.addValue(25, "mes", "Feb"); // my_bar_chart_dataset.addValue(22, "mes", "Mar"); // my_bar_chart_dataset.addValue(12, "mes", "Abr"); // my_bar_chart_dataset.addValue(40, "mes", "May"); // my_bar_chart_dataset.addValue(30, "mes", "jun"); // my_bar_chart_dataset.addValue(2, "mes", "Jul"); // my_bar_chart_dataset.addValue(15, "mes", "Ago"); /* Step -2:Define the JFreeChart object to create bar chart */ //JFreeChart chart=ChartFactory.createBarChart("Detalle de sus consumos","","MT3",my_bar_chart_dataset,PlotOrientation.VERTICAL,true,true,false); JFreeChart chart = ChartFactory.createBarChart("", "", "MT3", my_bar_chart_dataset, PlotOrientation.VERTICAL, true, true, false); //chart.setBackgroundPaint(Color.lightGray); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); CategoryItemRenderer renderer = new CustomRenderer(); renderer.setSeriesPaint(0, Color.DARK_GRAY); plot.setRenderer(renderer); plot.setBackgroundPaint(Color.white); chart.setBorderVisible(false); chart.setBackgroundPaint(Color.white); chart.setBorderStroke(null); chart.getLegend().visible = false; /* Step -3: Write the output as PNG file with bar chart information */ int width = 480; /* Width of the image */ int height = 250; /* Height of the image */ bi = chart.createBufferedImage(width, height); /* File BarChart=new File("output_chart.png"); ChartUtilities.saveChartAsPNG(BarChart,BarChartObject,width,height); */ } catch (Exception i) { System.out.println(i); } return bi; }
From source file:org.jfree.graphics2d.demo.SVGPieChartDemo1.java
/** * Creates a chart./*from w ww .j a va2 s .c o m*/ * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Smart Phones Manufactured / Q3 2011", // chart title dataset); chart.removeLegend(); // set a custom background for the chart chart.setBackgroundPainter(new GradientPainter(new Color(20, 20, 20), RectangleAnchor.TOP_LEFT, Color.DARK_GRAY, RectangleAnchor.BOTTOM_RIGHT)); // customise the title position and font TextTitle t = chart.getTitle(); t.setHorizontalAlignment(HorizontalAlignment.LEFT); t.setPaint(new Color(240, 240, 240)); t.setFont(new Font("Arial", Font.BOLD, 26)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPainter(null); plot.setInteriorGap(0.04); plot.setBorderPainter(null); // use gradients and white borders for the section colours plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE)); plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED)); plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN)); plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW)); plot.setBaseSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f)); // customise the section label appearance plot.setLabelFont(new Font("Courier New", Font.BOLD, 20)); plot.setLabelLinkPaint(Color.WHITE); plot.setLabelLinkStroke(new BasicStroke(2.0f)); plot.setLabelOutlineStroke(null); plot.setLabelPaint(Color.WHITE); plot.setLabelBackgroundPaint(null); // add a subtitle giving the data source TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", new Font("Courier New", Font.PLAIN, 12)); source.setPaint(Color.WHITE); source.setPosition(RectangleEdge.BOTTOM); source.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(source); return chart; }
From source file:gui.accessories.BattleSimFx.java
@Override public void init() { tableModel = new SampleTableModel(); // create javafx panel for charts chartFxPanel = new JFXPanel(); chartFxPanel.setPreferredSize(new Dimension(PANEL_WIDTH_INT, PANEL_HEIGHT_INT)); //JTable// w w w . j a v a 2 s . c o m JTable table = new JTable(tableModel); table.setAutoCreateRowSorter(true); table.setGridColor(Color.DARK_GRAY); BattleSimFx.DecimalFormatRenderer renderer = new BattleSimFx.DecimalFormatRenderer(); renderer.setHorizontalAlignment(JLabel.RIGHT); for (int i = 0; i < table.getColumnCount(); i++) { table.getColumnModel().getColumn(i).setCellRenderer(renderer); } JScrollPane tablePanel = new JScrollPane(table); tablePanel.setPreferredSize(new Dimension(PANEL_WIDTH_INT, TABLE_PANEL_HEIGHT_INT)); JPanel chartTablePanel = new JPanel(); chartTablePanel.setLayout(new BorderLayout()); //Split pane that holds both chart and table JSplitPane jsplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); jsplitPane.setTopComponent(chartTablePanel); jsplitPane.setBottomComponent(tablePanel); jsplitPane.setDividerLocation(410); chartTablePanel.add(chartFxPanel, BorderLayout.CENTER); // add(tablePanel, BorderLayout.CENTER); add(jsplitPane, BorderLayout.CENTER); // create JavaFX scene Platform.runLater(new Runnable() { @Override public void run() { createScene(); } }); }
From source file:uk.ac.abdn.csd.p2p.server.VertexPainter.java
/** * Method to tranform the colour asscoiated with a {@code Vertex} * @param v Instance of a {@code Vertex} * @return Instance of {@code Paint} object */// w w w. j a va 2 s. co m public Paint transform(Vertex v) //So for each node that we draw... { //We check the member variable, mColor, of the node. if (v.getColor().equalsIgnoreCase("yellow")) //If the node's mColor value is "yellow" we... return (Color.yellow); // Return our color, Color.yellow. else if (v.getColor().equalsIgnoreCase("red")) return (Color.red); else if (v.getColor().equalsIgnoreCase("blue")) return (Color.blue); else if (v.getColor().equalsIgnoreCase("green")) return (Color.green); else if (v.getColor().equalsIgnoreCase("orange")) return (Color.orange); else if (v.getColor().equalsIgnoreCase("pink")) return (Color.pink); else if (v.getColor().equalsIgnoreCase("black")) return (Color.black); else if (v.getColor().equalsIgnoreCase("cyan")) return (Color.cyan); else if (v.getColor().equalsIgnoreCase("dark_grey")) return (Color.DARK_GRAY); else if (v.getColor().equalsIgnoreCase("grey")) return (Color.gray); else if (v.getColor().equalsIgnoreCase("light_grey")) return (Color.lightGray); else if (v.getColor().equalsIgnoreCase("white")) return (Color.white); else return (Color.MAGENTA); }
From source file:org.cyberoam.iview.charts.Thermometer.java
/** * This method generates JFreeChart instance for Thermometer chart with iView customization. * @param reportID/*from ww w. ja va 2s . c om*/ * @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 dataset = 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)); rsw.next(); double free = Double.parseDouble(rsw.getString(yColumnDBname)); dataset = new DefaultValueDataset((100 * used) / (used + free)); ThermometerPlot plot = new ThermometerPlot(dataset); chart = new JFreeChart("", // chart title JFreeChart.DEFAULT_TITLE_FONT, plot, // plot false); // include legend chart.setBackgroundPaint(Color.white); plot.setThermometerStroke(new BasicStroke(2.0f)); plot.setThermometerPaint(Color.DARK_GRAY); plot.setBulbRadius(30); plot.setColumnRadius(15); plot.setUnits(ThermometerPlot.UNITS_NONE); plot.setMercuryPaint(Color.WHITE); plot.setValueFont(new Font("Vandara", Font.CENTER_BASELINE, 12)); plot.setBackgroundPaint(Color.white); plot.setBackgroundAlpha(0.0f); plot.setOutlineVisible(false); plot.setSubrangeInfo(0, 0, 50); plot.setSubrangeInfo(1, 50, 85); plot.setSubrangeInfo(2, 85, 100); plot.setSubrangePaint(0, new Color(75, 200, 85)); plot.setSubrangePaint(1, new Color(254, 211, 41)); plot.setSubrangePaint(2, new Color(255, 85, 85)); } catch (Exception e) { CyberoamLogger.appLog.debug("Thermometer=>getChart.exception : " + e, e); } return chart; }
From source file:edu.ucsd.hep.slhaviewer.view.MassGraphPanel.java
public MassGraphPanel() { this.setLayout(new BorderLayout()); dataset = new XYSeriesCollection(); JFreeChart chart = ChartFactory.createXYLineChart("Mass Spectrum", "", "mass [GeV]", dataset, PlotOrientation.VERTICAL, false, // no legend true, // add tooltips false // add urls );//from w w w . j a v a2 s . com // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); renderer = (XYLineAndShapeRenderer) plot.getRenderer(); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setTickMarksVisible(false); domainAxis.setTickLabelsVisible(false); chart.setBackgroundPaint(Color.WHITE); // 'outside' plot.setBackgroundPaint(Color.WHITE); // 'inside' plot.setRangeGridlinePaint(Color.DARK_GRAY); this.add(new ChartPanel(chart), BorderLayout.CENTER); }
From source file:uom.research.thalassemia.util.PieChartCreator.java
/** * Creates a chart.// w ww .ja v a 2s .c om * * @param dataset the dataset. * * @return A chart. */ private JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart(title, // chart title dataset, // data true, // no legend true, // tooltips false // no URL generation ); // set a custom background for the chart chart.setBackgroundPaint( new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY)); // customise the title position and font TextTitle t = chart.getTitle(); t.setHorizontalAlignment(HorizontalAlignment.LEFT); t.setPaint(new Color(240, 240, 240)); t.setFont(new Font("Arial", Font.BOLD, 26)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setInteriorGap(0.04); plot.setOutlineVisible(false); // use gradients and white borders for the section colours int itemIndex = 0; for (Object col : pieDataset.getKeys()) { plot.setSectionPaint(col.toString(), gradientPaints[itemIndex]); if (itemIndex == pieDataset.getItemCount() - 1) { itemIndex = 0; } itemIndex++; } plot.setBaseSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f)); // customise the section label appearance plot.setLabelFont(new Font("Courier New", Font.BOLD, 20)); plot.setLabelLinkPaint(Color.WHITE); plot.setLabelLinkStroke(new BasicStroke(2.0f)); plot.setLabelOutlineStroke(null); plot.setLabelPaint(Color.WHITE); plot.setLabelBackgroundPaint(null); // add a subtitle giving the data source TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", new Font("Courier New", Font.PLAIN, 12)); source.setPaint(Color.WHITE); source.setPosition(RectangleEdge.BOTTOM); source.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(source); return chart; }
From source file:org.executequery.gui.resultset.ResultSetTable.java
public ResultSetTable() { super();/*from w w w . j a v a 2 s . c o m*/ setDefaultOptions(); final StringCellEditor stringCellEditor = new StringCellEditor(); stringCellEditor.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1)); defaultCellEditor = new DefaultCellEditor(stringCellEditor) { public Object getCellEditorValue() { return stringCellEditor.getValue(); } }; final MultiLineStringCellEditor multiLineStringCellEditor = new MultiLineStringCellEditor(); multiLineStringCellEditor.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1)); multiLineCellEditor = new DefaultCellEditor(multiLineStringCellEditor) { public Object getCellEditorValue() { return multiLineStringCellEditor.getValue(); } }; }
From source file:support.TradingVolumeGui.java
private CategoryPlot createChartFrame(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart("Trading Volume", "Stock", "Volume, USD", dataset, PlotOrientation.HORIZONTAL, true, true, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.DARK_GRAY); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.getRenderer().setSeriesPaint(0, Color.BLUE); JFrame frame = new JFrame(); frame.setBackground(Color.WHITE); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setTitle("Hazelcast Jet Source Builder Sample"); frame.setBounds(WINDOW_X, WINDOW_Y, WINDOW_WIDTH, WINDOW_HEIGHT); frame.setLayout(new BorderLayout()); frame.add(new ChartPanel(chart)); frame.setVisible(true);//from www .j a v a 2s .c o m frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent) { hzMap.removeEntryListener(entryListenerId); } }); return plot; }