If you think the Android project android-augment-reality-framework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.jwetherell.augmented_reality.ui.objects;
//www.java2s.comimport android.graphics.Bitmap;
import android.graphics.Canvas;
/**
* This class extends PaintableObject to draw an icon.
*
* @author Justin Wetherell <phishman3579@gmail.com>
*/publicclass PaintableIcon extends PaintableObject {
private Bitmap bitmap = null;
public PaintableIcon(Bitmap bitmap, int width, int height) {
set(bitmap, width, height);
}
/**
* Set the bitmap. This should be used instead of creating new objects.
*
* @param bitmap
* Bitmap that should be rendered.
* @throws NullPointerException
* if Bitmap is NULL.
*/publicvoid set(Bitmap bitmap, int width, int height) {
if (bitmap == null) thrownew NullPointerException();
this.bitmap = Bitmap.createScaledBitmap(bitmap, width, height, true);
}
/**
* {@inheritDoc}
*/
@Override
publicvoid paint(Canvas canvas) {
if (canvas == null || bitmap == null) thrownew NullPointerException();
canvas.save();
canvas.translate(-getWidth()/2, -getHeight()/2);
paintBitmap(canvas, bitmap, x, y);
canvas.restore();
}
/**
* {@inheritDoc}
*/
@Override
publicfloat getWidth() {
return bitmap.getWidth();
}
/**
* {@inheritDoc}
*/
@Override
publicfloat getHeight() {
return bitmap.getHeight();
}
}