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:edu.ucla.stat.SOCR.chart.SuperCategoryChart_Stat.java
/** * reset dataTable to default (demo data), and refesh chart *///from w w w. jav a2 s . c o m public void resetExample() { dataset = (DefaultStatisticalCategoryDataset) createDataset(true); JFreeChart chart = createChart(dataset); chartPanel = new ChartPanel(chart, false); // setSummary(dataset); setChart(); hasExample = true; convertor.dataset2Table(dataset); JTable tempDataTable = convertor.getTable(); resetTableRows(tempDataTable.getRowCount() + 1); resetTableColumns(tempDataTable.getColumnCount() + 1); for (int i = 0; i < tempDataTable.getColumnCount(); i++) { columnModel.getColumn(i).setHeaderValue(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); }
From source file:com.fiveamsolutions.nci.commons.kmplot.KMPlotServiceTest.java
private KMPlot getPlot() { KMPlotConfiguration configuration = new KMPlotConfiguration(); configuration.setTitle("title"); configuration.setDurationLabel("duration"); configuration.setProbabilityLabel("probability"); configuration.getGroups().add(createGroup("group 1", 2, Color.RED)); configuration.getGroups().add(createGroup("group 2", 5, Color.GREEN)); configuration.getGroups().add(createGroup("group 3", 2, Color.BLUE)); configuration.getGroups().add(createGroup("group 4", 1, Color.BLACK)); configuration.getGroups().add(createGroup("group 5", 1, Color.GRAY)); KMPlot plot = new KMPlotServiceImpl().generatePlot(configuration); assertNotNull(plot);/*from w w w. ja va 2 s . com*/ assertNotNull(plot.getConfiguration()); assertNotNull(plot.getConfiguration().getGroups()); assertEquals(5, plot.getConfiguration().getGroups().size()); verifyGroup(plot, 0, "group 1", 2, Color.RED); verifyGroup(plot, 1, "group 2", 5, Color.GREEN); verifyGroup(plot, 2, "group 3", 2, Color.BLUE); verifyGroup(plot, 3, "group 4", 1, Color.BLACK); verifyGroup(plot, 4, "group 5", 1, Color.GRAY); return plot; }
From source file:com.xuggle.xuggler.UtilsTest.java
@SuppressWarnings("deprecation") @Test/*ww w .j a v a2 s . com*/ public void testImageToImageSolidColor() { int w = 50; int h = 50; int gray = Color.GRAY.getRGB(); // construct an all gray image BufferedImage image1 = new BufferedImage(w, h, BufferedImage.TYPE_3BYTE_BGR); for (int x = 0; x < w; ++x) for (int y = 0; y < h; ++y) image1.setRGB(x, y, gray); // convert image1 to a picture and then back to image2 BufferedImage image2 = Utils.videoPictureToImage(Utils.imageToVideoPicture(image1, 0)); // test that all the pixels in image2 are gray, but not black or // white for (int x = 0; x < w; ++x) for (int y = 0; y < h; ++y) { int pixel = image2.getRGB(x, y); assertTrue("color value missmatch", pixel == gray); } }
From source file:lu.lippmann.cdb.graph.mouse.CadralEditingGraphMousePlugin.java
/** * {@inheritDoc}// w ww .j av a 2 s . c o m */ @Override public void mouseDragged(MouseEvent e) { if (checkModifiers(e)) { @SuppressWarnings("unchecked") final VisualizationViewer<CNode, CEdge> vv = (VisualizationViewer<CNode, CEdge>) e.getSource(); final Layout<CNode, CEdge> layout = vv.getModel().getGraphLayout(); final GraphElementAccessor<CNode, CEdge> pickSupport = vv.getPickSupport(); if (startVertex != null) { transformEdgeShape(down, e.getPoint()); if (edgeIsDirected == EdgeType.DIRECTED) { transformArrowShape(down, e.getPoint()); final CNode pointedVertex = pickSupport.getVertex(layout, e.getX(), e.getY()); if (pointedVertex != null && pointedVertex != startVertex) { if (!pointedVertices.containsKey(pointedVertex)) { pointedVertices.put(pointedVertex, pointedVertex.getColor()); //save original color } Color prevColor = pointedVertex.getColor(); if (pointedVertex.getColor().equals(pointedVertices.get(pointedVertex))) { if (pointedVertex != this.lastDragVertex && this.lastDragVertex != null) { lastDragVertex.setColor(pointedVertices.get(lastDragVertex)); } //Don't change color if there is an existing edge if (layout.getGraph().findEdge(startVertex, pointedVertex) == null) { if (GraphUtil.isDarkNode(pointedVertex)) { if (prevColor.darker().equals(prevColor)) { pointedVertex.setColor(Color.GRAY); } else { if (prevColor.brighter().equals(prevColor)) { pointedVertex.setColor(Color.GRAY); } else { pointedVertex.setColor(pointedVertices.get(pointedVertex).brighter()); } } } else { pointedVertex.setColor(pointedVertices.get(pointedVertex).darker()); } } } this.lastDragVertex = this.dragVertex; this.dragVertex = pointedVertex; } else if (dragVertex != null) { dragVertex.setColor(pointedVertices.get(dragVertex)); } } } vv.repaint(); } }
From source file:com.github.cric.app.ui.SettingPanel.java
private void handleFocusLost(JTextField field, boolean isInt) { if (isInt) {/*from w w w.j a va 2 s.c o m*/ if (!validateInt(field)) { addBorder(field, Color.RED); } else { addBorder(field, Color.GRAY); } } else { if (!validateText(field)) { addBorder(field, Color.RED); } else { addBorder(field, Color.GRAY); } } }
From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.ClinicalPlot.java
private Color getColorForDataPoint(ClinicalDataPoint clinicalPoint) { String diseaseName = clinicalPoint.getDiseaseName(); Color diseaseColor = Color.GRAY; Color defaultColor = Color.GRAY; Color retColor = Color.GRAY; if (diseaseName != null) { DiseaseType disease = DiseaseType.valueOf(diseaseName); diseaseColor = disease.getColor(); }// w ww . j av a2 s . c o m int grade = clinicalPoint.getDiseaseGrade(); if (grade > 0) { for (int i = 0; i < grade - 1; i++) { diseaseColor = diseaseColor.brighter(); } } retColor = diseaseColor; if (retColor == null) { retColor = defaultColor; } return retColor; }
From source file:edu.ucla.stat.SOCR.chart.SuperCategoryChart_StatA.java
/** * reset dataTable to default (demo data), and refesh chart */// w ww . j av a 2s . co m public void resetExample() { dataset = (DefaultStatisticalCategoryDataset) createDataset(true); JFreeChart chart = createChart(dataset); chartPanel = new ChartPanel(chart, false); // setSummary(dataset); setChart(); hasExample = true; convertor.dataset2TableA(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)); } 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); }
From source file:com.bdb.weather.display.summary.TemperatureDeviationPlotPanel.java
public TemperatureDeviationPlotPanel(SummaryInterval interval, ViewLauncher theLauncher, SummarySupporter theSupporter) { this.setPrefSize(500, 300); this.interval = interval; chart = ChartFactory.createXYBarChart("Deviation from Average Temperature", "Date", true, "Deviation (" + Temperature.getDefaultUnit() + ")", null, PlotOrientation.VERTICAL, true, true, false);/*from w ww. j a v a2 s . c o m*/ chartViewer = new ChartViewer(chart); chartViewer.setPrefSize(500, 300); chartViewer.addChartMouseListener(new ChartMouseListenerFX() { @Override public void chartMouseClicked(ChartMouseEventFX event) { ChartEntity entity = event.getEntity(); // // Was a point on the plot selected? // if (entity instanceof XYItemEntity) { XYItemEntity itemEntity = (XYItemEntity) entity; XYDataset dataset = itemEntity.getDataset(); Number x = dataset.getXValue(itemEntity.getSeriesIndex(), itemEntity.getItem()); LocalDate date = LocalDate.from(Instant.ofEpochMilli(x.longValue())); boolean doubleClick = event.getTrigger().getClickCount() == 2; if (doubleClick) { supporter.launchView(launcher, date); } } } @Override public void chartMouseMoved(ChartMouseEventFX event) { // Do nothing } }); deviationPlot = (XYPlot) chart.getPlot(); this.launcher = theLauncher; this.supporter = theSupporter; DateFormat dateFormat = interval.getLegacyFormat(); StandardXYItemLabelGenerator labelGen = new StandardXYItemLabelGenerator( StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, dateFormat, Temperature.getDefaultFormatter()); StandardXYToolTipGenerator ttGen = new StandardXYToolTipGenerator( StandardCategoryToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT_STRING, dateFormat, Temperature.getDefaultFormatter()); valueAxis = deviationPlot.getRangeAxis(); valueAxis.setUpperMargin(.20); valueAxis.setLowerMargin(.20); deviationPlot.getDomainAxis().setVerticalTickLabels(true); DateAxis dateAxis = (DateAxis) deviationPlot.getDomainAxis(); dateAxis.setDateFormatOverride(dateFormat); //dateAxis.setTickUnit(interval.getDateTickUnit()); //DefaultTableColumnModel colModel = new DefaultTableColumnModel(); dataTable = new TableView(); //dataTable.setModel(tableModel); //dataTable.setColumnModel(colModel); //dataTable.setAutoCreateColumnsFromModel(false); for (int i = 0; i < TABLE_HEADINGS.length; i++) { TableColumn col = new TableColumn(); col.setText(TABLE_HEADINGS[i]); //col.setModelIndex(i); //colModel.addColumn(col); } //tableModel.setColumnCount(TABLE_HEADINGS.length); this.setTabContents(chartViewer, dataTable); lowRenderer.setBasePaint(Color.BLUE); lowRenderer.setBaseItemLabelGenerator(labelGen); lowRenderer.setBaseToolTipGenerator(ttGen); lowRenderer.setBarAlignmentFactor(.6); lowRenderer.setShadowVisible(false); meanRenderer.setSeriesPaint(0, Color.CYAN); meanRenderer.setBaseItemLabelGenerator(labelGen); meanRenderer.setBaseToolTipGenerator(ttGen); meanRenderer.setBarAlignmentFactor(.3); meanRenderer.setShadowVisible(false); highRenderer.setSeriesPaint(0, Color.GRAY); highRenderer.setBaseItemLabelGenerator(labelGen); highRenderer.setBaseToolTipGenerator(ttGen); highRenderer.setShadowVisible(false); }
From source file:net.sourceforge.subsonic.controller.FolderChartController.java
private JFreeChart createChart(CategoryDataset dataset, HttpServletRequest request) { JFreeChart chart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false);//from www . j ava 2s. co m CategoryPlot plot = chart.getCategoryPlot(); Paint background = new GradientPaint(0, 0, Color.lightGray, 0, IMAGE_MIN_HEIGHT, Color.white); plot.setBackgroundPaint(background); plot.setDomainGridlinePaint(Color.lightGray); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.gray); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); LogarithmicAxis rangeAxis = new LogarithmicAxis(null); rangeAxis.setStrictValuesFlag(false); rangeAxis.setAllowNegativesFlag(true); // rangeAxis.setTickUnit(new NumberTickUnit(.1, new DecimalFormat("##0%"))); plot.setRangeAxis(rangeAxis); // Disable bar outlines. BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // Set up gradient paint for series. GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.gray, 0.0f, 0.0f, new Color(0, 0, 64)); renderer.setSeriesPaint(0, gp0); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setBaseItemLabelFont(new Font("SansSerif", Font.BOLD, 11)); renderer.setItemLabelAnchorOffset(-45.0); renderer.setSeriesItemLabelPaint(0, Color.white); renderer.setBaseItemLabelPaint(Color.white); // Rotate labels. CategoryAxis domainAxis = plot.getDomainAxis(); // domainAxis.setCategoryLabelPositions(); // domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); // Set theme-specific colors. Color bgColor = getBackground(request); Color fgColor = getForeground(request); chart.setBackgroundPaint(bgColor); domainAxis.setTickLabelPaint(fgColor); domainAxis.setTickMarkPaint(fgColor); domainAxis.setAxisLinePaint(fgColor); rangeAxis.setTickLabelPaint(fgColor); rangeAxis.setTickMarkPaint(fgColor); rangeAxis.setAxisLinePaint(fgColor); return chart; }
From source file:ec.ui.view.StabilityView.java
private void showDetail(Graphs g) { XYPlot plot = detailChart.getXYPlot(); NumberAxis yAxis = new NumberAxis(); yAxis.setTickLabelPaint(Color.GRAY); plot.setRangeAxis(yAxis);//from w ww . j a v a2 s .com NumberAxis xAxis = new NumberAxis(); xAxis.setTickLabelPaint(Color.GRAY); xAxis.setTickUnit(new NumberTickUnit(1)); xAxis.setRange(-0.5, ((double) g.getMaxElements()) - 0.5); plot.setDomainAxis(xAxis); plot.setDataset(MEAN_INDEX, new BasicXYDataset(Collections.singletonList(g.S1_))); plot.setDataset(POINTS_INDEX, new BasicXYDataset(Collections.singletonList(g.S2_))); plot.setDataset(SMOOTH_INDEX, new BasicXYDataset(Collections.singletonList(g.S3_))); rescaleAxis((NumberAxis) plot.getRangeAxis()); detailChart.setTitle(g.label_); panel.setChart(detailChart); panel.setToolTipText("Right click to show complete data"); onColorSchemeChange(); }