
org.refcodes.graphical.impls.RgbPixmapImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of refcodes-graphical Show documentation
Show all versions of refcodes-graphical Show documentation
Artifact for graphical issues regarding RGB, pixel, fonts, and other stuff (utility).
// /////////////////////////////////////////////////////////////////////////////
// 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.RgbPixel;
import org.refcodes.graphical.RgbPixmap;
/**
* @author steiner
*
*/
public class RgbPixmapImpl implements RgbPixmap {
// /////////////////////////////////////////////////////////////////////////
// STATICS:
// /////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////
// CONSTANTS:
// /////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////
// VARIABLES:
// /////////////////////////////////////////////////////////////////////////
protected RgbPixel[][] _pixels = null;
// /////////////////////////////////////////////////////////////////////////
// CONSTRUCTORS:
// /////////////////////////////////////////////////////////////////////////
public RgbPixmapImpl() {}
public RgbPixmapImpl( RgbPixel[][] aPixels ) {
_pixels = aPixels;
}
public RgbPixmapImpl( int aWidth, int aHeight ) {
_pixels = new RgbPixel[aWidth][aHeight];
}
// /////////////////////////////////////////////////////////////////////////
// INJECTION:
// /////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////
// METHODS:
// /////////////////////////////////////////////////////////////////////////
@Override
public RgbPixel[][] getPixels() {
return _pixels;
}
@Override
public int getPixmapWidth() {
return _pixels.length;
}
@Override
public int getPixmapHeight() {
return _pixels[0].length;
}
@Override
public RgbPixel getPixelAt( int aPosX, int aPosY ) throws IndexOutOfBoundsException {
return _pixels[aPosX][aPosY];
}
// /////////////////////////////////////////////////////////////////////////
// HOOKS:
// /////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////
// HELPER:
// /////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////
// INNER CLASSES:
// /////////////////////////////////////////////////////////////////////////
public static class RgbPixmapPropertyBuilderImpl extends RgbPixmapImpl implements RgbPixmapPropertyBuilder {
public RgbPixmapPropertyBuilderImpl() {
super();
}
public RgbPixmapPropertyBuilderImpl( int aWidth, int aHeight ) {
super( aWidth, aHeight );
}
public RgbPixmapPropertyBuilderImpl( RgbPixel[][] aPixels ) {
super( aPixels );
}
@Override
public RgbPixmapPropertyBuilder withPixels( RgbPixel[][] aPixels ) {
setPixels( aPixels );
return this;
}
@Override
public void setPixelAt( RgbPixel aPixel, int aPosX, int aPosY ) throws IndexOutOfBoundsException {
_pixels[aPosX][aPosY] = aPixel;
}
@Override
public void setPixels( RgbPixel[][] aPixels ) {
_pixels = aPixels;
}
@Override
public RgbPixmapPropertyBuilder withPixelAt( RgbPixel aPixel, int aPosX, int aPosY ) throws IndexOutOfBoundsException {
setPixelAt( aPixel, aPosX, aPosY );
return this;
}
@Override
public RgbPixmapPropertyBuilder withPixelAt( int aPixel, int aPosX, int aPosY ) throws IndexOutOfBoundsException {
setPixelAt( aPixel, aPosX, aPosY );
return this;
}
@Override
public void setPixelAt( int aPixel, int aPosX, int aPosY ) throws IndexOutOfBoundsException {
setPixelAt( new RgbPixelImpl( aPixel ), aPosX, aPosY );
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy