// --------------------------------------- // 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_Focus_Window.java // // Class to define the parameters of the // RFV Focus Window: Dimensions of the // transitions regions and the main focus // region, as well as key offset values. // --------------------------------------- public class RFV_Focus_Window { // Focus Window Regions // Outermost transition region: 0 // Middle transition region: 1 // Innermost transition region: 2 // Focus region: 3 // ------------------------------ public int width[]; public int height[]; // Offsets of the top left region corner // relative to the mouse location // ------------------------------------- public int hor_offset[]; public int ver_offset[]; // Constant // -------- public static final int NUM_REGIONS = 4; // Constructor accepts input file with dimensions as arguemnt // ---------------------------------------------------------- public RFV_Focus_Window(RFV_Input_File input_file) { String token; width = new int[NUM_REGIONS]; height = new int[NUM_REGIONS]; hor_offset = new int[NUM_REGIONS]; ver_offset = new int[NUM_REGIONS]; // Read in dimensions // ------------------ input_file.readOpenBracket(); for (int i = 0; i < NUM_REGIONS; i++) { width[i] = input_file.readInteger(); height[i] = input_file.readInteger(); } validateDimensions(); calculateOffsets(); // See if any offsets are applied // ------------------------------ if (!input_file.isCloseBracket()) { token = input_file.readToken(); if (token.equalsIgnoreCase("focus_window_offsets")) { offsetRegions(input_file); } else RFV_Error.die(53, input_file.getLineNumber(), token); } input_file.readCloseBracket(); } // Method that checks the relative sizes of the regions // ---------------------------------------------------- private void validateDimensions() { boolean error_flag = false; for (int i = 0; i < NUM_REGIONS - 1; i++) { if (width[i] < width[i+1] || height[i] < height[i+1]) error_flag = true; } // If sizes invalid, error // ----------------------- if (error_flag) RFV_Error.die(54); } // Method that calculates the offset values // ---------------------------------------- private void calculateOffsets() { for (int i = 0; i < NUM_REGIONS; i++) { hor_offset[i] = width[i] / 2; ver_offset[i] = height[i] / 2; } } // Method to offset the regions from the centre of the window // ---------------------------------------------------------- private void offsetRegions(RFV_Input_File input_file) { // Read in new offsets and adjust existing ones accordingly // -------------------------------------------------------- input_file.readOpenBracket(); for (int i = 0; i < NUM_REGIONS; i++) { hor_offset[i] -= input_file.readInteger(); ver_offset[i] -= input_file.readInteger(); } input_file.readCloseBracket(); } }