Adjust a single component (red, green, blue or alpha) of a colour.
@param component The value to mutate.
@return The mutated component value.
885
private int mutateColourComponent(int component)
    {
        int mutatedComponent = (int) Math.round(component + mutationAmount.nextValue());
        mutatedComponent = Maths.restrictRange(mutatedComponent, 0, 255);
        return mutatedComponent;
    }
197496
public UI wrap(Component component) {
        if (component instanceof UI) {
            return (UI) component;
        }
        if (component instanceof Window) {
            return wrapWindow((Window) component);
        }
        if (component instanceof Layout) {
            return wrapLayout((Layout) component);
        }

        // Ok it's a component we cannot handle directly
        final VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        layout.setSizeFull();
        layout.addComponent(component);
        layout.setExpandRatio(component, 1);
        return wrapLayout(layout);
    }
401629
public void changeAlpha(int alpha) {
        alpha = alpha > 255 ? 255 : alpha < 0 ? 0 : alpha;

        Color foreground = getForeground();
        int red = foreground.getRed();
        int green = foreground.getGreen();
        int blue = foreground.getBlue();

        Color withAlpha = new Color(red, green, blue, alpha);
        super.setForeground(withAlpha);
    }
932924
public static JFrame runUnpacked(final JComponent component) {
		component.setPreferredSize(component.getSize());
		return run(component);
	}
302070
private void adaptButtonTextColor() {
        if (buttonTextColor != null) {
            if (positiveButton != null) {
                positiveButton.setTextColor(buttonTextColor);
            }

            if (neutralButton != null) {
                neutralButton.setTextColor(buttonTextColor);
            }

            if (negativeButton != null) {
                negativeButton.setTextColor(buttonTextColor);
            }
        }
    }
184420
function mutate(Component, title, api = {}) {
  class Mutated extends React.Component {
    constructor(props, context) {
      super(props);

      this.ToRender = Component;
      const mutations = context.mutations;

      if (!mutations || !mutations[title]) {
        return;
      }

      // Convert old style mutations to new style mutations
      if (!Array.isArray(mutations[title])) {
        mutations[title] = [mutations[title]];
      }

      // Apply all mutations to the component
      for (let mut of mutations[title]) {
        this.ToRender = mut(this.ToRender, api);
      }
    }

    render() {
      const ToRender = this.ToRender;
      return <ToRender {...this.props} />;
    }
  }

  Mutated.contextTypes = {
    mutations: PropTypes.object
  };

  return Mutated;
}
1200164
public void adjustColor(float r, float g, float b, float a) {
		if (color == Color.white) {
			color = new Color(1,1,1,1f);
		} 
		color.r += r;
		color.g += g;
		color.b += b;
		color.a += a;
	}
1289303
public void setColor(String red, String green, String blue, String alpha) {
		setColor(red, green, blue);
		setAlpha(alpha);
	}
994959
public static void setPreferredColor(int color) {
		final Preferences prefs = Preferences.userNodeForPackage(MapElementConstants.class);
		if (prefs != null) {
			prefs.putInt("COLOR", color); //$NON-NLS-1$
			try {
				prefs.flush();
			} catch (BackingStoreException exception) {
				//
			}
		}
	}
191938
protected static String render(final WebComponent component) {
		StringWriter stringWriter = new StringWriter();
		PrintWriter printWriter = new PrintWriter(stringWriter);
		component.paint(new WebXmlRenderContext(printWriter));
		printWriter.flush();
		String content = stringWriter.toString();
		return content;
	}
929065
public void setUnitColor(final Color COLOR) {
        if (null == unitColor) {
            _unitColor = COLOR;
            fireTileEvent(REDRAW_EVENT);
        } else {
            unitColor.set(COLOR);
        }
    }
760822
@Override
    protected Component doHighlight(final Component component, final ComponentAdapter adapter) {
        final Icon icon = getIcon(adapter.getValue(columnIndex));

        if (icon != null) {
            if (component instanceof IconAware) {
                ((IconAware) component).setIcon(icon);
            } else if (component instanceof JLabel) {
                ((JLabel) component).setIcon(icon);
            }
        } else {
            if (component instanceof JLabel) {
                ((JLabel) component).setText("");
            }
        }
        return component;
    }
446503
private static int setColorAlpha(int color, byte alpha) {
    return Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color));
  }
258998
public static int modulateColorAlpha(int color, int alpha) {
        int colorAlpha = color >>> 24;
        int scale = alpha + (alpha >> 7);
        int newAlpha = colorAlpha * scale >> 8;
        int r = (color >> 16) & 0xFF;
        int g = (color >> 8) & 0xFF;
        int b = color & 0xFF;
        return newAlpha << 24 | r << 16 | g << 8 | b;
    }
1135895
public static int getGraphicsDeviceIndexIsShowingOn(final Component component)
	{
		final GraphicsDevice graphicsDevice = getGraphicsDeviceIsShowingOn(component);
		final GraphicsDevice[] graphicsDevices = getAvailableScreens();
		for (int i = 0; i < graphicsDevices.length; i++)
		{
			if (graphicsDevices[i].equals(graphicsDevice))
			{
				return i;
			}
		}
		return 0;
	}
582855
public CharSequence newRenderedStatement(final Component component)
	{
		JsStatement statement;
		if (component != null)
		{
			component.setOutputMarkupId(true);
			statement = new JsStatement().$(component);
		}
		else
		{
			statement = new JsStatement();
		}

		for (final ChainableStatement defaultChainableStatement : chainableStatement)
		{
			statement.chain(defaultChainableStatement);
		}
		this.renderedStatement = statement.render();
		this.rendered = true;
		return this.renderedStatement;
	}
500229
@SuppressWarnings({ "checkstyle:magicnumber", "static-method" })
	@Pure
	public Color rgba(int color) {
		final int alpha = (color & 0xFF000000) >> 24;
		final int red = (color & 0x00FF0000) >> 16;
		final int green = (color & 0x0000FF00) >> 8;
		final int blue = color & 0x000000FF;
		final double opacity;
		switch (alpha) {
		case 0:
			opacity = 0.;
			break;
		case 255:
			opacity = 1.;
			break;
		default:
			opacity = ((double) alpha) / 255;
		}
		return Color.rgb(red, green, blue, opacity);
	}