All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.refcodes.graphical.impls.RgbPixelImpl Maven / Gradle / Ivy

Go to download

Artifact for graphical issues regarding RGB, pixel, fonts, and other stuff (utility).

There is a newer version: 3.3.9
Show newest version
// /////////////////////////////////////////////////////////////////////////////
// REFCODES.ORG
// /////////////////////////////////////////////////////////////////////////////
// This code is copyright (c) by Siegfried Steiner, Munich, Germany and licensed
// under the following (see "http://en.wikipedia.org/wiki/Multi-licensing")
// licenses:
// -----------------------------------------------------------------------------
// GNU General Public License, v3.0 ("http://www.gnu.org/licenses/gpl-3.0.html")
// -----------------------------------------------------------------------------
// Apache License, v2.0 ("http://www.apache.org/licenses/LICENSE-2.0")
// -----------------------------------------------------------------------------
// Please contact the copyright holding author(s) of the software artifacts in
// question for licensing issues not being covered by the above listed licenses,
// also regarding commercial licensing models or regarding the compatibility
// with other open source licenses.
// /////////////////////////////////////////////////////////////////////////////

package org.refcodes.graphical.impls;

import org.refcodes.graphical.GraphicalUtility;
import org.refcodes.graphical.RgbPixel;

/**
 * @author steiner
 *
 */
public class RgbPixelImpl implements RgbPixel {

	// /////////////////////////////////////////////////////////////////////////
	// STATICS:
	// /////////////////////////////////////////////////////////////////////////

	// /////////////////////////////////////////////////////////////////////////
	// CONSTANTS:
	// /////////////////////////////////////////////////////////////////////////

	// /////////////////////////////////////////////////////////////////////////
	// VARIABLES:
	// /////////////////////////////////////////////////////////////////////////

	private int _alphaPortion = 0;
	private int _redPortion = 0;
	private int _greenPortion = 0;
	private int _bluePortion = 0;

	// /////////////////////////////////////////////////////////////////////////
	// CONSTRUCTORS:
	// /////////////////////////////////////////////////////////////////////////

	public RgbPixelImpl() {};

	public RgbPixelImpl( int aAlphaPortion, int aRedPortion, int aGreenPortion, int aBluePortion ) {
		_alphaPortion = aAlphaPortion;
		_redPortion = aRedPortion;
		_greenPortion = aGreenPortion;
		_bluePortion = aBluePortion;
	}

	public RgbPixelImpl( int aRgbValue ) {
		setRgbValue( aRgbValue );
	}

	// /////////////////////////////////////////////////////////////////////////
	// INJECTION:
	// /////////////////////////////////////////////////////////////////////////

	// /////////////////////////////////////////////////////////////////////////
	// METHODS:
	// /////////////////////////////////////////////////////////////////////////

	@Override
	public int getAlphaPortion() {
		return _alphaPortion;
	}

	@Override
	public int getRedPortion() {
		return _redPortion;
	}

	@Override
	public int getGreenPortion() {
		return _greenPortion;
	}

	@Override
	public int getBluePortion() {
		return _bluePortion;
	}

	@Override
	public int toRgbValue() {
		return GraphicalUtility.toRgb( _alphaPortion, _redPortion, _greenPortion, _bluePortion );
	}

	@Override
	public void setRgbValue( int aRgbValue ) {
		_alphaPortion = GraphicalUtility.toAlpha( aRgbValue );
		_redPortion = GraphicalUtility.toRed( aRgbValue );
		_greenPortion = GraphicalUtility.toGreen( aRgbValue );
		_bluePortion = GraphicalUtility.toBlue( aRgbValue );
	}

	@Override
	public void setAlphaPortion( int aAlphaPortion ) {
		_alphaPortion = aAlphaPortion;

	}

	@Override
	public void setRedPortion( int aRedPortion ) {
		_redPortion = aRedPortion;
	}

	@Override
	public void setGreenPortion( int aGreenPortion ) {
		_greenPortion = aGreenPortion;
	}

	@Override
	public void setBluePortion( int aBluePortion ) {
		_bluePortion = aBluePortion;
	}

	// /////////////////////////////////////////////////////////////////////////
	// HOOKS:
	// /////////////////////////////////////////////////////////////////////////

	// /////////////////////////////////////////////////////////////////////////
	// HELPER:
	// /////////////////////////////////////////////////////////////////////////

	// /////////////////////////////////////////////////////////////////////////
	// INNER CLASSES:
	// /////////////////////////////////////////////////////////////////////////

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy