List of usage examples for java.awt Color RGBtoHSB
public static float[] RGBtoHSB(int r, int g, int b, float[] hsbvals)
From source file:osh.comdriver.simulation.cruisecontrol.ScheduleDrawer.java
/** * Creates a chart./* ww w .j a v a2 s. co m*/ * * @param dataset1 a dataset. * @return A chart. */ private static JFreeChart createChart(XYDataset dataset1, //power XYDataset dataset2, //costs XYDataset dataset3, long time) { JFreeChart chart = ChartFactory.createTimeSeriesChart("schedule", // title "time", // x-axis label "power", // y-axis label dataset1, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis axis1 = new NumberAxis("power"); NumberAxis axis2 = new NumberAxis("costs"); axis1.setAutoRangeIncludesZero(true); axis1.setUpperBound(5000); axis1.setLowerBound(-5000); axis2.setAutoRangeIncludesZero(true); axis2.setUpperBound(50); axis2.setLowerBound(0); plot.setRangeAxis(0, axis1); plot.setRangeAxis(1, axis2); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); plot.setDataset(2, dataset3); plot.mapDatasetToRangeAxis(2, 0); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); //TODO: SHADOWS OFF final StandardXYItemRenderer r1 = new StandardXYItemRenderer(); final StandardXYItemRenderer r2 = new StandardXYItemRenderer(); final StandardXYItemRenderer r3 = new StandardXYItemRenderer(); final StandardXYItemRenderer r4 = new StandardXYItemRenderer(); plot.setRenderer(0, r1); plot.setRenderer(1, r2); plot.setRenderer(2, r3); plot.setRenderer(3, r4); int numberOfSeries = 0; numberOfSeries += dataset1.getSeriesCount(); numberOfSeries += dataset2.getSeriesCount(); numberOfSeries += dataset3.getSeriesCount(); Color[] color = new Color[numberOfSeries]; for (int i = 0; i < numberOfSeries / 2; i++) { color[i] = Color.getHSBColor(i * 1.0f / (numberOfSeries / 2), 1.0f, 1.0f); } int i = 0; for (int j = 0; j < dataset1.getSeriesCount() / 2; j++) { float[] rgbcolor = Color.RGBtoHSB(color[i].getRed(), color[i].getGreen(), color[i].getBlue(), null); plot.getRendererForDataset(dataset1).setSeriesPaint(2 * j, Color.getHSBColor(rgbcolor[0], 1.0f, 1.0f)); plot.getRendererForDataset(dataset1).setSeriesPaint(2 * j + 1, Color.getHSBColor(rgbcolor[0], 1.0f, 0.6f)); i++; } for (int j = 0; j < dataset2.getSeriesCount() / 2; j++) { float[] rgbcolor = Color.RGBtoHSB(color[i].getRed(), color[i].getGreen(), color[i].getBlue(), null); plot.getRendererForDataset(dataset2).setSeriesPaint(2 * j, Color.getHSBColor(rgbcolor[0], 1.0f, 1.0f)); plot.getRendererForDataset(dataset2).setSeriesPaint(2 * j + 1, Color.getHSBColor(rgbcolor[0], 1.0f, 0.6f)); i++; } for (int j = 0; j < dataset3.getSeriesCount() / 2; j++) { float[] rgbcolor = Color.RGBtoHSB(color[i].getRed(), color[i].getGreen(), color[i].getBlue(), null); plot.getRendererForDataset(dataset3).setSeriesPaint(2 * j, Color.getHSBColor(rgbcolor[0], 1.0f, 1.0f)); plot.getRendererForDataset(dataset3).setSeriesPaint(2 * j + 1, Color.getHSBColor(rgbcolor[0], 1.0f, 0.6f)); i++; } // NOW line double upperBound = plot.getRangeAxis(1).getUpperBound(); double lowerBound = plot.getRangeAxis(1).getLowerBound(); XYSeries nowLine = new XYSeries("now"); nowLine.add(time * 1000, lowerBound); nowLine.add(time * 1000, upperBound); XYSeriesCollection nowColl = new XYSeriesCollection(); //power axis nowColl.addSeries(nowLine); XYDataset nowSet = nowColl; plot.setDataset(3, nowSet); plot.mapDatasetToRangeAxis(3, 1); plot.getRendererForDataset(nowSet).setSeriesPaint(0, Color.DARK_GRAY); plot.getRendererForDataset(nowSet).setSeriesStroke(0, (Stroke) new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 6.0f }, 0.0f)); plot.setDomainAxis(new DateAxis()); plot.getDomainAxis().setAutoRange(false); long begin = (time / 86400) * 86400 * 1000; //beginning of day long end = begin + 86400 * 2 * 1000; plot.getDomainAxis().setRange(begin, end); return chart; }
From source file:gdsc.utils.HSB_Picker.java
private void addValue(ImageProcessor ip, Point p) { int[] iArray = new int[3]; float[] hsbvals = new float[3]; int width = sampleSlider.getValue(); int limit = width * width; for (int y = -width; y <= width; y++) { for (int x = -width; x <= width; x++) { if (x * x + y * y > limit) continue; ip.getPixel(x + p.x, y + p.y, iArray); Color.RGBtoHSB(iArray[0], iArray[1], iArray[2], hsbvals); for (int i = 0; i < 3; i++) stats[i].addValue(hsbvals[i]); }//from w ww.j ava2 s.co m } updateDisplayedStatistics(); }
From source file:it.smartcommunitylab.parking.management.web.manager.MarkerIconStorage.java
private static float[] getHSBArray(int rgb) { int[] rgbArr = getRGBArray(rgb); return Color.RGBtoHSB(rgbArr[RED], rgbArr[GREEN], rgbArr[BLUE], null); }
From source file:edu.umn.cs.spatialHadoop.visualization.FrequencyMap.java
public void setGradientInfor(Color color1, Color color2, GradientType gradientType) { this.colors = new Color[] { color1, color2 }; this.hues = new float[colors.length]; this.saturations = new float[colors.length]; this.brightnesses = new float[colors.length]; for (int i = 0; i < colors.length; i++) { float[] hsbvals = new float[3]; Color.RGBtoHSB(colors[i].getRed(), colors[i].getGreen(), colors[i].getBlue(), hsbvals); hues[i] = hsbvals[0];/*from www. j av a2 s. c o m*/ saturations[i] = hsbvals[1]; brightnesses[i] = hsbvals[2]; } this.gradientType = gradientType; }
From source file:edu.umn.cs.spatialHadoop.nasa.HDFRasterLayer.java
public void setGradientInfo(Color color1, Color color2, GradientType gradientType) { this.colors = new Color[] { color1, color2 }; this.hues = new float[colors.length]; this.saturations = new float[colors.length]; this.brightnesses = new float[colors.length]; for (int i = 0; i < colors.length; i++) { float[] hsbvals = new float[3]; Color.RGBtoHSB(colors[i].getRed(), colors[i].getGreen(), colors[i].getBlue(), hsbvals); hues[i] = hsbvals[0];/*from w w w . ja v a 2 s . c om*/ saturations[i] = hsbvals[1]; brightnesses[i] = hsbvals[2]; } this.gradientType = gradientType; }
From source file:com.controlj.addon.gwttree.server.OpaqueBarRenderer3D.java
private Color getTopLight(Color primary) { float hsbVals[] = new float[3]; Color.RGBtoHSB(primary.getRed(), primary.getGreen(), primary.getBlue(), hsbVals); hsbVals[1] = 0.3f;/*from ww w . j a v a2 s.c om*/ hsbVals[2] = 0.97f; return Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2]); }
From source file:com.controlj.addon.gwttree.server.OpaqueBarRenderer3D.java
private Color getTopDark(Color primary) { float hsbVals[] = new float[3]; Color.RGBtoHSB(primary.getRed(), primary.getGreen(), primary.getBlue(), hsbVals); hsbVals[1] = 0.9f;/*from w w w . ja v a 2 s .com*/ hsbVals[2] = 0.6f; return Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2]); }
From source file:com.controlj.addon.gwttree.server.OpaqueBarRenderer3D.java
private Color getFrontDark(Color primary) { float hsbVals[] = new float[3]; Color.RGBtoHSB(primary.getRed(), primary.getGreen(), primary.getBlue(), hsbVals); hsbVals[1] = 1.0f;//from w w w .j a v a2s .c om hsbVals[2] = 0.5f; return Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2]); }
From source file:com.controlj.addon.gwttree.server.OpaqueBarRenderer3D.java
private Color getSideLight(Color primary) { float hsbVals[] = new float[3]; Color.RGBtoHSB(primary.getRed(), primary.getGreen(), primary.getBlue(), hsbVals); hsbVals[1] = .6f;/*from w w w . j av a 2 s . c om*/ hsbVals[2] = 0.6f; return Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2]); }
From source file:com.controlj.addon.gwttree.server.OpaqueBarRenderer3D.java
private Color getSideDark(Color primary) { float hsbVals[] = new float[3]; Color.RGBtoHSB(primary.getRed(), primary.getGreen(), primary.getBlue(), hsbVals); hsbVals[1] = 1.0f;/*from w w w. ja v a 2 s.co m*/ hsbVals[2] = 0.3f; return Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2]); }