/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * JavaWorld Library, Copyright 2011 Bryan Chadwick * * * * FILE: ./image/EmptyScene.java * * * * This file is part of JavaWorld. * * * * JavaWorld 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. * * * * JavaWorld 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 JavaWorld. If not, see . * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ package image; import java.awt.Color; import java.awt.Graphics; /** * * * Represents the empty (blank) Scene (a cropped Image). * *
 *    new EmptyScene(160, 90)
* *
* */ public class EmptyScene extends Scene{ protected int width; protected int height; protected Color color; 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) */ 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) */ public EmptyScene(int width, int height, String color){ this.width = width; this.height = height; this.color = Image.color(color); this.clipped = false; } /** Paint this Scene into the given graphics */ public void paint(Graphics g, int x, int y){ g.setColor(this.color); g.fillRect(x, y, this.width-1, this.height-1); if(this.clipped){ g.setColor(Color.black); g.drawRect(x, y, this.width-1,this.height-1); g.setClip(x+1, y+1, this.width-2, this.height-2); } } protected double leftOfPin(){ return 0; } protected double rightOfPin(){ return this.width; } protected double upOfPin(){ return 0; } protected double downOfPin(){ return this.height; } /** Return the Width of this Scene/Image */ public int width(){ return this.width; } /** Return the Width of this Scene/Image */ public int height(){ return this.height; } }