List of usage examples for java.awt Color Color
public Color(float r, float g, float b, float a)
From source file:Main.java
public static Color adjust2(Color original, double value, int maximumrange) { if (value > 1) value = 1;/*w ww . j a v a 2s.c om*/ if (value < 0) value = 0; int r = original.getRed(); int g = original.getGreen(); int b = original.getBlue(); double nah = value * maximumrange; r += (int) nah; g += (int) nah; b += (int) nah; r = colorSnap(r); g = colorSnap(g); b = colorSnap(b); return new Color(r, g, b, original.getAlpha()); }
From source file:ColorUtilities.java
public static Color blend(Color c0, Color c1) { double totalAlpha = c0.getAlpha() + c1.getAlpha(); double weight0 = c0.getAlpha() / totalAlpha; double weight1 = c1.getAlpha() / totalAlpha; double r = weight0 * c0.getRed() + weight1 * c1.getRed(); double g = weight0 * c0.getGreen() + weight1 * c1.getGreen(); double b = weight0 * c0.getBlue() + weight1 * c1.getBlue(); double a = Math.max(c0.getAlpha(), c1.getAlpha()); return new Color((int) r, (int) g, (int) b, (int) a); }
From source file:Main.java
/** * Adjusts a preset color to a roughness value. * @param orig The original color// ww w . j ava 2s. c om * @param a The roughness value. * @param maxmin The maximum and minimum differential. * @return A color that has been adjust to match the original and roughness. */ public static Color adjust(Color orig, double a, int maxmin) { if (a > 1) a = 1; if (a < 0) a = 0; int r = orig.getRed(); int g = orig.getGreen(); int b = orig.getBlue(); r = (int) (r - (a * maxmin)); g = (int) (g - (a * maxmin)); b = (int) (b - (a * maxmin)); r = colorSnap(r); g = colorSnap(g); b = colorSnap(b); return new Color(r, g, b, orig.getAlpha()); }
From source file:Main.java
/** * Creates a nifty looking inner shadow for the window. * @param width The width of the shadow. * @param height The height of the shadow. * @return The translucent shadow that was created. */// w w w .j a v a 2s .co m public static BufferedImage genInnerShadow(int width, int height) { BufferedImage shadowOuter = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics g = shadowOuter.getGraphics(); Graphics2D g2 = (Graphics2D) g; Point2D center = new Point2D.Float(width / 2, height / 2); float radius = width; Point2D focus = new Point2D.Float(width / 2, height / 2); float[] dist = { 0.0f, 1.0f }; Color[] colors = { new Color(0, 0, 0, 0), new Color(0, 0, 0, 220) }; RadialGradientPaint p = new RadialGradientPaint(center, radius, focus, dist, colors, CycleMethod.NO_CYCLE); g2.setPaint(p); g2.fillRect(0, 0, width, height); return shadowOuter; }
From source file:Main.java
public static Color neighbour(Color c1, Color c2, double f) { return new Color(c1.getRed() + (int) ((c2.getRed() - c1.getRed()) * f), c1.getGreen() + (int) ((c2.getGreen() - c1.getGreen()) * f), c1.getBlue() + (int) ((c2.getBlue() - c1.getBlue()) * f), c1.getAlpha() + (int) ((c2.getAlpha() - c1.getAlpha()) * f)); }
From source file:Main.java
public static void displayEditorPaneWithNoBorderAndTranslucent(JEditorPane editorPane) { editorPane.setOpaque(false);//from w w w . j ava 2s . c om editorPane.setBorder(null); editorPane.setBorder(BorderFactory.createEmptyBorder()); editorPane.setBackground(new Color(0, 0, 0, 0)); }
From source file:org.jfree.chart.demo.MeterChartDemo1.java
private static JFreeChart createChart(ValueDataset valuedataset) { MeterPlot meterplot = new MeterPlot(valuedataset); meterplot.setRange(new Range(0.0D, 60D)); meterplot.addInterval(new MeterInterval("Normal", new Range(0.0D, 35D), Color.lightGray, new BasicStroke(2.0F), new Color(0, 255, 0, 64))); meterplot.addInterval(new MeterInterval("Warning", new Range(35D, 50D), Color.lightGray, new BasicStroke(2.0F), new Color(255, 255, 0, 64))); meterplot.addInterval(new MeterInterval("Critical", new Range(50D, 60D), Color.lightGray, new BasicStroke(2.0F), new Color(255, 0, 0, 128))); meterplot.setNeedlePaint(Color.darkGray); meterplot.setDialBackgroundPaint(Color.white); meterplot.setDialOutlinePaint(Color.gray); meterplot.setDialShape(DialShape.CHORD); meterplot.setMeterAngle(260);/*w w w . ja v a2 s . c om*/ meterplot.setTickLabelsVisible(true); meterplot.setTickLabelFont(new Font("Dialog", 1, 10)); meterplot.setTickLabelPaint(Color.darkGray); meterplot.setTickSize(5D); meterplot.setTickPaint(Color.lightGray); meterplot.setValuePaint(Color.black); meterplot.setValueFont(new Font("Dialog", 1, 14)); JFreeChart jfreechart = new JFreeChart("Meter Chart 1", JFreeChart.DEFAULT_TITLE_FONT, meterplot, true); return jfreechart; }
From source file:org.jfree.chart.demo.GridBandDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createScatterPlot("Grid Band Demo 1", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, false, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setNoDataMessage("NO DATA"); xyplot.setRangeZeroBaselineVisible(true); xyplot.setDomainTickBandPaint(new Color(0, 100, 0, 50)); xyplot.setRangeTickBandPaint(new Color(0, 100, 0, 50)); return jfreechart; }
From source file:org.jfree.chart.demo.MeterChartDemo3.java
private static JFreeChart createChart(String s, ValueDataset valuedataset, DialShape dialshape) { MeterPlot meterplot = new MeterPlot(valuedataset); meterplot.setDialShape(dialshape);/* ww w. j a v a2 s . com*/ meterplot.setRange(new Range(0.0D, 60D)); meterplot.addInterval(new MeterInterval("Normal", new Range(0.0D, 35D), Color.lightGray, new BasicStroke(2.0F), new Color(0, 255, 0, 64))); meterplot.addInterval(new MeterInterval("Warning", new Range(35D, 50D), Color.lightGray, new BasicStroke(2.0F), new Color(255, 255, 0, 64))); meterplot.addInterval(new MeterInterval("Critical", new Range(50D, 60D), Color.lightGray, new BasicStroke(2.0F), new Color(255, 0, 0, 128))); meterplot.setNeedlePaint(Color.darkGray); meterplot.setDialBackgroundPaint(Color.white); meterplot.setDialOutlinePaint(Color.gray); meterplot.setMeterAngle(260); meterplot.setTickLabelsVisible(true); meterplot.setTickLabelFont(new Font("Dialog", 1, 10)); meterplot.setTickLabelPaint(Color.darkGray); meterplot.setTickSize(5D); meterplot.setTickPaint(Color.lightGray); meterplot.setValuePaint(Color.black); meterplot.setValueFont(new Font("Dialog", 1, 14)); JFreeChart jfreechart = new JFreeChart(s, JFreeChart.DEFAULT_TITLE_FONT, meterplot, true); return jfreechart; }
From source file:Main.java
Main() { getRootPane().setGlassPane(new JComponent() { public void paintComponent(Graphics g) { g.setColor(new Color(0, 0, 0, 100)); g.fillRect(0, 0, getWidth(), getHeight()); super.paintComponent(g); }/* w w w . j a va2 s . c om*/ }); JButton popDialog = new JButton("Block Frame"); popDialog.addActionListener(e -> { getRootPane().getGlassPane().setVisible(true); JOptionPane.showMessageDialog(Main.this, "Shady!"); getRootPane().getGlassPane().setVisible(false); }); setContentPane(popDialog); pack(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(350, 180); }