List of usage examples for java.awt Color WHITE
Color WHITE
To view the source code for java.awt Color WHITE.
Click Source Link
From source file:Containers.java
public Containers() { this.setBackground(Color.white); // This component is white this.setFont(new Font("Dialog", Font.BOLD, 24)); JPanel p1 = new JPanel(); p1.setBackground(new Color(200, 200, 200)); // Panel1 is darker this.add(p1); // p1 is contained by this component p1.add(new JButton("#1")); // Button 1 is contained in p1 JPanel p2 = new JPanel(); p2.setBackground(new Color(150, 150, 150)); // p2 is darker than p2 p1.add(p2); // p2 is contained in p1 p2.add(new JButton("#2")); // Button 2 is contained in p2 JPanel p3 = new JPanel(); p3.setBackground(new Color(100, 100, 100)); // p3 is darker than p2 p2.add(p3); // p3 is contained in p2 p3.add(new JButton("#3")); // Button 3 is contained in p3 JPanel p4 = new JPanel(); p4.setBackground(new Color(150, 150, 150)); // p4 is darker than p1 p1.add(p4); // p4 is contained in p1 p4.add(new JButton("#4")); // Button4 is contained in p4 p4.add(new JButton("#5")); // Button5 is also contained in p4 this.add(new JButton("#6")); // Button6 is contained in this component }
From source file:Similaridade.GraficosSimilaridade.java
public static JFreeChart criaGrafico2LinhasComDeslocada(CapturaAtual onda1, CapturaAtual onda2, int deslocamento, double correlacao, Paint cor1, Paint cor2) { String eixoy = new String("Current "); // verifica se fase ou fuga if (onda1.getCodEvento().getCodEvento() == 1) { // evento 1 de fuga eixoy = eixoy.concat("(mA)"); } else {//from w ww. j a v a2s .c o m eixoy = eixoy.concat("(A)"); } XYDataset dataset = newDataset2OndasComDeslocada(onda1, onda2, deslocamento, correlacao); // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title "Time (ms)", // x axis label eixoy, // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend false, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); // Definindo valores no eixo y double min = (double) DatasetUtilities.findMinimumRangeValue(dataset); double max = (double) DatasetUtilities.findMaximumRangeValue(dataset); plot.getRangeAxis().setRange(min - min * 0.005, //min max + min * 0.005); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseStroke(new BasicStroke(1.0f)); for (int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesLinesVisible(i, true); renderer.setSeriesShapesVisible(i, false); } // Ajustar para todas as cores padro, pelo menos 10 renderer.setSeriesPaint(0, cor1); renderer.setSeriesPaint(1, cor2); /* Cdigo para ter linhas tracejadas renderer.setSeriesStroke(1, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND, 20.0f, new float[] {5.0f}, 0.0f) ); renderer.setDrawSeriesLineAsPath(true); /* Final do Codigo para tracejadas */ plot.setRenderer(renderer); return chart; }
From source file:org.jfree.chart.demo.CompareToPreviousYearDemo.java
private static JFreeChart createChart() { XYDataset xydataset = createDataset2006(); XYDataset xydataset1 = createDataset2007(); DateAxis dateaxis = new DateAxis("Date"); Month month = new Month(1, 2007); Month month1 = new Month(12, 2007); dateaxis.setRange(month.getFirstMillisecond(), month1.getLastMillisecond()); dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM")); dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(); xylineandshaperenderer.setUseFillPaint(true); xylineandshaperenderer.setBaseFillPaint(Color.white); xylineandshaperenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{1}: {2}", new SimpleDateFormat("MMM-yyyy"), new DecimalFormat("0.00"))); XYPlot xyplot = new XYPlot(xydataset1, dateaxis, new NumberAxis("Sales"), xylineandshaperenderer); xyplot.setDomainPannable(true);/* ww w . j a va2s .c o m*/ xyplot.setRangePannable(true); DateAxis dateaxis1 = new DateAxis(); dateaxis1.setVisible(false); xyplot.setDomainAxis(1, dateaxis1); xyplot.setDataset(1, xydataset); xyplot.mapDatasetToDomainAxis(1, 1); XYLineAndShapeRenderer xylineandshaperenderer1 = new XYLineAndShapeRenderer(); xylineandshaperenderer1.setSeriesPaint(0, Color.blue); xylineandshaperenderer1.setUseFillPaint(true); xylineandshaperenderer1.setBaseFillPaint(Color.white); xylineandshaperenderer1.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{1}: {2}", new SimpleDateFormat("MMM-yyyy"), new DecimalFormat("0.00"))); xyplot.setRenderer(1, xylineandshaperenderer1); JFreeChart jfreechart = new JFreeChart("Sales Comparison Chart", xyplot); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); DateAxis dateaxis2 = (DateAxis) xyplot.getDomainAxis(); dateaxis2.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); ChartUtilities.applyCurrentTheme(jfreechart); return jfreechart; }
From source file:org.jfree.chart.demo.CategoryStepChartDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { CategoryStepRenderer categorysteprenderer = new CategoryStepRenderer(true); categorysteprenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); CategoryAxis categoryaxis = new CategoryAxis("Category"); NumberAxis numberaxis = new NumberAxis("Value"); CategoryPlot categoryplot = new CategoryPlot(categorydataset, categoryaxis, numberaxis, categorysteprenderer);//from ww w. j a v a2 s.c o m JFreeChart jfreechart = new JFreeChart("Category Step Chart", categoryplot); jfreechart.setBackgroundPaint(Color.white); categoryplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setDomainGridlinesVisible(true); categoryplot.setDomainGridlinePaint(Color.white); categoryplot.setRangeGridlinesVisible(true); categoryplot.setRangeGridlinePaint(Color.white); categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); categoryaxis.setLowerMargin(0.0D); categoryaxis.setUpperMargin(0.0D); categoryaxis.addCategoryLabelToolTip("Type 1", "The first type."); categoryaxis.addCategoryLabelToolTip("Type 2", "The second type."); categoryaxis.addCategoryLabelToolTip("Type 3", "The third type."); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setLabelAngle(0.0D); return jfreechart; }
From source file:BufferedAnimate.java
public void paint(Graphics g) { if ((oldSize == null) || (oldSize != getSize())) { oldSize = getSize();/*from w w w .ja v a 2 s . co m*/ buffer = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB); } if (insets == null) { insets = getInsets(); } // Calculate each time in case of resize int x = insets.left; int y = insets.top; int width = getWidth() - insets.left - insets.right; int height = getHeight() - insets.top - insets.bottom; int start = 0; int steps = colors.length; int stepSize = 360 / steps; synchronized (colors) { Graphics bufferG = buffer.getGraphics(); bufferG.setColor(Color.WHITE); bufferG.fillRect(x, y, width, height); for (int i = 0; i < steps; i++) { bufferG.setColor(colors[i]); bufferG.fillArc(x, y, width, height, start, stepSize); start += stepSize; } } g.drawImage(buffer, 0, 0, this); }
From source file:org.jfree.chart.demo.BoxAndWhiskerChartDemo1.java
private static JFreeChart createChart(BoxAndWhiskerCategoryDataset boxandwhiskercategorydataset) { JFreeChart jfreechart = ChartFactory.createBoxAndWhiskerChart("Box and Whisker Chart Demo 1", "Category", "Value", boxandwhiskercategorydataset, true); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); jfreechart.setBackgroundPaint(Color.white); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setDomainGridlinePaint(Color.white); categoryplot.setDomainGridlinesVisible(true); categoryplot.setRangeGridlinePaint(Color.white); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
From source file:ClipDemo.java
public void paintComponent(Graphics g) { super.paintComponent(g); // get damaged region Rectangle clipRect = g.getClipBounds(); int clipx = clipRect.x; int clipy = clipRect.y; int clipw = clipRect.width; int cliph = clipRect.height; // fill damaged region only g.setColor(Color.white); g.fillRect(clipx, clipy, clipw, cliph); if (clipx <= 240 && clipy <= 240) { g.setColor(Color.yellow); g.fillOval(0, 0, 240, 240);/* w w w . j a va2 s . c o m*/ System.out.println(" yellow Oval repainted."); } if (clipx + clipw >= 160 && clipx <= 400 && clipy + cliph >= 160 && clipy <= 400) { g.setColor(Color.magenta); g.fillOval(160, 160, 240, 240); System.out.println(" magenta Oval repainted."); } int iconWidth = java2sLogo.getIconWidth(); int iconHeight = java2sLogo.getIconHeight(); if (clipx + clipw >= 280 - (iconWidth / 2) && clipx <= (280 + (iconWidth / 2)) && clipy + cliph >= 120 - (iconHeight / 2) && clipy <= (120 + (iconHeight / 2))) { java2sLogo.paintIcon(this, g, 280 - (iconWidth / 2), 120 - (iconHeight / 2)); System.out.println(" logo below blue Rect repainted."); } if (clipx + clipw >= 120 - (iconWidth / 2) && clipx <= (120 + (iconWidth / 2)) && clipy + cliph >= 280 - (iconHeight / 2) && clipy <= (280 + (iconHeight / 2))) { java2sLogo.paintIcon(this, g, 120 - (iconWidth / 2), 280 - (iconHeight / 2)); System.out.println(" logo below red Rect repainted."); } if (clipx + clipw >= 60 && clipx <= 180 && clipy + cliph >= 220 && clipy <= 340) { g.setColor(red); g.fillRect(60, 220, 120, 120); System.out.println(" red Rect repainted."); } if (clipx + clipw > 140 && clipx < 260 && clipy + cliph > 140 && clipy < 260) { g.setColor(green); g.fillOval(140, 140, 120, 120); System.out.println(" green Oval repainted."); } if (clipx + clipw > 220 && clipx < 380 && clipy + cliph > 60 && clipy < 180) { g.setColor(blue); g.fillRect(220, 60, 120, 120); System.out.println(" blue Rect repainted."); } g.setColor(Color.black); g.setFont(monoFont); FontMetrics fm = g.getFontMetrics(); iconWidth = fm.stringWidth("Java Source"); iconHeight = fm.getAscent(); int d = fm.getDescent(); if (clipx + clipw > 120 - (iconWidth / 2) && clipx < (120 + (iconWidth / 2)) && clipy + cliph > (120 + (iconHeight / 4)) - iconHeight && clipy < (120 + (iconHeight / 4)) + d) { g.drawString("Java Source", 120 - (iconWidth / 2), 120 + (iconHeight / 4)); System.out.println(" Java Source repainted."); } g.setFont(sanFont); fm = g.getFontMetrics(); iconWidth = fm.stringWidth("and"); iconHeight = fm.getAscent(); d = fm.getDescent(); if (clipx + clipw > 200 - (iconWidth / 2) && clipx < (200 + (iconWidth / 2)) && clipy + cliph > (200 + (iconHeight / 4)) - iconHeight && clipy < (200 + (iconHeight / 4)) + d) { g.drawString("and", 200 - (iconWidth / 2), 200 + (iconHeight / 4)); System.out.println(" and repainted."); } g.setFont(serifFont); fm = g.getFontMetrics(); iconWidth = fm.stringWidth("Support."); iconHeight = fm.getAscent(); d = fm.getDescent(); if (clipx + clipw > 280 - (iconWidth / 2) && clipx < (280 + (iconWidth / 2)) && clipy + cliph > (280 + (iconHeight / 4)) - iconHeight && clipy < (280 + (iconHeight / 4)) + d) { g.drawString("Support.", 280 - (iconWidth / 2), 280 + (iconHeight / 4)); System.out.println(" Support. repainted."); } }
From source file:org.geoserver.monitor.web.OWSSummaryChartBasePanel.java
public OWSSummaryChartBasePanel(String id, Monitor monitor, String owsService) { super(id);//from w ww . jav a 2s. c o m this.owsService = owsService; Map<String, Integer> data = gatherData(monitor); DefaultPieDataset dataset = new DefaultPieDataset(); for (Map.Entry<String, Integer> e : data.entrySet()) { dataset.setValue(e.getKey(), e.getValue()); } JFreeChart chart = ChartFactory.createPieChart(getChartTitle(), dataset, true, true, false); chart.setBackgroundPaint(Color.WHITE); BufferedDynamicImageResource resource = new BufferedDynamicImageResource(); resource.setImage(chart.createBufferedImage(650, 500)); add(new NonCachingImage("chart", resource)); }
From source file:DialogSeparator.java
public void paint(Graphics g) { g.setColor(getBackground());//from w ww . j a v a2s.co m g.fillRect(0, 0, getWidth(), getHeight()); Dimension d = getSize(); int y = (d.height - 3) / 2; g.setColor(Color.white); g.drawLine(1, y, d.width - 1, y); y++; g.drawLine(0, y, 1, y); g.setColor(Color.gray); g.drawLine(d.width - 1, y, d.width, y); y++; g.drawLine(1, y, d.width - 1, y); String text = getText(); if (text.length() == 0) return; g.setFont(getFont()); FontMetrics fm = g.getFontMetrics(); y = (d.height + fm.getAscent()) / 2; int fontWidth = fm.stringWidth(text); g.setColor(getBackground()); g.fillRect(OFFSET - 5, 0, OFFSET + fontWidth, d.height); g.setColor(getForeground()); g.drawString(text, OFFSET, y); }
From source file:TextQualityDemoVALUE_TEXT_ANTIALIAS_LCD_HBGR.java
public void paintComponent(Graphics g) { Dimension d = this.getSize(); BufferedImage backBuffer = (BufferedImage) this.createImage(d.width, d.height); Graphics2D g2 = backBuffer.createGraphics(); g2.setColor(Color.WHITE); g2.fillRect(0, 0, d.width, d.height); g2.setColor(Color.BLACK);/*from w w w . j a v a 2 s . c om*/ g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, hintValue); g2.drawRect(0, 0, d.width - 1, d.height - 1); g2.drawString("abcdefghijklmnopqrstuvwxyz", 20, 40); g2.drawString("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 20, 60); g2.drawString("1234567890-=!@#$%^&*()_+,./<>?", 20, 80); g.drawImage(backBuffer, 0, 0, this); }