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:com.oculusinfo.ml.spark.unsupervised.TestDPMeans.java
/** * @param args/* www. ja va 2 s . co m*/ */ public static void main(String[] args) { int k = 5; try { FileUtils.deleteDirectory(new File("output/clusters")); FileUtils.deleteDirectory(new File("output/centroids")); } catch (IOException e1) { /* ignore (*/ } genTestData(k); JavaSparkContext sc = new JavaSparkContext("local", "OculusML"); SparkDataSet ds = new SparkDataSet(sc); ds.load("test.txt", new InstanceParser()); DPMeansClusterer clusterer = new DPMeansClusterer(80, 10, 0.001); clusterer.setOutputPaths("output/centroids", "output/clusters"); clusterer.registerFeatureType("point", MeanNumericVectorCentroid.class, new EuclideanDistance(1.0)); clusterer.doCluster(ds); try { final List<double[]> instances = readInstances(); final Color[] colors = { Color.red, Color.blue, Color.green, Color.magenta, Color.yellow, Color.black, Color.orange, Color.cyan, Color.darkGray, Color.white }; TestDPMeans t = new TestDPMeans(); t.add(new JComponent() { private static final long serialVersionUID = 7920802321066846416L; public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); for (double[] inst : instances) { int color = (int) inst[0]; g.setColor(colors[color]); Ellipse2D l = new Ellipse2D.Double(inst[1], inst[2], 5, 5); g2.draw(l); } } }); t.setDefaultCloseOperation(EXIT_ON_CLOSE); t.setSize(400, 400); t.setVisible(true); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.oculusinfo.ml.spark.unsupervised.TestThresholdClusterer.java
/** * @param args/* ww w .j av a2 s .c om*/ */ public static void main(String[] args) { int k = 5; try { FileUtils.deleteDirectory(new File("output/clusters")); FileUtils.deleteDirectory(new File("output/centroids")); } catch (IOException e1) { /* ignore (*/ } genTestData(k); JavaSparkContext sc = new JavaSparkContext("local", "OculusML"); SparkDataSet ds = new SparkDataSet(sc); ds.load("test.txt", new InstanceParser()); ThresholdClusterer clusterer = new ThresholdClusterer(80); clusterer.setOutputPaths("output/centroids", "output/clusters"); clusterer.registerFeatureType("point", MeanNumericVectorCentroid.class, new EuclideanDistance(1.0)); clusterer.doCluster(ds); try { final List<double[]> instances = readInstances(); final Color[] colors = { Color.red, Color.blue, Color.green, Color.magenta, Color.yellow, Color.black, Color.orange, Color.cyan, Color.darkGray, Color.white }; TestThresholdClusterer t = new TestThresholdClusterer(); t.add(new JComponent() { private static final long serialVersionUID = -5597119848880912541L; public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); for (double[] inst : instances) { int color = (int) inst[0]; g.setColor(colors[color]); Ellipse2D l = new Ellipse2D.Double(inst[1], inst[2], 5, 5); g2.draw(l); } } }); t.setDefaultCloseOperation(EXIT_ON_CLOSE); t.setSize(400, 400); t.setVisible(true); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.oculusinfo.ml.spark.unsupervised.TestKMeans.java
/** * @param args// w w w. j a v a 2 s . com */ public static void main(String[] args) { int k = 5; try { FileUtils.deleteDirectory(new File("output/clusters")); FileUtils.deleteDirectory(new File("output/centroids")); } catch (IOException e1) { /* ignore (*/ } genTestData(k); JavaSparkContext sc = new JavaSparkContext("local", "OculusML"); SparkDataSet ds = new SparkDataSet(sc); ds.load("test.txt", new SparkInstanceParser() { private static final long serialVersionUID = 1L; @Override public Tuple2<String, Instance> call(String line) throws Exception { Instance inst = new Instance(); String tokens[] = line.split(","); NumericVectorFeature v = new NumericVectorFeature("point"); double x = Double.parseDouble(tokens[0]); double y = Double.parseDouble(tokens[1]); v.setValue(new double[] { x, y }); inst.addFeature(v); return new Tuple2<String, Instance>(inst.getId(), inst); } }); KMeansClusterer clusterer = new KMeansClusterer(k, 10, 0.001, "output/centroids", "output/clusters"); clusterer.registerFeatureType("point", MeanNumericVectorCentroid.class, new EuclideanDistance(1.0)); clusterer.doCluster(ds); try { final List<double[]> instances = readInstances(); final Color[] colors = { Color.red, Color.blue, Color.green, Color.magenta, Color.yellow, Color.black, Color.orange, Color.cyan, Color.darkGray, Color.white }; TestKMeans t = new TestKMeans(); t.add(new JComponent() { private static final long serialVersionUID = 2059497051387104848L; public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); for (double[] inst : instances) { int color = (int) inst[0]; g.setColor(colors[color]); Ellipse2D l = new Ellipse2D.Double(inst[1], inst[2], 5, 5); g2.draw(l); } } }); t.setDefaultCloseOperation(EXIT_ON_CLOSE); t.setSize(400, 400); t.setVisible(true); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:de.codesourcery.eve.skills.ui.utils.CalendarWidget.java
public static void main(String[] args) throws Exception { final SimpleDateFormat DF = new SimpleDateFormat("dd.MM"); final Calendar specialDate = Calendar.getInstance(); specialDate.add(Calendar.DAY_OF_MONTH, 5); final AtomicBoolean doStuff = new AtomicBoolean(false); final ICalendarRenderer renderer = new ICalendarRenderer() { @Override/* w ww.j a v a 2s .co m*/ public String getDateLabel(Date date) { return DF.format(date); } @Override public String getText(Date date) { if (DateUtils.isSameDay(date, specialDate.getTime()) && doStuff.get()) { return "SPECIAL !!!"; } return "some\nmultiline\ntext"; } @Override public String getToolTip(Date date) { return getText(date); } @Override public Color getTextColor(Date date) { return Color.RED; } }; final JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new GridBagLayout()); final CalendarWidget widget = new CalendarWidget(new Date(), renderer); widget.addSelectionListener(new ISelectionListener<Date>() { @Override public void selectionChanged(Date selected) { System.out.println("Selected date > " + selected); } }); frame.getContentPane().add(widget, new ConstraintsBuilder().end()); frame.pack(); frame.setVisible(true); java.lang.Thread.sleep(2 * 1000); doStuff.set(true); widget.refreshDateLabel(specialDate.getTime()); }
From source file:edu.osu.netmotifs.warswap.ui.GenerateMotifImages.java
public static void main(String[] args) { HashMap<Integer, Color> cHash = new HashMap<Integer, Color>(); cHash.put(0, Color.BLUE);/*from ww w . j av a 2 s. co m*/ cHash.put(2, Color.BLACK); cHash.put(1, Color.RED); try { new GenerateMotifImages(cHash, "/home/mitra/workspace/uni-workspace/warswap_tool/warswap.subgraphsdddd.OUT", 3, "data/htmout.htm").createHtm(1, 0, 10); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:Main.java
private static int[] makeGradientPallet() { BufferedImage image = new BufferedImage(100, 1, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); Point2D start = new Point2D.Float(0f, 0f); Point2D end = new Point2D.Float(99f, 0f); float[] dist = { 0.0f, 0.5f, 1.0f }; Color[] colors = { Color.RED, Color.YELLOW, Color.GREEN }; g2.setPaint(new LinearGradientPaint(start, end, dist, colors)); g2.fillRect(0, 0, 100, 1);/*from w w w . j a v a 2 s. co m*/ g2.dispose(); int width = image.getWidth(null); int[] pallet = new int[width]; PixelGrabber pg = new PixelGrabber(image, 0, 0, width, 1, pallet, 0, width); try { pg.grabPixels(); } catch (Exception e) { e.printStackTrace(); } return pallet; }
From source file:net.sf.maltcms.chromaui.charts.GradientPaintScale.java
/** * * @param args/*from www .j a va2s . c o m*/ */ public static void main(String[] args) { double[] st = ImageTools.createSampleTable(256); Logger.getLogger(GradientPaintScale.class.getName()).info(Arrays.toString(st)); double min = 564.648; double max = 24334.234; GradientPaintScale gps = new GradientPaintScale(st, min, max, new Color[] { Color.BLACK, Color.RED, Color.orange, Color.yellow, Color.white }); double val = min; double incr = (max - min) / (st.length - 1); Logger.getLogger(GradientPaintScale.class.getName()).log(Level.INFO, "Increment: {0}", incr); for (int i = 0; i < st.length; i++) { Logger.getLogger(GradientPaintScale.class.getName()).log(Level.INFO, "Value: {0}", val); gps.getPaint(val); val += incr; } Logger.getLogger(GradientPaintScale.class.getName()).info("Printing min and max values"); Logger.getLogger(GradientPaintScale.class.getName()).log(Level.INFO, "Min: {0} gps min: {1}", new Object[] { min, gps.getPaint(min) }); Logger.getLogger(GradientPaintScale.class.getName()).log(Level.INFO, "Max: {0} gps max: {1}", new Object[] { max, gps.getPaint(max) }); JList jl = new JList(); DefaultListModel dlm = new DefaultListModel(); jl.setModel(dlm); jl.setCellRenderer(new ListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value instanceof JLabel) { // Border b = // BorderFactory.createCompoundBorder(BorderFactory // .createEmptyBorder(0, 0, 5, 0), BorderFactory // .createLineBorder(Color.BLACK, 1)); // ((JLabel) value).setBorder(b); return (Component) value; } return new JLabel(value.toString()); } }); JFrame jf = new JFrame(); jf.add(new JScrollPane(jl)); jf.setVisible(true); jf.setSize(200, 400); for (int alpha = -10; alpha <= 10; alpha++) { for (int beta = 1; beta <= 20; beta++) { gps.setAlphaBeta(alpha, beta); // System.out.println(Arrays.toString(gps.st)); // System.out.println(Arrays.toString(gps.sampleTable)); BufferedImage bi = gps.getLookupImage(); ImageIcon ii = new ImageIcon(bi); dlm.addElement(new JLabel(ii)); } } }
From source file:org.jfree.graphics2d.demo.ImageTest.java
private static void drawClipTest(Graphics2D g2) { g2.translate(10, 20);//w w w .j a v a2 s . c o m g2.setColor(Color.RED); g2.fillRect(10, 10, 100, 100); g2.clip(new Rectangle(0, 0, 60, 60)); g2.setPaint(Color.BLUE); g2.fillRect(10, 10, 100, 100); g2.setClip(null); g2.setPaint(Color.GREEN); g2.fillRect(60, 60, 50, 50); }
From source file:Main.java
public static void highlight(JTextComponent textComp) { try {//from w ww . j a va 2 s . c o m Highlighter hilite = textComp.getHighlighter(); Document doc = textComp.getDocument(); hilite.addHighlight(3, 5, new MyHighlightPainter(Color.red)); } catch (BadLocationException e) { e.printStackTrace(); } }
From source file:Main.java
public static Border getBorderRed() { return BorderFactory.createLineBorder(Color.red); }