/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * AndroidWorld Library, Copyright 2011 Bryan Chadwick * * * * FILE: ./android/image/EmptyScene.java * * * * This file is part of AndroidWorld. * * * * AndroidWorld is free software: you can redistribute it and/or * * modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version * * 3 of the License, or (at your option) any later version. * * * * AndroidWorld is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with AndroidWorld. If not, see . * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ package android.image; import android.graphics.Canvas; import android.graphics.Paint; /** * * * Represents the empty (blank) Scene (a cropped Image). * *
 *    new EmptyScene(160, 90)
* *
* */ public class EmptyScene extends Scene{ protected int width; protected int height; protected Paint paint = Image.WHITE; protected boolean clipped; /** Construct an EmptyScene of (Width x Height) */ public EmptyScene(double width, double height){ this(round(width), round(height)); } /** Construct an EmptyScene of (Width x Height) with the given * background color. */ public EmptyScene(double width, double height, String color){ this(round(width), round(height), color); } /** Construct an EmptyScene of (Width x Height) */ public EmptyScene(int width, int height){ this(width, height, "white"); this.clipped = true; } /** Construct an EmptyScene of (Width x Height) with the given * background color. */ public EmptyScene(int width, int height, String color){ this.width = width; this.height = height; this.paint = Image.painter(Image.color(color), Image.SOLID); this.clipped = false; } /** Paint this Scene into the given graphics */ public void paint(Canvas c, int x, int y){ c.drawRect(x, y, width, height, this.paint); if(this.clipped){ c.drawRect(x, y, width, height, Image.BLACK_OUTLINE); c.clipRect(x+1, y+1, width-1, height-1); } } protected double leftOfPin(){ return 0; } protected double rightOfPin(){ return width; } protected double upOfPin(){ return 0; } protected double downOfPin(){ return height; } /** Return the Width of this Scene/Image */ public int width(){ return width; } /** Return the Width of this Scene/Image */ public int height(){ return height; } }