// --------------------------------------- // Restricted Focus Viewer (RFV) Program // Version 2.1 // Language: Java 2 // October, 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. // --------------------------------------- // RFV_Display_Element.java // // This is the superclass for all display // elements used by the RFV. // --------------------------------------- import java.awt.*; public abstract class RFV_Display_Element { // Boolean to determine if instance is a single element, // or a group of elements (such as a row or a column) // and boolean to determine if instance is flexible space // ------------------------------------------------------ private boolean single_element; private boolean flexible_space; // Variables for dimensions and offset on the display // -------------------------------------------------- protected int width; protected int height; protected int x_offset; protected int y_offset; // Variable to determine parent node in a tree // ------------------------------------------- private RFV_Display_Element parent; // Constructor // ----------- public RFV_Display_Element(boolean se, boolean fs) { single_element = se; flexible_space = fs; width = 0; height = 0; x_offset = 0; y_offset = 0; parent = null; } // Set the parent of this element in the tree // ------------------------------------------ public void setParent(RFV_Display_Element element) { parent = element; } // Returns single element status // ----------------------------- public boolean isSingleElement() { return single_element; } // Returns flexible space status // ----------------------------- public boolean isFlexibleSpace() { return flexible_space; } // Returns the width of the element // -------------------------------- public int getWidth() { return width; } // Returns the height of the element // --------------------------------- public int getHeight() { return height; } // Sets the element location // ------------------------- public void setLocation(int xc, int yc) { x_offset = xc; y_offset = yc; } // Returns true if the coordinates given // are within the element, false otherwise // --------------------------------------- public boolean inElement(int xc, int yc) { if (xc >= x_offset) if (yc >= y_offset) if (xc < x_offset + width) if (yc < y_offset + height) return true; return false; } // Abstract draw function for subclasses // ------------------------------------- public abstract void draw(Graphics g); }