List of usage examples for java.awt Color Color
public Color(float r, float g, float b, float a)
From source file:ColorUtil.java
public static Color blend(Color c1, Color c2, double v) { double v2 = 1 - v; return c1 == null ? (c2 == null ? null : c2) : c2 == null ? c1// w ww . j a v a 2 s . c o m : new Color(Math.min(255, (int) (c1.getRed() * v2 + c2.getRed() * v)), Math.min(255, (int) (c1.getGreen() * v2 + c2.getGreen() * v)), Math.min(255, (int) (c1.getBlue() * v2 + c2.getBlue() * v)), Math.min(255, (int) (c1.getAlpha() * v2 + c2.getAlpha() * v))); }
From source file:org.jfree.chart.demo.XYPolygonAnnotationDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createScatterPlot("XYPolygonAnnotationDemo1", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); XYPolygonAnnotation xypolygonannotation = new XYPolygonAnnotation( new double[] { 2D, 5D, 2.5D, 8D, 3D, 5D, 2.5D, 2D }, null, null, new Color(200, 200, 255, 100)); xypolygonannotation.setToolTipText("Target Zone"); xylineandshaperenderer.addAnnotation(xypolygonannotation, Layer.BACKGROUND); return jfreechart; }
From source file:org.quickserver.net.qsadmin.plugin.stats.MeterChart.java
public MeterChart(String title) { data = new DefaultValueDataset(0.0); meterplot = new MeterPlot(data); range = new Range(0, 20000); bgColor = new Color(238, 238, 230, 255); meterplot.setRange(range);/*w w w . j a va 2 s . c o m*/ meterplot.setNormalRange(new Range(0, 4000)); meterplot.setWarningRange(new Range(4000, 9000)); meterplot.setCriticalRange(new Range(9000, 20000)); meterplot.setUnits(""); meterplot.setDrawBorder(false); meterplot.setInsets(new Insets(2, 2, 2, 2)); meterchart = new JFreeChart(title + " Meter", JFreeChart.DEFAULT_TITLE_FONT, meterplot, false); meterchart.setBackgroundPaint(bgColor); panelMeter = new ChartPanel(meterchart); setLayout(new BorderLayout()); add(panelMeter, BorderLayout.CENTER); }
From source file:Commander.Main.java
/** * Creates new form Main/*from ww w .j a va 2 s. c o m*/ */ public Main(java.awt.Frame parent, boolean modal) { super(parent, modal); //Set tranparant Color transparant = new Color(0, 0, 0, 0); setUndecorated(true); getRootPane().setOpaque(false); getContentPane().setBackground(transparant); setBackground(transparant); initComponents(); //Set components transparant transparant = new Color(0, 0, 0, 1); txtCommand.setBackground(transparant); txtCommand.setForeground(Color.GREEN); txtCommand.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0, 150))); jScrollPane1.getViewport().setBackground(transparant); jScrollPane1.getViewport().setOpaque(false); txtError.setBackground(transparant); txtError.setForeground(Color.RED); txtError.setEditable(false); txtError.setFocusable(false); jScrollPane1.setVisible(false); setAlwaysOnTop(true); pack(); Rectangle screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); int width = getPreferredSize().width; int height = getPreferredSize().height; setLocation(screen.width - width - 20, screen.height - height - 20); txtCommand.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { if (jScrollPane1.isVisible()) { jScrollPane1.setVisible(false); } } @Override public void removeUpdate(DocumentEvent e) { if (jScrollPane1.isVisible()) { jScrollPane1.setVisible(false); } } @Override public void changedUpdate(DocumentEvent e) { //Not supported } }); String home = System.getProperty("user.home"); defaultLocations[0] = home + "/Documents"; defaultLocations[1] = home + "/Pictures"; defaultLocations[2] = home + "/Downloads"; defaultLocations[3] = home + "/Music"; // run("Casino.jar", new ArrayList<>()); }
From source file:UI.MainViewPanel.java
public ChartPanel getPanel1(Metric1 m1) { int totalRiskCount = m1.totalCriticalCount + m1.totalHighCount + m1.totalLowCount + m1.totalMediumCount; String[][] risks = new String[totalRiskCount][3]; PieChart pieChart = new PieChart(m1.totalCriticalCount, m1.totalHighCount, m1.totalMediumCount, m1.totalLowCount, "", risks, true); ChartPanel thisChart = pieChart.drawPieChart(); thisChart.setBackground(Color.white); JFreeChart chart = thisChart.getChart(); chart.setBackgroundPaint(new Color(0, 0, 0, 0)); Plot plot = chart.getPlot();//from w w w . ja va 2s . co m plot.setBackgroundPaint(chartBackgroundColor); return thisChart; }
From source file:eu.esdihumboldt.hale.ui.views.styledmap.tool.InstanceTool.java
/** * Default constructor/*from ww w.java2 s . com*/ */ public InstanceTool() { BoxRenderer renderer = new BoxRenderer(); renderer.setBackColor(new Color(0, 255, 255, 50)); renderer.setBorderColor(new Color(0, 255, 255, 255)); setRenderer(renderer); }
From source file:be.ugent.maf.cellmissy.gui.view.renderer.jfreechart.CompassRenderer.java
@Override public void drawSeries(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, PolarPlot plot, XYDataset dataset, int seriesIndex) { // compute the right color for the paint int length = GuiUtils.getAvailableColors().length; Color color = GuiUtils.getAvailableColors()[index % length]; // get all the data points int numPoints = dataset.getItemCount(seriesIndex); // set STroke and Paint of the graphics g2.setStroke(new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); g2.setPaint(new Color(color.getRed(), color.getGreen(), color.getBlue(), 175)); // iterate through the points of the dataset for (int i = 0; i < numPoints; i++) { double theta = dataset.getXValue(seriesIndex, i); // the angle at the center double radius = dataset.getYValue(seriesIndex, i); // the frequency Point p0 = plot.translateToJava2D(0, 0, plot.getAxis(), dataArea); Point p1 = plot.translateToJava2D(theta, radius, plot.getAxis(), dataArea); Line2D line = new Line2D.Double(p0, p1); g2.draw(line);/*from w ww . j av a 2 s . c o m*/ } }
From source file:Main.java
@Override protected void paintComponent(Graphics g) { int width = this.getWidth(); int height = this.getHeight(); float startPointX = 0.0f; float startPointY = 0.0f; float endPointX = width; float endPointY = 0.0f; Color startColor = new Color(red, green, blue, 255); Color endColor = new Color(red, green, blue, 0); Paint paint = new GradientPaint(startPointX, startPointY, startColor, endPointX, endPointY, endColor); Graphics2D g2D = (Graphics2D) g; g2D.setPaint(paint);//w ww.j a va2 s .com g2D.fillRect(0, 0, width, height); }
From source file:com.smash.revolance.ui.model.helper.ImageHelper.java
public static BufferedImage eraseRect(BufferedImage image, int x, int y, int w, int h, double xScale, double yScale) { x = (int) (x * xScale); w = (int) (w * xScale); y = (int) (y * yScale); h = (int) (h * yScale); Graphics2D g = image.createGraphics(); g.setColor(new Color(0, 0, 0, 0)); g.fillRect(x, y, w, h);//from ww w . j a v a 2s .c o m g.dispose(); return image; }
From source file:org.jfree.chart.demo.CategoryMarkerDemo2.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createLineChart("Category Marker Demo 2", "Category", "Count", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer(); lineandshaperenderer.setSeriesShapesVisible(0, true); lineandshaperenderer.setDrawOutlines(true); lineandshaperenderer.setUseFillPaint(true); lineandshaperenderer.setBaseFillPaint(Color.white); CategoryMarker categorymarker = new CategoryMarker("Category 4", new Color(0, 0, 255, 25), new BasicStroke(1.0F)); categorymarker.setDrawAsLine(false); categorymarker.setAlpha(1.0F);/* w w w .j av a 2 s. c o m*/ categorymarker.setLabel("Marker Label"); categorymarker.setLabelFont(new Font("Dialog", 0, 11)); categorymarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); categorymarker.setLabelOffset(new RectangleInsets(2D, 5D, 2D, 5D)); categoryplot.addDomainMarker(categorymarker, Layer.BACKGROUND); return jfreechart; }