List of usage examples for java.awt Color cyan
Color cyan
To view the source code for java.awt Color cyan.
Click Source Link
From source file:com.oculusinfo.ml.spark.unsupervised.TestThresholdClusterer.java
/** * @param args/*from w ww . j a v a 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()); 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/*from ww w. j av a2 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 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:Main.java
public static Element toXML(Color c, Document document) { Element result = document.createElement("color"); String name;// w w w .ja va 2s. c o m if (c.equals(Color.WHITE)) { name = "white"; } else if (c.equals(Color.CYAN)) { name = "cyan"; } else if (c.equals(Color.YELLOW)) { name = "yellow"; } else if (c.equals(Color.PINK)) { name = "pink"; } else if (c.equals(Color.GREEN)) { name = "green"; } else { name = "white"; } result.setAttribute("name", name); return result; }
From source file:Main.java
public static Color toColor(Node n) { if (!n.getNodeName().equals("color")) { throw new IllegalArgumentException(n.getNodeName()); }//from www. j a v a2 s .co m NamedNodeMap map = n.getAttributes(); String s = map.getNamedItem("name").getNodeValue(); if (s.equals("white")) { return Color.WHITE; } else if (s.equals("green")) { return Color.GREEN; } else if (s.equals("pink")) { return Color.PINK; } else if (s.equals("cyan")) { return Color.CYAN; } else if (s.equals("yellow")) { return Color.YELLOW; } else { return Color.WHITE; } }
From source file:ImageProc.java
public static void imwrite(File file, int[][] classificationMat, int imgDim1, int imgDim2) { BufferedImage image = new BufferedImage(imgDim2, imgDim1, BufferedImage.TYPE_INT_RGB); for (int i = 0; i < imgDim1; i++) { for (int j = 0; j < imgDim2; j++) { switch (classificationMat[i][j]) { case 1: image.setRGB(j, i, Color.BLUE.getRGB()); break; case 2: image.setRGB(j, i, Color.CYAN.getRGB()); break; case 3: image.setRGB(j, i, Color.GREEN.getRGB()); break; case 4: image.setRGB(j, i, Color.ORANGE.getRGB()); break; case 5: image.setRGB(j, i, Color.RED.getRGB()); break; }//from www .jav a 2s . c om } } try { ImageIO.write(image, "png", file); } catch (IOException e) { e.printStackTrace(); } }
From source file:KeyTextComponent.java
public KeyTextComponent() { setBackground(Color.CYAN); KeyListener internalKeyListener = new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (actionListenerList != null) { int keyCode = keyEvent.getKeyCode(); String keyText = KeyEvent.getKeyText(keyCode); ActionEvent actionEvent = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, keyText); actionListenerList.actionPerformed(actionEvent); }//from w w w .ja v a 2s.com } }; MouseListener internalMouseListener = new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { requestFocusInWindow(); } }; addKeyListener(internalKeyListener); addMouseListener(internalMouseListener); }
From source file:ColorBlocks.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Dimension d = getSize();//from w w w . j av a 2 s.c om g2.translate(d.width / 2, d.height / 2); Color[] colors = { Color.white, Color.lightGray, Color.gray, Color.darkGray, Color.black, Color.red, Color.pink, Color.orange, Color.yellow, Color.green, Color.magenta, Color.cyan, Color.blue }; float size = 25; float x = -size * colors.length / 2; float y = -size * 3 / 2; // Show all the predefined colors. for (int i = 0; i < colors.length; i++) { Rectangle2D r = new Rectangle2D.Float(x + size * (float) i, y, size, size); g2.setPaint(colors[i]); g2.fill(r); } //a linear gradient. y += size; Color c1 = Color.yellow; Color c2 = Color.blue; for (int i = 0; i < colors.length; i++) { float ratio = (float) i / (float) colors.length; int red = (int) (c2.getRed() * ratio + c1.getRed() * (1 - ratio)); int green = (int) (c2.getGreen() * ratio + c1.getGreen() * (1 - ratio)); int blue = (int) (c2.getBlue() * ratio + c1.getBlue() * (1 - ratio)); Color c = new Color(red, green, blue); Rectangle2D r = new Rectangle2D.Float(x + size * (float) i, y, size, size); g2.setPaint(c); g2.fill(r); } // Show an alpha gradient. y += size; c1 = Color.red; for (int i = 0; i < colors.length; i++) { int alpha = (int) (255 * (float) i / (float) colors.length); Color c = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), alpha); Rectangle2D r = new Rectangle2D.Float(x + size * (float) i, y, size, size); g2.setPaint(c); g2.fill(r); } // Draw a frame around the whole thing. y -= size * 2; Rectangle2D frame = new Rectangle2D.Float(x, y, size * colors.length, size * 3); g2.setPaint(Color.black); g2.draw(frame); }
From source file:com.github.errantlinguist.latticevisualiser.StatePaintTransformer.java
/** * /*from w w w . j a v a 2s . c o m*/ * @return A map of {@link StateType StateTypes} to {@link Color Colors} for * deriving the colour used to draw the vertex representing a state. */ static final ImmutableMap<StateType, Color> makeColorMap() { final ImmutableMap.Builder<StateType, Color> builder = ImmutableMap.builder(); builder.put(StateType.INITIAL, Color.CYAN); builder.put(StateType.FINAL, Color.MAGENTA); builder.put(StateType.GOAL, Color.RED); builder.put(StateType.INTERMEDIATE, Color.GREEN); return builder.build(); }
From source file:ButtonwithImageIcon.java
public ButtonPanel() { JButton btn = new JButton("Push Me", new BoxIcon(Color.blue, 2)); btn.setRolloverIcon(new BoxIcon(Color.cyan, 3)); btn.setPressedIcon(new BoxIcon(Color.yellow, 4)); btn.setHorizontalTextPosition(JButton.LEFT); btn.setBorder(BorderFactory.createEtchedBorder()); btn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Button was pressed."); }//from w w w. jav a2s .com }); add(btn); }
From source file:ihm.PaneTab.java
public PaneTab() { super();//w w w. ja v a2 s. com //super.setPreferredSize(new Dimension(600,600)); //mainActivity.setPreferredSize(new Dimension(600,600)); mainActivity.setBackground(Color.GREEN); tabPane1 = new JPanel(); tabPane2 = new JPanel(); tabPane3 = new JPanel(); tabPane1.setBackground(Color.BLUE); tabPane2.setBackground(Color.CYAN); tabPane3.setBackground(Color.MAGENTA); mainActivity.add(tabPane1); mainActivity.setTitleAt(0, "Ram"); mainActivity.add(tabPane2); mainActivity.setTitleAt(1, "Rem"); mainActivity.add(tabPane3); mainActivity.setTitleAt(2, "Emilia"); DataList test = new DataList(); //mainActivity.add("Ram",tabPane1); //mainActivity.add("Rem",tabPane2); //mainActivity.add("Emilia",tabPane3); super.add(mainActivity); super.setVisible(true); }