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:ta4jexamples.indicators.CandlestickChart.java
public static void main(String[] args) { /**// ww w. j a v a2 s . c o m * Getting time series */ TimeSeries series = CsvTradesLoader.loadBitstampSeries(); /** * Creating the OHLC dataset */ OHLCDataset ohlcDataset = createOHLCDataset(series); /** * Creating the additional dataset */ TimeSeriesCollection xyDataset = createAdditionalDataset(series); /** * Creating the chart */ JFreeChart chart = ChartFactory.createCandlestickChart("Bitstamp BTC price", "Time", "USD", ohlcDataset, true); // Candlestick rendering CandlestickRenderer renderer = new CandlestickRenderer(); renderer.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST); XYPlot plot = chart.getXYPlot(); plot.setRenderer(renderer); // Additional dataset int index = 1; plot.setDataset(index, xyDataset); plot.mapDatasetToRangeAxis(index, 0); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false); renderer2.setSeriesPaint(index, Color.blue); plot.setRenderer(index, renderer2); // Misc plot.setRangeGridlinePaint(Color.lightGray); plot.setBackgroundPaint(Color.white); NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis(); numberAxis.setAutoRangeIncludesZero(false); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); /** * Displaying the chart */ displayChart(chart); }
From source file:com.oculusinfo.ml.spark.unsupervised.TestDPMeans.java
/** * @param args/* ww w . ja v a 2 s. c o 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 a v a 2 s . c o 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:ColorSink.java
/** This is a simple test program for ColorSource and ColorSink */ public static void main(String[] args) { // Create a window JFrame f = new JFrame("ColorSourceTest"); f.getContentPane().setLayout(new BorderLayout()); // Add some ColorSources JPanel panel = new JPanel(); f.getContentPane().add(panel, BorderLayout.NORTH); panel.add(new ColorSource(Color.yellow)); panel.add(new ColorSource(Color.pink)); panel.add(new ColorSource(Color.white)); panel.add(new ColorSource(Color.gray)); // Add a ColorSink ColorSink sink = new ColorSink(); f.getContentPane().add(sink, BorderLayout.CENTER); // Pop it all up f.setSize(400, 300);//from w w w. jav a 2 s . c o m f.show(); }
From source file:com.oculusinfo.ml.spark.unsupervised.TestKMeans.java
/** * @param args// w ww. j a v a2s .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:lu.lippmann.cdb.weka.SilhouetteUtil.java
public static void main(String[] args) throws Exception { final Instances ds = WekaDataAccessUtil.loadInstancesFromARFFOrCSVFile( //new File("./samples/csv/uci/zoo.csv")); //new File("./samples/arff/UCI/cmc.arff")); //new File("./samples/csv/direct-marketing-bank-reduced.csv")); //new File("./samples/csv/bank.csv")); //new File("./samples/csv/preswissroll.csv")); new File("./samples/csv/iris.csv")); //new File("./samples/csv/lines.csv")); //new File("./samples/csv/pima.csv")); //new File("./samples/csv/isolet.csv")); //new File("./samples/csv/iris.csv")); final SimpleKMeans kmeans = WekaMachineLearningUtil.buildSimpleKMeansClustererWithK(3); final WekaClusteringResult cr = WekaMachineLearningUtil.computeClusters(kmeans, ds); final JFrame mainFrame = new JFrame(); mainFrame.setTitle("Silhouette plot"); mainFrame.setBackground(Color.WHITE); LogoHelper.setLogo(mainFrame);// w ww . java2s. co m mainFrame.getContentPane().setLayout(new BorderLayout()); mainFrame.getContentPane().add(buildSilhouettePanel(ds, cr), BorderLayout.CENTER); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainFrame.setSize(1200, 900); mainFrame.setVisible(true); }
From source file:Main.java
public static JList getListBarChart() { JList list = new JList(); list.setVisibleRowCount(-1);//from w w w. j a va 2s . c o m list.setBackground(Color.WHITE); return list; }
From source file:Main.java
public static boolean verifyIntegerTextField(JTextField field) { try {/* w ww . j a v a 2 s.c o m*/ Integer.valueOf(field.getText()); field.setBackground(Color.WHITE); } catch (NumberFormatException e) { field.setBackground(Color.LIGHT_GRAY); return false; } return true; }
From source file:Main.java
public static Color toColor(Node n) { if (!n.getNodeName().equals("color")) { throw new IllegalArgumentException(n.getNodeName()); }//from w ww . j a va2s. c om 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:Main.java
private static BufferedImage map(int sizeX, int sizeY) { final BufferedImage res = new BufferedImage(sizeX, sizeY, BufferedImage.TYPE_INT_RGB); for (int x = 0; x < sizeX; x++) { for (int y = 0; y < sizeY; y++) { res.setRGB(x, y, Color.WHITE.getRGB()); }//from w ww.j a v a2s .c o m } return res; }