List of usage examples for java.awt Color magenta
Color magenta
To view the source code for java.awt Color magenta.
Click Source Link
From source file:ColorComboBox.java
public static void main(String args[]) { Color colors[] = { Color.black, Color.blue, Color.cyan, Color.darkGray, Color.gray, Color.green, Color.lightGray, Color.magenta, Color.orange, Color.pink, Color.red, Color.white, Color.yellow }; JFrame frame = new JFrame("Color JComboBox"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); final JComboBox comboBox = new JComboBox(colors); comboBox.setMaximumRowCount(5);//from w w w.j a v a2 s . c om comboBox.setEditable(true); comboBox.setRenderer(new ColorCellRenderer()); Color color = (Color) comboBox.getSelectedItem(); ComboBoxEditor editor = new ColorComboBoxEditor(color); comboBox.setEditor(editor); contentPane.add(comboBox, BorderLayout.NORTH); final JLabel label = new JLabel(); label.setOpaque(true); label.setBackground((Color) comboBox.getSelectedItem()); contentPane.add(label, BorderLayout.CENTER); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Color selectedColor = (Color) comboBox.getSelectedItem(); label.setBackground(selectedColor); } }; comboBox.addActionListener(actionListener); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { UIManager.put("ComboBox.background", new ColorUIResource(Color.yellow)); UIManager.put("JTextField.background", new ColorUIResource(Color.yellow)); UIManager.put("ComboBox.selectionBackground", new ColorUIResource(Color.magenta)); UIManager.put("ComboBox.selectionForeground", new ColorUIResource(Color.blue)); new Main();/* w w w . j a va 2s .c om*/ }
From source file:ComboTableCellRenderer.java
public static void main(String args[]) { Color choices[] = { Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN, Color.BLUE, Color.MAGENTA }; ComboTableCellRenderer renderer = new ComboTableCellRenderer(); JComboBox comboBox = new JComboBox(choices); comboBox.setRenderer(renderer);// ww w .j a va 2 s . c o m TableCellEditor editor = new DefaultCellEditor(comboBox); JFrame frame = new JFrame("Editable Color Table"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TableModel model = new ColorTableModel(); JTable table = new JTable(model); TableColumn column = table.getColumnModel().getColumn(1); column.setCellRenderer(renderer); column.setCellEditor(editor); JScrollPane scrollPane = new JScrollPane(table); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(400, 150); frame.setVisible(true); }
From source file:it.iit.genomics.cru.igb.bundles.mi.view.TestJung.java
public static void main(String[] args) { Graph<MoleculeEntry, EdgeInteraction> graph = new SparseMultigraph<>(); MoleculeEntry v1 = new MoleculeEntry("A"); v1.addGeneName("A"); v1.setTaxid("9606"); MoleculeEntry v2 = new MoleculeEntry("B"); v2.addGeneName("b"); v2.setTaxid("9606"); MoleculeEntry v3 = new MoleculeEntry("DNA"); v3.addGeneName("DNA"); v3.setTaxid(MoleculeEntry.TAXID_DNA); EdgeInteraction edge = new EdgeInteraction(true, true, true, "e1"); graph.addEdge(edge, v1, v2, EdgeType.UNDIRECTED); EdgeInteraction edge2 = new EdgeInteraction(false, false, true, "e2"); graph.addEdge(edge2, v1, v3, EdgeType.UNDIRECTED); EdgeInteraction edge3 = new EdgeInteraction(false, false, false, "e3"); graph.addEdge(edge3, v2, v3, EdgeType.UNDIRECTED); // The Layout<V, E> is parameterized by the vertex and edge types Layout<MoleculeEntry, EdgeInteraction> layout = new ISOMLayout(graph); layout.setSize(new Dimension(500, 600)); // sets the initial size of the space // The BasicVisualizationServer<V,E> is parameterized by the edge types VisualizationViewer<MoleculeEntry, EdgeInteraction> vv = new VisualizationViewer<>(layout); vv.setPreferredSize(new Dimension(550, 650)); //Sets the viewing area size vv.setBackground(Color.WHITE); Transformer<MoleculeEntry, Paint> vertexPaint = new Transformer<MoleculeEntry, Paint>() { @Override//from w w w . j ava2s . co m public Paint transform(MoleculeEntry molecule) { switch (molecule.getTaxid()) { case MoleculeEntry.TAXID_DNA: ; case MoleculeEntry.TAXID_RNA: return Color.GREEN; case MoleculeEntry.TAXID_LIGAND: return Color.MAGENTA; default: return Color.GREEN; } } }; Transformer<EdgeInteraction, Paint> edgePaint = new Transformer<EdgeInteraction, Paint>() { @Override public Paint transform(EdgeInteraction interaction) { return interaction.hasStructure ? Color.BLACK : Color.GRAY; } }; final Stroke edgeStroke01 = new BasicStroke(); final float nodeSize = 20; final Stroke edgeStrokeBothContacts = new ShapeStroke(new Shape[] { new Ellipse2D.Float(0, 0, 10, 10) }, nodeSize, true, true); final Stroke edgeStrokeStartContacts = new ShapeStroke(new Shape[] { new Ellipse2D.Float(0, 0, 10, 10) }, nodeSize, true, false); final Stroke edgeStrokeEndContacts = new ShapeStroke(new Shape[] { new Ellipse2D.Float(0, 0, 10, 10) }, nodeSize, false, true); final Stroke edgeStrokeBothContact = new CompoundStroke(edgeStroke01, edgeStrokeBothContacts, CompoundStroke.ADD); final Stroke edgeStrokeStartContact = new CompoundStroke(edgeStroke01, edgeStrokeStartContacts, CompoundStroke.ADD); final Stroke edgeStrokeEndContact = new CompoundStroke(edgeStroke01, edgeStrokeEndContacts, CompoundStroke.ADD); Transformer<EdgeInteraction, Stroke> edgeStrokeTransformer = new Transformer<EdgeInteraction, Stroke>() { @Override public Stroke transform(EdgeInteraction s) { if (s.hasContactsA && s.hasContactsB) { return edgeStrokeBothContact; } if (s.hasContactsA) { return edgeStrokeStartContact; } if (s.hasContactsB) { return edgeStrokeEndContact; } return edgeStroke01; } }; Transformer<MoleculeEntry, String> moleculeLabeller = new Transformer<MoleculeEntry, String>() { @Override public String transform(MoleculeEntry s) { return s.getGeneName(); } }; vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vv.getRenderContext().setEdgeDrawPaintTransformer(edgePaint); vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer); vv.getRenderContext().setVertexLabelTransformer(moleculeLabeller); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR); DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); vv.setGraphMouse(graphMouse); JFrame frame = new JFrame("Network " + "A"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(vv); frame.pack(); frame.setVisible(true); }
From source file:PowerMethod.power_method.java
public static void main(String[] args) { ////////////////////////////////////////////////////// // Edit vals to contain values for matrix A // // Edit vals2 to contain values for initial vector // ////////////////////////////////////////////////////// double[][] vals = { { 3, 4 }, { 3, 1 } }; RealMatrix A = new Array2DRowRealMatrix(vals); double[][] vals2 = { { 1 }, { 1 } }; RealMatrix u = new Array2DRowRealMatrix(vals2); power_object a = power_method(A, u, .1, 7); List<RealMatrix> matrices = genMatrices(); List<trace_det> trace_dets = new ArrayList<>(); double trace; double det;//from www . ja v a 2 s. c o m int iterA; int iterInverseA; for (RealMatrix r : matrices) { MatrixMethods m = new MatrixMethods(r); RealMatrix inverseR = m.inverseMatrix(); power_object largestVal = power_method(r, u, .00005, 100); power_object smallestVal = power_method(inverseR, u, .00005, 100); if (largestVal == null || smallestVal == null) { continue; } trace = m.trace(); det = m.determinant(); iterA = largestVal.getNumN(); iterInverseA = smallestVal.getNumN(); trace_det td = new trace_det(trace, det, iterA, iterInverseA); trace_dets.add(td); } JFreeChart chart = ChartFactory.createXYLineChart("Trace vs. Determinant for Power Method", "Determinant", "Trace", createDataSetA(trace_dets), PlotOrientation.VERTICAL, true, true, false); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(560, 367)); final XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.BLUE); renderer.setSeriesPaint(2, Color.GREEN); renderer.setSeriesPaint(3, Color.BLACK); renderer.setSeriesPaint(4, Color.YELLOW); renderer.setSeriesPaint(5, Color.PINK); renderer.setSeriesPaint(6, Color.ORANGE); renderer.setSeriesPaint(7, Color.GRAY); renderer.setSeriesPaint(8, Color.MAGENTA); renderer.setSeriesPaint(9, Color.LIGHT_GRAY); renderer.setSeriesPaint(10, Color.DARK_GRAY); //renderer.setSeriesStroke( 0 , new BasicStroke( 3.0f ) ); //renderer.setSeriesStroke( 1 , new BasicStroke( 2.0f ) ); plot.setRenderer(renderer); ChartFrame frame = new ChartFrame("Power Method", chart); frame.pack(); frame.setVisible(true); JFreeChart inverseChart = ChartFactory.createXYLineChart("Trace vs. Determinant for Inverse Power Method", "Determinant", "Trace", createDataSetAInverse(trace_dets), PlotOrientation.VERTICAL, true, true, false); ChartPanel inverseChartPanel = new ChartPanel(inverseChart); inverseChartPanel.setPreferredSize(new java.awt.Dimension(560, 367)); final XYPlot inversePlot = inverseChart.getXYPlot(); XYLineAndShapeRenderer inverseRenderer = new XYLineAndShapeRenderer(); inverseRenderer.setSeriesPaint(0, Color.RED); inverseRenderer.setSeriesPaint(1, Color.BLUE); inverseRenderer.setSeriesPaint(2, Color.GREEN); inverseRenderer.setSeriesPaint(3, Color.BLACK); inverseRenderer.setSeriesPaint(4, Color.YELLOW); inverseRenderer.setSeriesPaint(5, Color.PINK); inverseRenderer.setSeriesPaint(6, Color.ORANGE); inverseRenderer.setSeriesPaint(7, Color.GRAY); inverseRenderer.setSeriesPaint(8, Color.MAGENTA); inverseRenderer.setSeriesPaint(9, Color.LIGHT_GRAY); inverseRenderer.setSeriesPaint(10, Color.DARK_GRAY); inversePlot.setRenderer(renderer); ChartFrame inverseFrame = new ChartFrame("Power Method", inverseChart); inverseFrame.pack(); inverseFrame.setVisible(true); }
From source file:com.oculusinfo.ml.spark.unsupervised.TestDPMeans.java
/** * @param args/*from ww w . java 2s . 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()); 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//w ww . j a va 2 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/*from w ww .j a va 2s. 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 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:ColorBlocks.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Dimension d = getSize();// w ww.j ava2 s . co m 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:RoundGradientPaintFill.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; RoundRectangle2D r = new RoundRectangle2D.Float(5, 5, 150, 150, 25, 25); RoundGradientPaint rgp = new RoundGradientPaint(75, 75, Color.magenta, new Point2D.Double(0, 85), Color.blue);//from www . j a v a 2 s.c o m g2.setPaint(rgp); g2.fill(r); }