List of usage examples for java.awt Color RED
Color RED
To view the source code for java.awt Color RED.
Click Source Link
From source file:datojava.jcalendar.DJFechasEspInv.java
@Override public Color getSpecialForegroundColor() { return Color.RED; }
From source file:dataminning2.Graphplot.java
protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int w = getWidth(); int h = getHeight(); // Draw ordinate. g2.draw(new Line2D.Double(PAD, PAD, PAD, h - PAD)); // Draw abcissa. g2.draw(new Line2D.Double(PAD, h - PAD, w - PAD, h - PAD)); double xInc = (double) (w - 2 * PAD) / (data.length - 1); double scale = (double) (h - 2 * PAD) / 88; // Mark data points. g2.setPaint(Color.red); int length1 = 0; int length2 = data.length / 3; for (int i = 0; i < length2; i++) { double x = PAD + i * dataX[i]; double y = h - PAD - scale * dataY[i]; g2.fill(new Ellipse2D.Double(x - 2, y - 2, 4, 4)); }//w w w . ja va 2 s . co m g2.setPaint(Color.BLUE); int lengthnew = length1 + length2; length2 = length2 + lengthnew; for (int i = lengthnew; i < length2; i++) { double x = PAD + i * dataX[i]; double y = h - PAD - scale * dataY[i]; g2.fill(new Ellipse2D.Double(x - 2, y - 2, 4, 4)); } g2.setPaint(Color.YELLOW); lengthnew = lengthnew + lengthnew; for (int i = length2; i < data.length; i++) { double x = PAD + i * dataX[i]; double y = h - PAD - scale * dataY[i]; g2.fill(new Ellipse2D.Double(x - 2, y - 2, 4, 4)); } }
From source file:utils.ChartUtils.java
/** * Update values of a bar chart//from w w w. j a va2 s . c om * * @param labelsByFreq Labels ordered by frequency * @param nInstances Number of instances * @param cp CategoryPlot */ public static void updateValuesBarChart(ImbalancedFeature[] labelsByFreq, int nInstances, CategoryPlot cp) { DefaultCategoryDataset data = new DefaultCategoryDataset(); double prob; labelsByFreq = MetricUtils.sortByFrequency(labelsByFreq); double sum = 0.0; for (int i = 0; i < labelsByFreq.length; i++) { prob = labelsByFreq[i].getAppearances() * 1.0 / nInstances; sum += prob; data.setValue(prob, labelsByFreq[i].getName(), " "); } cp.setDataset(data); // add mean mark sum = sum / labelsByFreq.length; Marker start = new ValueMarker(sum); start.setPaint(Color.red); start.setLabelFont(new Font("SansSerif", Font.BOLD, 12)); start.setLabel(" Mean: " + MetricUtils.truncateValue(sum, 3)); cp.addRangeMarker(start); }
From source file:DoubleBufferedImage.java
public void paint(Graphics g) { if (xLocation == imageWidth) xLocation = 0;/*from www . j a v a2s. c om*/ dbImageGraphics.clearRect(0, 0, imageWidth, imageHeight); dbImageGraphics.drawImage(originalImage, 0, 0, this); dbImageGraphics.setColor(Color.red); dbImageGraphics.fillOval(xLocation, imageHeight / 2, 20, 20); //now dbImage's drawing area appears g.drawImage(dbImage, 0, 0, this); xLocation++; repaint(10); }
From source file:com.mgmtp.perfload.loadprofiles.ui.component.IntegerCellEditor.java
@Override public boolean stopCellEditing() { String s = (String) super.getCellEditorValue(); JTextField textField = (JTextField) getComponent(); if (isBlank(s)) { textField.setBorder(new LineBorder(Color.red)); return false; }/*from w w w . j a v a2 s.c o m*/ try { value = Integer.valueOf(s); } catch (NumberFormatException ex2) { textField.setBorder(new LineBorder(Color.red)); textField.selectAll(); return false; } return super.stopCellEditing(); }
From source file:dataminning2.DBScanGraphplot.java
protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int w = getWidth(); int h = getHeight(); // Draw ordinate. g2.draw(new Line2D.Double(PAD, PAD, PAD, h - PAD)); // Draw abcissa. g2.draw(new Line2D.Double(PAD, h - PAD, w - PAD, h - PAD)); double xInc = (double) (w - 2 * PAD) / (data.length - 1); double scale = (double) (h - 2 * PAD) / 88; // Mark data points. g2.setPaint(Color.red); int length1 = 0; int length2 = data.length / 3; for (int i = 0; i < data.length; i++) { double x = PAD + i * dataX[i]; double y = h - PAD - scale * dataY[i]; g2.fill(new Ellipse2D.Double(x - 2, y - 2, 4, 4)); }//ww w.ja v a 2 s .co m }
From source file:MainClass.java
public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException { // pageIndex 0 corresponds to page number 1. if (pageIndex >= 1) return Printable.NO_SUCH_PAGE; PrinterGraphics p = (PrinterGraphics) g; System.out.println(p.getPrinterJob().getCopies()); System.out.println(p.getPrinterJob().getJobName()); Graphics2D g2 = (Graphics2D) g; double w = pf.getImageableWidth(); double h = pf.getImageableHeight(); int xo = (int) pf.getImageableX(); int yo = (int) pf.getImageableY(); Rectangle2D r = new Rectangle2D.Double(xo, yo, w, h); g2.setColor(Color.red); g2.draw(r);// w ww. j a v a2 s.c om Shape s = new Ellipse2D.Double(xo + 4, yo + 4, 32, 32); g2.fill(s); return Printable.PAGE_EXISTS; }
From source file:ImageDuplicity.java
private void createOffscreenImage() { Dimension d = getSize();/*w ww . j a va 2 s . co m*/ int width = d.width; int height = d.height; image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); try { String filename = "largeJava2sLogo.jpg"; InputStream in = getClass().getResourceAsStream(filename); JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(in); BufferedImage image = decoder.decodeAsBufferedImage(); in.close(); g2.drawImage(image, 0, 0, width, height, null); } catch (Exception e) { System.out.print(e); } g2.setStroke(new BasicStroke(2)); Color[] colors = { Color.red, Color.blue, Color.green }; for (int i = -32; i < 40; i += 8) { g2.setPaint(colors[Math.abs(i) % 3]); g2.drawOval(i, i, width - i * 2, height - i * 2); } }
From source file:de.codesourcery.geoip.Main.java
public static void main(String[] args) throws Exception { final IGeoLocator<StringSubject> locator = createGeoLocator(); final JFrame frame = new JFrame("GeoIP"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { try { locator.dispose();//from w ww .j av a2s. co m } catch (Exception e1) { e1.printStackTrace(); } }; }); final MapImage image = MapImage.getRobinsonWorldMap(); // MapImage.getMillerWorldMap(); final MapCanvas canvas = new MapCanvas(image); for (GeoLocation<StringSubject> loc : locator.locate(getSpammers())) { if (loc.hasValidCoordinates()) { canvas.addCoordinate(PointRenderer.createPoint(loc, Color.YELLOW)); } } // canvas.addCoordinate( PointRenderer.createPoint( ZERO , Color.YELLOW ) ); // canvas.addCoordinate( PointRenderer.createPoint( WELLINGTON , Color.RED ) ); // canvas.addCoordinate( PointRenderer.createPoint( MELBOURNE , Color.RED ) ); // canvas.addCoordinate( PointRenderer.createPoint( HAMBURG , Color.RED ) ); final double heightToWidth = image.height() / (double) image.width(); // preserve aspect ratio of map canvas.setPreferredSize(new Dimension(640, (int) Math.round(640 * heightToWidth))); JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); panel.add(new JLabel("Scale-X")); final JTextField scaleX = new JTextField(Double.toString(image.getScaleX())); scaleX.setColumns(5); final JTextField scaleY = new JTextField(Double.toString(image.getScaleY())); scaleY.setColumns(5); final ActionListener listener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { double x = Double.parseDouble(scaleX.getText()); double y = Double.parseDouble(scaleY.getText()); image.setScale(x, y); canvas.repaint(); } }; scaleX.addActionListener(listener); scaleY.addActionListener(listener); panel.add(new JLabel("Scale-X")); panel.add(scaleX); panel.add(new JLabel("Scale-Y")); panel.add(scaleY); final JTextField ipAddress = new JTextField("www.kickstarter.com"); ipAddress.setColumns(20); final ActionListener ipListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final String destinationIP = ipAddress.getText(); if (StringUtils.isBlank(destinationIP)) { return; } /* * Perform traceroute. */ final List<String> hops; try { if (TracePath.isPathTracingAvailable()) { hops = TracePath.trace(destinationIP); } else { System.err.println("tracepath not available."); if (TracePath.isValidAddress(destinationIP)) { hops = new ArrayList<>(); hops.add(destinationIP); } else { System.err.println(destinationIP + " is no valid IP"); return; } } } catch (Exception ex) { System.err.println("Failed to trace " + destinationIP); ex.printStackTrace(); return; } System.out.println("Trace contains " + hops.size() + " IPs"); /* * Gather locations. */ final List<StringSubject> subjects = new ArrayList<>(); for (String ip : hops) { subjects.add(new StringSubject(ip)); } final List<GeoLocation<StringSubject>> locations; try { long time = -System.currentTimeMillis(); locations = locator.locate(subjects); time += System.currentTimeMillis(); System.out.println("Locating hops for " + destinationIP + " returned " + locations.size() + " valid locations ( time: " + time + " ms)"); System.out.flush(); } catch (Exception e2) { e2.printStackTrace(); return; } /* * Weed-out invalid/unknown locations. */ { GeoLocation<StringSubject> previous = null; for (Iterator<GeoLocation<StringSubject>> it = locations.iterator(); it.hasNext();) { final GeoLocation<StringSubject> location = it.next(); if (!location.hasValidCoordinates() || (previous != null && previous.coordinate().equals(location.coordinate()))) { it.remove(); System.err.println("Ignoring invalid/duplicate location for " + location); } else { previous = location; } } } /* * Populate chart. */ System.out.println("Adding " + locations.size() + " hops to chart"); System.out.flush(); canvas.removeAllCoordinates(); if (locations.size() == 1) { canvas.addCoordinate( PointRenderer.createPoint(locations.get(0), getLabel(locations.get(0)), Color.BLACK)); } else if (locations.size() > 1) { GeoLocation<StringSubject> previous = locations.get(0); MapPoint previousPoint = PointRenderer.createPoint(previous, getLabel(previous), Color.BLACK); final int len = locations.size(); for (int i = 1; i < len; i++) { final GeoLocation<StringSubject> current = locations.get(i); // final MapPoint currentPoint = PointRenderer.createPoint( current , getLabel( current ) , Color.BLACK ); final MapPoint currentPoint = PointRenderer.createPoint(current, Color.BLACK); // canvas.addCoordinate( LineRenderer.createLine( previousPoint , currentPoint , Color.RED ) ); canvas.addCoordinate(CurvedLineRenderer.createLine(previousPoint, currentPoint, Color.RED)); previous = locations.get(i); previousPoint = currentPoint; } } System.out.println("Finished adding"); System.out.flush(); canvas.repaint(); } }; ipAddress.addActionListener(ipListener); panel.add(new JLabel("IP")); panel.add(ipAddress); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(panel, BorderLayout.NORTH); frame.getContentPane().add(canvas, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); }
From source file:AlphaCompositeSRCOUT.java
public void paint(Graphics g) { Graphics2D g2D = (Graphics2D) g; int w = getSize().width; int h = getSize().height; BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D big = bi.createGraphics(); ac = AlphaComposite.getInstance(compositeRule, alphaValue); big.setColor(Color.red); big.drawString("Destination", w / 4, h / 4); big.fill(new Ellipse2D.Double(0, h / 3, 2 * w / 3, h / 3)); big.setColor(Color.blue);/*from w ww . j a v a2s . c om*/ big.drawString("Source", 3 * w / 4, h / 4); big.setComposite(ac); big.fill(new Ellipse2D.Double(w / 3, h / 3, 2 * w / 3, h / 3)); g2D.drawImage(bi, null, 0, 0); }