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

org.refcodes.graphical.impls.PositionImpl 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.Position;

/**
 * @author steiner
 *
 */
public class PositionImpl implements Position {

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

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

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

	protected int _posX;
	protected int _posY;

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

	protected PositionImpl() {}

	public PositionImpl( int aPosX, int aPosY ) {
		_posX = aPosX;
		_posY = aPosY;
	}

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

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

	@Override
	public int getPositionX() {
		return _posX;
	}

	@Override
	public int getPositionY() {
		return _posY;
	}

	@Override
	public String toString() {
		return getClass().getSimpleName() + "(" + _posX + " x " + _posY + ")@" + hashCode();
	}

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

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

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

	public static class PositionPropertyBuilderImpl extends PositionImpl implements PositionPropertyBuilder {

		public PositionPropertyBuilderImpl() {
			super();
		}

		public PositionPropertyBuilderImpl( int aPosX, int aPosY ) {
			super( aPosX, aPosY );
		}

		@Override
		public void setPositionX( int aPosX ) {
			_posX = aPosX;
		}

		@Override
		public PositionPropertyBuilderImpl withPositionX( int aPosX ) {
			_posX = aPosX;
			return this;
		}

		@Override
		public void setPositionY( int aPosY ) {
			_posY = aPosY;
		}

		@Override
		public PositionPropertyBuilderImpl withPositionY( int aPosY ) {
			_posY = aPosY;
			return this;
		}

		@Override
		public PositionPropertyBuilderImpl withPosition( int aPosX, int aPosY ) {
			setPosition( aPosX, aPosY );
			return this;
		}

		@Override
		public PositionPropertyBuilderImpl withPosition( Position aPosition ) {
			setPosition( aPosition );
			return this;
		}

		@Override
		public void setPosition( int aPosX, int aPosY ) {
			_posX = aPosX;
			_posY = aPosY;

		}

		@Override
		public void setPosition( Position aPosition ) {
			_posX = aPosition.getPositionX();
			_posY = aPosition.getPositionY();
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy