List of usage examples for java.awt Color getRed
public int getRed()
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;/*w ww . j a va 2s . 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 getSideDark(Color primary) { float hsbVals[] = new float[3]; Color.RGBtoHSB(primary.getRed(), primary.getGreen(), primary.getBlue(), hsbVals); hsbVals[1] = 1.0f;// ww w . j a va 2 s . co m hsbVals[2] = 0.3f; return Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2]); }
From source file:gr.iti.mklab.reveal.forensics.util.Util.java
public static float[][][] getResizedImageDifference(BufferedImage image1, BufferedImage image2, int newWidth, int newHeight) { // Calculate the subsampled difference between two buffered images float[][][] outputMap = new float[3][newWidth][newHeight]; float widthModifier = (float) image1.getWidth() / newWidth; float heightModifier = (float) image1.getHeight() / newHeight; Color tmpColor1, tmpColor2; for (int ii = 0; ii < newHeight; ii++) { for (int jj = 0; jj < newWidth; jj++) { try { tmpColor1 = new Color( image1.getRGB(Math.round(jj * widthModifier), Math.round(ii * heightModifier))); tmpColor2 = new Color( image2.getRGB(Math.round(jj * widthModifier), Math.round(ii * heightModifier))); outputMap[0][jj][ii] = (float) (tmpColor1.getRed() - tmpColor2.getRed()) * (tmpColor1.getRed() - tmpColor2.getRed()); outputMap[1][jj][ii] = (float) (tmpColor1.getGreen() - tmpColor2.getGreen()) * (tmpColor1.getGreen() - tmpColor2.getGreen()); outputMap[2][jj][ii] = (float) (tmpColor1.getBlue() - tmpColor2.getBlue()) * (tmpColor1.getBlue() - tmpColor2.getBlue()); } catch (Exception e) { System.out.println(newHeight + " " + newWidth + " " + image1.getHeight() + " " + image1.getWidth() + " " + ii + " " + jj + " " + Math.round(ii * heightModifier) + " " + Math.round(jj * widthModifier) + " " + heightModifier + " " + widthModifier); e.printStackTrace();/*from w w w . jav a 2 s . c o m*/ return outputMap; } } } return outputMap; }
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 w w. j a v a2 s.c o m } }
From source file:io.github.minecraftgui.models.network.packets.PacketSetAttribute.java
public PacketSetAttribute(Component component, Shape shape, State state, double percentage, long time, Color value) { this.component = component; this.shape = shape; this.state = state; this.percentage = percentage; this.time = time; this.value = new JSONObject().put(NetworkController.R, value.getRed()) .put(NetworkController.G, value.getGreen()).put(NetworkController.B, value.getBlue()) .put(NetworkController.A, value.getAlpha()); }
From source file:io.github.minecraftgui.models.network.packets.PacketSetAttribute.java
public PacketSetAttribute(Component component, State state, Color value) { this.component = component; this.shape = component.getShape(); this.state = state; this.percentage = 1; this.time = 0; this.value = new JSONObject().put(NetworkController.R, value.getRed()) .put(NetworkController.G, value.getGreen()).put(NetworkController.B, value.getBlue()) .put(NetworkController.A, value.getAlpha()); }
From source file:net.sf.mzmine.chartbasics.chartthemes.EStandardChartTheme.java
public void setNoBackground(boolean state) { Color c = ((Color) this.getPlotBackgroundPaint()); Color cchart = ((Color) this.getChartBackgroundPaint()); this.setPlotBackgroundPaint(new Color(c.getRed(), c.getGreen(), c.getBlue(), state ? 0 : 255)); this.setChartBackgroundPaint( new Color(cchart.getRed(), cchart.getGreen(), cchart.getBlue(), state ? 0 : 255)); this.setLegendBackgroundPaint( new Color(cchart.getRed(), cchart.getGreen(), cchart.getBlue(), state ? 0 : 255)); }
From source file:ro.nextreports.server.web.dashboard.indicator.IndicatorWidgetView.java
@SuppressWarnings("unchecked") public IndicatorWidgetView(String id, WidgetModel model, boolean zoom, Map<String, Object> urlQueryParameters) { super(id, model, zoom); final String widgetId = model.getWidgetId(); final IndicatorModel indicatorModel = new IndicatorModel(widgetId, urlQueryParameters); setModel(new CompoundPropertyModel(indicatorModel)); add(new Label("error", new Model<String>()) { private static final long serialVersionUID = 1L; @Override/*w ww . ja va 2 s. c o m*/ protected void onInitialize() { super.onInitialize(); if (indicatorModel.getObject() == null) { if (indicatorModel.getError() instanceof NoDataFoundException) { setDefaultModelObject("No Data Found"); } else { setDefaultModelObject(ExceptionUtils.getRootCauseMessage(indicatorModel.getError())); } } } @Override public boolean isVisible() { return indicatorModel.hasError(); } }); container = new WebMarkupContainer("indicator") { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { return !indicatorModel.hasError(); } }; container.setOutputMarkupId(true); // indicator background color is set to the entire container Color background = indicatorModel.getObject().getBackground(); String s = "background-color: rgb(" + background.getRed() + "," + background.getGreen() + "," + background.getBlue() + ");"; container.add(new AttributeAppender("style", s)); add(container); add(new HTML5Behavior(zoom, indicatorModel)); container.add(new EmptyPanel("image")); //IndicatorHTML5Panel panel = new IndicatorHTML5Panel("image", width, height, indicatorModel); //IndicatorImagePanel panel = new IndicatorImagePanel("image", width, height, indicatorModel); //container.add(panel); }
From source file:guineu.modules.dataanalysis.PCA.ProjectionPlotPanel.java
public ProjectionPlotPanel(ProjectionPlotWindow masterFrame, ProjectionPlotDataset dataset, ParameterSet parameters) {//from ww w . jav a2s. com super(null); boolean createLegend = true; if (dataset.getNumberOfGroups() > 20) { createLegend = false; } chart = ChartFactory.createXYAreaChart("", dataset.getXLabel(), dataset.getYLabel(), dataset, PlotOrientation.VERTICAL, createLegend, false, false); chart.setBackgroundPaint(Color.white); setChart(chart); // title TextTitle chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chart.removeSubtitle(chartTitle); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.setForegroundAlpha(dataPointAlpha); NumberFormat numberFormat = NumberFormat.getNumberInstance(); // set the X axis (component 1) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setNumberFormatOverride(numberFormat); // set the Y axis (component 2) properties NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setNumberFormatOverride(numberFormat); plot.setDataset(dataset); spotRenderer = new ProjectionPlotRenderer(plot, dataset); itemLabelGenerator = new ProjectionPlotItemLabelGenerator(parameters); spotRenderer.setBaseItemLabelGenerator(itemLabelGenerator); spotRenderer.setBaseItemLabelsVisible(true); spotRenderer.setBaseToolTipGenerator(new ProjectionPlotToolTipGenerator(parameters)); plot.setRenderer(spotRenderer); // Setup legend if (createLegend) { LegendItemCollection legendItemsCollection = new LegendItemCollection(); for (int groupNumber = 0; groupNumber < dataset.getNumberOfGroups(); groupNumber++) { Object paramValue = dataset.getGroupParameterValue(groupNumber); if (paramValue == null) { // No parameter value available: search for raw data files // within this group, and use their names as group's name String fileNames = new String(); for (int itemNumber = 0; itemNumber < dataset.getItemCount(0); itemNumber++) { String rawDataFile = dataset.getRawDataFile(itemNumber); if (dataset.getGroupNumber(itemNumber) == groupNumber) { fileNames = fileNames.concat(rawDataFile); } } if (fileNames.length() == 0) { fileNames = "Empty group"; } paramValue = fileNames; } Color nextColor = (Color) spotRenderer.getGroupPaint(groupNumber); Color groupColor = new Color(nextColor.getRed(), nextColor.getGreen(), nextColor.getBlue(), (int) Math.round(255 * dataPointAlpha)); legendItemsCollection.add(new LegendItem(paramValue.toString(), "-", null, null, spotRenderer.getDataPointsShape(), groupColor)); } plot.setFixedLegendItems(legendItemsCollection); } else { Dataset legends = new SimpleBasicDataset("Legends"); legends.addColumnName("Samples"); for (int groupNumber = 0; groupNumber < dataset.getNumberOfGroups(); groupNumber++) { Object paramValue = dataset.getGroupParameterValue(groupNumber); if (paramValue == null) { // No parameter value available: search for raw data files // within this group, and use their names as group's name String fileNames = new String(); for (int itemNumber = 0; itemNumber < dataset.getItemCount(0); itemNumber++) { String rawDataFile = dataset.getRawDataFile(itemNumber); if (dataset.getGroupNumber(itemNumber) == groupNumber) { fileNames = fileNames.concat(rawDataFile.toString()); } } if (fileNames.length() == 0) { fileNames = "Empty group"; } paramValue = fileNames; } Color nextColor = (Color) spotRenderer.getGroupPaint(groupNumber); Color groupColor = new Color(nextColor.getRed(), nextColor.getGreen(), nextColor.getBlue(), (int) Math.round(255 * dataPointAlpha)); PeakListRow row = new SimplePeakListRowOther(); row.setPeak("Samples", paramValue.toString()); legends.addRow(row); legends.addRowColor(groupColor); } GuineuCore.getDesktop().AddNewFile(legends); } }
From source file:app.springapp.ImageConverter.java
public int getBlockValue(int x1, int y1, int n, boolean flag) { BufferedImage im;//from ww w . j a va2 s. co m if (flag) { im = new_image; } else { im = org_image; } int x2 = getX(x1, y1, n); int y2 = getY(x1, y1, n); int sum = 0; int i = x1, j = y1; while (i != x2 || j != y2) { int rgb = im.getRGB(i, j); Color c = new Color(rgb); sum += c.getRed() % 2; sum += c.getBlue() % 2; sum += c.getGreen() % 2; if (i + 1 < org_image.getWidth()) { i = i + 1; } else { j++; i = 0; } } int rgb = im.getRGB(x2, y2); Color c = new Color(rgb); sum += c.getRed() % 2; sum += c.getBlue() % 2; sum += c.getGreen() % 2; return sum; }