List of usage examples for java.awt Color Color
public Color(float r, float g, float b, float a)
From source file:org.pathvisio.cytoscape.superpathways.PieGenerator.java
public void generatePie(int number) { // Defining the dataset DefaultPieDataset dataset = new DefaultPieDataset(); for (int i = 0; i < number; i++) { String temp = String.valueOf(i); dataset.setValue(temp, 10);//from w w w.j a v a 2 s . c o m } // Defining the chart JFreeChart chart = ChartFactory.createPieChart("", dataset, false, false, false); // Defining the chartPanel //final ChartPanel chartPanel = new ChartPanel(chart); //chartPanel.setPreferredSize(new java.awt.Dimension(350, 350)); //setContentPane(chartPanel); // Defining the plot PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelGenerator(null); plot.setInteriorGap(0.0); //add the following two lines to make the background transparent chart.setBackgroundPaint(new Color(255, 255, 255, 0)); plot.setBackgroundPaint(new Color(255, 255, 255, 0)); //plot.setBackgroundAlpha(0.0f); // Specify the colors here PieRenderer renderer = new PieRenderer(colors); renderer.setColor(plot, dataset); try { // This will create a PNG image ChartUtilities.saveChartAsPNG(new File(imageLocation + "chart.png"), chart, 280, 280, null, true, // encodeAlpha 0); } catch (Exception e) { System.out.println("Exception while creating the chart"); } }
From source file:org.matsim.contrib.drt.analysis.DensityScatterPlots.java
public static JFreeChart createPlot(String title, String xAxisLabel, String yAxisLabel, XYSeries series, Pair<Double, Double> lineCoeffs) { XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series);/*from w w w. j a v a 2 s.c o m*/ double maxValue = Math.max(series.getMaxX(), series.getMaxY()); // y=x XYSeries lineXY = new XYSeries("y = x"); lineXY.add(0, 0); lineXY.add(maxValue, maxValue); dataset.addSeries(lineXY); if (lineCoeffs != null) { // a*y+b=x double a = lineCoeffs.getLeft(); double b = lineCoeffs.getRight(); String namePrefix = a == 0 ? "" : (a + " * y + "); XYSeries lineABXY = new XYSeries(namePrefix + b + " = x"); lineABXY.add(b, 0); if (a == 0) { lineABXY.add(b, maxValue); } else { lineABXY.add(maxValue, (maxValue - b) / a); } dataset.addSeries(lineABXY); } final JFreeChart chart = ChartFactory.createScatterPlot(title, xAxisLabel, yAxisLabel, dataset); XYPlot xyPlot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyPlot.getRenderer(0); renderer.setSeriesPaint(0, new Color(255, 0, 0, 50)); renderer.setSeriesShape(0, CIRCLE); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesVisibleInLegend(0, false); for (int i = 1; i < dataset.getSeriesCount(); i++) { renderer.setSeriesPaint(i, new Color(0, 0, 0)); renderer.setSeriesLinesVisible(i, true); renderer.setSeriesShapesVisible(i, false); renderer.setSeriesVisibleInLegend(i, false); } xyPlot.getDomainAxis().setUpperBound(maxValue); xyPlot.getRangeAxis().setUpperBound(maxValue); xyPlot.getDomainAxis().setLowerBound(0); xyPlot.getRangeAxis().setLowerBound(0); return chart; }
From source file:Main.java
@Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Graphics2D g2 = (Graphics2D) g; int bottomLineY = height - thickness - shadowPad; RoundRectangle2D.Double bubble = new RoundRectangle2D.Double(0 + strokePad, 0 + strokePad, width - thickness - shadowPad, bottomLineY, radius, radius); Area area = new Area(bubble); g2.setRenderingHints(hints);/* w w w . jav a2 s . c o m*/ g2.setColor(color); g2.setStroke(stroke); g2.draw(area); Area shadowArea = new Area(new Rectangle(0, 0, width, height)); shadowArea.subtract(area); g.setClip(shadowArea); Color shadow = new Color(color.getRed(), color.getGreen(), color.getBlue(), 128); g2.setColor(shadow); g2.translate(shadowPad, shadowPad); g2.draw(area); }
From source file:net.pms.newgui.Splash.java
/** * Show the splash screen before the application GUI starts. * <p>/*from ww w .j a v a 2 s.co m*/ * When the GUI started call the {@code .dispose()} to release all resources used by this * {@code Splash} class and return all memory they consume to the OS. * @return */ public Splash(PmsConfiguration config) { this.configuration = config; if (!configuration.isShowSplashScreen()) { return; } img = new ImageIcon(getClass().getResource("/resources/images/splash.png")); imglabel = new JLabel(img); imglabel.setBounds(0, 0, img.getIconWidth(), img.getIconHeight()); setSize(imglabel.getWidth(), imglabel.getHeight()); setUndecorated(true); setBackground(new Color(1.0f, 1.0f, 1.0f, 0.0f)); setLocationRelativeTo(null); setLayout(null); add(imglabel); imglabel.addMouseListener(this); if (System.getProperty("console") == null) { setVisible(true); } }
From source file:com.sciaps.common.RegionMarkerItem.java
private void createMarker() { final Color c = new Color(8, 255, 8, 63); marker_ = new IntervalMarker(min_, max_, c, new BasicStroke(2.0f), null, null, 1.0f); String[] tmp = name_.split("-"); marker_.setLabel(tmp[0]);/* w w w . j ava2 s .co m*/ marker_.setLabelPaint(Color.blue); marker_.setLabelFont(new java.awt.Font("Tahoma", 1, 14)); marker_.setLabelOffset(new RectangleInsets(50, 10, 10, 20)); }
From source file:net.sf.maltcms.chromaui.charts.ChartCustomizer.java
/** * * @param color/*from w ww.j a v a 2 s.c o m*/ * @param alpha * @return */ public static Color withAlpha(Color color, float alpha) { Color ca = new Color(color.getRed(), color.getGreen(), color.getBlue(), (int) (alpha * 255.0f)); return ca; }
From source file:battleheartlegacybuilder.mainWindow.java
/** * Creates new form mainWindow//w w w . jav a2 s .c om */ public mainWindow() { createInGameClassesFromJson(); initComponents(); fillLabelLists(); buildGridskills(); fillComboClasses(); this.pnl_skills.setBackground(new Color(1.0f, 1.0f, 1.0f, 0.0f)); this.pnl_passives.setBackground(new Color(1.0f, 1.0f, 1.0f, 0.0f)); this.pnl_skillsGrids.setBackground(new Color(1.0f, 1.0f, 1.0f, 0.0f)); hideSkillsPanel(); }
From source file:org.jfree.chart.demo.CompassFormatDemo1.java
private static JFreeChart createChart() { XYDataset xydataset = createDirectionDataset(600); JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Time", "Date", "Direction", xydataset, true, true, false);/*from ww w. j av a 2s . co m*/ XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.getDomainAxis().setLowerMargin(0.0D); xyplot.getDomainAxis().setUpperMargin(0.0D); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); TickUnits tickunits = new TickUnits(); tickunits.add(new NumberTickUnit(180D, new CompassFormat())); tickunits.add(new NumberTickUnit(90D, new CompassFormat())); tickunits.add(new NumberTickUnit(45D, new CompassFormat())); tickunits.add(new NumberTickUnit(22.5D, new CompassFormat())); numberaxis.setStandardTickUnits(tickunits); xyplot.setRangeAxis(numberaxis); XYAreaRenderer xyarearenderer = new XYAreaRenderer(); NumberAxis numberaxis1 = new NumberAxis("Force"); numberaxis1.setRange(0.0D, 12D); xyarearenderer.setSeriesPaint(0, new Color(0, 0, 255, 128)); xyplot.setDataset(1, createForceDataset(600)); xyplot.setRenderer(1, xyarearenderer); xyplot.setRangeAxis(1, numberaxis1); xyplot.mapDatasetToRangeAxis(1, 1); return jfreechart; }
From source file:Layers.java
public void paint(Graphics g) { Color c1 = new Color(200, 100, 100, 50); // r, g, b, a Color c2 = new Color(100, 200, 000, 128); Color c3 = new Color(100, 200, 000, 255); g.setColor(c1);/*from w w w. jav a 2s . c o m*/ g.fillRect(0, 0, width / 2, height / 2); g.setColor(c2); g.fillRect(width / 4, height / 4, width / 2, height / 2); g.setColor(c3); g.fillRect(width / 3, height / 3, width / 4, height / 4); }
From source file:net.sourceforge.entrainer.socket.FlashColour.java
/** * Gets the color./*from w w w .java2 s .co m*/ * * @return the color */ @JsonIgnore public Color getColor() { return new Color(getRed(), getGreen(), getBlue(), getAlpha()); }