List of usage examples for java.awt Color gray
Color gray
To view the source code for java.awt Color gray.
Click Source Link
From source file:de.mpg.mpdl.inge.pubman.web.statistic_charts.StatisticChartServlet.java
/** * Creates the statistic chart./*w w w . j ava2s .co m*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(CategoryDataset dataset) { // create the chart JFreeChart chart = ChartFactory.createStackedBarChart(null, // chart title "", // domain axis label "", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend false, // tooltips? false // URLs? ); // set the background color for the chart chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(0xf5, 0xf5, 0xf5)); plot.setDomainGridlinePaint(Color.gray); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.gray); // set the range axis to display integers only final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLowerBound(0); // disable bar outlines... StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer(); renderer.setBarPainter(new StandardBarPainter()); renderer.setDrawBarOutline(false); // set up gradient paints for series /* * 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.red, 0.0f, 0.0f, new Color(64, * 0, 0)); */ Color series1Color = new Color(0xfa, 0x80, 0x72); Color series2Color = new Color(0x64, 0x95, 0xed); renderer.setSeriesPaint(1, series1Color); renderer.setSeriesPaint(0, series2Color); // remove shadow renderer.setShadowVisible(false); // // Labels in bars /* * renderer.setSeriesItemLabelsVisible(0, true); renderer.setSeriesItemLabelGenerator(0, new * StandardCategoryItemLabelGenerator()); renderer.setSeriesItemLabelPaint(0, Color.white); * renderer.setSeriesItemLabelsVisible(1, true); renderer.setSeriesItemLabelGenerator(1, new * StandardCategoryItemLabelGenerator()); renderer.setSeriesItemLabelPaint(1, Color.white); */ // setCategorySummary(dataset); // rotate labels on x-axis CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); return chart; }
From source file:de.tud.kom.p2psim.impl.skynet.visualization.MetricsPlot.java
private HashMap<String, SeriesInfo> createMetricSeriesInfo(DataSet dataSet) { String[] names = dataSet.getNames(); HashMap<String, SeriesInfo> tempMap = new HashMap<String, SeriesInfo>(); SeriesInfo seriesInfo = null;/* w w w. j a va 2s . c o m*/ for (int i = 0; i < names.length; i++) { DeviationSet set = dataSet.getValues()[i]; if (names[i].startsWith("Min_")) { seriesInfo = new SeriesInfo(interval, names[i], Color.BLUE, new BasicStroke(1)); } else if (names[i].startsWith("Max_")) { seriesInfo = new SeriesInfo(interval, names[i], Color.RED, new BasicStroke(1)); } else if (names[i].startsWith("Measured")) { seriesInfo = new SeriesInfo(interval, names[i], Color.GRAY, new BasicStroke(3)); } else { seriesInfo = new SeriesInfo(interval, names[i], Color.BLACK, new BasicStroke(4)); } seriesInfo.getDataSeries().add(dataSet.getTime(), set.getValue(), set.getValue() + set.getDeviation(), Math.max(set.getValue() - set.getDeviation(), 0)); tempMap.put(names[i], seriesInfo); } return tempMap; }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java
@Test public void testConfigurationPropertiesWithColorArray() { ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); Color colorValue = config.colorArray[0]; assertEquals(Color.class, colorValue.getClass()); assertEquals(Color.gray, colorValue); assertEquals(3, config.colorArray.length); }
From source file:AlphaTest.java
/** * Draws the axes for the graph.//from w w w . ja v a 2s .com */ protected void drawAxes(Graphics g, long lMaxTime) { drawGraphString(g, -1, "Alpha vs. Time (ms)", m_nGraphMaxWidth / 2, m_nGraphMaxHeight + 20); // draw the frame drawAreaRect(g, 0, 0, m_nMaxWidth, m_nMaxHeight); // draw the X axis drawGraphLine(g, 0, 0, m_nGraphMaxWidth, 0); // draw the Y axis drawGraphLine(g, 0, 0, 0, m_nGraphMaxHeight); // draw the horizontal Y axis lines for (double yAxisTick = 0; yAxisTick <= 1.0; yAxisTick += 0.2) { double yTick = yAxisTick * m_nGraphMaxHeight; g.setColor(Color.gray); drawGraphLine(g, 0, yTick, m_nGraphMaxWidth, yTick); g.setColor(Color.black); drawGraphString(g, 3, "" + yAxisTick, -20, yTick); } }
From source file:edu.dlnu.liuwenpeng.render.CandlestickRenderer.java
/** * Creates a new renderer for candlestick charts. * <P> //from ww w . jav a 2 s.c o m * Use -1 for the candle width if you prefer the width to be calculated * automatically. * * @param candleWidth the candle width. * @param drawVolume a flag indicating whether or not volume bars should * be drawn. * @param toolTipGenerator the tool tip generator. <code>null</code> is * none. */ public CandlestickRenderer(double candleWidth, boolean drawVolume, XYToolTipGenerator toolTipGenerator) { super(); setBaseToolTipGenerator(toolTipGenerator); this.candleWidth = candleWidth; this.drawVolume = drawVolume; this.volumePaint = Color.gray; this.upPaint = Color.green; this.downPaint = Color.red; this.useOutlinePaint = false; // false preserves the old behaviour // prior to introducing this flag }
From source file:net.pms.newgui.StatusTab.java
public JComponent build() { // Apply the orientation for the locale ComponentOrientation orientation = ComponentOrientation.getOrientation(PMS.getLocale()); String colSpec = FormLayoutUtil.getColSpec("pref, 30dlu, fill:pref:grow, 30dlu, pref", orientation); // 1 2 3 4 5 FormLayout layout = new FormLayout(colSpec, // 1 2 3 4 5 // ////////////////////////////////////////////////// "p," // Detected Media Renderers --------------------// 1 + "9dlu," // // + "fill:p:grow," // <renderers> // 3 + "3dlu," // // + "p," // ---------------------------------------------// 5 + "3dlu," // | | // + "p," // Connected | Memory Usage |<bitrate> // 7 + "3dlu," // | | // + "p," // <icon> | <statusbar> | // 9 ////////////////////////////////////////////////// );/*from www .j av a 2s . c o m*/ PanelBuilder builder = new PanelBuilder(layout); builder.border(Borders.DIALOG); builder.opaque(true); CellConstraints cc = new CellConstraints(); // Renderers JComponent cmp = builder.addSeparator(Messages.getString("StatusTab.9"), FormLayoutUtil.flip(cc.xyw(1, 1, 5), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); Font bold = cmp.getFont().deriveFont(Font.BOLD); Color fgColor = new Color(68, 68, 68); cmp.setFont(bold); renderers = new JPanel(new GuiUtil.WrapLayout(FlowLayout.CENTER, 20, 10)); JScrollPane rsp = new JScrollPane(renderers, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); rsp.setBorder(BorderFactory.createEmptyBorder()); rsp.setPreferredSize(new Dimension(0, 260)); rsp.getHorizontalScrollBar().setLocation(0, 250); builder.add(rsp, cc.xyw(1, 3, 5)); cmp = builder.addSeparator(null, FormLayoutUtil.flip(cc.xyw(1, 5, 5), colSpec, orientation)); // Connected jl = new JLabel(Messages.getString("StatusTab.3")); builder.add(jl, FormLayoutUtil.flip(cc.xy(1, 7, "center, top"), colSpec, orientation)); jl.setFont(bold); jl.setForeground(fgColor); imagePanel = buildImagePanel("/resources/images/icon-status-connecting.png"); builder.add(imagePanel, FormLayoutUtil.flip(cc.xy(1, 9), colSpec, orientation)); // Memory memBarUI = new GuiUtil.SegmentedProgressBarUI(Color.white, Color.gray); memBarUI.setActiveLabel("{}", Color.white, 0); memBarUI.setActiveLabel("{}", Color.red, 90); memBarUI.addSegment("", memColor); memBarUI.addSegment("", bufColor); memBarUI.setTickMarks(getTickMarks(), "{}"); memoryProgressBar = new GuiUtil.CustomUIProgressBar(0, 100, memBarUI); memoryProgressBar.setStringPainted(true); memoryProgressBar.setForeground(new Color(75, 140, 181)); memoryProgressBar.setString(Messages.getString("StatusTab.5")); JLabel mem = builder .addLabel( "<html><b>" + Messages.getString("StatusTab.6") + "</b> (" + Messages.getString("StatusTab.12") + ")</html>", FormLayoutUtil.flip(cc.xy(3, 7), colSpec, orientation)); mem.setForeground(fgColor); builder.add(memoryProgressBar, FormLayoutUtil.flip(cc.xyw(3, 9, 1), colSpec, orientation)); // Bitrate String bitColSpec = "left:pref, 3dlu, right:pref:grow"; PanelBuilder bitrateBuilder = new PanelBuilder(new FormLayout(bitColSpec, "p, 1dlu, p, 1dlu, p")); bitrateLabel = new JLabel("<html><b>" + Messages.getString("StatusTab.13") + "</b> (" + Messages.getString("StatusTab.11") + ")</html>"); bitrateLabel.setForeground(fgColor); bitrateBuilder.add(bitrateLabel, FormLayoutUtil.flip(cc.xy(1, 1), bitColSpec, orientation)); currentBitrateLabel = new JLabel(Messages.getString("StatusTab.14")); currentBitrateLabel.setForeground(fgColor); bitrateBuilder.add(currentBitrateLabel, FormLayoutUtil.flip(cc.xy(1, 3), bitColSpec, orientation)); currentBitrate = new JLabel("0"); currentBitrate.setForeground(fgColor); bitrateBuilder.add(currentBitrate, FormLayoutUtil.flip(cc.xy(3, 3), bitColSpec, orientation)); peakBitrateLabel = new JLabel(Messages.getString("StatusTab.15")); peakBitrateLabel.setForeground(fgColor); bitrateBuilder.add(peakBitrateLabel, FormLayoutUtil.flip(cc.xy(1, 5), bitColSpec, orientation)); peakBitrate = new JLabel("0"); peakBitrate.setForeground(fgColor); bitrateBuilder.add(peakBitrate, FormLayoutUtil.flip(cc.xy(3, 5), bitColSpec, orientation)); builder.add(bitrateBuilder.getPanel(), FormLayoutUtil.flip(cc.xywh(5, 7, 1, 3, "left, top"), colSpec, orientation)); JPanel panel = builder.getPanel(); // Apply the orientation to the panel and all components in it panel.applyComponentOrientation(orientation); JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setBorder(BorderFactory.createEmptyBorder()); startMemoryUpdater(); return scrollPane; }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java
@Test public void testConfigurationPropertiesWithColorList() { ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); Color colorValue = config.colorList.get(0); assertEquals(Color.class, colorValue.getClass()); assertEquals(Color.gray, colorValue); assertEquals(3, config.colorList.size()); }
From source file:org.pf.midea.SimulationController.java
@Override public void run() { textAreaNumeric.setText(""); XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); double progress = 0; double progressStep = 100.0 / (planCells.length * (hSquareHigh - hSquareLow + hSquareStep) / hSquareStep); progressBar.setValue(0);/* www . ja va 2s . c om*/ for (int i = 0; i < planCells.length; i++) { XYSeries xySeries; if (showLineNumbers) xySeries = new XYSeries(String.valueOf(i + 1) + ") " + planCells[i].getShortDescription()); else xySeries = new XYSeries(planCells[i].getShortDescription()); textAreaNumeric.append(planCells[i].getDescription() + "\n"); textAreaNumeric.setCaretPosition(textAreaNumeric.getDocument().getLength()); PlanStates.SourceType currentSourceType = planCells[i].getSourceCell().getSourceType(); PlanStates.CodeType currentCodeType = planCells[i].getCodeCell().getCodeType(); PlanStates.ModulationType currentModulationType = planCells[i].getModulationCell().getModulationType(); PlanStates.ChannelType currentChannelType = planCells[i].getChannelCell().getChannelType(); PlanStates.ErrorsType currentErrorsType = planCells[i].getErrorsCell().getErrorsType(); BinaryNumber[] sourcePoints = null; switch (currentSourceType) { case ST_TEST: sourcePoints = ConstellationPointsGenerator.getTestPoints(currentModulationType, iterationsCount); break; case ST_RANDOM: sourcePoints = ConstellationPointsGenerator.getRandomPoints(currentModulationType, iterationsCount); break; } Coder coder = null; Decoder decoder = null; switch (currentCodeType) { case CT_NONE: coder = new CoderNone(); decoder = new DecoderNone(); break; case CT_HAMMING74: coder = new CoderHamming74(); decoder = new DecoderHamming74(); break; case CT_CYCLIC: coder = new CoderCyclic85(); decoder = new DecoderCyclic85(); break; case CT_BCH155: coder = new CoderBCH155(); decoder = new DecoderBCH155(); break; } Modulator modulator = null; Demodulator demodulator = null; switch (currentModulationType) { case MT_ASK: modulator = new ModulatorASK(); demodulator = new DemodulatorASK(); break; case MT_FSK: modulator = new ModulatorFSK(); demodulator = new DemodulatorFSK(); break; case MT_BPSK: modulator = new ModulatorBPSK(); demodulator = new DemodulatorBPSK(); break; case MT_QPSK: modulator = new ModulatorQPSK(); demodulator = new DemodulatorQPSK(); break; case MT_8PSK: modulator = new Modulator8PSK(); demodulator = new Demodulator8PSK(); break; case MT_16PSK: modulator = new Modulator16PSK(); demodulator = new Demodulator16PSK(); break; case MT_32PSK: modulator = new Modulator32PSK(); demodulator = new Demodulator32PSK(); break; case MT_16QAM: modulator = new Modulator16QAM(); demodulator = new Demodulator16QAM(); break; case MT_32QAM: modulator = new Modulator32QAM(); demodulator = new Demodulator32QAM(); break; case MT_64QAM: modulator = new Modulator64QAM(); demodulator = new Demodulator64QAM(); break; case MT_256QAM: modulator = new Modulator256QAM(); demodulator = new Demodulator256QAM(); break; } Channel channel = null; switch (currentChannelType) { case CHT_AWGN: channel = new ChannelAWGN(); break; case CHT_RAYLEIGH: channel = new ChannelRayleigh(); break; } BinaryNumber[] encoded = coder.encode(sourcePoints); Signal[] modulated = modulator.modulate(encoded); double error = 0; for (double h = hSquareLow; h <= hSquareHigh; h += hSquareStep) { double realH; if (dBs) realH = StatisticsTools.decibelsToTimes(h); else realH = h; Signal[] noised = channel.noise(realH, modulated); BinaryNumber[] demodulated = demodulator.demodulate(noised); noised = null; System.gc(); BinaryNumber[] decoded = decoder.decode(demodulated); demodulated = null; System.gc(); switch (currentErrorsType) { case ET_SER: error = StatisticsTools.getSER(sourcePoints, decoded); break; case ET_BER: error = StatisticsTools.getBER(sourcePoints, decoded); break; } decoded = null; System.gc(); if (error > 0) { xySeries.add(h, error); textAreaNumeric.append(String.valueOf(h) + "\t" + String.valueOf(error) + "\n"); textAreaNumeric.setCaretPosition(textAreaNumeric.getDocument().getLength()); } progress += progressStep; progressBar.setValue((int) Math.round(progress)); } xySeriesCollection.addSeries(xySeries); textAreaNumeric.append("\n"); textAreaNumeric.setCaretPosition(textAreaNumeric.getDocument().getLength()); } JFreeChart chart = ChartFactory.createXYLineChart("", dBs ? "" : "", "?", xySeriesCollection, PlotOrientation.VERTICAL, true, true, false); chart.getLegend().setPosition(RectangleEdge.RIGHT); XYPlot xyPlot = chart.getXYPlot(); for (int i = 0; i < planCells.length; i++) { xyPlot.getRenderer().setSeriesStroke(i, new BasicStroke(planCells[i].getLineWidth())); if (planCells[i].getLineColor() != null) xyPlot.getRenderer().setSeriesPaint(i, planCells[i].getLineColor()); if (showLineNumbers) { XYSeries currentSeries = xySeriesCollection.getSeries(i); double annotationY = currentSeries.getY(0).doubleValue(); double annotationX = currentSeries.getX(0).doubleValue(); for (int j = 1; j < currentSeries.getItemCount(); j++) if (currentSeries.getY(j).doubleValue() == 0) { annotationY = currentSeries.getY(j - 1).doubleValue(); annotationX = currentSeries.getX(j - 1).doubleValue(); break; } else { annotationY = currentSeries.getY(j).doubleValue(); annotationX = currentSeries.getX(j).doubleValue(); } XYTextAnnotation annotation = new XYTextAnnotation(String.valueOf(i + 1), annotationX, annotationY); annotation.setBackgroundPaint(Color.WHITE); annotation.setFont(new Font("Dialog", 0, 14)); xyPlot.addAnnotation(annotation); } } xyPlot.setBackgroundPaint(Color.WHITE); xyPlot.setDomainGridlinePaint(Color.GRAY); xyPlot.setRangeGridlinePaint(Color.GRAY); NumberAxis domainAxis = new NumberAxis("h, " + (dBs ? "" : "")); LogAxis rangeAxis = new LogAxis("?"); rangeAxis.setNumberFormatOverride(new HumanNumberFormat(1)); domainAxis.setTickLabelFont(new Font("Dialog", 0, 14)); rangeAxis.setTickLabelFont(new Font("Dialog", 0, 14)); xyPlot.setDomainAxis(domainAxis); xyPlot.setRangeAxis(rangeAxis); ChartPanel nestedPanel = new ChartPanel(chart); chartPanel.removeAll(); chartPanel.add(nestedPanel, new CellConstraints()); chartPanel.updateUI(); }
From source file:unalcol.termites.boxplots.SucessfulRatesHybrid.java
private static JFreeChart createChart(CategoryDataset categorydataset, ArrayList<Double> pf) { JFreeChart jfreechart = ChartFactory.createBarChart("Success Rates - " + getTitle(pf), "", "", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.getTitle().setFont(new Font("Sans-Serif", Font.PLAIN, 18)); jfreechart.setBackgroundPaint(new Color(221, 223, 238)); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.white); categoryplot.setDomainGridlinePaint(Color.white); categoryplot.setRangeGridlinePaint(Color.gray); categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); BarRenderer renderer = (BarRenderer) categoryplot.getRenderer(); //categoryplot.setBackgroundPaint(new Color(221, 223, 238)); renderer.setSeriesPaint(0, new Color(130, 165, 70)); renderer.setSeriesPaint(1, new Color(220, 165, 70)); renderer.setSeriesPaint(4, new Color(255, 165, 70)); renderer.setDrawBarOutline(false);/*from w w w . j a v a2s.co m*/ renderer.setShadowVisible(false); // renderer.setMaximumBarWidth(1); renderer.setGradientPaintTransformer(null); renderer.setDefaultBarPainter(new StandardBarPainter()); categoryplot.setRenderer(renderer); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setUpperMargin(0.25D); CategoryItemRenderer categoryitemrenderer = categoryplot.getRenderer(); categoryitemrenderer.setBaseItemLabelsVisible(true); categoryitemrenderer.setBaseItemLabelGenerator(new LabelGenerator(null)); numberaxis.setRange(0, 100); //numberaxis.setNumberFormatOverride(NumberFormat.getPercentInstance()); Font font = new Font("SansSerif", Font.ROMAN_BASELINE, 12); numberaxis.setTickLabelFont(font); CategoryAxis axisd = categoryplot.getDomainAxis(); ValueAxis axisr = categoryplot.getRangeAxis(); axisd.setTickLabelFont(font); axisr.setTickLabelFont(font); axisd.setMaximumCategoryLabelLines(5); final ChartPanel chartPanel = new ChartPanel(jfreechart); chartPanel.setPreferredSize(new java.awt.Dimension(1300, 370)); FileOutputStream output; try { output = new FileOutputStream("sucessrates1" + pf + ".jpg"); ChartUtilities.writeChartAsJPEG(output, 1.0f, jfreechart, 1300, 370, null); } catch (FileNotFoundException ex) { Logger.getLogger(MessagesSent1.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(MessagesSent1.class.getName()).log(Level.SEVERE, null, ex); } return jfreechart; }
From source file:edu.ucla.stat.SOCR.chart.SuperXYChart_QQ.java
/** * reset dataTable to default (demo data), and refesh chart *//*w w w .j a va2 s. co m*/ public void resetExample() { XYDataset dataset = createDataset(true); JFreeChart chart = createChart(dataset); chartPanel = new ChartPanel(chart, false); setChart(); hasExample = true; convertor.Y2Table(raw_y, row_count); //convertor.dataset2Table(dataset); JTable tempDataTable = convertor.getTable(); resetTableRows(tempDataTable.getRowCount() + 1); resetTableColumns(tempDataTable.getColumnCount()); for (int i = 0; i < tempDataTable.getColumnCount(); i++) { columnModel.getColumn(i).setHeaderValue(tempDataTable.getColumnName(i)); // System.out.println("updateExample tempDataTable["+i+"] = " +tempDataTable.getColumnName(i)); } columnModel = dataTable.getColumnModel(); dataTable.setTableHeader(new EditableHeader(columnModel)); for (int i = 0; i < tempDataTable.getRowCount(); i++) for (int j = 0; j < tempDataTable.getColumnCount(); j++) { dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j); } dataPanel.removeAll(); dataPanel.add(new JScrollPane(dataTable)); dataTable.setGridColor(Color.gray); dataTable.setShowGrid(true); dataTable.doLayout(); // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003 try { dataTable.setDragEnabled(true); } catch (Exception e) { } dataPanel.validate(); // do the mapping setMapping(); updateStatus(url); }