This text file contains excepts from the Java Surface Profile Program Java source code. Many of the error messages in the program avoid exceptions that would have been thrown. This by testing before the processor finds the error. This avoids unpleasant program hanups but the error messages produced are more relevant to me as the programer than to the average person. Many of these messages will never be hit and therefore never seen. To give some relivance to messages the user may see in the status bar this file includes all the messages in the SurfApp.java file as they appear in their method. public class SurfEvent extends Applet implements KeyListener, Runnable This is the class specified in the surf.html where the operating system will look to begin the surf program after compiling the code in the SurfEvent.class file. Operation begins at the init() method where gobal variables and images are initialized and the program thread started. The run() method is the entry point for the operating system during program operation. The update() method is the method where the operating system receives images from the Surf program for the operating system to display in a window in screen memory. The SurfEvent class also handles loading PARAM(s) from the surf.html file and the focus scan for the buttons and data entry buttons except the buttons on the plot board. public class Btn_Floa extends SurfEvent This accessory class handles drawing buttons and data entry buttons. Methods in this class handle the users data entry by fitering invalid characters and storing and displaying partially completed data entry. public class ShoBtnAr extends SurfEvent This class is not normally used during program operation. It was used during constrution of the SurfEvent class. Shift ? will actuate the ShoBtnAr class. The source code for this class is at the bottom of this file. public class MMouseLs extends SurfEvent implements MouseListener, MouseMotionListener This class accepts all mouse events from the operating system. Mouse variables that are global for the Surf program but unseen by the operating system are updated in this class. public class Mouble extends SurfEvent The program keeps length variables as centimeters in double precision floating point variables. Length input to the program can be in various units. This class does unit conversion between centimeters and the other units of length. The class also displays the system of units selection menu and handles users mouse input for system of units selection. public class SurfApp extends SurfEvent This class is the main class for the Surf program and is not involved with the operating system interface. The SurfApp class is covered in greater detail below. public class RmR_fuct extends SurfApp This class parses the users formula that was read in as a PARAM from the surf.html file. The error messages for the formula parsing are covered in the Applet_PARAM_source.htm file. public class DisplayArrays extends SurfApp This class handles the 'Display Arrays' selection and the 'Save Array' selection on the plot board menu. Below is the SurfApp class in greater detail. import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.applet.*; import java.lang.*; import java.util.*; import java.text.*; import java.io.*; import java.net.*; import java.math.*; public class SurfApp extends SurfEvent { Declairation of static variables. // static boolean first_pass_ron_app_initializing = true; // global variable static void scan_app() { if( first_pass_ron_app_initializing ) { Initializing of variables. } Handle user Esc key input for the SurfApp class. Handle s key input. Handle w key input. Handle t or f key input. Handle z key input. Message from Btn_Floa. Program has accepted users changed data input. { if( old_mirror_diameter != metric_cm[ m_d_btn ] || old_radius_of_curvature != metric_cm[ r_c_btn ] || old_entered_val_const_b != entered_val[ const_b ] || old_metric_cm_cPf_btn != metric_cm[ cPf_btn ] || old_light_source_moves != light_source_moves ) { if( old_light_source_moves != light_source_moves ) { old_light_source_moves = light_source_moves; if( light_source_moves ) exception_or_error[ 124 ] = " Light source on the tester moves with the knife edge "; else exception_or_error[ 124 ] = " Light source on the tester does not move with the knife edge "; Press the clear button with the x key to reinitialize all dependant data. } old_mirror_diameter = metric_cm[ m_d_btn ]; old_radius_of_curvature = metric_cm[ r_c_btn ]; old_entered_val_const_b = entered_val[ const_b ]; old_metric_cm_cPf_btn = metric_cm[ cPf_btn ]; formu_starward_metric = null; // And therefore: formulas_transform_surface_metric = null; // Strings: s_simulated_data_formula = null; s_formu_starward_metric = null; metric_cm_assocated_with_data_mkr_zero = 0; zone_marker_pixels[ 0 ] = -01; marker_pin_0_on = false; starward_to_surface_called = 'N'; plot_board_control( 'T' ); // Draw replot alert bars. fill_transform_correction_array( 'i' ); // i for reinitialization g_plot_board.setColor( Color.darkGray ); Alert Lines //SA- L2,01234 g_plot_board.drawLine( 64, plot_menu_y + 1, 64, plot_menu_y + ( plot_menu_h * 5 ) - 1 ); //SA- L3,01234 g_plot_board.drawLine( 67, plot_menu_y + 1, 67, plot_menu_y + ( plot_menu_h * 5 ) - 1 ); //SA- L4,--234 g_plot_board.drawLine( 70, plot_menu_y + ( plot_menu_h * 2 ) + 1, 70, plot_menu_y + ( plot_menu_h * 5 ) - 1 ); //SA- R2,EF g_plot_board.drawLine( plot_source_mx + plot_menu_w + 7, plot_source_my + 1, plot_source_mx + plot_menu_w + 7, plot_source_my + plot_menu_h * 2 ); } if( old_pin_1_data != metric_cm[ z_1_btn ] || old_pin_2_data != metric_cm[ z_2_btn ] || old_pin_3_data != metric_cm[ z_3_btn ] || old_pin_4_data != metric_cm[ z_4_btn ] || old_pin_5_data != metric_cm[ z_5_btn ] || old_pin_6_data != metric_cm[ z_6_btn ] || old_pin_7_data != metric_cm[ z_7_btn ] || old_pin_8_data != metric_cm[ z_8_btn ] ) { old_pin_1_data = metric_cm[ z_1_btn ]; old_pin_2_data = metric_cm[ z_2_btn ]; old_pin_3_data = metric_cm[ z_3_btn ]; old_pin_4_data = metric_cm[ z_4_btn ]; old_pin_4_data = metric_cm[ z_5_btn ]; old_pin_6_data = metric_cm[ z_6_btn ]; old_pin_7_data = metric_cm[ z_7_btn ]; old_pin_8_data = metric_cm[ z_8_btn ]; plot_board_control( 't' ); Alert Lines g_plot_board.setColor( Color.darkGray ); if( plot_me_data_source == 'F' ) g_plot_board.setColor( Color.orange ); //SA- L2,--234 g_plot_board.drawLine( 64, plot_menu_y + ( plot_menu_h * 2 ) + 1, 64, plot_menu_y + ( plot_menu_h * 5 ) - 1 ); } starward_scale_muliplier = 1 / metric_cm[ star_sc ] * plot_scale_constant; surface_scale_muliplier = 1 / metric_cm[ surf_sc ] * plot_scale_constant; recalculate_values(); repaint_app1_image = 2; scan_summary = 4; } // Increment through color selections. if( toggle_state[ 1 ] ) { } // Selects the mirror charicterization page or the measured data page. if( toggle_state[ 2 ] || change_to_page_two ) { } // Begin plotting. if( toggle_state[ 3 ] ) { button_pressed = true; ................... Cancel Alert Lines if( blue_alert_for_starward_formula ) { blue_alert_for_starward_formula = false; g_plot_board.setColor( Color.white ); //SA- R4,F g_plot_board.drawLine( plot_source_mx + plot_menu_w + 13, plot_source_my + plot_menu_h + 1, plot_source_mx + plot_menu_w + 13, plot_source_my + plot_menu_h * 2 - 1 ); //SA- L1,0 draw_dashed_alert_lines( 61, true, 'z', 'w', 'z' ); } } // Select the R'- R(0) = f( r ) function to be used. if( toggle_state[ 4 ] ) { ................ // Draw replot alert bars. g_plot_board.setColor( Color.darkGray ); if( plot_me_data_source == 'F' ) //SA- L3,01234 g_plot_board.drawLine( 67, plot_menu_y + 1, 67, plot_menu_y + plot_menu_h * 5 ); else { g_plot_board.setColor( Color.orange ); //SA- L3,-1234 g_plot_board.drawLine( 67, plot_menu_y + plot_menu_h + 1, 67, plot_menu_y + plot_menu_h * 5 ); g_plot_board.setColor( Color.darkGray ); } //SA- L3,-1 g_plot_board.drawLine( 67, plot_menu_y + plot_menu_h + 1, 67, plot_menu_y + 2 * plot_menu_h ); //SA- R1,-F g_plot_board.drawLine( plot_source_mx + plot_menu_w + 4, plot_source_my + plot_menu_h + 1, plot_source_mx + plot_menu_w + 4, plot_source_my + plot_menu_h * 2 ); //SA- R1,---t g_plot_board.drawLine( plot_source_mx + plot_menu_w + 4, plot_surface_my + 1, plot_source_mx + plot_menu_w + 4, plot_surface_my + plot_menu_h - 1 ); if( formula_as_a_surface_metric == null ) { g_plot_board.setColor( Color.yellow ); //SA- R1,--------f g_plot_board.drawLine( plot_source_mx + plot_menu_w + 4, plot_surface_my + plot_menu_h * 3 + 1, plot_source_mx + plot_menu_w + 4, plot_surface_my + plot_menu_h * 4 ); } } // Clear plotting screen. if( toggle_state[ 5 ] ) { button_pressed = true; see_behind_buttons += 1; if( see_behind_buttons == 1 ) btn_frame_color[ 5 ] = Color.red; if( see_behind_buttons > 1 || see_behind_buttons == 0 ) { if( see_behind_buttons > 1 ) clear_app_image( g_off_scr_app1, g_off_scr_appR, g_plot_board ); see_behind_buttons = 0; } if( see_behind_buttons != 1 ) btn_frame_color[ 5 ] = default_btn_frame_color; old_focus[ 5 ] = default_old_focus; refesh_Menu_Screen_selector = true; toggle_state[ 10 ] = true; repaint_app1_image = 2; } // Show mirror percent zone markers. if( toggle_state[ 6 ] ) { button_pressed = true; show_zone_markers_index += 1; if( show_zone_markers_index > 3 ) show_zone_markers_index = 0; if( show_zone_markers_index > 0 ) btn_frame_color[ 6 ] = Color.gray; else btn_frame_color[ 6 ] = default_btn_frame_color; old_focus[ 6 ] = default_old_focus; // Can't see the markers when the plotboard is on. if( see_plot_board || ( show_menu && see_behind_buttons == 0 ) ) { show_zone_markers_index = 1; // Markers pins not visible on page 1. if( data_page_number == 1 ) change_to_page_two = true; // Markers not visible due plot board in front. if( see_plot_board ) toggle_state[ plot_on ] = true; // Markers not visible due legend picture is on. if( show_menu && see_behind_buttons == 0 ) toggle_state[ 10 ] = true; } repaint_app1_image = 2; } // Load PARAM's from applet viewers temporary .html file. if( toggle_state[ 7 ] ) { button_pressed = true; PARAM_control = 'L'; // tells SurfEvent to reload various PARAM(s) // from the surf.html file. Cancel alert bars. g_plot_board.setColor( Color.white ); if( blue_alert_for_entered_data ) { blue_alert_for_entered_data = false; //SA- R4,E g_plot_board.drawLine( plot_source_mx + plot_menu_w + 13, plot_source_my + 1, plot_source_mx + plot_menu_w + 13, plot_source_my + plot_menu_h - 1 ); //SA- L1,0 draw_dashed_alert_lines( 61, true, 'w', 'z', 'z' ); } g_plot_board.setColor( Color.yellow ); //SA- R2,E g_plot_board.drawLine( plot_source_mx + plot_menu_w + 7, plot_source_my, plot_source_mx + plot_menu_w + 7, plot_source_my + plot_menu_h ); //SA- L2,01--- g_plot_board.drawLine( 64, plot_menu_y + 1, 64, plot_menu_y + plot_menu_h * 2 ); repaint_app1_image = 2; scan_summary = 4; } // Set marker pin zero to an area weighted percent zone so // that half the un obscured surface area lies inside of // the pin and half the un obscured surface area lies // outside of the pin. if( old_zone_marker_pixels_0 != zone_marker_pixels[ 0 ] ) { // Used to reset the button legend. old_zone_marker_pixels_0 = zone_marker_pixels[ 0 ]; my_font_string[ 8 ] = " Set Pin[o]"; old_focus[ 8 ] = default_old_focus; plot_board_control( 'P' ); } while( toggle_state[ 8 ] ) // never loops { button_pressed = true; old_focus[ 8 ] = default_old_focus; repaint_app1_image = 2; if( plot_menu_selection != 0 ) { //metric_cm_assocated_with_data_mkr_zero = 0; //zone_marker_pixels[ 0 ] = -01; marker_pin_0_on = false; font_color[ 8 ] = default_focus_color; plot_board_control( 'P' ); break; } else { font_color[ 8 ] = Color.black; if( soft_colors ) font_color[ 8 ] = default_font_color; } while( true ) // never loops { if( marker_pin_0_on ) { metric_cm_assocated_with_data_mkr_zero = 0; zone_marker_pixels[ 0 ] = -01; marker_pin_0_on = false; break; } marker_pin_0_on = true; break; } if( marker_pin_0_on ) { if ( set_data_for_marker_pin_0_to_the_curve( false ) ) // initialize { percent_zone_focus = 0; old_zone_marker_pixels_0 = zone_marker_pixels[ 0 ]; my_font_string[ 8 ] = " "+scratch_format.format( zone_marker_pixels[ 0 ] / 2 )+" %"; } else marker_pin_0_on = false; } break; } // Add or subtract the same amount from each data entry so that the // data entry pointed to by "percent_zone_focus" will be zero. if( toggle_state[ 9 ] ) { button_pressed = true; font_color[ 9 ] = Color.black; if( soft_colors ) font_color[ 9 ] = default_font_color; my_font_string[ 9 ] = " Zero Data "; if( zero_value_at_percent_zone_of_focused_pin() ) { my_font_string[ 9 ] = " at pin ["+z_to_8_perc_zone_foc+"] "; zero_data_pin_pressed_at = milliseconds; } old_focus[ 9 ] = default_old_focus; repaint_app1_image = 2; } if( repaint_app1_image != 0 ) { if( zero_data_pin_pressed_at + 4000 < milliseconds ) { my_font_string[ 9 ] = " Zero Data "; old_focus[ 9 ] = default_old_focus; } } // Image image_plot_board; Image onto which to to plot the mirror // Graphics g_plot_board; profile graphs. if( toggle_state[ plot_on ] ) { button_pressed = true; while( true ) // Never loops. { if( see_plot_board ) { see_plot_board = false; my_font_string[ plot_on ] = " Show Plot"; break; } else { see_plot_board = true; btn_color[ plot_on ] = default_butn_color; my_font_string[ plot_on ] = "!Show Plot"; plot_board_control( '!' ); } break; } legend_for_plot_board_scale(); old_focus[ plot_on ] = default_old_focus; repaint_app1_image = 2; } // Menu/Screen selector. if( toggle_state[ 10 ] ) { button_pressed = true; btn_color[ 10 ] = Color.black; btn_color[ plot_on ] = Color.black; if( !refesh_Menu_Screen_selector ) show_screen = !show_screen; while( true ) // never loops { if( see_behind_buttons == 1 ) { if( show_screen ) { show_menu = false; my_font_string[ 10 ] = "Show Button"; } else { show_menu = true; my_font_string[ 10 ] = "Show Screen"; btn_color[ 10 ] = default_butn_color; btn_color[ plot_on ] = default_butn_color; } break; } if( see_behind_buttons != 1 ) { if( show_screen ) { show_menu = false; my_font_string[ 10 ] = "Show Menu"; } else { show_menu = true; my_font_string[ 10 ] = "Show Screen"; btn_color[ 10 ] = default_butn_color; btn_color[ plot_on ] = default_butn_color; } break; } } old_focus[ 5 ] = default_old_focus; old_focus[ 10 ] = default_old_focus; old_focus[ plot_on ] = default_old_focus; repaint_app1_image = 2; } // static double starward_scale_muliplier = 1; // static double surface_scale_muliplier = 1; // toggle_state[ star_sc ] is set when the starward plot size scale or // the plot size units have been changed. if( toggle_state[ star_sc ] ) { button_pressed = true; starward_scale_muliplier = 1 / metric_cm[ star_sc ] * plot_scale_constant; plot_board_control( 'S' ); // Requires a background repaint to remove old stuff. repaint_app1_image = 2; } // toggle_state[ surf_sc ] is set when the surface plot size scale or // the plot size units have been changed. if( toggle_state[ surf_sc ] ) { button_pressed = true; surface_scale_muliplier = 1 / metric_cm[ surf_sc ] * plot_scale_constant; plot_board_control( 'S' ); // Requires a background repaint to remove old stuff. repaint_app1_image = 2; } if( button_pressed ) { button_pressed = false; for( int i = 0; i <= max_btns_or_floats; i++ ) toggle_state[ i ] = false; } plot_board_control( 'G' ); if( repaint_app1_image > 0 ) { // tk.beep(); repaint_app1_image -= 1; if( !plotting_in_progress ) draw_legend_on_mirror_silhouette(); // g_off_scr_appR ); g_off_scr_app1.drawImage( image_off_scr_appR, 0, 0, my_event ); if( show_zone_markers_index > 0 ) draw_zone_markers(); // g_off_scr_app1 ); if( see_plot_board ) { g_off_scr_app1.drawImage( image_plot_board, 0, 0, my_event ); legend_for_plot_board_scale(); } repaint_my_app = true; } if( display_arrays ) DisplayArrays.display_arrays( g_display_arrays ); } static void update_colors_button( boolean reset ) { ................................. } // static int percent_zone_focus = 0; // static int old_percent_zone_focus = -1; // static int z_to_8_perc_zone_foc = 0; static void draw_percent_zone_legends() { Supplies the menu for the user so the user can see where to click the mouse to change the marker pin positions. if( old_percent_zone_focus != percent_zone_focus ) { old_percent_zone_focus = percent_zone_focus; z_to_8_perc_zone_foc = 0; if( percent_zone_focus == z_1_btn ) z_to_8_perc_zone_foc = 1; if( percent_zone_focus == z_2_btn ) z_to_8_perc_zone_foc = 2; if( percent_zone_focus == z_3_btn ) z_to_8_perc_zone_foc = 3; if( percent_zone_focus == z_4_btn ) z_to_8_perc_zone_foc = 4; if( percent_zone_focus == z_5_btn ) z_to_8_perc_zone_foc = 5; if( percent_zone_focus == z_6_btn ) z_to_8_perc_zone_foc = 6; if( percent_zone_focus == z_7_btn ) z_to_8_perc_zone_foc = 7; if( percent_zone_focus == z_8_btn ) z_to_8_perc_zone_foc = 8; } for( int i = 1; i < 9; i++ ) { g_percent_zone_legend[ i ].setColor( default_background_color ); g_percent_zone_legend[ i ].fillRect( 0, 0, percent_z_legend_w, percent_z_legend_h ); g_percent_zone_legend[ i ].setColor( default_red_legend_color ); g_percent_zone_legend[ i ].drawRect( 112, 2, 40, 17 ); if( zone_marker_pixels[ i ] < -.01 ) { g_percent_zone_legend[ i ].drawString(" Undefined ", 5, 16 ); if( zone_marker_pixels[ i ] < -5 ) zone_marker_pixels[ i ] = -5; } else { g_percent_zone_legend[ i ].drawString(" "+i+", "+ scratch_format.format( zone_marker_pixels[ i ] / 2 )+" %", 0, 15 ); g_percent_zone_legend[ i ].drawRect( 102, 2, 10, 17 ); if( i == z_to_8_perc_zone_foc ) { g_percent_zone_legend[ i ].setColor( default_focus_color ); g_percent_zone_legend[ i ].fillRect( 103, 3, 10, 16 ); g_percent_zone_legend[ i ].setColor( default_red_legend_color ); } } if( z_to_8_perc_zone_foc > 0 ) { if( i == z_to_8_perc_zone_foc ) { if( zone_marker_pixels[ i ] < -.01 ) { zone_marker_pixels[ i ] += 2; old_percent_zone_focus = -1; if( zone_marker_pixels[ i ] < 0 ) { percent_zone_focus = 0; break; } } g_percent_zone_legend[ i ].drawRect( 132, 2, 20, 17 ); g_percent_zone_legend[ i ].drawRect( 152, 2, 20, 17 ); g_percent_zone_legend[ i ].drawRect( 112, 2, 20, 17 ); g_percent_zone_legend[ i ].drawRect( 172, 2, 20, 17 ); // if( show_zone_markers_index > 0 && show_zone_markers_index < 3 ) // { draw_arrow__percent_zone_leg( i, 141, 6, true ); draw_arrow__percent_zone_leg( i, 161, 6, false ); draw_arrow__percent_zone_leg( i, 121, 6, true ); draw_arrow__percent_zone_leg( i, 181, 6, false ); // } } } } } static void draw_arrow__percent_zone_leg( int i, int x_pos, int y_pos, boolean up ) { ...................................... } static void scan_percent_zone_legends() { if( ( show_menu && see_behind_buttons != 1 ) || show_zone_markers_index == 1 ) { This method is called repeatedly by SurfEvent. The method finds whether the mouse is in the boxes used to change the marker pin location. .............................. } } static void draw_zone_markers() { Draws the zone marker pins on the silhouette of the mirror. Draws the legends associated with the marker pins on the silhouette. ..................................... } static void draw_legend_on_mirror_silhouette() { Draws the writing at the upper left corner of the mirror silhouette. Draws the formula if it is in use. ........................................ } static void f1_f2_f3_show_calc( Graphics g_off_scr_appR ) { Used only during the parsing of the users formula that was read in from the surf.html file. Called only to display the parsing recorded in RmR_funct.class ........................................... } // Controls calls to methods to refresh the plotboard. // char called_by: // 'I' Initialization // 'G' plot_board_control( 'G' ); Hits this every time. // 'C' toggle_state[ 1 ] Plot color change. // 'T' toggle_state[ 0 ] Mirror param change. // 't' toggle_state[ 0 ] Users data entries changed. // 'S' toggle_state[ star_sc ] or toggle_state[ surf_sc ] // 'Z' zero_value_at_percent_zone_of_focused_pin() // 'P' set_data_for_marker_pin_0_to_the_curve() // '!' toggle_state[ plot_on ] Plot board on/off. // 'm' Left side menu change. // 'r' Starward source change. // 's' Surface source change. // 'Q' static final double plot_scale_constant = 100; static void plot_board_control( char called_by ) { if( plotting_in_progress )// plotting_in_progress = true, means a formula is being parsed. { plot_board_mode_click = false; old_plot_me_data_source = plot_me_data_source; old_plot_surface_source = plot_surface_source; return; } // First pass initializing. if( called_by == 'I' ) { // Initialize the scale multipliers. starward_scale_muliplier = 1 / metric_cm[ star_sc ] * plot_scale_constant; surface_scale_muliplier = 1 / metric_cm[ surf_sc ] * plot_scale_constant; clear_and_draw_the_plotting_outlines( true ); // clear // Cross section of the mirror at the bottom of the plotboard. // with a sphereical and test mirror reference surfaces. calculate_display_sphere_parab( true, false ); // calculate, full_plot // Clears the ploting area and displays the data points if // plot_menu_selection is 0 or 1. draw_users_data_points( false ); // ghost curve_fit_to_entered_data_points(); draw_curv_fit_to_data( false, false ); // ghost, do_the_old_curve scale_for_plot_board( true, true ); // starward, erase wedge_test = 'I'; stow_or_retrieve_stowed_image( 'I' ); // char I_S_or_R return; } if( !see_plot_board && !show_menu ) return; boolean selection_changed = false; // Normal operation after initializing. boolean plot_source_changed = false; while( called_by == 'G' ) // Never loops { // Triggered by a change picked up by the plotboard menu mouse scan. if( plot_menu_focus != old_plot_menu_focus ) { plot_board_menu(); repaint_app1_image = 2; } if( plot_board_mode_click ) { plot_board_mode_click = false; plot_source_changed = false; clear_and_draw_the_plotting_outlines( true ); // clear selection_changed = true; break; } if( old_plot_me_data_source != plot_me_data_source ) { old_plot_me_data_source = plot_me_data_source; plot_source_changed = false; clear_and_draw_the_plotting_outlines( true ); // clear selection_changed = true; break; } if( old_plot_surface_source != plot_surface_source ) { old_plot_surface_source = plot_surface_source; plot_source_changed = true; clear_and_draw_the_plotting_outlines( true ); // clear selection_changed = true; break; } return; } // Dim the zero data button font for zero data on plot_menu_selection == 1. font_color[ 9 ] = default_font_color; if( !soft_colors ) font_color[ 9 ] = default_font_black; if( plot_menu_selection == 1 ) font_color[ 9 ] = default_butn_color; if( plot_menu_selection != 2 && plot_menu_selection != 3 && plot_menu_selection != 4 ) { // Clear the wedge_test legend. g_plot_board.setColor( c_plot_board_bkgrnd ); g_plot_board.fillRect( plot_bo_mirror_center - 61, mirror_surface_ref_line - 140, 50, 260 ); g_plot_board.setColor( Color.white ); g_plot_board.fillRect( plot_bo_mirror_center - 11, mirror_surface_ref_line - 129, 6, 249 ); // Refesh the Sphere and Parab refrence curves that were offset. if( zero_value_at_percent_zone_of_focused_pin_called ) calculate_display_sphere_parab( true, false ); // boolean calculate, boolean full_plot } // Clear the integration display int x_2 = plot_bo_mirror_center + 410; g_plot_board.setColor( c_plot_board_bkgrnd ); g_plot_board.fillRect( x_2, mirror_surface_ref_line - 22, 150, 48 ); g_plot_board.fillRect( x_2, mirror_surface_ref_line + 25, 90, 50 ); // Triggered by a change in color selection. // Triggered by call from set pin zero. if( called_by == 'C' || called_by == 'P' ) { // Since pin zero presumably moved. if( called_by == 'P' ) clear_and_draw_the_plotting_outlines( true ); // clear legend_for_plot_board_scale(); if( plot_menu_selection == 0 ) { if( curve_fit_to_entered_data_points() ) draw_curv_fit_to_data( false, false ); // ghost, do_the_old_curve draw_users_data_points( false ); // ghost } if( plot_menu_selection == 1 ) { if( curve_fit_to_entered_data_points() ) draw_curv_fit_to_data( true, true ); // ghost, do_the_old_curve draw_users_data_points( true ); // ghost plot_entered_data_minus_starward_selected_formula(); } // static void plot_surface_minus_reference_surface( double[] minuend, double[] subtrahind ) if( plot_menu_selection > 1 && plot_menu_selection < 5 && !plot_source_changed ) { // Reference surface 't' for transform of starward formula. if( plot_surface_source == 't' ) plot_surface_minus_reference_surface( data__surface_metric, formulas_transform_surface_metric ); // Reference surface 'p' for the formula for a parabola. if( plot_surface_source == 'p' ) plot_surface_minus_reference_surface( data__surface_metric, parabo_sag_metric ); // Reference surface 's' for the formula for a sphere. if( plot_surface_source == 's' ) plot_surface_minus_reference_surface( data__surface_metric, sphere_sag_metric ); // Reference surface 'f'. Use the users formula directly as a surface. if( plot_surface_source == 'f' ) plot_surface_minus_reference_surface( data__surface_metric, formula_as_a_surface_metric ); } plot_board_menu(); repaint_app1_image = 2; return; } // Data entry change. ( Size or units. ) and plotboard on/off. if( selection_changed || called_by == 'T' || called_by == 't' || called_by == 'S' || called_by == 'Z' || called_by == '!' ) { // Draws the little lable below the plotting scale data entry. legend_for_plot_board_scale(); if( called_by == 'T' ) // Cross section of the mirror at the bottom of the plotboard. // with a sphereical and test mirror reference surfaces. calculate_display_sphere_parab( true, false ); // calculate, full_plot else calculate_display_sphere_parab( false, false ); // calculate, full_plot // Can't plot two graphs with different scales. if( called_by == 'S' ) { clear_and_draw_the_plotting_outlines( true ); // clear if( type_of_event[ star_sc ] == 'D' ) scale_for_plot_board( true, false ); // starward, erase if( type_of_event[ surf_sc ] == 'D' ) scale_for_plot_board( false, false ); // surface, erase } // Plotboard on/off if( called_by == '!' ) if( !color_was_changed ) clear_and_draw_the_plotting_outlines( true ); // clear else if( color_was_changed ) clear_and_draw_the_plotting_outlines( false ); // clear else clear_and_draw_the_plotting_outlines( true ); // clear if( plot_menu_selection == 0 && !plot_source_changed ) { // Blocks updating if surface has been zeroed at a data pin. // Used only on plot_menu_selection 2, 3, and 4. if( blue_alert_for_transf_starward || blue_alert_for_ref_surface ) { blue_alert_for_transf_starward = false; blue_alert_for_ref_surface = false; //SA- L1,--234 draw_dashed_alert_lines( 61, false, 'w', 'z', 'z' ); g_plot_board.setColor( Color.white ); //SA- R4,t g_plot_board.drawLine( plot_source_mx + plot_menu_w + 13, plot_surface_my + 1, plot_source_mx + plot_menu_w + 13, plot_surface_my + ( plot_menu_h * 4 ) - 1 ); //SA- L1,--234 draw_dashed_alert_lines( 61, false, 'z', 'w', 'z' ); //SA- L4,--234 draw_alert_bars_for_corrector_L4a_L4b_and_R3( false, 'w', 'z', 'w', 'z', 'w', 'z', 'w', 'z' ); } // 'Set pin zero' is active on plot_menu_selection == 0 so // set the font color so it can be seen. font_color[ 8 ] = Color.black; if( soft_colors ) font_color[ 8 ] = default_font_color; old_focus[ 8 ] = default_old_focus; if( wedge_test == 'i' ) wedge_test = 'N'; type_of_event[ star_sc ] = 'D'; old_focus[ star_sc ] = default_old_focus; type_of_event[ surf_sc ] = 'z'; old_focus[ surf_sc ] = default_old_focus; scale_for_plot_board( true, false ); // starward, erase if( called_by != 't' ) calculate_display_sphere_parab( true, false ); // calculate, full_plot if( plot_me_data_source == 'E' ) { if( curve_fit_to_entered_data_points() ) { if( called_by == 't' ) // User entered new data. { clear_and_draw_the_plotting_outlines( true ); // clear scale_for_plot_board( true, false ); // starward, erase } draw_curv_fit_to_data( false, true ); // ghost, do_the_old_curve } draw_users_data_points( false ); // ghost legend_for_data_array = "Users_measured_data"; } if( plot_me_data_source == 'F' ) { draw_users_data_points( true ); // ghost double temp = 0; if( !alert_starward_formula__array_null() ) { if( curve_fit_to_entered_data_points() ) draw_curv_fit_to_data( true, false ); // ghost, do_the_old_curve try { Thread.sleep( 800 ); } catch(InterruptedException ex) {} for( int copy = 0; copy < 401; copy++ ) { temp = formu_starward_metric[ copy ]; if( !light_source_moves ) temp *= 2; curv_fit_to_data[ copy ] = temp; } g_plot_board.setColor( Color.white ); //SA- L3,0 g_plot_board.drawLine( 67, plot_menu_y + 1, 67, plot_menu_y + plot_menu_h ); //SA- L3,--234 g_plot_board.drawLine( 67, plot_menu_y + ( plot_menu_h * 2 ) + 1, 67, plot_menu_y + ( plot_menu_h * 5 ) + 1 ); draw_curv_fit_to_data( false, false ); // ghost, do_the_old_curve String s_temp = make_string_from_R_R_function_index(); s_simulated_data_formula = String.valueOf( s_temp ); legend_for_data_array = "Simulated_users_data"; } } return; } if( plot_menu_selection == 1 && !plot_source_changed ) { if( wedge_test == 'i' ) wedge_test = 'N'; type_of_event[ star_sc ] = 'D'; old_focus[ star_sc ] = default_old_focus; type_of_event[ surf_sc ] = 'z'; old_focus[ surf_sc ] = default_old_focus; scale_for_plot_board( true, false ); // starward, erase if( curve_fit_to_entered_data_points() ) draw_curv_fit_to_data( true, false ); // ghost, do_the_old_curve draw_users_data_points( true ); // ghost if( !alert_starward_formula__array_null() ) plot_starward_selected_formula( true ); // true for ghost else return; plot_entered_data_minus_starward_selected_formula(); return; } if( plot_menu_selection > 1 && plot_menu_selection < 5 && !plot_source_changed ) { type_of_event[ star_sc ] = 'z'; old_focus[ star_sc ] = default_old_focus; type_of_event[ surf_sc ] = 'D'; old_focus[ surf_sc ] = default_old_focus; scale_for_plot_board( false, false ); // surface, erase // Select the reference curve to subtract from the unknown. // static void plot_surface_minus_reference_surface( double[] minuend, double[] subtrahind ) // Reference surface 't' for transform of starward formula. if( plot_surface_source == 't' ) { if( alert_starward_formula__array_null() ) return; while( transform_correction_array_status[ 0 ] != 'x' ) // never loops { if( auto_recalculation ) { if( transform_correction_array_status[ 1 ] == 'z' ) { plot_surface_source = 'p'; fill_transform_correction_array( 'p' ); return; } break; } else { show_exception_or_error = true; exception_or_error[ 118 ] = " 'Transform of selected formula' x_transform_correction_array[] not initialized."; } break; } // Transform the data, curv_fit_to_data[] to fill the surface array, // data__surface_metric[ fill ]. starward_to_surface_transform( 'y', 'D' ); // char disp_transf, char called_by plot_surface_minus_reference_surface( data__surface_metric, formulas_transform_surface_metric ); } // Reference surface 'p' for the formula for a parabola. if( plot_surface_source == 'p' ) { if( transform_correction_array_status[ 1 ] == 'z' ) { if( auto_recalculation ) fill_transform_correction_array( 'p' ); else { show_exception_or_error = true; exception_or_error[ 118 ] = "Selected surface reference source, 'Parabolic surface' p_transform_correction_array[] not initialized."; } } // Transform the data, curv_fit_to_data[] to fill the surface array, // data__surface_metric[ fill ]. starward_to_surface_transform( 'y', 'D' ); // char disp_transf, char called_by plot_surface_minus_reference_surface( data__surface_metric, parabo_sag_metric ); } // Reference surface 's' for the formula for a sphere. if( plot_surface_source == 's' ) { if( transform_correction_array_status[ 2 ] == 'z' ) { if( auto_recalculation ) fill_transform_correction_array( 's' ); else { show_exception_or_error = true; exception_or_error[ 118 ] = "Selected surface reference source, 'Sperical Surface' s_transform_correction_array[] not initialized."; } } // Transform the data, curv_fit_to_data[] to fill the surface array, // data__surface_metric[ fill ]. starward_to_surface_transform( 'y', 'D' ); // char disp_transf, char called_by char temp = starward_to_surface_called; starward_to_surface_called = 'n'; calculate_display_sphere_parab( false, true ); // calculate, full_plot // for( int test = 0; test < 401; test++ ) // sphere_sag_metric[ test ] = 50; starward_to_surface_called = temp; plot_surface_minus_reference_surface( data__surface_metric, sphere_sag_metric ); } // Reference surface 'f'. Use the users formula directly as a surface. if( plot_surface_source == 'f' ) { while( transform_correction_array_status[ 0 ] != 'x' ) // never loops { if( auto_recalculation ) { if( transform_correction_array_status[ 1 ] == 'z' ) { plot_surface_source = 'p'; fill_transform_correction_array( 'p' ); return; } break; } else { show_exception_or_error = true; exception_or_error[ 118 ] = " 'R'-Ro as a Surface' x_transform_correction_array[] not initialized."; } break; } // Transform the data, curv_fit_to_data[] to fill the surface array, // data__surface_metric[ fill ]. starward_to_surface_transform( 'y', 'D' ); // char disp_transf, char called_by char temp = starward_to_surface_called; starward_to_surface_called = 'n'; calculate_display_sphere_parab( false, true ); // calculate, full_plot starward_to_surface_called = temp; plot_surface_minus_reference_surface( data__surface_metric, formula_as_a_surface_metric ); } return; } } if( plot_source_changed ) { if( plot_surface_source == 't' ) { if( alert_starward_formula__array_null() ) return; } type_of_event[ star_sc ] = 'z'; old_focus[ star_sc ] = default_old_focus; type_of_event[ surf_sc ] = 'D'; old_focus[ surf_sc ] = default_old_focus; clear_and_draw_the_plotting_outlines( true ); // clear scale_for_plot_board( false, false ); // boolean called_by_starward, boolean erase plot_surf_ref__transform__parab__sph__formu_surf( plot_surface_source ); } repaint_app1_image = 2; } static String s_simulated_data_formula = null; static String s_formu_starward_metric = null; static String make_string_from_R_R_function_index() { String string_from_R_R_function_index = null; if( R_R_function_index == -1 ) string_from_R_R_function_index = " R' - Ro = 0, sphere "; if( R_R_function_index == 0 ) string_from_R_R_function_index = " R' - Ro = rsq/R, parabola "; if( R_R_function_index > 0 ) string_from_R_R_function_index = " R' - Ro formula f"+R_R_function_index+"(r,R) "; return string_from_R_R_function_index; } static char type_of_scale = 'T'; static void scale_for_plot_board( boolean called_by_starward, boolean erase ) { Draws the scale at the right side of the plot board. ............................................... } static final int plot_board_clip = 130; static void draw_users_data_points( boolean ghost ) { Draws the users entered data points as an overlay on top of the curve to fit data on the plot board. ................................ } static int old_draw_curv_fit_to_data[] = null; static int old_draw_curv_fit_to_data_color_index = 2; static private void draw_curv_fit_to_data( boolean ghost, boolean do_the_old_curve ) { This method is used to plot the curve to fit data. ................................. } // static final int plot_board_clip = 130; // Used when plotting users starward data minus formula starward data. static void plot_starward_selected_formula( boolean ghost ) { ............................ } // static final int plot_board_clip = 130; static Color previous_minus_color = null; static double previous_entered_minus_formula[] = null; static void plot_entered_data_minus_starward_selected_formula() { Used when the second button on the left side of the plot board is selected. .................................... } static boolean plot_surface_minus_reference_surface( double[] minuend, double[] subtrahind ) { if( minuend == null ) { exception_or_error[ 117 ] = " plot_surface_minus_reference_surface(), minuend[] is null. "; show_exception_or_error = true; return false; } if( subtrahind == null ) { exception_or_error[ 117 ] = " plot_surface_minus_reference_surface(), subtrahind[] is null. "; show_exception_or_error = true; return false; } Draws the unknown surface and marker pins. Draws the reference surface in yellow. Applies the weighting for the unknown surface minus the reference surface as required when plot board button L3, L4 or L5 are selected. Draws the unknown surface minus the reference surface in the users selected color. Draws the wave front error in three shades of cyan. Draws the wedge display and its legends when they are in use. Tallys the integration and RMS values and displays before the method returns. ............................................. } // static final int plot_board_clip = 130; // static double sphere_sag_metric[] = new double[ 401 ]; // static double parabo_sag_metric[] = new double[ 401 ]; static private boolean clear_text__surface_formula = false; static void plot_surf_ref__transform__parab__sph__formu_surf( char source ) { int x_pos2 = plot_bo_mirror_center + 4; int y_pos2 = mirror_surface_ref_line + 112; if( source == 'c' ) { if( clear_text__surface_formula ) { g_plot_board.setColor( c_plot_board_bkgrnd ); g_plot_board.fillRect( x_pos2, y_pos2, 495, 24 ); clear_text__surface_formula = false; } return; } g_plot_board.setColor( light_yellow_color ); g_plot_board.fillRect( plot_bo_mirror_center + 12, mirror_surface_ref_line + 4, 335, 12 ); g_plot_board.setColor( Color.black ); if( source == 't' ) { g_plot_board.drawString(" Reference surface: Surface transform of starward formula. ", plot_bo_mirror_center + 15, mirror_surface_ref_line + 14 ); if( formulas_transform_surface_metric == null ) { show_exception_or_error = true; exception_or_error[ 122 ] = " plot_surf_ref__transform__parab__sph__formu_surf(), array: formulas_transform_surface_metric == null "; return; } } if( source == 'p' ) { g_plot_board.drawString(" Reference surface: Parabolic Surface ", plot_bo_mirror_center + 15, mirror_surface_ref_line + 14 ); if( parabo_sag_metric == null ) { show_exception_or_error = true; exception_or_error[ 122 ] = " plot_surf_ref__transform__parab__sph__formu_surf(), array: parabo_sag_metric == null "; return; } } if( source == 's' ) { g_plot_board.drawString(" Reference surface: Sphereical Surface ", plot_bo_mirror_center + 15, mirror_surface_ref_line + 14 ); if( sphere_sag_metric == null ) { show_exception_or_error = true; exception_or_error[ 122 ] = " plot_surf_ref__transform__parab__sph__formu_surf(), array: sphere_sag_metric == null "; return; } } if( source == 'f' ) { g_plot_board.drawString(" Reference surface: Formula used as a Surface Reference", plot_bo_mirror_center + 15, mirror_surface_ref_line + 14 ); if( formula_as_a_surface_metric == null ) { show_exception_or_error = true; exception_or_error[ 122 ] = " plot_surf_ref__transform__parab__sph__formu_surf(), array: formula_as_a_surface_metric == null "; String formula = make_string_from_R_R_function_index(); g_plot_board.setColor( default_butn_color ); g_plot_board.fillRect( x_pos2, y_pos2, 495, 24 ); g_plot_board.setColor( default_red_legend_color ); g_plot_board.drawString(" Right click 'Formula as a Surface' button to load reference array with: ", x_pos2, y_pos2 + 10 ); g_plot_board.drawString(" "+formula+" (Note, substitute a surface formula in place of the Ro - R'.)", x_pos2, y_pos2 + 21 ); clear_text__surface_formula = true; plot_surface_source = 'p'; return; } } // Draw the curve onto the plot board. When the user selects a different surface reference this method plots the users new selection. ....................................... } // static final int plot_board_clip = 130; static void stow_or_retrieve_stowed_image( char I_S_or_R ) { Used to stow and paste a stowed image onto the plot board. Buttons 8 and 9 on the left side of the plot board. ........................................ } // static final int plot_board_clip = 130; static void clear_and_draw_the_plotting_outlines( boolean clear ) { plot_surf_ref__transform__parab__sph__formu_surf( 'c' ); // Clear unneeded text. Clears the plot board and draws new ordinates. ....................................... } // This function draws the little PLOT SCALE tag below the Plot Scale data entry. static void legend_for_plot_board_scale() { ....................................... } static void plot_board_menu() { Receives the output from scan_plot_board_menu() and uses that output to draw the 'focus' highlight on a button. Translates scan_plot_board_menu() output into settings for contol variables. Calls draw_plot_board_menu_legend( boolean selecton_final, int legend ) to draw the legend at the top of the plot board image. } static void draw_plot_board_menu_legend( boolean selecton_final, int legend ) { Draws the legend at the top of the plot board image. .................................... } static void scan_plot_board_menu() { This is the mouse focus scan for the buttons on the plot board image. This method also loads arrays: formula_as_a_reference_starward_metric[] and formula_as_a_surface_metric[] when directed by a user right mouse click. ....................................... // Scan for the right side, mirror data and surface reference source. if( x_mouse_position > plot_source_mx + 3 && x_mouse_position < plot_source_mx + plot_menu_w - 6 ) { int local_plot_source_my = plot_source_my; if( y_mouse_position > local_plot_source_my && y_mouse_position < local_plot_source_my + plot_menu_h ) { plot_menu_focus = 11; old_plot_menu_focus = -2; return; } local_plot_source_my += plot_menu_h; if( y_mouse_position > local_plot_source_my && y_mouse_position < local_plot_source_my + plot_menu_h ) { plot_menu_focus = 12; old_plot_menu_focus = -2; return; } local_plot_source_my = plot_surface_my; // Surface reference source: transform of starward formula. if( y_mouse_position > local_plot_source_my && y_mouse_position < local_plot_source_my + plot_menu_h ) { plot_menu_focus = 16; old_plot_menu_focus = -2; if( right_button_pressed ) { if( transform_correction_array_status[ 0 ] == 'z' ) { if( alert_starward_formula__array_null() ) { right_button_pressed = false; return; } if( formula_as_a_reference_starward_metric == null ) formula_as_a_reference_starward_metric = new double[ 441 ]; double temp = 0; for( int copy = 0; copy < 441; copy++ ) { temp = formu_starward_metric[ copy ]; formula_as_a_reference_starward_metric[ copy ] = temp; } s_formula_as_a_reference_starward_metric = make_string_from_R_R_function_index(); g_plot_board.setColor( Color.green ); //SA- R2,--t g_plot_board.drawLine( plot_source_mx + plot_menu_w + 7, plot_surface_my + 1, plot_source_mx + plot_menu_w + 7, plot_surface_my + plot_menu_h - 1 ); } else { exception_or_error[ 123 ] = " x key + 'Clear' to reset and null reference arrays. "; show_exception_or_error = true; return; } // Will calibrate the p_transform_correction_array[] to use until // the x_transform_correction_array[] has been calibrated. fill_transform_correction_array( 't' ); // char called_by right_button_pressed = false; } return; } local_plot_source_my += plot_menu_h; // Surface reference source: parabolic surface. if( y_mouse_position > local_plot_source_my && y_mouse_position < local_plot_source_my + plot_menu_h ) { plot_menu_focus = 17; old_plot_menu_focus = -2; return; } local_plot_source_my += plot_menu_h; // Surface reference source: sphereical surface. if( y_mouse_position > local_plot_source_my && y_mouse_position < local_plot_source_my + plot_menu_h ) { plot_menu_focus = 18; old_plot_menu_focus = -2; return; } local_plot_source_my += plot_menu_h; // Surface reference source: formula as a surface. if( y_mouse_position > local_plot_source_my && y_mouse_position < local_plot_source_my + plot_menu_h ) { plot_menu_focus = 19; old_plot_menu_focus = -2; if( right_button_pressed ) { if( transform_correction_array_status[ 0 ] == 'z' ) { if( alert_starward_formula__array_null() ) { right_button_pressed = false; return; } if( formula_as_a_surface_metric == null ) formula_as_a_surface_metric = new double[ 401 ]; double temp = 0; for( int copy = 0; copy < 401; copy++ ) { temp = formu_starward_metric[ copy ]; formula_as_a_surface_metric[ copy ] = temp; } s_formula_as_a_surface_metric = make_string_from_R_R_function_index(); g_plot_board.setColor( Color.green ); g_plot_board.drawLine( plot_source_mx + plot_menu_w + 7, plot_surface_my + plot_menu_h * 3 + 1, plot_source_mx + plot_menu_w + 7, plot_surface_my + plot_menu_h * 4 - 1 ); // Clear text requesting this right click. clear_text__surface_formula = true; plot_surf_ref__transform__parab__sph__formu_surf( 'c' ); } else { exception_or_error[ 123 ] = " x key + 'Clear' to reset and null reference arrays. "; show_exception_or_error = true; return; } // Will calibrate the p_transform_correction_array[] to use until // the x_transform_correction_array[] has been calibrated. fill_transform_correction_array( 'f' ); // char called_by right_button_pressed = false; } return; } } plot_menu_focus = -1; } static void clear_plot_board_menu() { Clears and redraws the buttons on the plot board so the user will know where to place the mouse to make desired selection. ........................................... } // Clear app image is similar to clear on a calculator. // It is intended to reset all program control variables // and wipe the image clean. // formula_as_a_reference_starward_metric[] and // formula_as_a_surface_metric[] are not nulled by this method. static void clear_app_image( Graphics g_off_scr_app1, Graphics g_off_scr_appR, Graphics g_plot_board ) { .............................. g_plot_board.setColor( Color.red ); //SA- L2,--234 g_plot_board.drawLine( 64, plot_menu_y + ( plot_menu_h * 2 ) + 1, 64, plot_menu_y + plot_menu_h * 5 ); //SA- L3,--234 g_plot_board.drawLine( 67, plot_menu_y + ( plot_menu_h * 2 ) + 1, 67, plot_menu_y + plot_menu_h * 5 ); draw_alert_bars_locating_dots(); ............................... } static void recalculate_values() { Updates the data for: Page one center obstruction magnification exit pupil caustic X and Y values Page two R'-Ro Sets red colored button frame for zero mirror diameter. ............................................. } static final Color green_glass_color = new Color( 158,194,183 ); static final Color light_yellow_color = new Color( 224,228,148 ); static double sphere_sag_metric[] = new double[ 401 ]; static double sphere_sag_pixels[] = new double[ 401 ]; static double parabo_sag_metric[] = new double[ 401 ]; static double r_sq_ovr_R_metric[] = new double[ 401 ]; static double KE_to_surface_ratio[] = new double[ 401 ]; static double formu_starward_metric[] = null; // formula_as_a_surface_metric[] copied from formu_starward_metric[] by user as needed. // Right mouse click on 'Formula Surface Reference' to load. // static double formula_as_a_surface_metric[] = null; static void calculate_display_sphere_parab( boolean calculate, boolean full_plot ) { int x_pos = plot_bo_mirror_center; int y_pos = plot_board_height - 62; double metric_mirr_size = metric_cm[ m_d_btn ]; double metric_Rad_of_Cv = metric_cm[ r_c_btn ]; double metric_diag_size = metric_cm[ diagbtn ]; double diag_pixels = 0; int i_diag_pixels = 0; diag_pixels = ( metric_diag_size / metric_mirr_size ) * 400; i_diag_pixels = (int)( Math.rint( diag_pixels ) ); if( calculate ) { double metricRad_of_Cv_sq = metric_Rad_of_Cv * metric_Rad_of_Cv; double old_parab_temp = 0; double metric_r_x_sq = 0; for( int px = 0; px < 401; px++ ) { // 400 steps of .5 each ( its a radius ) double metric_r_x = metric_mirr_size / 800; metric_r_x *= (double)px; metric_r_x_sq = metric_r_x * metric_r_x; if( metric_r_x < metric_Rad_of_Cv ) sphere_sag_metric[ px ] = metric_Rad_of_Cv - Math.sqrt( metricRad_of_Cv_sq - metric_r_x_sq ); else sphere_sag_metric[ px ] = metric_Rad_of_Cv; sphere_sag_pixels[ px ] = ( sphere_sag_metric[ px ] / metric_mirr_size ) * 400; double parab_temp = metric_r_x_sq / ( 2 * metric_Rad_of_Cv ); int test_parab = (int)( ( parab_temp / metric_mirr_size ) * 800 ); if( y_pos - test_parab < 3 ) parabo_sag_metric[ px ] = old_parab_temp; else { parabo_sag_metric[ px ] = parab_temp; old_parab_temp = parab_temp; } double temp_r_R = metric_r_x_sq / ( 2 * metric_Rad_of_Cv ); r_sq_ovr_R_metric[ px ] = temp_r_R; } } zero_value_at_percent_zone_of_focused_pin_called = false; // Display on every pass. // Background behind mirror in cross section. g_plot_board.setColor( c_plot_board_bkgrnd ); g_plot_board.fillRect( x_pos - 22, y_pos - 37, 423, 87 ); // Edge elevation reference. ( little arrow ) g_plot_board.setColor( Color.darkGray ); g_plot_board.drawLine( x_pos, y_pos, x_pos + 4, y_pos ); g_plot_board.drawLine( x_pos + 402, y_pos, x_pos + 407, y_pos ); g_plot_board.drawLine( x_pos + 403, y_pos - 1, x_pos + 403, y_pos - 1 ); g_plot_board.drawLine( x_pos + 403, y_pos + 1, x_pos + 403, y_pos + 1 ); int clip_off = 330; if( full_plot || ( wedge_test == 'Y' && plot_menu_selection < 2 ) ) clip_off = mirror_surface_ref_line - plot_board_clip; boolean first_pass = true; for( int m_rad = 1; m_rad < 401; m_rad++ ) { double sag_parabo = parabo_sag_metric[ m_rad ]; int parabo_pixel = (int)Math.rint( ( sag_parabo / metric_mirr_size ) * 800 ); double sag_sphere = sphere_sag_metric[ m_rad ]; int sphere_pixel = (int)Math.rint( ( sag_sphere / metric_mirr_size ) * 800 ); // Avoid trying to plot off the bottom of the Applet. if( parabo_pixel < - 41 || sphere_pixel < - 41 ) break; // Parabolic mirror int test_overrun = y_pos - parabo_pixel; if( m_rad >= i_diag_pixels && test_overrun > clip_off && test_overrun < plot_board_height ) { g_plot_board.setColor( green_glass_color ); g_plot_board.drawLine( x_pos + m_rad, y_pos - parabo_pixel, x_pos + m_rad, y_pos + 41 ); } // Spherical reference test_overrun = y_pos - sphere_pixel; if( test_overrun > clip_off && test_overrun < plot_board_height ) { // If plotting data surface or formula surface don't plot sphere surface. if( starward_to_surface_called == 'N' || starward_to_surface_called == 'n' ) { if( first_pass ) { first_pass = false; g_plot_board.setColor( c_plot_board_bkgrnd ); g_plot_board.fillRect( plot_bo_mirror_center - 8, y_pos - 9, 7, 10 ); g_plot_board.setColor( Color.black ); g_plot_board.drawString("S", plot_bo_mirror_center - 8, y_pos ); } g_plot_board.setColor( Color.black ); g_plot_board.drawLine( x_pos + m_rad, y_pos - sphere_pixel, x_pos + m_rad , y_pos - sphere_pixel ); } } } /* Optional display of reference parabola's r_sq / R // r_sq / R int r_R_offset = y_pos - 34; int r_R_pixel = (int)( ( r_sq_ovr_R_metric[ 400 ] / metric_mirr_size ) * 800 ); if( r_R_pixel > 0 && r_R_offset + r_R_pixel < plot_board_height ) { g_plot_board.setColor( light_yellow_color ); g_plot_board.drawLine( x_pos - 12, r_R_offset + 2, x_pos - 12, r_R_offset + r_R_pixel - 2 ); g_plot_board.drawLine( x_pos - 11, r_R_offset + 1, x_pos - 11, r_R_offset + r_R_pixel - 1 ); g_plot_board.setColor( Color.black ); g_plot_board.drawLine( x_pos - 10, r_R_offset , x_pos - 10, r_R_offset + r_R_pixel ); g_plot_board.setColor( light_yellow_color ); g_plot_board.drawLine( x_pos - 9, r_R_offset + 1, x_pos - 9, r_R_offset + r_R_pixel - 1 ); g_plot_board.drawLine( x_pos - 8, r_R_offset + 2, x_pos - 8, r_R_offset + r_R_pixel - 2 ); } g_plot_board.setColor ( light_yellow_color ); g_plot_board.fillRect( x_pos + 7, y_pos + 4, 250, 12 ); g_plot_board.setColor( Color.black ); g_plot_board.drawString(" r_sq over R + (r^4 / 2 * R^3) is "+four_past_format.format( Mouble.to_display_value( r_sq_ovr_R_metric[ 400 ], m_d_btn ) )+" " +Mouble.select_proper_units_string_for( sys_of_units[ m_d_btn ] )+" ", x_pos + 10, y_pos + 14 ); */ if( calculate ) { // Calculate a ratio so we can find how much the mirror surface // changes with a change of center_of_curvature measurement. KE_to_surface_ratio[ 0 ] = 0; for( int m_rad = 1; m_rad < 401; m_rad++ ) { double delta_R_of_C = r_sq_ovr_R_metric[ m_rad ]; double delta_surface = sphere_sag_metric[ m_rad ] - parabo_sag_metric[ m_rad ]; KE_to_surface_ratio[ m_rad ] = delta_surface / delta_R_of_C; } } // Percent scale g_plot_board.setColor( default_focus_color ); g_plot_board.fillRect( x_pos, y_pos + 45, 401, 8 ); g_plot_board.setColor( Color.black ); for( int i = 0; i < 401; i += 4 ) { g_plot_board.drawLine( x_pos + i, y_pos + 49, x_pos + i, y_pos + 52 ); if( ( i % 20 ) == 0 ) g_plot_board.drawLine( x_pos + i, y_pos + 47, x_pos + i, y_pos + 52 ); if( ( i % 40 ) == 0 ) g_plot_board.drawLine( x_pos + i, y_pos + 45, x_pos + i, y_pos + 52 ); } } static double ix = 0; static double d_normalized_R_of_C; static final int mirror_surface_ref_line = 190; // static double formu_starward_metric[] = new double[ 441 ]; // Was: static void plot_ronchi_display(... in the Ronchi program. static private final Font starward_formula_plotboard_font = new Font( my_font_string_4, Font.PLAIN, 10 ); static void fill_starward_array( boolean first_pass ) { // initialization if( first_pass ) { if( formu_starward_metric == null ) formu_starward_metric = new double[ 441 ]; ix = 0; d_normalized_R_of_C = 400 * metric_cm[ r_c_btn ] / metric_cm[ m_d_btn ]; ledger_color_white = false; // Prepairs the plot board for a temporary display of the mirror surface profile. g_plot_board.setColor( c_plot_board_bkgrnd ); g_plot_board.fillRect( plot_bo_mirror_center + 1, mirror_surface_ref_line - plot_board_clip, 399, plot_board_clip * 2 ); // Re-draw percent scale. g_plot_board.setColor( Color.gray ); for( int i = 0; i < 401; i += 4 ) { g_plot_board.drawLine( plot_bo_mirror_center + i, mirror_surface_ref_line - 1, plot_bo_mirror_center + i, mirror_surface_ref_line + 1 ); if( ( i % 20 ) == 0 ) g_plot_board.drawLine( plot_bo_mirror_center + i, mirror_surface_ref_line - 2, plot_bo_mirror_center + i, mirror_surface_ref_line + 2 ); if( ( i % 40 ) == 0 ) g_plot_board.drawLine( plot_bo_mirror_center + i, mirror_surface_ref_line - 3, plot_bo_mirror_center + i, mirror_surface_ref_line + 3 ); } return; } int array_and_plot_index = 0; // static int re_view_count = 40; for( int i = 0; i < re_view_count; i++ ) { if( ix < 221 ) { double d_r_squared_xy = ix * ix; double d_delta_xy = 0; if( R_R_function_index == -1 ) d_delta_xy = 0; // Sphere, constant radius at all xy. if( R_R_function_index == 0 ) d_delta_xy = ( funcion_r_sq_R( d_r_squared_xy, d_normalized_R_of_C ) ); if( R_R_function_index > 0 ) d_delta_xy = ( RmR_fuct.funcion_f1_f2_f3( Math.sqrt( d_r_squared_xy ), d_normalized_R_of_C ) ); double d_starward_pxl = 0; array_and_plot_index = (int)( ix * 2 ); if( array_and_plot_index < 441 ) { d_starward_pxl = d_delta_xy; d_delta_xy = ( d_delta_xy / 400 ) * metric_cm[ m_d_btn ]; formu_starward_metric[ array_and_plot_index ] = d_delta_xy; } else { show_exception_or_error = true; exception_or_error[ 100 ] = " Array out of bounds, formu_starward_metric() "; plotting_in_progress = false; g_plot_board.setColor( Color.red ); //SA- L3,--2345 g_plot_board.drawLine( 67, plot_menu_y + plot_menu_h + 1, 67, plot_menu_y + plot_menu_h * 5 ); return; } int i_starward_pxl = (int)( Math.rint( d_starward_pxl ) ); g_plot_board.setColor( plot_colorsR[ plotting_color_index ] ); if( i_starward_pxl > plot_board_clip ) { i_starward_pxl = plot_board_clip; g_plot_board.setColor( Color.red ); } if( i_starward_pxl < -plot_board_clip ) { i_starward_pxl = -plot_board_clip; g_plot_board.setColor( Color.red ); } g_plot_board.drawLine( plot_bo_mirror_center + array_and_plot_index, mirror_surface_ref_line - i_starward_pxl, plot_bo_mirror_center + array_and_plot_index, mirror_surface_ref_line - i_starward_pxl ); ix += .5; // Allows escape from plotting loop. if( reset_re_view_count ) { reset_re_view_count = false; if( R_R_function_index > 0 ) { show_calc = 1; btn_frame_color[ 4 ] = Color.green; re_view_count = 5; old_focus[ 4 ] = default_old_focus; break; } } } // Checks for all done. if( ix > 220 ) { function___chars = null; function_of_char = null; funct_char__copy = null; function___paren = null; funct_paren_copy = null; d_function_varib = null; plotting_in_progress = false; g_plot_board.setFont( starward_formula_plotboard_font ); String function_num = null; g_plot_board.setColor( c_plot_board_bkgrnd ); if( !param_W_active ) // param_W_active, see RmR_fuct file. g_plot_board.fillRect( plot_bo_mirror_center - 10, mirror_surface_ref_line + 4, 450, 12 ); g_plot_board.setColor( light_yellow_color ); if( R_R_function_index == -1 ) function_num = " R' - Ro is 0, sphere. "; if( R_R_function_index == 0 ) function_num = " R' - Ro is rsq/R, parab. "; if( R_R_function_index > 0 ) { if( R_R_function_index == 1 ) function_num = "R' - Ro is f1(r,R) = "+funct_01+" "; if( R_R_function_index == 2 ) function_num = "R' - Ro is f2(r,R) = "+funct_02+" "; if( R_R_function_index == 3 ) function_num = "R' - Ro is f3(r,R) = "+funct_03+" "; if( !param_W_active ) g_plot_board.fillRect( plot_bo_mirror_center - 10, mirror_surface_ref_line + 4, 420, 12 ); g_plot_board.setColor( Color.black ); g_plot_board.drawString(" "+function_num+" ", plot_bo_mirror_center - 10, mirror_surface_ref_line + 14 ); } else { g_plot_board.fillRect( plot_bo_mirror_center + 12, mirror_surface_ref_line + 4, 170, 12 ); g_plot_board.setColor( Color.black ); g_plot_board.drawString(" "+function_num+" ", plot_bo_mirror_center + 15, mirror_surface_ref_line + 14 ); } // Cancel replot alert bars as necessary. g_plot_board.setColor( Color.yellow ); //SA- L3,0 g_plot_board.drawLine( 67, plot_menu_y + 1, 67, plot_menu_y + plot_menu_h ); //SA- L3,--2345 g_plot_board.drawLine( 67, plot_menu_y + ( plot_menu_h * 2 ) + 1, 67, plot_menu_y + plot_menu_h * 5 ); g_plot_board.setColor( Color.white ); //SA- L3,-1 g_plot_board.drawLine( 67, plot_menu_y + plot_menu_h, 67, plot_menu_y + plot_menu_h * 2 ); //SA- R1,-1 g_plot_board.drawLine( plot_source_mx + plot_menu_w + 4, plot_source_my + plot_menu_h, plot_source_mx + plot_menu_w + 4, plot_source_my + plot_menu_h * 2 ); //SA- R2,F g_plot_board.drawLine( plot_source_mx + plot_menu_w + 7, plot_source_my + plot_menu_h, plot_source_mx + plot_menu_w + 7, plot_source_my + plot_menu_h * 2 ); //SA- R1,----4 g_plot_board.drawLine( plot_source_mx + plot_menu_w + 4, plot_source_my + plot_menu_h * 3 + 1, plot_source_mx + plot_menu_w + 4, plot_source_my + plot_menu_h * 4 ); //SA- R1,-----s g_plot_board.drawLine( plot_source_mx + plot_menu_w + 4, plot_surface_my + plot_menu_h * 3, plot_source_mx + plot_menu_w + 4, plot_surface_my + plot_menu_h * 4 ); g_plot_board.setColor( Color.white ); //SA- R1,--t g_plot_board.drawLine( plot_source_mx + plot_menu_w + 4, plot_surface_my + 1, plot_source_mx + plot_menu_w + 4, plot_surface_my + plot_menu_h - 1 ); if( auto_recalculation ) { if( transform_correction_array_status[ 1 ] == 'z' ) { plot_surface_source = 'p'; fill_transform_correction_array( 'p' ); } } starward_to_surface_transform( 'Y', 'F' ); // char disp_transf, char called_by String s_temp = make_string_from_R_R_function_index(); s_formu_starward_metric = String.valueOf( s_temp ); break; } } if( show_calc > 1 ) // Draws progress line. { g_off_scr_appR.setColor( Color.white ); g_off_scr_appR.drawLine( x_app_image_center + (int)ix, (int)y_app_image_center - 1, x_app_image_center + (int)ix, (int)y_app_image_center + 1 ); } // Copy the ploted image onto the anti flicker image. // Repeated during plotting to show progress. g_off_scr_app1.drawImage( image_off_scr_appR, 0, 0, my_event ); } // static boolean auto_recalculation = false; static boolean alert_starward_formula__array_null() { if( formu_starward_metric == null ) { if( auto_recalculation ) { if( plotting_in_progress ) return false; toggle_state[ 3 ] = true; return true; } g_plot_board.setColor( lite_plot_colorsR[ plotting_color_index ] ); g_plot_board.fillRect( x_pos[ 3 ] - 2, y_pos[ 3 ] - 3, sm_bwidth[ 3 ] + 4, bheight[3 ] + 5 ); g_plot_board.setColor( plot_colorsR[ 1 ] ); g_plot_board.drawRect( x_pos[ 3 ] - 3, y_pos[ 3 ] - 3, sm_bwidth[ 3 ] + 5, bheight[3 ] + 5 ); g_plot_board.drawRect( x_pos[ 3 ] - 2, y_pos[ 3 ] - 2, sm_bwidth[ 3 ] + 3, bheight[3 ] + 3 ); g_plot_board.setColor( Color.black ); g_plot_board.drawString("Formula[] null", x_pos[ 3 ] + 4, y_pos[ 3 ] + 15 ); show_exception_or_error = true; exception_or_error[ 116 ] = " formu_starward_metric[ ] is null. 'Start Plot' to fill. "; repaint_app1_image = 2; return true; } g_plot_board.setColor( c_plot_board_bkgrnd ); g_plot_board.fillRect( x_pos[ 3 ] - 5, y_pos[ 3 ] - 3, sm_bwidth[ 3 ] + 10, bheight[3 ] + 6 ); return false; } static double funcion_r_sq_R( double d_r_squared, double d_R ) { //double d_r_squared = d_r * d_r; double d_r_sq_over_R = d_r_squared / d_R; return( d_r_sq_over_R * .5 ); } static double curv_fit_to_data[] = null; // public static double zone_marker_pixels[] = new double[ 9 ]; // static int data_btn_ptr[] = new int[ 9 ]; // static double metric_cm_assocated_with_data_mkr_zero = 0; // static double metric_cm[ data_btn_ptr[ j ] ] static private boolean curve_fit_to_entered_data_points() { double sorted_zone_marker_pixels[] = new double[ 11 ]; double sorted_marker_pin_data[] = new double[ 11 ]; // zone_marker_pixels[ 0 ] is not used for curve fitting. // After the curve is fit zone_marker_pixels[ 0 ] is set to // a radius such that half the mirror surface is inside // and half the mirror surface is outside. Then its data is // set to the apropriate index in the curve curv_fit_to_data[] // by function set_data_for_marker_pin_0_to_the_curve(). // If null then the input data has probably been changed. if( curv_fit_to_data == null ) curv_fit_to_data = new double[ 451 ]; for( int zero = 0; zero < 451; zero++ ) curv_fit_to_data[ zero ] = 0; // Sort the zone_marker_pixels[] by assending radius(es). // Put results into sorted_zone_marker_pixels[]. for( int pre = 0; pre < 11; pre++ ) sorted_zone_marker_pixels[ pre ] = -5; int this_element = -1; int from_ptr = 0; double test_value = 0; double review_value = 0; int maybe = -1; boolean used[] = new boolean[ 10 ]; for( int it = 0; it < 10; it++ ) used[ it ] = false; int ptr_for_sorted_array = 1; int count = 0; boolean all_elements_used = false; while( !all_elements_used ) { this_element += 1; if( this_element > 10 ) this_element = 0; if( this_element < 9 ) { test_value = zone_marker_pixels[ this_element ]; for( from_ptr = 0; from_ptr < 9; from_ptr++ ) { if( !used[ from_ptr ] ) { review_value = zone_marker_pixels[ from_ptr ]; if( review_value <= test_value ) { test_value = review_value; maybe = from_ptr; } } } } if( ptr_for_sorted_array < 10 ) { if( maybe > -1 ) { // Marker pins with negative r will not be part of the sort. // Also marker pin 0 will be set to the finished curve. if( zone_marker_pixels[ maybe ] < 0 || maybe == 0 ) used[ maybe ] = true; if( !used[ maybe ] ) { double sort_value = ( 2 * zone_marker_pixels[ maybe ] ); sorted_zone_marker_pixels[ ptr_for_sorted_array ] = sort_value; // Assort the data values to go with their marker pin locations. double test_data = 0; // if( ptr_for_sorted_array == 0 ) // test_data = metric_cm_assocated_with_data_mkr_zero; // else test_data = metric_cm[ data_btn_ptr[ maybe ] ]; if( sort_value < 0 ) sorted_marker_pin_data[ ptr_for_sorted_array ] = -6.666; else sorted_marker_pin_data[ ptr_for_sorted_array ] = test_data; ptr_for_sorted_array += 1; used[ maybe ] = true; maybe = -1; } } } all_elements_used = false; for( int fin = 0; fin > 9; fin++ ) { if( !used[ fin ] ) all_elements_used = true; } count+= 1; if( count > 50 ) // Just for good luck. break; } // Identify invalid marker pins. boolean valid_marker_pin[] = new boolean[ 11 ]; int number_of_valid_pins = 0; double data_value_of_first_valid_pin = 0; for( int val = 0; val < 11; val++ ) { valid_marker_pin[ val ] = false; if( sorted_zone_marker_pixels[ val ] >= 0 ) { if( number_of_valid_pins == 0 ) data_value_of_first_valid_pin = sorted_marker_pin_data[ val ]; valid_marker_pin[ val ] = true; // If there are two valid marker pins then the phantom pins are also valid. number_of_valid_pins += 1; } } // If by some chance all marker pins are undefined // then no curve can be fit. if( number_of_valid_pins < 2 ) { show_exception_or_error = true; exception_or_error[ 0 ] = " At least two marker pins must be set in the range 0 to 100 percent. No curve defined. "; if( number_of_valid_pins == 0 ) { for( int zero = 0; zero < 451; zero++ ) curv_fit_to_data[ zero ] = 0; } else { for( int zerp = 0; zerp < 451; zerp++ ) curv_fit_to_data[ zerp ] = data_value_of_first_valid_pin; } return true; } // Pad the low end of the array. // Put a 'phantom' marker pin at a negative radius. boolean users_inner_pin_is_at_the_center = false; for( int pad = 0; pad < 10; pad++ ) { if( valid_marker_pin[ pad + 1 ] ) { if( sorted_zone_marker_pixels[ pad + 1 ] > .05 ) { sorted_zone_marker_pixels[ 0 ] = - sorted_zone_marker_pixels[ pad + 1 ]; valid_marker_pin[ 0 ] = true; sorted_marker_pin_data[ 0 ] = sorted_marker_pin_data[ pad + 1 ]; break; } if( sorted_zone_marker_pixels[ pad + 1 ] > -.05 && sorted_zone_marker_pixels[ pad + 1 ] < .05 ) { sorted_zone_marker_pixels[ 0 ] = - sorted_zone_marker_pixels[ pad + 2 ]; valid_marker_pin[ 0 ] = true; sorted_marker_pin_data[ 0 ] = sorted_marker_pin_data[ pad + 2 ]; users_inner_pin_is_at_the_center = true; break; } } } // Pad the high end of the array. // Put a 'phantom' marker pin beyond the mirror edge. { boolean unable_to_extrapolate = false; double high_pad_pixels = 425; double pixels_minus_one = 0; double pixels_minus_two = 0; double data_minus_one = 0; double data_minus_two = 0; double delta_r = 0; double delta_data = 0; for( int pae = 10; pae > 0; pae-- ) { if( valid_marker_pin[ pae - 1 ] ) { sorted_zone_marker_pixels[ pae ] = high_pad_pixels; pixels_minus_one = sorted_zone_marker_pixels[ pae - 1 ]; data_minus_one = sorted_marker_pin_data[ pae - 1 ]; if( pae - 1 > 0 ) { for( int paf = pae - 2; paf >= 0; paf-- ) { if( valid_marker_pin[ paf] ) { pixels_minus_two = sorted_zone_marker_pixels[ paf ]; data_minus_two = sorted_marker_pin_data[ paf ]; break; } if( paf == 0 ) unable_to_extrapolate = true; } if( !unable_to_extrapolate ) { delta_r = pixels_minus_one - pixels_minus_two; delta_data = data_minus_one - data_minus_two; sorted_marker_pin_data[ pae ] = data_minus_one + ( ( delta_data / delta_r ) * ( high_pad_pixels - pixels_minus_one ) ); } } else unable_to_extrapolate = true; if( unable_to_extrapolate ) sorted_marker_pin_data[ pae ] = sorted_marker_pin_data[ pae - 1 ]; valid_marker_pin[ pae ] = true; break; } } } // double sorted_zone_marker_pixels[] = new double[ 11 ]; // double sorted_marker_pin_data[] = new double[ 11 ]; // Find the curve slope ( = delta y / delta r ) at each data point radius. // First find the slope from data point n-1 and to data point n+1. double slope_from_n_minus_1[] = new double[ 11 ]; double slope_to___n_plus__1[] = new double[ 11 ]; for( int slpa = 0; slpa < 11; slpa++ ) { double delta_r = 0; double delta_data = 0; if( valid_marker_pin[ slpa ] ) { // n from n-1 if( slpa > 0 ) { delta_r = sorted_zone_marker_pixels[ slpa ] - sorted_zone_marker_pixels[ slpa - 1 ]; delta_data = sorted_marker_pin_data[ slpa ] - sorted_marker_pin_data[ slpa - 1 ]; } if( delta_r == 0 ) delta_r = .00001; slope_from_n_minus_1[ slpa ] = delta_data / delta_r; if( slpa < 10 ) { // n to n+1 delta_r = sorted_zone_marker_pixels[ slpa + 1 ] - sorted_zone_marker_pixels[ slpa ]; delta_data = sorted_marker_pin_data[ slpa + 1 ] - sorted_marker_pin_data[ slpa ]; } if( delta_r == 0 ) delta_r = .00001; slope_to___n_plus__1[ slpa ] = delta_data / delta_r; } } // Find the bisecting angle of from_angle[] and to___angle[]. double from_angle[] = new double[ 11 ]; double to___angle[] = new double[ 11 ]; double bisecting_angle[] = new double[ 11 ]; double bisecting_slope[] = new double[ 11 ]; boolean pin_spacing_is_ok = true; for( int bisec = 1; bisec < 10; bisec++ ) { from_angle[ bisec ] = Math.atan( slope_from_n_minus_1[ bisec ] ); to___angle[ bisec ] = Math.atan( slope_to___n_plus__1[ bisec ] ); double _fr_angle = from_angle[ bisec ]; if( _fr_angle < 0 ) _fr_angle = -_fr_angle; if( 1.57 - _fr_angle < 1.3 ) // 1.571 is 90 degrees in radians. pin_spacing_is_ok = false; double _to_angle = to___angle[ bisec ]; if( _to_angle < 0 ) _to_angle = -_to_angle; if( 1.57 - _to_angle < 1.3 ) pin_spacing_is_ok = false; if( !pin_spacing_is_ok ) { show_exception_or_error = true; exception_or_error[ 0 ] = " Marker pins are spaced too close together. "; } bisecting_angle[ bisec ] = .5 * ( from_angle[ bisec ] + to___angle[ bisec ] ); bisecting_slope[ bisec ] = Math.tan( bisecting_angle[ bisec ] ); } // Make sure the high end pad pin slope is defined. for( int hi_bisec = 10; hi_bisec > 0; hi_bisec-- ) { if( valid_marker_pin[ hi_bisec ] ) { bisecting_angle[ hi_bisec ] = from_angle[ hi_bisec ]; bisecting_slope[ hi_bisec ] = slope_from_n_minus_1[ hi_bisec ]; break; } } // Set the low end pad pin's slope as a reflection of the first or second pin. if( users_inner_pin_is_at_the_center ) { bisecting_angle[ 0 ] = -bisecting_angle[ 2 ]; bisecting_slope[ 0 ] = -bisecting_slope[ 2 ]; } else { bisecting_angle[ 0 ] = 0; bisecting_slope[ 0 ] = 0; } // double sorted_zone_marker_pixels[] = new double[ 11 ]; // double sorted_marker_pin_data[] = new double[ 11 ]; // double bisecting_slope[] = new double[ 11 ]; // Fit sin or cos waves to the data points to finish // the fitted curve. // static double curv_fit_to_data[] = new double[ 431 ]; double pi = Math.PI; // double fouth_pi = .25 * Math.PI; double half_pi = .5 * pi; // double thr_fo_pi = .75 * pi; // double one_one_fo = 1.25 * pi; double th_haf_pi = 1.5 * pi; double two_pi = 2 * pi; double thre_pi = 3 * pi; double five_pi = 5 * pi; double sevn_pi = 7 * pi; double r_0 = 0; int ir_0 = 0; double r_1 = 0; int ir_1 = 0; double delta_r = 0; double data_0 = 0; double data_1 = 0; double slope0 = 0; double slope1 = 0; double bet_slope0 = 0; double bet_slope1 = 0; double bet_slope = 0; double bet_point = 0; int curv = 0; double dbetween = 0; double forward = 0; double back = 0; double center1 = 0; double center2 = 0; double center3 = 0; double center4 = 0; double center5 = 0; for( int next = 0; next < 11; next++ ) { if( valid_marker_pin[ next ] ) { if( next < 10 ) { r_0 = sorted_zone_marker_pixels[ next ]; ir_0 = (int)( Math.rint( r_0 ) ); r_1 = sorted_zone_marker_pixels[ next + 1 ]; ir_1 = (int)( Math.rint( r_1 ) ); delta_r = r_1 - r_0; data_0 = sorted_marker_pin_data[ next ]; data_1 = sorted_marker_pin_data[ next + 1 ]; slope0 = bisecting_slope[ next ]; slope1 = bisecting_slope[ next + 1 ]; bet_slope0 = slope_to___n_plus__1[ next ]; bet_slope1 = slope_from_n_minus_1[ next + 1 ]; bet_slope = bet_slope0 + bet_slope1; bet_slope *= .5; for( curv = ir_0; curv < ir_1; curv++ ) { dbetween = (double)curv - r_0; bet_point = data_0 + ( bet_slope0 * dbetween ); forward = data_0 + ( dbetween * slope0 ); back = data_1 - ( dbetween * -slope1 ) + ( delta_r * -slope1 ); forward *= Math.cos( ( dbetween / delta_r ) * half_pi ) * ( delta_r - dbetween ) / delta_r; back *= Math.cos( ( ( dbetween / delta_r ) * half_pi ) + th_haf_pi ) * ( dbetween ) / delta_r; center1 = Math.sin( ( dbetween / delta_r ) * pi ); center1 *= bet_point; center1 *= .296; center2 = Math.cos( ( ( ( dbetween ) / delta_r ) * thre_pi ) + th_haf_pi ); center2 *= bet_point; center2 *= .0037; center3 = Math.cos( ( ( ( dbetween ) / delta_r ) * five_pi ) + th_haf_pi ); center3 *= bet_point; center3 *= .00075; //.001; //scale_multiplier; center4 = Math.cos( ( ( ( dbetween ) / delta_r ) * sevn_pi ) + th_haf_pi ); center4 *= bet_point; center4 *= .00026; if( curv > -1 && curv < 451 ) curv_fit_to_data[ curv ] = forward + back + center1 + center2 + center3 + center4; if( curv > 600 ) break; } } else break; } else break; } /* // Used to test the curve smoothing. for( int tst = 0; tst < 451; tst++ ) curv_fit_to_data[ tst ] = 0; curv_fit_to_data[ 100 ] = 100; curv_fit_to_data[ 101 ] = -100; curv_fit_to_data[ 103 ] = 100; curv_fit_to_data[ 220 ] = 100; curv_fit_to_data[ 221 ] = 100; curv_fit_to_data[ 223 ] = 100; */ if( pin_spacing_is_ok && !see_angle_lines ) { for( int smo = 0; smo < 15; smo++ ) smooth_the_curve( curv_fit_to_data ); } // Cancel alert lines as needed. g_plot_board.setColor( Color.white ); //SA- L1,01234 draw_dashed_alert_lines( 61, false, 'z', 'z', 'w' ); //SA- R2,E g_plot_board.drawLine( plot_source_mx + plot_menu_w + 7, plot_source_my, plot_source_mx + plot_menu_w + 7, plot_source_my + plot_menu_h ); //SA- L2,01--- g_plot_board.drawLine( 64, plot_menu_y + 1, 64, plot_menu_y + plot_menu_h * 2 ); //SA- R1,E g_plot_board.drawLine( plot_source_mx + plot_menu_w + 4, plot_source_my + 1, plot_source_mx + plot_menu_w + 4, plot_source_my + plot_menu_h ); if( !pin_spacing_is_ok || see_angle_lines ) { g_plot_board.setColor( Color.red ); //SA- L1,01234 // draw_dashed_alert_lines( int L_line, boolean starward, char zeroing_color_1, char zeroing_color_2, char curve_fit_color ) draw_dashed_alert_lines( 61, false, 'z', 'z', 'r' ); //SA- R1,E g_plot_board.drawLine( plot_source_mx + plot_menu_w + 4, plot_source_my + 1, plot_source_mx + plot_menu_w + 4, plot_source_my + plot_menu_h - 1 ); } // Correction for a non linear curve and F4 curve. // static private double supply_function_of_delta_r( double delta_r, char test ) //for( int test_ = 0; test_ < 451; test_++ ) // supply_function_of_delta_r( (double)test_, 'A', -1 ); double non_linear = 0; double sq_rt_slope0 = 0; double sq_rt_slope1 = 0; double n0_to_from_diff = 0; double n1_to_from_diff = 0; double function_of_delta_r = 0; for( int next = 0; next < 11; next++ ) { if( valid_marker_pin[ next ] ) { if( next < 10 ) { r_0 = sorted_zone_marker_pixels[ next ]; ir_0 = (int)( Math.rint( r_0 ) ); r_1 = sorted_zone_marker_pixels[ next + 1 ]; ir_1 = (int)( Math.rint( r_1 ) ); delta_r = r_1 - r_0; data_0 = sorted_marker_pin_data[ next ]; data_1 = sorted_marker_pin_data[ next + 1 ]; slope0 = bisecting_slope[ next ]; slope1 = bisecting_slope[ next + 1 ]; sq_rt_slope0 = slope0; sq_rt_slope1 = slope1; if( sq_rt_slope0 < 0 ) { sq_rt_slope0 = -sq_rt_slope0; sq_rt_slope0 = Math.sqrt( sq_rt_slope0 ); sq_rt_slope0 = -sq_rt_slope0; } else sq_rt_slope0 = Math.sqrt( sq_rt_slope0 ); if( sq_rt_slope1 < 0 ) { sq_rt_slope1 = -sq_rt_slope1; sq_rt_slope1 = Math.sqrt( sq_rt_slope1 ); sq_rt_slope1 = -sq_rt_slope1; } else sq_rt_slope1 = Math.sqrt( sq_rt_slope1 ); bet_slope0 = slope_to___n_plus__1[ next ]; bet_slope1 = slope_from_n_minus_1[ next + 1 ]; bet_slope = bet_slope0 + bet_slope1; bet_slope *= .5; n0_to_from_diff = slope_to___n_plus__1[ next ] - slope_from_n_minus_1[ next ]; n1_to_from_diff = slope_to___n_plus__1[ next + 1 ] - slope_from_n_minus_1[ next + 1 ]; function_of_delta_r = supply_function_of_delta_r( delta_r, 'z', next ); // supply_function_of_delta_r( delta_r, 'Y', next ); for( curv = ir_0; curv < ir_1; curv++ ) { dbetween = (double)curv - r_0; bet_point = data_0 + ( bet_slope0 * dbetween ); double temp = 0; if( curv > -1 && curv < 451 ) { temp = curv_fit_to_data[ curv ]; center1 = Math.sin( ( dbetween / delta_r ) * pi ); center1 *= .000043; //metric_cm[ eye_btn ]; //.00004; center1 *= .2; //metric_cm[ eye_btn ]; //.000005; // asymetric center2 = Math.sin( ( dbetween / delta_r ) * two_pi ); center3 = Math.sin( ( ( ( dbetween ) / delta_r ) * thre_pi ) + pi ); center3 *= .0000015; center4 = Math.sin( ( ( ( dbetween ) / delta_r ) * five_pi ) ); center4 *= -.0000002; center5 = Math.sin( ( ( ( dbetween ) / delta_r ) * sevn_pi ) ); //sevn_pi ) + th_haf_pi center5 *= -.0000002; center2 *= ( dbetween * sq_rt_slope1 ) + ( ( delta_r - dbetween ) * sq_rt_slope0 ); center2 *= .00000031; non_linear = ( center1 + center2 + center3 + center4 + center5 ) * delta_r; non_linear *= function_of_delta_r; non_linear *= ( dbetween * n1_to_from_diff ) + ( ( delta_r - dbetween ) * n0_to_from_diff ); non_linear *= .26; //metric_cm[ eye_btn ]; curv_fit_to_data[ curv ] = non_linear + temp; } if( curv > 600 ) break; } } else break; } else break; } if( pin_spacing_is_ok && !see_angle_lines ) { for( int smo = 0; smo < 15; smo++ ) smooth_the_curve( curv_fit_to_data ); } if( !pin_spacing_is_ok || see_angle_lines ) { // Draw the curve onto the plot board. draw_curv_fit_to_data( false, false ); // ghost, do_the_old_curve // Draw the slope lines and the bisecting line. int mkr_pixels = 0; int height = 0; boolean on_scale_x = false; double scale = 0; for( int dispsl = 0; dispsl < 11; dispsl++ ) { if( valid_marker_pin[ dispsl ] ) { mkr_pixels = (int)( sorted_zone_marker_pixels[ dispsl ] ); // Convert from cm to pixels. scale = starward_scale_muliplier; // Scale the data. height = (int)( Math.rint( sorted_marker_pin_data[ dispsl ] * scale ) ); on_scale_x = false; if( mkr_pixels > -1 && mkr_pixels < 407 ) on_scale_x = true; int line_length = 30; int line_startx = (int)( mkr_pixels - line_length ); int line_endx = (int)( mkr_pixels + line_length ); int mline_starty = height - (int)( slope_from_n_minus_1[ dispsl ] * line_length * scale ); int mline_endy = height + (int)( slope_from_n_minus_1[ dispsl ] * line_length * scale ); int pline_starty = height - (int)( slope_to___n_plus__1[ dispsl ] * line_length * scale ); int pline_endy = height + (int)( slope_to___n_plus__1[ dispsl ] * line_length * scale ); int biline_starty = height - (int)( bisecting_slope[ dispsl ] * line_length * scale ); int biline_endy = height + (int)( bisecting_slope[ dispsl ] * line_length * scale ); if( on_scale_x ) { g_plot_board.setColor( light_yellow_color ); if( dispsl > 0 ) { if( mirror_surface_ref_line - mline_starty > 4 && mirror_surface_ref_line - mline_starty < plot_board_height - 4 && mirror_surface_ref_line - mline_endy > 4 && mirror_surface_ref_line - mline_endy < plot_board_height - 4 ) g_plot_board.drawLine( plot_bo_mirror_center + line_startx, mirror_surface_ref_line - mline_starty, plot_bo_mirror_center + line_endx, mirror_surface_ref_line - mline_endy ); } g_plot_board.setColor( Color.cyan ); if( dispsl < 10 ) { if( mirror_surface_ref_line - pline_starty > 4 && mirror_surface_ref_line - pline_starty < plot_board_height - 4 && mirror_surface_ref_line - pline_endy > 4 && mirror_surface_ref_line - pline_endy < plot_board_height - 4 ) g_plot_board.drawLine( plot_bo_mirror_center + line_startx, mirror_surface_ref_line - pline_starty, plot_bo_mirror_center + line_endx, mirror_surface_ref_line - pline_endy ); } g_plot_board.setColor( Color.red ); if( dispsl > 0 && dispsl < 10 ) { if( mirror_surface_ref_line - biline_starty > 4 && mirror_surface_ref_line - biline_starty < plot_board_height - 4 && mirror_surface_ref_line - biline_endy > 4 && mirror_surface_ref_line - biline_endy < plot_board_height - 4 ) g_plot_board.drawLine( plot_bo_mirror_center + line_startx, mirror_surface_ref_line - biline_starty, plot_bo_mirror_center + line_endx, mirror_surface_ref_line - biline_endy ); } } } } } // Used for de bugging the sort routien. if( show_sort ) { // Used to test sort routien. int test_text_y = 10; g_plot_board.setColor( c_plot_board_bkgrnd ); //483 g_plot_board.fillRect( plot_bo_mirror_center - 11, mirror_surface_ref_line - 184, 500, 182 ); for( int disp = 0; disp < 11; disp++ ) { test_text_y += 15; g_plot_board.setColor( Color.black ); if( disp > 0 && disp < 10 ) { double zone = 2 * zone_marker_pixels[ disp - 1 ]; g_plot_board.drawString(" "+(disp - 1)+" "+four_past_format.format( zone )+" ", plot_bo_mirror_center + 5, test_text_y ); } g_plot_board.setColor( Color.red ); if( valid_marker_pin[ disp ] ) g_plot_board.setColor( Color.green ); g_plot_board.drawString(" "+disp+" "+four_past_format.format( sorted_zone_marker_pixels[ disp ] )+" ", plot_bo_mirror_center + 70, test_text_y ); g_plot_board.drawString(" "+disp+" "+four_past_format.format( sorted_marker_pin_data[ disp ] )+" ", plot_bo_mirror_center + 150, test_text_y ); double _from_angle = ( ( from_angle[ disp ] ) / pi ) * 180; g_plot_board.drawString(" "+four_past_format.format( _from_angle )+" ", plot_bo_mirror_center + 225, test_text_y ); double _to_angle = ( ( to___angle[ disp ] ) / pi ) * 180; g_plot_board.drawString(" "+four_past_format.format( _to_angle )+" ", plot_bo_mirror_center + 300, test_text_y ); double _bisector = ( ( bisecting_angle[ disp ] ) / pi ) * 180; g_plot_board.drawString(" "+four_past_format.format( _bisector )+" ", plot_bo_mirror_center + 375, test_text_y ); } return false; } return true; } static private double supply_function_of_delta_r( double delta_r, char test, int next ) { Receives the distance between sorted data pins and returns a custom asymmetric bell curve. ................................. } // Box car averager // dampens high frequency variations and outliers. static private void smooth_the_curve( double[] curve_to_smooth ) { .......................... } // Using the the curv_fit_to_data[] or the formu_starward_metric[] // fill the transformed_curve[] and plot the result. // static double curv_fit_to_data[] = new double[ 401 ]; // static double formu_starward_metric[] = new double[ 441 ]; static double data__surface_metric[] = new double[ 401 ]; static double formulas_transform_surface_metric[] = null; static double different_from_a_sphere_400 = 0; // Used during testing F# error correction. static double transformed_curve[] = new double[ 1601 ]; // disp_transf called_by // 'T' transform only 'D' Transforms from users data or simulated data. // 'Y' do both 'F' Called by fill_starward_array() // 'y' do both but clip the display. 'f', 'p' or 's' Called by fill_transform_correction_array(). static private void starward_to_surface_transform( char disp_transform, char called_by ) { if( formulas_transform_surface_metric == null ) starward_to_surface_called = 'N'; boolean imaginary = true; int imaginary_set_at = 402; while( disp_transform == 'Y' || disp_transform == 'y' || disp_transform == 'T' ) // never loops { // Blocks updating if surface has been zeroed at a data pin. if( blue_alert_for_transf_starward ) break; double temp_array[] = new double[ 1601 ]; int temp_array_index = 0; boolean array_filled = false; double metric_cm_m_d_btn = metric_cm[ m_d_btn ]; if( called_by == 'F' ) // formulas_transform_surface_metric[] set to null when formulas changed. { if( alert_starward_formula__array_null() ) return; if( formulas_transform_surface_metric == null ) formulas_transform_surface_metric = new double[ 401 ]; for( int normalize = 0; normalize < 401; normalize++ ) { double temp = formu_starward_metric[ normalize ]; temp = 400 * ( temp / metric_cm_m_d_btn ); // Spread the data in the array. temp_array[ temp_array_index ] = temp; temp_array_index += 4; } array_filled = true; } if( called_by == 'D' ) // curv_fit_to_data[] set to null when users data has changed. { if( curv_fit_to_data == null ) { exception_or_error[ 114 ] = " starward_to_surface_transform(), array curv_fit_to_data[] is null. "; show_exception_or_error = 5000; return; } if( data__surface_metric == null ) data__surface_metric = new double[ 401 ]; for( int normalizf = 0; normalizf < 401; normalizf++ ) { double temp = curv_fit_to_data[ normalizf ]; if( !light_source_moves ) temp *= .5; temp = 400 * ( temp / metric_cm_m_d_btn ); // Spread the data in the array. temp_array[ temp_array_index ] = temp; temp_array_index += 4; } array_filled = true; } // Used by: fill_transform_correction_array() if( called_by == 'x' || called_by == 'p' || called_by == 's' ) { if( starward_sample_for_transform == null ) { exception_or_error[ 114 ] = " starward_to_surface_transform(), array starward_sample_for_transform[] is null. "; show_exception_or_error = 5000; return; } if( transform_returned_for_correction == null ) transform_returned_for_correction = new double[ 401 ]; for( int normalizg = 0; normalizg < 401; normalizg++ ) { double temp = 0; temp = starward_sample_for_transform[ normalizg ]; temp = 400 * ( temp / metric_cm_m_d_btn ); // Spread the data in the array. temp_array[ temp_array_index ] = temp; temp_array_index += 4; } array_filled = true; } // Zero the array at the mirror's center. if( array_filled ) { double offset = 0; offset = temp_array[ 0 ]; if( offset != 0 ) { double temp = 0; temp_array_index = 0; for( int zero = 0; zero < 401; zero++ ) { temp = temp_array[ temp_array_index ]; temp -= offset; temp_array[ temp_array_index ] = temp; temp_array_index += 4; } } } else break; // Fill in the unused array elements by averaging. double fill_in_temp_lo = 0; double fill_in_temp_hi = 0; double quartile = 0; for( int fill_in = 0; fill_in < 1601; fill_in++ ) { if( fill_in % 4 == 0 ) { fill_in_temp_lo = temp_array[ fill_in ]; if( fill_in < 1597 ) { fill_in_temp_hi = temp_array[ fill_in + 4 ]; quartile = ( fill_in_temp_lo + fill_in_temp_hi ) * .25; fill_in_temp_lo += quartile; temp_array[ fill_in + 1 ] = fill_in_temp_lo; fill_in_temp_lo += quartile; temp_array[ fill_in + 2 ] = fill_in_temp_lo; fill_in_temp_lo += quartile; temp_array[ fill_in + 3 ] = fill_in_temp_lo; } else break; } } // Constants for transformer. d_normalized_R_of_C = 400 * metric_cm[ r_c_btn ] / metric_cm[ m_d_btn ]; double local_normalized_R_of_C = d_normalized_R_of_C * 4; double half_ROC = 400; double half_ROC_sq = half_ROC * half_ROC; // Constants for correction factors. double correction_factor0 = 0; double F_number_factor = d_normalized_R_of_C / 800; F_number_factor = 1.3 / ( F_number_factor / 3 ); //metric_cm[ eye_btn ]; // d_normalized_R_of_C * .5 / metric_cm[ eye_btn ] * .5; //metric_cm[ eye_btn ]; // Transformer variables double sag_n_ = 0; double sag_n_plus_one = 0; double RoC_n_ = 0; double RoC_n_plus_one = 0; double r___n_ = 0; double r___n_plus_one = 0; double R_four_m_S_three = 0; double R_s_term = 0; double from_r_term = 0; double step_up = 0; for( int i = 0; i < 1601; i++ ) transformed_curve[ i ] = 0; imaginary = false; temp_array_index = 0; for( int j = 0; j < 1601; j++ ) { if( !imaginary ) { sag_n_ = transformed_curve[ j ]; RoC_n_ = temp_array[ j ] + local_normalized_R_of_C; if( j < 1600 ) RoC_n_plus_one = temp_array[ j + 1 ] + local_normalized_R_of_C; else { RoC_n_plus_one = RoC_n_; imaginary = true; } r___n_ = .5 * (double)j; r___n_plus_one = .5 * (double)( j + 1 ); // Length in the y direction from S n to R n+1 R_four_m_S_three = RoC_n_plus_one - sag_n_; R_s_term = R_four_m_S_three * R_four_m_S_three; R_s_term = R_s_term + ( r___n_ * r___n_ ); // Square of length of line from r n to R n+1 in pixels. R_s_term *= .25; // Now Square of 1/2 of length of line from r n to R n+1 in pixels. // x distance from the center of the r n to R n+1 line to r4. from_r_term = r___n_plus_one - ( .5 * r___n_ ); from_r_term *= from_r_term; step_up = R_s_term - from_r_term; if( step_up > 0 ) step_up = Math.sqrt( step_up ); else { imaginary = true; imaginary_set_at = j; step_up = 0; show_exception_or_error = 5000; exception_or_error[ 111 ] = "Unable square root of a negative number: starward_to_surface_transform( ) "; } step_up = ( .5 * R_four_m_S_three ) - step_up; sag_n_plus_one = step_up + sag_n_; // Correction factor improves accuracy for sphere. correction_factor0 = F_number_factor / sag_n_plus_one; //.000001 ); correction_factor0 *= -.00001; //correction_factor0 *= metric_cm[ eye_btn ]; sag_n_plus_one *= correction_factor0 + 1; if( j < 1600 ) transformed_curve[ j + 1 ] = sag_n_plus_one; else imaginary = true; } else { if( j % 20 == 0 ) { transformed_curve[ j ] = 17; if( j < 1600 ) j += 1; } else transformed_curve[ j ] = .5; } temp_array_index += 4; } // Condense transformed curve double condense_temp = 0; temp_array_index = 0; for( int condense = 0; condense < 1601; condense++ ) { condense_temp = transformed_curve[ condense ]; if( condense % 4 == 0 ) { transformed_curve[ temp_array_index ] = condense_temp * .25; temp_array_index += 1; } } double correction_factor1 = 0; // Find 400 numbers propotional to this curve minus a sphere. double temp_transform_ = 0; double temp_sph_sag_pxl = 0; double temp_how_different_from_a_sphere = 0; double correction_to_zero_for_sphere = .0000039272 / 400; for( int sph = 0; sph < 401; sph++ ) { temp_sph_sag_pxl = sphere_sag_pixels[ sph ]; temp_transform_ = transformed_curve[ sph ]; temp_how_different_from_a_sphere = temp_transform_ - temp_sph_sag_pxl; // Correction to zero for a sphere. temp_how_different_from_a_sphere -= correction_to_zero_for_sphere * sph; if( sph == 400 ) // Used during testing. Displays with s key then space bar. different_from_a_sphere_400 = temp_how_different_from_a_sphere; // Correction to correct for low F#. Linear correction. correction_factor1 = temp_how_different_from_a_sphere * -1.31; //metric_cm[ eye_btn ]; // Correction to correct for low F#. Curve at mirror edge correction. correction_factor1 += (double)sph * temp_how_different_from_a_sphere * .00005; //metric_cm[ eye_btn ]; transformed_curve[ sph ] -= correction_factor1; } // Curve transformer correction. Correction array(s) set by: // static private void fill_transform_correction_array( char called_by ) double metric_to_pixel = ( 1 / metric_cm_m_d_btn ) * 400; boolean a_calibration_run = false; if( called_by == 'x' || called_by == 'p' || called_by == 's' ) a_calibration_run = true; double corr_temp = 0; double temp_transform_correction = 0; boolean using_p_flag = false; while( called_by == 'x' || ( !a_calibration_run && ( plot_surface_source == 't' || plot_surface_source == 'f' ) ) ) { // If arrays for called_by == 'x' are not valid then use parabolic p_transform_correction_array[ correct ]; if( !a_calibration_run && transform_correction_array_status[ 0 ] != 'x' ) { using_p_flag = true; break; } if( deact_correction_temporary == 0 ) break; for( int correct = 0; correct < 401; correct++ ) { corr_temp = transformed_curve[ correct ]; temp_transform_correction = x_transform_correction_array[ correct ]; corr_temp = corr_temp + temp_transform_correction; transformed_curve[ correct ] = corr_temp; } break; } while( called_by == 'p' || ( !a_calibration_run && ( plot_surface_source == 'p' || using_p_flag ) ) ) { if( deact_correction_temporary == 1 ) break; for( int correct = 0; correct < 401; correct++ ) { corr_temp = transformed_curve[ correct ]; temp_transform_correction = p_transform_correction_array[ correct ]; corr_temp = corr_temp + temp_transform_correction; transformed_curve[ correct ] = corr_temp; } break; } while( called_by == 's' || ( !a_calibration_run && plot_surface_source == 's' ) ) { if( deact_correction_temporary == 2 ) break; for( int correct = 0; correct < 401; correct++ ) { corr_temp = transformed_curve[ correct ]; temp_transform_correction = s_transform_correction_array[ correct ]; corr_temp = corr_temp + temp_transform_correction; transformed_curve[ correct ] = corr_temp; } break; } if( called_by == 'D' ) { for( int fill = 0; fill < 401; fill++ ) { double temp_d = transformed_curve[ fill ]; temp_d = ( temp_d / 400 ) * metric_cm_m_d_btn; data__surface_metric[ fill ] = temp_d; } g_plot_board.setColor( Color.white ); //SA- L2,--234 g_plot_board.drawLine( 64, plot_menu_y + ( plot_menu_h * 2 ) + 1, 64, plot_menu_y + plot_menu_h * 5 ); } if( called_by == 'F' ) { for( int fill2 = 0; fill2 < 401; fill2++ ) { // formulas_transform_surface_metric[] set to null when formulas changed. double temp_f = transformed_curve[ fill2 ]; temp_f = ( temp_f / 400 ) * metric_cm_m_d_btn; formulas_transform_surface_metric[ fill2 ] = temp_f; } } if( called_by == 'x' || called_by == 'p' || called_by == 's' ) { for( int fill3 = 0; fill3 < 401; fill3++ ) { double temp_c = transformed_curve[ fill3 ]; temp_c = ( temp_c / 400 ) * metric_cm_m_d_btn; transform_returned_for_correction[ fill3 ] = temp_c; } } starward_to_surface_called = called_by; break; } if( disp_transform == 'T' ) return; // Below is for transform then display or just display only. // This plot is on top of the green mirror cross section at the bottom of the plot board. int x_pos = plot_bo_mirror_center; int y_pos = plot_board_height - 62; boolean clipping = false; for( int k = 0; k < 401; k++ ) { int surf_pxl = (int)Math.rint( 2 * transformed_curve[ k ] ); // Formula mirror's surface. g_plot_board.setColor( plot_colors[ plotting_color_index ] ); if( imaginary && k > imaginary_set_at ) g_plot_board.setColor( Color.red ); if( disp_transform == 'y' ) { if( surf_pxl > -42 && y_pos - surf_pxl > 325 ) g_plot_board.drawLine( x_pos + k, y_pos - surf_pxl, x_pos + k, y_pos - surf_pxl ); else clipping = true; } if( disp_transform == 'Y' ) { if( surf_pxl > -42 && y_pos - surf_pxl > ( mirror_surface_ref_line - ( plot_board_clip + 5 ) ) ) g_plot_board.drawLine( x_pos + k, y_pos - surf_pxl, x_pos + k, y_pos - surf_pxl ); } while( clipping ) // never loops { if( starward_to_surface_called != 'N' && starward_to_surface_called != 'n' ) break; g_plot_board.setColor( Color.red ); if( surf_pxl > 0 ) g_plot_board.drawLine( x_pos + k, 325, x_pos + k, 325 ); break; } } // Legend, Plot source g_plot_board.setColor( c_plot_board_bkgrnd ); g_plot_board.fillRect( plot_bo_mirror_center - 8, y_pos - 9, 7, 10 ); g_plot_board.setColor( plot_colors[ plotting_color_index ] ); if( called_by == 'D' ) g_plot_board.drawString("D", plot_bo_mirror_center - 8, y_pos ); if( called_by == 'F' ) g_plot_board.drawString("F", plot_bo_mirror_center - 8, y_pos ); } static private void fill_transform_correction_array( char called_by ) { // Correction multipliers set to 0 so as to have no effect. // 'i' for initialize if( called_by == 'i' ) { for( int tca = 0; tca < 401; tca++ ) { x_transform_correction_array[ tca ] = 0; p_transform_correction_array[ tca ] = 0; s_transform_correction_array[ tca ] = 0; } ........................... //SA- R3,--tpsf draw_alert_bars_for_corrector_L4a_L4b_and_R3( true, 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G' ); If the x key has been pressed { formula_as_a_reference_starward_metric = null; formula_as_a_surface_metric = null; .................. plot_surface_source = 'p'; g_plot_board.setColor( Color.red ); //SA- R2,--t g_plot_board.drawLine( plot_source_mx + plot_menu_w + 7, plot_surface_my + 1, plot_source_mx + plot_menu_w + 7, plot_surface_my + plot_menu_h - 1 ); //SA- R2,--f g_plot_board.drawLine( plot_source_mx + plot_menu_w + 7, plot_surface_my + plot_menu_h * 3 + 1, plot_source_mx + plot_menu_w + 7, plot_surface_my + plot_menu_h * 4 - 1 ); } return; } // Block updating if surface has been zeroed at a data pin. { ............................................ g_plot_board.setColor( default_red_legend_color ); g_plot_board.drawString(" Fill transform correction array is blocked due an array is zeroed", x_pos2, y_pos2 + 10 ); g_plot_board.drawString(" at a marker pin. Fill correction arrays before zeroing an array.", x_pos2, y_pos2 + 21 ); repaint_app1_image = 2; exception_or_error[ 0 ] = " fill_transform_correction_array(), Unable to calibrate with curve zeroed at a pin."; show_exception_or_error = true; return; } // Before allowing calibration on formula arrays both // starward and surface arrays must be valid. .................................. if( formula_as_a_reference_starward_metric != null && formula_as_a_surface_metric != null ) { if( transform_correction_array_status[ 0 ] == 'z' ) { transform_correction_array_status[ 0 ] = 'Z'; g_plot_board.setColor( default_butn_color ); g_plot_board.fillRect( x_pos2, y_pos2, 325, 24 ); g_plot_board.setColor( Color.darkGray ); g_plot_board.drawRect( x_pos2, y_pos2, 325, 24 ); g_plot_board.setFont( new Font( my_font_string_4, Font.PLAIN, 10 ) ); g_plot_board.setColor( default_red_legend_color ); g_plot_board.drawString(" Starward, \""+s_formula_as_a_reference_starward_metric+"\", tranforms to:", x_pos2, y_pos2 + 10 ); g_plot_board.drawString(" Surface, \""+s_formula_as_a_surface_metric+"\". t or f ", x_pos2, y_pos2 + 21 ); repaint_app1_image = 2; } } return; } // User has verifyied that Starward formula goes with Surface formula // or user disagrees with that. .................................... starward_sample_for_transform = new double[ 401 ]; if( called_by == 'x' ) { for( int xr = 0; xr < 401; xr++ ) { double temp = formula_as_a_reference_starward_metric[ xr ]; starward_sample_for_transform[ xr ] = temp; } } if( called_by == 'p' ) // 'p' for parabola { for( int pr = 0; pr < 401; pr++ ) { double temp = r_sq_ovr_R_metric[ pr ]; starward_sample_for_transform[ pr ] = temp; } } if( called_by == 's' ) // 's' for sphere { for( int sp = 0; sp < 401; sp++ ) starward_sample_for_transform[ sp ] = 0; } // Correction adjustments set to 0 so as to have no effect. if( called_by == 'x' ) for( int tca = 0; tca < 401; tca++ ) x_transform_correction_array[ tca ] = 0; if( called_by == 'p' ) for( int tcb = 0; tcb < 401; tcb++ ) p_transform_correction_array[ tcb ] = 0; if( called_by == 's' ) for( int tcc = 0; tcc < 401; tcc++ ) s_transform_correction_array[ tcc ] = 0; // Call for transform without any correction. starward_to_surface_transform( 'T', called_by ); // char disp_transf, char called_by if( transform_returned_for_correction == null ) { exception_or_error[ 114 ] = " fill_transform_correction_array(), array transform_returned_for_correction[] is null. "; show_exception_or_error = true; return; } // Use results to set values in transform_correction_array. double temp_return = 0; double metric_cm_m_d_btn = metric_cm[ m_d_btn ]; // 't' for transform of starward formula. 'f' for a formula for the surface. // Both formulas have been validated by the user. if( called_by == 'x' ) { double temp_calibrate = 0; for( int tcax = 0; tcax < 401; tcax++ ) { temp_calibrate = formula_as_a_surface_metric[ tcax ]; temp_return = transform_returned_for_correction[ tcax ]; temp_return = temp_calibrate - temp_return; x_transform_correction_array[ tcax ] = 400 * ( temp_return / metric_cm_m_d_btn ); } transform_correction_array_status[ 0 ] = 'x'; show_exception_or_error = true; exception_or_error[ 0 ] = " "; draw_alert_bars_for_corrector_L4a_L4b_and_R3( true, 'w', 'w', 'z', 'z', 'z', 'z', 'w', 'w' ); } if( called_by == 'p' ) // 'p' for parabola { double temp_parab = 0; for( int tcap = 0; tcap < 401; tcap++ ) { temp_parab = parabo_sag_metric[ tcap ]; temp_return = transform_returned_for_correction[ tcap ]; temp_return = temp_parab - temp_return; p_transform_correction_array[ tcap ] = 400 * ( temp_return / metric_cm_m_d_btn ); } transform_correction_array_status[ 1 ] = 'p'; show_exception_or_error = true; exception_or_error[ 0 ] = " "; draw_alert_bars_for_corrector_L4a_L4b_and_R3( true, 'z', 'z', 'w', 'w', 'z', 'z', 'z', 'z' ); if( transform_correction_array_status[ 0 ] != 'x' ) draw_alert_bars_for_corrector_L4a_L4b_and_R3( true, 'O', 'O', 'z', 'z', 'z', 'z', 'O', 'O' ); } if( called_by == 's' ) // 's' for sphere { double temp_sphere = 0; for( int tcas = 0; tcas < 401; tcas++ ) { temp_sphere = sphere_sag_metric[ tcas ]; temp_return = transform_returned_for_correction[ tcas ]; temp_return = temp_sphere - temp_return; s_transform_correction_array[ tcas ] = 400 * ( temp_return / metric_cm_m_d_btn ); } transform_correction_array_status[ 2 ] = 's'; show_exception_or_error = true; exception_or_error[ 0 ] = " "; draw_alert_bars_for_corrector_L4a_L4b_and_R3( true, 'z', 'z', 'z', 'z', 'w', 'w', 'z', 'z' ); } starward_sample_for_transform = null; transform_returned_for_correction = null; } static private void draw_alert_bars_for_corrector_L4a_L4b_and_R3( boolean is_for_L4b, char L3_t, char R3_t, char L3_p, char R3_p, char L3_s, char R3_s, char L3_f, char R3_f ) { ....................... } static private void draw_alert_bars_locating_dots() { Draws the little dots above and below the alert bars. ................................. } // Add or subtract the same amount from each data entry so that the // data entry pointed to by "percent_zone_focus" will be zero. // if( toggle_state[ 8 ] ) // static double metric_cm_assocated_with_data_mkr_zero = 0; // If plot_me_data_source == 'E' zero the users data points. // If plot_me_data_source == 'F' zero the substituted formula at // the focus data point but use formu_starward_metric[] value // since the formula has no data points. static boolean zero_value_at_percent_zone_of_focused_pin_called = false; static boolean blue_alert_for_entered_data = false; static boolean blue_alert_for_starward_formula = false; static boolean blue_alert_for_transf_starward = false; static boolean blue_alert_for_ref_surface = false; static private boolean zero_value_at_percent_zone_of_focused_pin() { double radius_of_focused_pin = 2 * zone_marker_pixels[ z_to_8_perc_zone_foc ]; int iradius_of_focused_pin = (int)( Math.rint( radius_of_focused_pin ) ); if( iradius_of_focused_pin > -1 && iradius_of_focused_pin < 401 ) ; else { show_exception_or_error = true; exception_or_error[ 119 ] = "Radius of selected (data pin) not on mirror."; return false; } // User now selects a pin on the mirror. show_exception_or_error = true; exception_or_error[ 0 ] = " "; if( wedge_test != 'N' ) { wedge_zero_at = iradius_of_focused_pin; plot_board_mode_click = true; return false; } if( plot_menu_selection == 0 ) { if( plot_me_data_source == 'E' ) { double entered_data_value = metric_cm[ percent_zone_focus ]; if( percent_zone_focus == 0 ) entered_data_value = metric_cm_assocated_with_data_mkr_zero; if( entered_data_value != 0 ) { for( int i = z_1_btn - 1; i <= z_8_btn; i++ ) { if( i == z_1_btn - 1 ) { metric_cm_assocated_with_data_mkr_zero -= entered_data_value; //tk.beep(); } if( i >= z_1_btn ) { metric_cm[ i ] -= entered_data_value; entered_val[ i ] = Mouble.to_display_value( metric_cm[ i ], i ); old_focus[ i ] = default_old_focus; } } g_plot_board.setColor( Color.blue ); //SA- R4,E g_plot_board.drawLine( plot_source_mx + plot_menu_w + 13, plot_source_my + 1, plot_source_mx + plot_menu_w + 13, plot_source_my + plot_menu_h - 1 ); //SA- L1,0 //draw_dashed_alert_lines( int L_line, boolean starward, char zeroing_color_1, char zeroing_color_2, char curve_fit_color ) draw_dashed_alert_lines( 61, true, 'b', 'z', 'z' ); zero_value_at_percent_zone_of_focused_pin_called = true; blue_alert_for_entered_data = true; plot_board_control( 'Z' ); return true; } tk.beep(); show_exception_or_error = true; exception_or_error[ 0 ] = "Data for "+z_to_8_perc_zone_foc+", already zero. "; plot_board_control( 'P' ); return false; } if( plot_me_data_source == 'F' ) { if( formu_starward_metric == null ) { show_exception_or_error = true; exception_or_error[ 120 ] = "zero_value_at_percent_zone_of_focused_pin(), array: formu_starward_metric[ ] == null."; return false; } double present_value_of_starward_formula_at_focus = formu_starward_metric[ iradius_of_focused_pin ]; if( present_value_of_starward_formula_at_focus != 0 ) { double temp = 0; for( int form = 0; form < 401; form++ ) { temp = formu_starward_metric[ form ] - present_value_of_starward_formula_at_focus; formu_starward_metric[ form ] = temp; } g_plot_board.setColor( Color.blue ); //SA- R4,F g_plot_board.drawLine( plot_source_mx + plot_menu_w + 13, plot_source_my + plot_menu_h + 1, plot_source_mx + plot_menu_w + 13, plot_source_my + plot_menu_h * 2 - 1 ); //SA- L1,0 draw_dashed_alert_lines( 61, true, 'z', 'b', 'z' ); zero_value_at_percent_zone_of_focused_pin_called = true; blue_alert_for_starward_formula = true; plot_board_control( 'Z' ); return true; } show_exception_or_error = true; exception_or_error[ 121 ] = "Array: formu_starward_metric[ ], data already at zero at radius of pin: "+z_to_8_perc_zone_foc+". "; plot_board_control( 'P' ); return false; } } if( plot_menu_selection > 1 && plot_menu_selection < 5 ) { boolean arrays_are_ok = true; if( data__surface_metric == null ) { show_exception_or_error = true; exception_or_error[ 120 ] = "zero_value_at_percent_zone_of_focused_pin(), array: data__surface_metric[ ] == null."; arrays_are_ok = false; } if( plot_surface_source == 't' ) { if( formulas_transform_surface_metric == null ) { show_exception_or_error = true; exception_or_error[ 121 ] = "zero_value_at_percent_zone_of_focused_pin(), array: formulas_transform_surface_metric[ ] == null."; arrays_are_ok = false; } } if( !arrays_are_ok ) return false; boolean both_arrays_already_zeroed = true; double present_value_of_data_surface_metric_at_focus = data__surface_metric[ iradius_of_focused_pin ]; if( present_value_of_data_surface_metric_at_focus != 0 ) { //tk.beep(); double temp = 0; for( int dat_s = 0; dat_s < 401; dat_s++ ) { temp = data__surface_metric[ dat_s ] - present_value_of_data_surface_metric_at_focus; data__surface_metric[ dat_s ] = temp; } //SA- L1,--234 draw_dashed_alert_lines( 61, false, 'b', 'z', 'z' ); blue_alert_for_transf_starward = true; both_arrays_already_zeroed = false; } else { show_exception_or_error = true; exception_or_error[ 120 ] = "Array: data__surface_metric[ ], data already at zero at radius of pin: "+z_to_8_perc_zone_foc+". "; } if( plot_surface_source == 't' ) { double present_value_of_formulas_transform_surface_metric_at_focus = formulas_transform_surface_metric[ iradius_of_focused_pin ]; if( present_value_of_formulas_transform_surface_metric_at_focus != 0 ) { //tk.beep(); double temp = 0; for( int for_s = 0; for_s < 401; for_s++ ) { temp = formulas_transform_surface_metric[ for_s ] - present_value_of_formulas_transform_surface_metric_at_focus; formulas_transform_surface_metric[ for_s ] = temp; } g_plot_board.setColor( Color.blue ); //SA- R4,t g_plot_board.drawLine( plot_source_mx + plot_menu_w + 13, plot_surface_my + 1, plot_source_mx + plot_menu_w + 13, plot_surface_my + plot_menu_h - 1 ); //SA- L1,--234 draw_dashed_alert_lines( 61, false, 'z', 'b', 'z' ); //SA- L4,--234 draw_alert_bars_for_corrector_L4a_L4b_and_R3( false, 'b', 'z', 'z', 'z', 'z', 'z', 'z', 'z' ); blue_alert_for_ref_surface = true; both_arrays_already_zeroed = false; } else { show_exception_or_error = true; exception_or_error[ 121 ] = "Array: formulas_transform_surface_metric[ ], data already at zero at radius of pin: "+z_to_8_perc_zone_foc+". "; } } if( plot_surface_source == 'p' ) { double present_value_of_parabo_sag_metric_at_focus = parabo_sag_metric[ iradius_of_focused_pin ]; if( present_value_of_parabo_sag_metric_at_focus != 0 ) { //tk.beep(); double temp = 0; for( int for_s = 0; for_s < 401; for_s++ ) { temp = parabo_sag_metric[ for_s ] - present_value_of_parabo_sag_metric_at_focus; parabo_sag_metric[ for_s ] = temp; } g_plot_board.setColor( Color.blue ); //SA- R4,-p g_plot_board.drawLine( plot_source_mx + plot_menu_w + 13, plot_surface_my + plot_menu_h + 1, plot_source_mx + plot_menu_w + 13, plot_surface_my + plot_menu_h * 2 - 1 ); //SA- L1,--2345 draw_dashed_alert_lines( 61, false, 'z', 'b', 'z' ); //SA- L4,--234 draw_alert_bars_for_corrector_L4a_L4b_and_R3( false, 'z', 'z', 'b', 'z', 'z', 'z', 'z', 'z' ); blue_alert_for_ref_surface = true; both_arrays_already_zeroed = false; } else { show_exception_or_error = true; exception_or_error[ 121 ] = "Array: parabo_sag_metric[ ], data already at zero at radius of pin: "+z_to_8_perc_zone_foc+". "; } } if( plot_surface_source == 's' ) { double present_value_of_sphere_sag_metric_at_focus = sphere_sag_metric[ iradius_of_focused_pin ]; if( present_value_of_sphere_sag_metric_at_focus != 0 ) { //tk.beep(); double temp = 0; for( int for_s = 0; for_s < 401; for_s++ ) { temp = sphere_sag_metric[ for_s ] - present_value_of_sphere_sag_metric_at_focus; sphere_sag_metric[ for_s ] = temp; } g_plot_board.setColor( Color.blue ); //SA- R4,--s g_plot_board.drawLine( plot_source_mx + plot_menu_w + 13, plot_surface_my + plot_menu_h * 2 + 1, plot_source_mx + plot_menu_w + 13, plot_surface_my + plot_menu_h * 3 - 1 ); //SA- L1,--234 draw_dashed_alert_lines( 61, false, 'z', 'b', 'z' ); //SA- L4,--234 draw_alert_bars_for_corrector_L4a_L4b_and_R3( false, 'z', 'z', 'z', 'z', 'b', 'z', 'z', 'z' ); blue_alert_for_ref_surface = true; both_arrays_already_zeroed = false; } else { show_exception_or_error = true; exception_or_error[ 121 ] = "Array: sphere_sag_metric[ ], data already at zero at radius of pin: "+z_to_8_perc_zone_foc+". "; } } if( plot_surface_source == 'f' ) { double present_value_of_formula_as_a_surface_metric_at_focus = formula_as_a_surface_metric[ iradius_of_focused_pin ]; if( present_value_of_formula_as_a_surface_metric_at_focus != 0 ) { //tk.beep(); double temp = 0; for( int for_s = 0; for_s < 401; for_s++ ) { temp = formula_as_a_surface_metric[ for_s ] - present_value_of_formula_as_a_surface_metric_at_focus; formula_as_a_surface_metric[ for_s ] = temp; } g_plot_board.setColor( Color.blue ); //SA- R4,---f g_plot_board.drawLine( plot_source_mx + plot_menu_w + 13, plot_surface_my + plot_menu_h * 3 + 1, plot_source_mx + plot_menu_w + 13, plot_surface_my + plot_menu_h * 4 -1 ); //SA- L1,--234 draw_dashed_alert_lines( 61, false, 'z', 'b', 'z' ); //SA- L4,--234 draw_alert_bars_for_corrector_L4a_L4b_and_R3( false, 'z', 'z', 'z', 'z', 'z', 'z', 'b', 'z' ); blue_alert_for_ref_surface = true; both_arrays_already_zeroed = false; } else { show_exception_or_error = true; exception_or_error[ 121 ] = "Array: sphere_sag_metric[ ], data already at zero at radius of pin: "+z_to_8_perc_zone_foc+". "; } } if( both_arrays_already_zeroed ) return false; zero_value_at_percent_zone_of_focused_pin_called = true; plot_board_control( 'Z' ); return true; } show_exception_or_error = true; exception_or_error[ 121 ] = "zero_value_at_percent_zone_of_focused_pin(), Failed: unspecified."; return false; } static private void draw_dashed_alert_lines( int L_line, boolean starward, char zeroing_color_1, char zeroing_color_2, char curve_fit_color ) { Draws dashed alert lines. .......................... } // zone_marker_pixels[ 0 ] is not used by the method // curve_fit_to_entered_data_points(). Instead // curve_fit_to_entered_data_points() must be called first in // order to fill the array curv_fit_to_data[] and then // the data for zone_marker_pixels[ 0 ] is set to the apropriate // array ellement in curv_fit_to_data[]. // if( toggle_state[ 8 ] ) static private boolean set_data_for_marker_pin_0_has_been_called = false; static private int index_of_pin_at_104_percent = -10; static private int i_of_pin_at_104_percent = -10; static private int index_of_pin_at_0_percent = -10; static private int i_of_pin_at_0_percent = -10; static boolean set_data_for_marker_pin_0_to_the_curve( boolean initialize ) { if( initialize ) { if( set_data_for_marker_pin_0_has_been_called ) { if( index_of_pin_at_104_percent > 0 && index_of_pin_at_104_percent < 9 ) { if( i_of_pin_at_104_percent >= z_1_btn && i_of_pin_at_104_percent <= z_8_btn ) { zone_marker_pixels[ index_of_pin_at_104_percent ] = -4; metric_cm[ i_of_pin_at_104_percent ] = 0; type_of_event[ i_of_pin_at_104_percent ] = 'z'; old_focus[ i_of_pin_at_104_percent ] = default_old_focus; } } if( index_of_pin_at_0_percent > 0 && index_of_pin_at_0_percent < 9 ) { if( i_of_pin_at_0_percent >= z_1_btn && i_of_pin_at_0_percent <= z_8_btn ) { zone_marker_pixels[ index_of_pin_at_0_percent ] = -4; metric_cm[ i_of_pin_at_0_percent ] = 0; type_of_event[ i_of_pin_at_0_percent ] = 'z'; old_focus[ i_of_pin_at_0_percent ] = default_old_focus; } } } set_data_for_marker_pin_0_has_been_called = false; return false; } if( curv_fit_to_data == null ) { show_exception_or_error = 5000; exception_or_error[ 112 ] = " set_data_for_marker_pin_0_to_the_curve(), curv_fit_to_data[] = null. "; return false; } recalculate_values(); // Variables prepaired for drawing mirror silhouette. double metric_mirr_size = metric_cm[ m_d_btn ]; double metric_diag_size = metric_cm[ diagbtn ]; if( metric_mirr_size < 0 ) metric_mirr_size = 0 - metric_mirr_size; if( metric_diag_size < 0 ) metric_diag_size = 0 - metric_diag_size; // Secondary mirror can't be bigger than primary mirror. if( metric_diag_size > metric_mirr_size ) metric_diag_size = metric_mirr_size; // Mirror surface area prepaired. double math_pi = Math.PI; double mirr_rad_in_cm = .5 * metric_mirr_size; double diag_rad_in_cm = .5 * metric_diag_size; double mirr_surface_in_sq_cm = mirr_rad_in_cm * mirr_rad_in_cm * math_pi; double diag_surface_in_sq_cm = diag_rad_in_cm * diag_rad_in_cm * math_pi; // Place pin[0] in the surface area weighted center of the remaining surface. double remaining_surface_in_sq_cm = mirr_surface_in_sq_cm - diag_surface_in_sq_cm; double half_of_rem_surface = .5 * remaining_surface_in_sq_cm; double half_rem_surface_plus_diag_surface = half_of_rem_surface + diag_surface_in_sq_cm; double equivalent_radius_in_cm = half_rem_surface_plus_diag_surface / math_pi; equivalent_radius_in_cm = Math.sqrt( equivalent_radius_in_cm ); double equivalent_radius_in_pixels = equivalent_radius_in_cm / metric_cm[ m_d_btn ] * 400; zone_marker_pixels[ 0 ] = equivalent_radius_in_pixels; // First check to see if pin[0] is right on top of an existing // data pin. If so use that data. boolean pin_zero_set_done = false; boolean use_pin_data_directly = false; int i_of_pin_data_directly = -1; int index_of_pin_radius_directly = -1; double zo_mp = 0; double pin_z = zone_marker_pixels[ 0 ]; int index = 9; for( int i = z_8_btn; i >= z_1_btn; i-- ) { index -= 1; zo_mp = zone_marker_pixels[ index ]; if( zo_mp < 201 && zo_mp > -.001 ) { if( pin_z > zo_mp - .05 && pin_z < zo_mp + .05 ) { metric_cm_assocated_with_data_mkr_zero = metric_cm[ i ]; i_of_pin_data_directly = i; index_of_pin_radius_directly = index; use_pin_data_directly = true; pin_zero_set_done = true; break; } } } int r_pixels = (int)Math.rint( equivalent_radius_in_pixels * 2 ); if( index_of_pin_radius_directly > -1 ) r_pixels = (int)Math.rint( 2 * zone_marker_pixels[ index_of_pin_radius_directly ] ); if( r_pixels > -1 && r_pixels < 401 ) ; else { show_exception_or_error = 5000; exception_or_error[ 112 ] = " set_data_for_marker_pin_0_to_the_curve(), curv_fit_to_data[ "+r_pixels+" ] out of bounds "; return false; } if( !use_pin_data_directly ) { metric_cm_assocated_with_data_mkr_zero = curv_fit_to_data[ r_pixels ]; pin_zero_set_done = true; } if( !pin_zero_set_done ) { show_exception_or_error = 5000; exception_or_error[ 113 ] = " set_data_for_marker_pin_0_to_the_curve(), unable to set pin zero to the curve. "; return false; } // Pin zero has been set to the curv_fit_to_data[]. // Set the focus to pin zero and redraw. percent_zone_focus = 0; draw_percent_zone_legends(); set_data_for_marker_pin_0_has_been_called = true; plot_board_control( 'P' ); // Calculate and display the conic of the curve using the // radius and data from the curve at mirror center and pin[o]. double curv_value_at_zero = 0; double curv_value_at_pin_zero = 0; double pin_o_radius = 0; boolean conic_valid = true; int x_conic_disp = plot_bo_mirror_center + 412; int y_conic_disp = mirror_surface_ref_line + 104; g_plot_board.setColor( c_plot_board_bkgrnd ); g_plot_board.fillRect( x_conic_disp, y_conic_disp, 70, 19 ); g_plot_board.setFont( new Font( my_font_string_4, Font.PLAIN, 10 ) ); if( plot_me_data_source == 'E' ) { if( curv_fit_to_data == null ) { g_plot_board.setColor( Color.gray ); g_plot_board.drawString(" conic ", x_conic_disp - 1, y_conic_disp + 7 ); g_plot_board.drawString(" curv null ", x_conic_disp - 1, y_conic_disp + 17 ); conic_valid = false; } } else { if( formula_as_a_reference_starward_metric == null ) { g_plot_board.setColor( Color.gray ); g_plot_board.drawString(" conic ", x_conic_disp - 1, y_conic_disp + 7 ); g_plot_board.drawString(" refr null ", x_conic_disp - 1, y_conic_disp + 17 ); conic_valid = false; } } while( conic_valid ) // never loops { pin_o_radius = zone_marker_pixels[ 0 ]; pin_o_radius *= 2; if( pin_o_radius < .6 ) { g_plot_board.setColor( Color.gray ); g_plot_board.drawString(" conic ", x_conic_disp - 1, y_conic_disp + 7 ); g_plot_board.drawString(" no pin[o]", x_conic_disp - 1, y_conic_disp + 17 ); conic_valid = false; break; } // g_plot_board.setColor( Color.magenta ); // g_plot_board.drawString(" conic ", x_conic_disp - 130, y_conic_disp + 7 ); // g_plot_board.drawString(" "+pin_o_radius+" ", x_conic_disp - 130, y_conic_disp + 17 ); int array_index = 0; array_index = (int)Math.rint( pin_o_radius ); if( array_index > 438 ) { g_plot_board.setColor( Color.gray ); g_plot_board.drawString(" conic ", x_conic_disp - 1, y_conic_disp + 7 ); g_plot_board.drawString("!array index", x_conic_disp - 1, y_conic_disp + 17 ); conic_valid = false; break; } if( plot_me_data_source == 'E' ) { curv_value_at_zero = curv_fit_to_data[ 0 ]; curv_value_at_pin_zero = curv_fit_to_data[ array_index ]; } else { curv_value_at_zero = formula_as_a_reference_starward_metric[ 0 ]; curv_value_at_pin_zero = formula_as_a_reference_starward_metric[ array_index ]; } break; } double conic = 0; boolean conic_will_be_positive = true; double starward_difference = 0; double metric_pin_o_radius = 0; double metric_R_of_C = 0; double one_third = 1; while( conic_valid ) // never loops { starward_difference = curv_value_at_pin_zero - curv_value_at_zero; if( !light_source_moves && plot_me_data_source == 'E' ) starward_difference *= .5; metric_pin_o_radius = ( pin_o_radius / 800 ) * metric_mirr_size; // Convert from pixels to cm . metric_R_of_C = metric_cm[ r_c_btn ]; starward_difference *= 3; if( curv_value_at_pin_zero > curv_value_at_zero ) conic_will_be_positive = false; starward_difference += metric_R_of_C; if( starward_difference <= curv_value_at_zero ) { g_plot_board.setColor( Color.gray ); g_plot_board.drawString(" conic ", x_conic_disp - 1, y_conic_disp + 7 ); g_plot_board.drawString(" neg data ", x_conic_disp - 1, y_conic_disp + 17 ); break; } starward_difference = starward_difference / metric_R_of_C; starward_difference *= starward_difference; one_third = one_third / 3; starward_difference = Math.pow( starward_difference, one_third ); starward_difference = 1 - starward_difference; conic = ( metric_pin_o_radius * metric_pin_o_radius ) / ( metric_R_of_C * metric_R_of_C ); conic = starward_difference / conic; conic = Math.abs( conic ); if( !conic_will_be_positive ) conic = 0 - conic; g_plot_board.setColor( plot_colors[ plotting_color_index ] ); g_plot_board.drawString(" conic =", x_conic_disp - 1, y_conic_disp + 7 ); g_plot_board.drawString(" "+two_past_format.format( conic )+" ", x_conic_disp - 1, y_conic_disp + 17 ); //g_plot_board.drawString(" "+conic+" ", x_conic_disp - 1, y_conic_disp + 17 ); break; } //repaint_app1_image = 2; // Allow user to skip: Set pin 0 and pin 104. if( a_key_was_pressed != 'z' ) { if( key_that_was_hit == ' ' ) { a_key_was_pressed = 'z'; key_that_was_hit = 0; return true; } } // If there is no pin at 104 percent then put a pin there and // set it to formula projection of pin zero. // To procede we will need formu_starward_metric[] so check now. if( formu_starward_metric == null ) { show_exception_or_error = 5000; exception_or_error[ 113 ] = "To set pin at 0 and 104 percent the starward formula must be set to r_sq / R or to your formula."; return true; } // If there is no pin at 104 percent then put a pin there and // set it to formula projection of pin zero. // Pin zero is at the centroid of the unobstructed area. boolean there_is_already_a_pin_at_104 = false; index = 9; for( int i = z_8_btn; i >= z_1_btn; i-- ) { index -= 1; zo_mp = zone_marker_pixels[ index ]; if( zo_mp > 207.4 && zo_mp < 208.6 ) there_is_already_a_pin_at_104 = true; } if( there_is_already_a_pin_at_104 ) { show_exception_or_error = 3000; exception_or_error[ 113 ] = " set_data_for_marker_pin_0_to_the_curve(), returning due there is already a pin at 104 percent. "; return true; } // See if there is an unused pin to put at 104 percent. index_of_pin_at_104_percent = -10; i_of_pin_at_104_percent = -10; index = 9; for( int i = z_8_btn; i >= z_1_btn; i-- ) { index -= 1; zo_mp = zone_marker_pixels[ index ]; if( zo_mp < -.001 ) { index_of_pin_at_104_percent = index; i_of_pin_at_104_percent = i; break; } } if( index_of_pin_at_104_percent < 0 ) { show_exception_or_error = 3000; exception_or_error[ 113 ] = "set_data_for_marker_pin_0_to_the_curve(), returning due there is no pin available to put at 104 percent."; return true; } zone_marker_pixels[ index_of_pin_at_104_percent ] = 208; double formu_temp = formu_starward_metric[ r_pixels ]; if( !light_source_moves ) formu_temp *= 2; double diff_bet__metric_cm_asso_mkr_zero__and__formu_starward_metric = metric_cm_assocated_with_data_mkr_zero; diff_bet__metric_cm_asso_mkr_zero__and__formu_starward_metric -= formu_temp; //double test_disp = formu_starward_metric[ 416 ]; //test_disp = Mouble.to_display_value( test_disp, i_of_pin_at_104_percent ); //show_exception_or_error = 5000; //exception_or_error[ 0 ] = "formu_starward_metric[ 416 ] is "+display_format.format( test_disp )+""; //show_exception_or_error = 5000; //exception_or_error[ 0 ] = "r_pixels is "+display_format.format( r_pixels )+""; double formu_temp104 = formu_starward_metric[ 416 ]; if( !light_source_moves ) formu_temp104 *= 2; metric_cm[ i_of_pin_at_104_percent ] = formu_temp104 + diff_bet__metric_cm_asso_mkr_zero__and__formu_starward_metric; type_of_event[ i_of_pin_at_104_percent ] = 'D'; old_focus[ i_of_pin_at_104_percent ] = default_old_focus; draw_percent_zone_legends(); double for_cue = metric_cm[ i_of_pin_at_104_percent ]; for_cue = Mouble.to_display_value( for_cue, i_of_pin_at_104_percent ); //show_exception_or_error = 5000; //exception_or_error[ 112 ] = "The value for pin "+index_of_pin_at_104_percent+" at 104 percent has been set to: "+display_format.format( for_cue )+""; int x_pos2 = plot_bo_mirror_center + 20; int y_pos2 = mirror_surface_ref_line + 112; g_plot_board.setColor( default_butn_color ); g_plot_board.fillRect( x_pos2, y_pos2, 370, 12 ); g_plot_board.setColor( Color.lightGray ); g_plot_board.drawRect( x_pos2, y_pos2, 370, 12 ); g_plot_board.setFont( new Font( my_font_string_4, Font.PLAIN, 10 ) ); g_plot_board.setColor( default_red_legend_color ); g_plot_board.drawString(" The value for pin "+index_of_pin_at_104_percent+" at 104 percent has been set to: "+display_format.format( for_cue )+"", x_pos2, y_pos2 + 10 ); plot_board_control( 'P' ); repaint_app1_image = 2; // If there is no pin at 0 percent then put a pin there and // set it to formula projection of pin zero. // Pin zero is at the centroid of the unobstructed area. boolean there_is_already_a_pin_at_0 = false; index = 0; for( int i = z_1_btn; i <= z_8_btn; i++ ) { index += 1; zo_mp = zone_marker_pixels[ index ]; if( zo_mp > -.001 && zo_mp < .6 ) there_is_already_a_pin_at_0 = true; } if( there_is_already_a_pin_at_0 ) { show_exception_or_error = 3000; exception_or_error[ 113 ] = " set_data_for_marker_pin_0_to_the_curve(), returning due there is already a pin at 0 percent. "; return true; } // See if there is an unused pin to put at 0 percent. index_of_pin_at_0_percent = -10; i_of_pin_at_0_percent = -10; index = 9; for( int i = z_8_btn; i >= z_1_btn; i-- ) { index -= 1; zo_mp = zone_marker_pixels[ index ]; if( zo_mp < -.001 ) { index_of_pin_at_0_percent = index; i_of_pin_at_0_percent = i; break; } } if( index_of_pin_at_0_percent < 0 ) { show_exception_or_error = 3000; exception_or_error[ 113 ] = "set_data_for_marker_pin_0_to_the_curve(), returning due there is no pin available to put at 0 percent."; return true; } zone_marker_pixels[ index_of_pin_at_0_percent ] = 0; double formu_temp0 = formu_starward_metric[ r_pixels ]; if( !light_source_moves ) formu_temp0 *= 2; //double diff_bet__metric_cm_asso_mkr_zero__and__formu_starward_metric = metric_cm_assocated_with_data_mkr_zero; //diff_bet__metric_cm_asso_mkr_zero__and__formu_starward_metric -= formu_temp; //double test_disp = formu_starward_metric[ 416 ]; //test_disp = Mouble.to_display_value( test_disp, i_of_pin_at_104_percent ); //show_exception_or_error = 5000; //exception_or_error[ 0 ] = "formu_starward_metric[ 416 ] is "+display_format.format( test_disp )+""; //show_exception_or_error = 5000; //exception_or_error[ 0 ] = "r_pixels is "+display_format.format( r_pixels )+""; double formu_temp00 = formu_starward_metric[ 0 ]; if( !light_source_moves ) formu_temp00 *= 2; metric_cm[ i_of_pin_at_0_percent ] = formu_temp00 + diff_bet__metric_cm_asso_mkr_zero__and__formu_starward_metric; type_of_event[ i_of_pin_at_0_percent ] = 'D'; old_focus[ i_of_pin_at_0_percent ] = default_old_focus; draw_percent_zone_legends(); for_cue = metric_cm[ i_of_pin_at_0_percent ]; for_cue = Mouble.to_display_value( for_cue, i_of_pin_at_0_percent ); //show_exception_or_error = 5000; //exception_or_error[ 113 ] = "The value for pin "+index_of_pin_at_0_percent+" at 0 percent has been set to: "+display_format.format( for_cue )+""; g_plot_board.setColor( default_butn_color ); g_plot_board.fillRect( x_pos2, y_pos2 + 12, 370, 12 ); g_plot_board.setColor( Color.lightGray ); g_plot_board.drawRect( x_pos2, y_pos2 + 12, 370, 12 ); g_plot_board.setFont( new Font( my_font_string_4, Font.PLAIN, 10 ) ); g_plot_board.setColor( default_red_legend_color ); g_plot_board.drawString(" The value for pin "+index_of_pin_at_0_percent+" at 0 percent has been set to: "+display_format.format( for_cue )+"", x_pos2, y_pos2 + 22 ); plot_board_control( 'P' ); repaint_app1_image = 2; return true; } }// end of class Below is the ShoBtnAr class. import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.applet.*; import java.lang.*; import java.util.*; import java.text.*; import java.io.InputStream; import java.net.*; //import java.math.*; public class ShoBtnAr extends SurfEvent { static long last_display_time = 0; static long display_delay = 475; static boolean show_button_outlines = false; // Format of the event data arrays. // one two three four five six // char type_of_event | Int focus | Int old_focus | boolean toggle_state | Int x | Int y // 'B' for button -1 not //on/off or x_pos y_pos // 'D' for data entry 1 yes on and reset // 'd' dependant variable 10 pressed where consumed. // 'r' or 'R' special 20 Activated for data entry. // for image[ 0 ] -20 Locked out // 30 metric_morph // seven eight nine ten eleven // int sm_bwidth | int big_bwidth | Int height | Double entered_val | String ini_double // sm_bwidth big_bwidth bheight entered value From ini file. // // twelve thirteen fourteen // String s_type_units | char sys_of_units | Double metric_cm // "pounds" 'z' set manually Calculations done in // "light years" 'M' length_metric_morph metric centimeters. // // fifteen sixteen seventeen // Color btn_frame_color | Color btn_color | Color btn_focus_color // eighteen nineteen twenty // String my_font_string | Color font_color | Font_size font_size // // twemtyone // int page_association static void list_event_params( int start_i, Font JVM_default_font, Graphics g_off_screen1, Graphics g_off_screen2, SurfEvent my_event ) { milliseconds = System.currentTimeMillis(); look_at_button_params = 'Y'; if( show_button_outlines ) { if( x_mouse_position < 180 && y_mouse_position < 180 ) if( x_mouse_position > 0 && y_mouse_position > 0 ) look_at_button_params = 'y'; } g_off_screen2.setColor( Color.yellow ); g_off_screen2.fillRect( 0, 0, 180, 187 ); g_off_screen2.setColor( Color.black ); // g_off_screen2.drawString("String_key is "+String_key, 10, 14 ); // g_off_screen2.drawString("key_that_was_hit is "+key_that_was_hit, 10, 28 ); g_off_screen2.drawString("a_key_was_pressed "+a_key_was_pressed+" ", 10, 28 ); int key_number = key_that_was_hit; g_off_screen2.drawString("key_that_was_hit is "+key_that_was_hit+" "+key_number, 10, 42 ); g_off_screen2.drawString("code_that_was_hit is "+code_that_was_hit+" "+code_that_was_hit, 10, 56 ); g_off_screen2.drawString("mouse_position x is "+x_mouse_position, 10, 70 ); g_off_screen2.drawString("mouse_position y is "+y_mouse_position, 10, 84 ); g_off_screen2.drawString("left_button_pressed is "+left_button_pressed, 10, 98 ); g_off_screen2.drawString("right_button_pressed is "+right_button_pressed, 10, 112 ); g_off_screen2.drawString("mouse_moved is "+mouse_moved, 10, 126 ); if( show_button_outlines ) { g_off_screen2.setColor( Color.blue ); g_off_screen2.drawString("data_page_number is "+data_page_number, 10, 140 ); } // g_off_screen2.drawString("k_array_pointer is "+k_array_pointer, 10, 112 ); // g_off_screen2.drawString("ch_entered is "+ch_entered, 10, 126 ); g_off_screen2.setColor( Color.red ); g_off_screen2.drawString("shobtnarr_index is "+shobtnarr_index+" < >", 10, 155 ); g_off_screen2.drawString("To see button outline:", 10, 169 ); g_off_screen2.drawString(" 'right click' or \\" , 10, 183 ); // Not necessary to update button properties so often. if( last_display_time + display_delay < milliseconds ) { last_display_time = milliseconds; int i; if( start_i > max_btns_or_floats - 6 ) start_i = max_btns_or_floats - 6; if( start_i < 0 ) start_i = 0; g_off_screen1.setColor( Color.white ); g_off_screen1.fillRect( 0, 0, applet_width, applet_height ); int vSpace = 187; int horiz_shift = 0; int alt_horiz_shift = 0; String s_local_sys_of_units = null; for( i = start_i; i <= start_i + 7; i++ ) { s_local_sys_of_units = Mouble.select_proper_units_string_for( sys_of_units[ i ] ); g_off_screen1.setColor( font_color[ i ] ); g_off_screen1.drawString("type_of_event "+ i +" is "+type_of_event[ i ], 10 + horiz_shift, 14 + vSpace ); g_off_screen1.drawString("focus "+ i +" is "+focus[ i ], 10 + horiz_shift, 28 + vSpace ); g_off_screen1.drawString("toggle_state "+ i +" is "+toggle_state[ i ], 10 + horiz_shift, 42 + vSpace ); g_off_screen1.drawString("x_pos "+ i +" is "+x_pos[ i ], 10 + horiz_shift, 56 + vSpace ); g_off_screen1.drawString("y_pos "+ i +" is "+y_pos[ i ], 10 + horiz_shift, 70 + vSpace ); g_off_screen1.drawString("bwidth "+ i +" is "+sm_bwidth[ i ], 10 + horiz_shift, 84 + vSpace ); g_off_screen1.drawString("bheight "+ i +" is "+bheight[ i ], 10 + horiz_shift, 98 + vSpace ); g_off_screen1.drawString(""+entered_val[ i ]+""+s_local_sys_of_units, 10 + horiz_shift, 112 + vSpace ); g_off_screen1.drawString(""+metric_cm[ i ]+"cm", 10 + horiz_shift, 126 + vSpace ); g_off_screen1.setColor( btn_frame_color[ i ] ); g_off_screen1.drawString("btn_frame_color "+ i +" ", 10 + horiz_shift, 140 + vSpace ); g_off_screen1.setColor( btn_color[ i ] ); g_off_screen1.fillRect( alt_horiz_shift, 144 + vSpace, 142, 15 ); g_off_screen1.setColor( btn_focus_color[ i ] ); g_off_screen1.fillRect( alt_horiz_shift - 45, 144 + vSpace, 44, 15 ); g_off_screen1.setColor( font_color[ i ] ); g_off_screen1.drawString(""+btn_color[ i ], alt_horiz_shift - 48, 154 + vSpace ); g_off_screen1.drawString("font & color "+ i +" "+my_font_string[ i ], 10 + horiz_shift, 168 + vSpace ); g_off_screen1.drawString("font_size "+ i +" is "+font_size[ i ], 10 + horiz_shift, 182 + vSpace ); vSpace += 187; if( vSpace > 187 ) { vSpace = 0; horiz_shift += 175; if( horiz_shift < 350 ) horiz_shift = 200; alt_horiz_shift += 189; } if( i >= max_btns_or_floats ) break; } while( right_button_pressed ) // Never loops { right_button_pressed = false; if( show_button_outlines ) { show_button_outlines = false; break; } if( !show_button_outlines ) { show_button_outlines = true; break; } break; } if( show_button_outlines ) { for( int j = 0; j <= max_btns_or_floats; j++ ) { // Keep page 1 and page 2 outlines from both displaying // at the same time. if( page_assoc[ j ] == default_page_assoc || page_assoc[ j ] == data_page_number ) { g_off_screen1.setColor( btn_frame_color[ j ] ); if( toggle_state[ j ] ) g_off_screen1.setColor( Color.black ); g_off_screen1.drawRect( x_pos[ j ], y_pos[ j ], sm_bwidth[ j ] - 1, bheight[ j ] - 1 ); g_off_screen1.drawRect( x_pos[ j ] + 1, y_pos[ j ] + 1, sm_bwidth[ j ] - 3, bheight[ j ] - 3 ); g_off_screen1.setColor( Color.cyan ); if( focus[ j ] == -1 || focus[ j ] == -20 ) g_off_screen1.setColor( btn_color[ j ] ); if( focus[ j ] == 1 ) g_off_screen1.setColor( btn_focus_color[ j ] ); if( focus[ j ] == 20 ) g_off_screen1.setColor( Color.red ); if( focus[ j ] == 30 ) g_off_screen1.setColor( Color.yellow ); g_off_screen1.drawRect( x_pos[ j ] + 2, y_pos[ j ] + 2, sm_bwidth[ j ] - 5, bheight[ j ] - 5 ); g_off_screen1.drawRect( x_pos[ j ] + 3, y_pos[ j ] + 3, sm_bwidth[ j ] - 7, bheight[ j ] - 7 ); g_off_screen1.setColor( font_color[ j ] ); g_off_screen1.drawString("Btn#", x_pos[ j ] + 4, y_pos[ j ] + 17 ); g_off_screen1.setColor( Color.red ); g_off_screen1.drawString(""+j+""+type_of_event[ j ]+" ", x_pos[ j ] + 32, y_pos[ j ] + 17 ); g_off_screen1.setColor( Color.blue ); g_off_screen1.drawString(""+sys_of_units[ j ]+" SyU", x_pos[ j ] + 58, y_pos[ j ] + 17 ); } } } } scan_summary = 4; try {Thread.sleep(50);} // Seems there is a delay before the off screen image is ready. catch(InterruptedException e) {} } }