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:net.lldp.checksims.ui.results.ScrollViewer.java
/** * Create a scroll viewer from a sortable Matrix Viewer * @param results the sortableMatrix to view * @param toRevalidate frame to revalidate sometimes *///www. j av a2s . c o m public ScrollViewer(SimilarityMatrix exportMatrix, SortableMatrixViewer results, JFrame toRevalidate) { resultsView = new JScrollPane(results); setBackground(Color.black); resultsView.addComponentListener(new ComponentListener() { @Override public void componentHidden(ComponentEvent arg0) { } @Override public void componentMoved(ComponentEvent arg0) { } @Override public void componentResized(ComponentEvent ce) { Dimension size = ce.getComponent().getSize(); results.padToSize(size); } @Override public void componentShown(ComponentEvent arg0) { } }); resultsView.getViewport().addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Rectangle r = resultsView.getViewport().getViewRect(); results.setViewAt(r); } }); resultsView.setBackground(Color.black); sidebar = new JPanel(); setPreferredSize(new Dimension(900, 631)); setMinimumSize(new Dimension(900, 631)); sidebar.setPreferredSize(new Dimension(200, 631)); sidebar.setMaximumSize(new Dimension(200, 3000)); resultsView.setMinimumSize(new Dimension(700, 631)); resultsView.setPreferredSize(new Dimension(700, 631)); sidebar.setBackground(Color.GRAY); setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); this.add(sidebar); this.add(resultsView); resultsView.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); resultsView.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); resultsView.getVerticalScrollBar().setUnitIncrement(16); resultsView.getHorizontalScrollBar().setUnitIncrement(16); Integer[] presetThresholds = { 80, 60, 40, 20, 0 }; JComboBox<Integer> threshHold = new JComboBox<Integer>(presetThresholds); threshHold.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { if (event.getStateChange() == ItemEvent.SELECTED) { Integer item = (Integer) event.getItem(); results.updateThreshold(item / 100.0); toRevalidate.revalidate(); toRevalidate.repaint(); } } }); threshHold.setSelectedIndex(0); results.updateThreshold((Integer) threshHold.getSelectedItem() / 100.0); JTextField student1 = new JTextField(15); JTextField student2 = new JTextField(15); KeyListener search = new KeyListener() { @Override public void keyPressed(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { results.highlightMatching(student1.getText(), student2.getText()); toRevalidate.revalidate(); toRevalidate.repaint(); } @Override public void keyTyped(KeyEvent e) { } }; student1.addKeyListener(search); student2.addKeyListener(search); Collection<MatrixPrinter> printerNameSet = MatrixPrinterRegistry.getInstance() .getSupportedImplementations(); JComboBox<MatrixPrinter> exportAs = new JComboBox<>(new Vector<>(printerNameSet)); JButton exportAsSave = new JButton("Save"); JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setCurrentDirectory(new java.io.File(".")); fc.setDialogTitle("Save results"); exportAsSave.addActionListener(ae -> { MatrixPrinter method = (MatrixPrinter) exportAs.getSelectedItem(); int err = fc.showDialog(toRevalidate, "Save"); if (err == JFileChooser.APPROVE_OPTION) { try { FileUtils.writeStringToFile(fc.getSelectedFile(), method.printMatrix(exportMatrix)); } catch (InternalAlgorithmError | IOException e1) { // TODO log / show error } } }); JPanel thresholdLabel = new JPanel(); JPanel studentSearchLabel = new JPanel(); JPanel fileOutputLabel = new JPanel(); thresholdLabel.setBorder(BorderFactory.createTitledBorder("Matching Threshold")); studentSearchLabel.setBorder(BorderFactory.createTitledBorder("Student Search")); fileOutputLabel.setBorder(BorderFactory.createTitledBorder("Save Results")); thresholdLabel.add(threshHold); studentSearchLabel.add(student1); studentSearchLabel.add(student2); fileOutputLabel.add(exportAs); fileOutputLabel.add(exportAsSave); studentSearchLabel.setPreferredSize(new Dimension(200, 100)); studentSearchLabel.setMinimumSize(new Dimension(200, 100)); thresholdLabel.setPreferredSize(new Dimension(200, 100)); thresholdLabel.setMinimumSize(new Dimension(200, 100)); fileOutputLabel.setPreferredSize(new Dimension(200, 100)); fileOutputLabel.setMinimumSize(new Dimension(200, 100)); sidebar.setMaximumSize(new Dimension(200, 4000)); sidebar.add(thresholdLabel); sidebar.add(studentSearchLabel); sidebar.add(fileOutputLabel); }
From source file:org.codehaus.mojo.chronos.chart.HistoryChartGenerator.java
public final void createGcChart(HistoricSamples samples, String dataId) throws IOException { XYPlot xyplot1 = newPlot(samples.getGcRatio(dataId), "chronos.label.gc.ratio", true); xyplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); xyplot1.getRenderer().setSeriesPaint(0, Color.GREEN); xyplot1.getRangeAxis().setStandardTickUnits(NumberAxis.createStandardTickUnits()); XYPlot xyplot2 = newPlot(samples.getKbCollectedPrSecond(dataId), "chronos.label.gc.kbpersec", true); xyplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); xyplot2.getRenderer().setSeriesPaint(0, Color.GRAY); xyplot2.getRangeAxis().setStandardTickUnits(NumberAxis.createStandardTickUnits()); String timeLabel = bundle.getString("chronos.label.gc.historytime"); DateAxis timeAxis = ChartUtil.createTimeAxis(timeLabel, new SimpleDateFormat()); XYPlot combinedPlot = ChartUtil.createCombinedPlot(timeAxis, xyplot1, xyplot2); // xyplot1.setDomainAxis( timeAxis ); // XYPlot combinedPlot = xyplot1; JFreeChart chart = new JFreeChart(bundle.getString("chronos.label.gc"), combinedPlot); renderer.renderChart("history-gc-" + dataId, chart); }
From source file:edu.mit.fss.examples.member.gui.PowerSubsystemPanel.java
/** * Instantiates a new power subsystem panel for a subsystem. * * @param subsystem the subsystem/*from w ww.j a v a 2s. co m*/ */ public PowerSubsystemPanel(SpacePowerSubsystem subsystem) { this.subsystem = subsystem; logger.trace("Creating and adding energy storage chart panel."); storageDataset = new TimeSeriesCollection(); storageSeries = new TimeSeries("Storage"); storageDataset.addSeries(storageSeries); storageChart = ChartFactory.createTimeSeriesChart(null, "Time", "Stored Energy (W-hr)", storageDataset, false, false, false); storageChart.setBackgroundPaint(getBackground()); if (storageChart.getPlot() instanceof XYPlot) { XYPlot xyPlot = (XYPlot) storageChart.getPlot(); XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES); renderer.setSeriesShape(0, new Ellipse2D.Double(-2, -2, 4, 4)); xyPlot.setRenderer(renderer); xyPlot.setBackgroundPaint(Color.WHITE); xyPlot.setDomainGridlinePaint(Color.GRAY); xyPlot.setRangeGridlinePaint(Color.GRAY); } addTab("Storing", new ChartPanel(storageChart)); logger.trace("Creating and adding energy transformation chart panel."); powerDataset = new TimeSeriesCollection(); generationSeries = new TimeSeries("Generation"); powerDataset.addSeries(generationSeries); consumptionSeries = new TimeSeries("Consumption"); powerDataset.addSeries(consumptionSeries); powerChart = ChartFactory.createTimeSeriesChart(null, "Time", "Power (W)", powerDataset, true, false, false); powerChart.setBackgroundPaint(getBackground()); if (powerChart.getPlot() instanceof XYPlot) { XYPlot xyPlot = (XYPlot) powerChart.getPlot(); XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES); renderer.setSeriesShape(0, new Ellipse2D.Double(-2, -2, 4, 4)); renderer.setSeriesPaint(0, Color.red); renderer.setSeriesShape(1, new Ellipse2D.Double(-2, -2, 4, 4)); renderer.setSeriesPaint(1, Color.green); xyPlot.setRenderer(renderer); xyPlot.setBackgroundPaint(Color.WHITE); xyPlot.setDomainGridlinePaint(Color.GRAY); xyPlot.setRangeGridlinePaint(Color.GRAY); } JPanel chartPanel = new JPanel(new BorderLayout()); chartPanel.add(new ChartPanel(powerChart), BorderLayout.CENTER); chartPanel.add(new JButton(exportAction), BorderLayout.SOUTH); addTab("Transforming", chartPanel); }
From source file:ca.sqlpower.wabit.swingui.report.selectors.FancyTextBoxSelectorField.java
public FancyTextBoxSelectorField(final TextBoxSelector selector, Runnable refreshRoutine) { this.selector = selector; this.refreshRoutine = refreshRoutine; this.addFocusListener(focusListener); this.addKeyListener(this.enterKeyListener); this.selector.addSPListener(spListener); setText(selector.getCurrentValue() == null ? null : selector.getCurrentValue().toString()); if (getText().length() == 0 || ObjectUtils.equals(getText(), selector.getDefaultValue())) { setText(selector.getDefaultValue() == null ? null : selector.getDefaultValue().toString()); setForeground(Color.GRAY); setFont(getFont().deriveFont(Font.ITALIC)); } else {/*from w w w . j a v a 2 s .c om*/ setForeground(Color.BLACK); setFont(getFont().deriveFont(Font.PLAIN)); } }
From source file:com.wattzap.view.graphs.MMPGraph.java
public MMPGraph(XYSeries series) { super();//from ww w. j a v a2s . c om NumberAxis yAxis = new NumberAxis(userPrefs.messages.getString("poWtt")); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); double maxY = series.getMaxY(); yAxis.setRange(0, maxY + 20); yAxis.setTickLabelPaint(Color.white); yAxis.setLabelPaint(Color.white); LogAxis xAxis = new LogAxis(userPrefs.messages.getString("time")); xAxis.setTickLabelPaint(Color.white); xAxis.setBase(4); xAxis.setAutoRange(false); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setRange(1, series.getMaxX() + 500); xAxis.setNumberFormatOverride(new NumberFormat() { @Override public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) { long millis = (long) number * 1000; if (millis >= 60000) { return new StringBuffer(String.format("%d m %d s", TimeUnit.MILLISECONDS.toMinutes((long) millis), TimeUnit.MILLISECONDS.toSeconds((long) millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes((long) millis)))); } else { return new StringBuffer(String.format("%d s", TimeUnit.MILLISECONDS.toSeconds((long) millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes((long) millis)))); } } @Override public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) { return new StringBuffer(String.format("%s", number)); } @Override public Number parse(String source, ParsePosition parsePosition) { return null; } }); XYPlot plot = new XYPlot(new XYSeriesCollection(series), xAxis, yAxis, new XYLineAndShapeRenderer(true, false)); JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBackgroundPaint(Color.gray); plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.darkGray); /*plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray);*/ ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setTickLabelPaint(Color.white); domainAxis.setLabelPaint(Color.white); chartPanel = new ChartPanel(chart); chartPanel.setSize(100, 800); chartPanel.setFillZoomRectangle(true); chartPanel.setMouseWheelEnabled(true); chartPanel.setBackground(Color.gray); setLayout(new BorderLayout()); add(chartPanel, BorderLayout.CENTER); setBackground(Color.black); chartPanel.revalidate(); setVisible(true); }
From source file:com.att.aro.main.TraceOverviewPanel.java
/** * Initializes the Main panel and its various components. */// w ww . j a va 2s . co m private void initialize() { JFreeChart chart = ChartFactory.createBarChart(rb.getString("overview.traceoverview.title"), null, null, createDataset(null), PlotOrientation.HORIZONTAL, false, true, false); chart.setBackgroundPaint(this.getBackground()); chart.getTitle().setFont(AROUIManager.HEADER_FONT); this.plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); CategoryAxis valueRangeAxis = plot.getDomainAxis(); valueRangeAxis.setMaximumCategoryLabelWidthRatio(1.0f); valueRangeAxis.setMaximumCategoryLabelLines(2); valueRangeAxis.setLabelFont(AROUIManager.LABEL_FONT); valueRangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLabel(rb.getString("analysisresults.percentile")); rangeAxis.setRange(0.0, 100.0); rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setLabelFont(AROUIManager.LABEL_FONT); rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); BarRenderer renderer = new StackedBarRenderer(); renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR); renderer.setAutoPopulateSeriesPaint(false); renderer.setBaseItemLabelGenerator(new PercentLabelGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelPaint(Color.black); // Make second bar in stack invisible renderer.setSeriesItemLabelsVisible(1, false); renderer.setSeriesPaint(1, new Color(0, 0, 0, 0)); ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT); renderer.setBasePositiveItemLabelPosition(insideItemlabelposition); ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition); renderer.setBarPainter(new StandardBarPainter()); renderer.setShadowVisible(false); renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT); renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() { @Override public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) { String traceInfo = ""; switch (arg2) { case TRACE_AVERAGE: traceInfo = rb.getString("tooltip.traceAnalysis.avg"); break; case TRACE_ENERGY: traceInfo = rb.getString("tooltip.traceAnalysis.engy"); break; case TRACE_OVERHEAD: traceInfo = rb.getString("tooltip.traceAnalysis.ovrhd"); break; } return traceInfo; } }); plot.setRenderer(renderer); plot.getDomainAxis().setMaximumCategoryLabelLines(2); ChartPanel chartPanel = new ChartPanel(chart, WIDTH, HEIGHT, ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH + 100, 100, ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH, ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT, USER_BUFFER, PROPERTIES, COPY, SAVE, PRINT, ZOOM, TOOL_TIPS); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); this.add(chartPanel, BorderLayout.CENTER); }
From source file:com.att.aro.main.ProperSessionTerminationPanel.java
/** * Initializes the Panel for Proper Session Termination plot. *//*from w w w . ja v a2 s. co m*/ private void initialize() { JFreeChart chart = ChartFactory.createBarChart(rb.getString("overview.sessionoverview.title"), null, null, createDataset(null), PlotOrientation.HORIZONTAL, false, false, false); chart.setBackgroundPaint(this.getBackground()); chart.getTitle().setFont(AROUIManager.HEADER_FONT); this.plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setMaximumCategoryLabelWidthRatio(1.0f); domainAxis.setMaximumCategoryLabelLines(2); domainAxis.setLabelFont(AROUIManager.LABEL_FONT); domainAxis.setTickLabelFont(AROUIManager.LABEL_FONT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLabel(rb.getString("analysisresults.percentage")); rangeAxis.setRange(0.0, 100.0); rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setLabelFont(AROUIManager.LABEL_FONT); rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); BarRenderer renderer = new StackedBarRenderer(); renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR); renderer.setAutoPopulateSeriesPaint(false); renderer.setBaseItemLabelGenerator(new PercentLabelGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelPaint(Color.black); // Make second bar in stack invisible renderer.setSeriesItemLabelsVisible(1, false); renderer.setSeriesPaint(1, new Color(0, 0, 0, 0)); ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT); renderer.setBasePositiveItemLabelPosition(insideItemlabelposition); ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition); renderer.setBarPainter(new StandardBarPainter()); renderer.setShadowVisible(false); renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT); renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() { @Override public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) { String sessionInfo = ""; switch (arg2) { case SESSION_TERMINATION: sessionInfo = rb.getString("tooltip.sessionTermination"); break; case SESSION_TIGHT_CONN: sessionInfo = rb.getString("tooltip.sessionTightConn"); break; case SESSION_BURST: sessionInfo = rb.getString("tooltip.sessionBurst"); break; case SESSION_LONG_BURST: sessionInfo = rb.getString("tooltip.sessionLongBurst"); break; } return sessionInfo; } }); plot.setRenderer(renderer); plot.getDomainAxis().setMaximumCategoryLabelLines(2); ChartPanel chartPanel = new ChartPanel(chart, WIDTH, HEIGHT, ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH + 100, 100, ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH, ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT, USER_BUFFER, PROPERTIES, COPY, SAVE, PRINT, ZOOM, TOOL_TIPS); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); this.add(chartPanel, BorderLayout.CENTER); }
From source file:org.jreserve.gui.calculations.factor.editor.AccidentFactorPlot.java
private Component createPlotComponent() { boolean legend = true; boolean tooltips = false; boolean urls = false; chart = ChartFactory.createLineChart(null, null, null, dataSet, PlotOrientation.VERTICAL, legend, tooltips, urls);/*from w ww . j a va 2s . c o m*/ CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.GRAY); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.WHITE); plot.setDomainGridlinePaint(Color.WHITE); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); axis.setAutoRangeStickyZero(true); renderer = plot.getRenderer(); if (renderer instanceof LineAndShapeRenderer) { LineAndShapeRenderer lasr = (LineAndShapeRenderer) renderer; lasr.setBaseShapesVisible(true); lasr.setDrawOutlines(true); lasr.setUseFillPaint(true); lasr.setBaseStroke(new BasicStroke(2)); ColorGenerator colors = new DefaultColorGenerator(); int count = dataSet.getRowCount(); int r = 3; Shape circle = new Ellipse2D.Float(-r, -r, 2 * r, 2 * r); for (int i = 0; i < count; i++) { Paint color = colors.nextColor(); lasr.setSeriesPaint(i, color); lasr.setSeriesFillPaint(i, color); lasr.setSeriesShape(i, circle); } } return new ChartPanel(chart); }
From source file:org.jfree.experimental.chart.plot.dial.StandardDialFrame.java
/** * Creates a new instance of <code>StandardDialFrame</code> that spans * the arc specified./*from w w w .j a v a 2s . co m*/ * * @param startAngle the startAngle (in degrees). * @param extent the extent of the arc (in degrees, counter-clockwise). */ public StandardDialFrame(double startAngle, double extent) { this.backgroundPaint = Color.gray; this.foregroundPaint = new Color(100, 100, 150); this.stroke = new BasicStroke(2.0f); this.innerRadius = 0.25; this.outerRadius = 0.75; this.startAngle = startAngle; this.extent = extent; }
From source file:extern.AsymmetricStatisticalBarRenderer.java
/** * Default constructor.// w w w .j a v a 2s . c o m */ public AsymmetricStatisticalBarRenderer() { super(); this.errorIndicatorPaint = Color.gray; this.errorIndicatorStroke = new BasicStroke(1.0f); }