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:iad_zad3.gui.Charts.java
public static JFreeChart getKmeansChart(final List<double[]> data, final List<double[]> centroids) { JFreeChart jfreechart = ChartFactory.createScatterPlot("", "x", "y", createDataset(data, centroids), PlotOrientation.VERTICAL, false, false, false); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesShape(1, circleSmall); renderer.setSeriesPaint(1, Color.RED); renderer.setSeriesShape(0, circleBig); renderer.setSeriesPaint(0, Color.BLUE); ValueAxis domainAxis = xyPlot.getDomainAxis(); domainAxis.setRange(DataStats.minVal[0] * 1.2, DataStats.maxVal[0] * 1.2); ValueAxis rangeAxis = xyPlot.getRangeAxis(); rangeAxis.setRange(DataStats.minVal[1] * 1.2, DataStats.maxVal[1] * 1.2); jfreechart.setBackgroundPaint(Color.WHITE); return jfreechart; }
From source file:ComplexExample.java
public ComplexExample() { JPanel left = new JPanel(); left.setBackground(Color.red); JPanel right = new JPanel(); right.setBackground(Color.white); new MyDropTargetListener(right); DragSource ds = new DragSource(); ds.createDefaultDragGestureRecognizer(left, DnDConstants.ACTION_COPY, this); setLayout(new FlowLayout()); add(left);/*from ww w . j ava 2s . co m*/ add(right); setSize(40, 50); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLocationRelativeTo(null); setVisible(true); }
From source file:Main.java
public Main() { super("Drop Test"); setSize(300, 300);/* ww w . j a va 2 s . com*/ getContentPane().add(new JLabel("Drop something here:"), BorderLayout.NORTH); ta.setBackground(Color.white); getContentPane().add(ta, BorderLayout.CENTER); dt = new DropTarget(ta, this); setVisible(true); }
From source file:Main.java
/** * Creates and returns image from the given text. * @param text input text//from w w w. j a va 2 s . c o m * @param font text font * @return image with input text */ public static BufferedImage createImageFromText(String text, Font font) { //You may want to change these setting, or make them parameters boolean isAntiAliased = true; boolean usesFractionalMetrics = false; FontRenderContext frc = new FontRenderContext(null, isAntiAliased, usesFractionalMetrics); TextLayout layout = new TextLayout(text, font, frc); Rectangle2D bounds = layout.getBounds(); int w = (int) Math.ceil(bounds.getWidth()); int h = (int) Math.ceil(bounds.getHeight()) + 2; BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); //for example; Graphics2D g = image.createGraphics(); g.setColor(Color.WHITE); g.fillRect(0, 0, w, h); g.setColor(Color.BLACK); g.setFont(font); Object antiAliased = isAntiAliased ? RenderingHints.VALUE_TEXT_ANTIALIAS_ON : RenderingHints.VALUE_TEXT_ANTIALIAS_OFF; g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, antiAliased); Object fractionalMetrics = usesFractionalMetrics ? RenderingHints.VALUE_FRACTIONALMETRICS_ON : RenderingHints.VALUE_FRACTIONALMETRICS_OFF; g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, fractionalMetrics); g.drawString(text, (float) -bounds.getX(), (float) -bounds.getY()); g.dispose(); return image; }
From source file:MainClass.java
public JPanel createNested(boolean opaque) { JPanel outer = new JPanel(new FlowLayout()); JPanel inner = new JPanel(new FlowLayout()); outer.setBackground(Color.white); inner.setBackground(Color.black); inner.setOpaque(opaque);//www.j av a 2 s .c o m inner.setBorder(BorderFactory.createLineBorder(Color.gray)); inner.add(new JButton("Button")); outer.add(inner); return outer; }
From source file:Charts.BarChart.java
@Override protected JFreeChart createChart(String title, String x, String y) { JFreeChart barChart = this.makeJFreeChart(title, x, y); // Custom chart.. barChart.setBackgroundPaint(Color.white); return barChart; }
From source file:org.jfree.chart.demo.StackedBarChartDemo6.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createStackedBarChart("Stacked Bar Chart Demo 6", "Category", "Value", categorydataset, PlotOrientation.HORIZONTAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); StackedBarRenderer stackedbarrenderer = (StackedBarRenderer) categoryplot.getRenderer(); stackedbarrenderer.setDrawBarOutline(false); long l = System.currentTimeMillis(); stackedbarrenderer.setBase(l);// w w w . j a v a2s . c o m DateAxis dateaxis = new DateAxis("Date"); dateaxis.setLowerMargin(0.0D); categoryplot.setRangeAxis(dateaxis); return jfreechart; }
From source file:Main.java
public void paintComponent(Graphics g) { ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(Color.black);/* w w w. ja v a 2 s .c o m*/ g.drawString(month.format(date), 34, 36); g.setColor(Color.white); g.drawString(year.format(date), 235, 36); Calendar today = Calendar.getInstance(); today.setTime(date); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.DATE, 1); cal.add(Calendar.DATE, -cal.get(Calendar.DAY_OF_WEEK) + 1); for (int week = 0; week < 6; week++) { for (int d = 0; d < 7; d++) { Color col = Color.black; g.drawString(day.format(cal.getTime()), d * 30 + 46 + 4, week * 29 + 81 + 20); cal.add(Calendar.DATE, +1); } } }
From source file:com.compomics.pepshell.view.statistics.JFreeChartPanel.java
private static void setupPlot(CategoryPlot categoryPlot) { categoryPlot.setBackgroundPaint(Color.white); categoryPlot.setRangeGridlinePaint(Color.black); // hide the border of the sorrounding box categoryPlot.setOutlinePaint(Color.white); // get domanin and range axes CategoryAxis domainAxis = categoryPlot.getDomainAxis(); ValueAxis rangeAxis = categoryPlot.getRangeAxis(); // set label paint for axes to black domainAxis.setLabelPaint(Color.black); rangeAxis.setLabelPaint(Color.black); // set font for labels, both on domain and range axes domainAxis.setLabelFont(new Font("Tahoma", Font.BOLD, 12)); rangeAxis.setLabelFont(new Font("Tahoma", Font.BOLD, 12)); }
From source file:org.jfree.chart.demo.XYPolygonAnnotationDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createScatterPlot("XYPolygonAnnotationDemo1", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); XYPolygonAnnotation xypolygonannotation = new XYPolygonAnnotation( new double[] { 2D, 5D, 2.5D, 8D, 3D, 5D, 2.5D, 2D }, null, null, new Color(200, 200, 255, 100)); xypolygonannotation.setToolTipText("Target Zone"); xylineandshaperenderer.addAnnotation(xypolygonannotation, Layer.BACKGROUND); return jfreechart; }