// --------------------------------------- // Restricted Focus Viewer (RFV) Program // Version 2.1 // Language: Java 2 // November, 2000 // Copyright (C) 2000 Anthony R. Jansen // --------------------------------------- // This program 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 2 // of the License, or (at your option) any later version. // This program 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 this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // --------------------------------------- // Replayer_Status_Image.java // // This class stores and draws the status // image that indicates the status of the // Replayer. // --------------------------------------- import java.awt.*; import java.awt.image.*; public class Replayer_Status_Image implements ImageObserver { // Variables // --------- private int status_x_pos; private int status_y_pos; private Image status_image; private boolean visible; // Constants // --------- public static final int STATUS_WIDTH = 95; public static final int STATUS_HEIGHT = 30; // Constructor // ----------- public Replayer_Status_Image(Image image, RFV_Defaults defaults) { visible = true; status_image = image; status_x_pos = defaults.getFrameSize().width - STATUS_WIDTH; status_y_pos = defaults.getFrameSize().height - STATUS_HEIGHT; update(false, false, Replayer.NORMAL_SPEED); } // Updates the status image // ------------------------ public void update(boolean running, boolean paused, int speed_factor) { Graphics g = status_image.getGraphics(); g.setColor(Color.black); g.fillRect(0, 0, STATUS_WIDTH, STATUS_HEIGHT); g.setColor(new Color(0, 255, 0)); // Update play symbols // ------------------- if (running && !paused) { int x_array[] = {17, 17, 28}; int y_array[] = {10, 20, 15}; g.fillPolygon(x_array, y_array, 3); } else if (running && paused) { g.fillRect(17, 10, 4, 10); g.fillRect(23, 10, 4, 10); } else { g.fillRect(17, 10, 10, 10); } // Update speed meter // ------------------ g.drawLine(40, 19, 80, 19); for (int i = 1; i <= 5; i++) g.drawLine(30 + (i*10), 19, 30 + (i*10), 16); g.setColor(Color.red); g.fillOval(27 + (speed_factor*10), 9, 6, 6); } // Toggles whether visible or not // ------------------------------ public void toggleVisible() { if (visible) visible = false; else visible = true; } // Draws the status image at the specified offset // ---------------------------------------------- public void draw(Graphics g) { if (visible) g.drawImage(status_image, status_x_pos, status_y_pos, this); } // Required for the ImageObserver interface // ---------------------------------------- public boolean imageUpdate(Image img, int flags, int xc, int yc, int w, int h) { return true; } }