package diagapplet.plotter; //****************************************************************************** // plotter.java: Applet // //****************************************************************************** import java.applet.*; import java.awt.*; import java.awt.event.*; import java.net.*; import java.io.*; import java.util.*; import diagapplet.utils.StandAloneApplet; import diagapplet.utils.URLLoadInfoPanel; import diagapplet.utils.CountList; //============================================================================== // Main Class for applet plotter // //============================================================================== public class dplotter extends StandAloneApplet implements Runnable, Cloneable, MouseListener, AdjustmentListener, ActionListener, ItemListener { private String last_url_loaded = null; static public boolean start_applet_after_creating_new_window = true; static Vector dplotter_vector = new Vector(); private double last_user_set_x_scale = 100.0; private static int max_points_per_plot = -1; // -1 = no limit boolean just_zoomed_to_max = false; Checkbox labelPointsCheckbox = null; Checkbox keyCheckbox = null; Button fitToGraphButton = null; public boolean update_scale_needed = false; boolean max_x_is_newest = false; boolean min_x_is_newest = false; boolean max_y_is_newest = false; boolean min_y_is_newest = false; static public final int MINIMUM_WIDTH = 540; static public final int MINIMUM_HEIGHT = 240; static public boolean load_params_on_init = true; static public boolean load_params_on_start = true; boolean even_zooms = false; boolean load_url_needed = false; public static int max_dplotter_num = 0; public int dplotter_num; String save_directory = null; static public boolean debug_on = false; GridBagLayout textPanelLayout = null; TextField urlTextField = null; Button loadButton = null; Button browseButton = null; Button saveButton = null; public boolean need_resize = true; String current_plot_name = null; boolean TextAreaWasModified = true; boolean TextIsUpToDate = false; PlotData current_pd = null; static Enumeration colors_enum = null; static Color current_line_color = null; static Color current_point_color = Color.cyan; Button optPlotDeleteButton = null; Checkbox optPlotShowCheckbox = null; Button optPlotClearButton = null; String current_panel_name = "Graph"; Panel textPanel = null; TextArea textArea = null; public boolean repaint_needed = true; Button zoom_in_button = null; Button zoom_out_button = null; URLLoadInfoPanel load_info_panel = null; public Hashtable options_hash_table = null; static Hashtable colorsHashtable = null; Hashtable reverseColorsHashtable = null; Scrollbar vert_scroll_bar = null; Scrollbar horz_scroll_bar = null; public PlotGraph plot_graph = null; FlowLayout main_layout = null; Panel innerPanel = null; GridBagLayout innerLayout = null; Label title_label = null; Choice optKeyGraphChoice = null; Panel choicePanel = null; CardLayout choicePanelLayout = null; Panel graphPanel = null; FlowLayout graphPanelLayout = null; Panel graphInnerPanel = null; GridBagLayout graphInnerLayout = null; Panel optionsPanel = null; Panel optionsInnerPanel = null; FlowLayout optionsLayout = null; GridBagLayout optionsInnerLayout = null; Choice optChoice = null; TextField optTextField = null; Button optModifyButton = null; boolean options_modified = true; CountList optPlotsList = null; int optPlotsListCount = 0; static Color back_color = null; static Color grid_color = null; static Color zero_rad_color = null; static Color axis_color= null; static public boolean continous_update = false; Button newWindowButton = null; double radius_minimum = +1E9; double radius_maximum = -1E9; static public double user_specified_radius_offset = 0.0; static public boolean use_user_specified_radius_offset=false; // THREAD SUPPORT: // m_plotter is the Thread object for the applet //-------------------------------------------------------------------------- Thread m_plotter = null; // PARAMETER SUPPORT: // Parameters allow an HTML author to pass information to the applet; // the HTML author specifies them using the tag within the // tag. The following variables are used to store the values of the // parameters. //-------------------------------------------------------------------------- // Members for applet parameters // = //-------------------------------------------------------------------------- static public int m_width = MINIMUM_WIDTH; static public int m_height = MINIMUM_HEIGHT; private double m_max_x = 1.0; private double m_max_y = 1.0; private double m_min_x = 0.0; private double m_min_y = 0.0; private String m_title = ""; private boolean m_show_grid = false; private double m_grid_x = 0.0; private double m_grid_y = 0.0; private String m_url = ""; static public boolean m_color = true; private static String m_back_color_name = "black"; private static String m_grid_color_name = "blue"; private static String m_zero_rad_color_name = "green"; private static String m_axis_color_name = "white"; private int m_scroll_width = 0; private int m_scroll_height = 0; public static final int CARTESIAN_COORD_TYPE = 1; public static final int POLAR_COORD_TYPE = 2; public String coordinate_type_name ="cartesian"; public static int coordinate_type = CARTESIAN_COORD_TYPE; public static boolean mark_points = true; // Parameter names. To change a name of a parameter, you need only make // a single change. Simply modify the value of the parameter string below. //-------------------------------------------------------------------------- private final String PARAM_width = "width"; private final String PARAM_height = "height"; private final String PARAM_max_x = "max_x"; private final String PARAM_max_y = "max_y"; private final String PARAM_min_x = "min_x"; private final String PARAM_min_y = "min_y"; private final String PARAM_title = "title"; private final String PARAM_show_grid = "show_grid"; private final String PARAM_grid_x = "grid_x"; private final String PARAM_grid_y = "grid_y"; private final String PARAM_url = "url"; private final String PARAM_color = "color"; private final String PARAM_back_color_name = "back_color_name"; private final String PARAM_grid_color_name = "grid_color_name"; private final String PARAM_axis_color_name = "axis_color_name"; private final String PARAM_scroll_width = "scroll_width"; private final String PARAM_scroll_height = "scroll_height"; private final String PARAM_debug_on = "debug_on"; private final String PARAM_coordinate_type = "coordinate_type"; private final String PARAM_mark_points = "mark_points"; private final String PARAM_use_buffer = "use_buffer"; private final String PARAM_reload_url_on_start = "reload_url_on_start"; public boolean reload_url_on_start=true; // plotter Class Constructor //-------------------------------------------------------------------------- public dplotter() { // TODO: Add constructor code here max_dplotter_num = dplotter_vector.size(); dplotter_num = max_dplotter_num; max_dplotter_num++; dplotter_vector.insertElementAt(this, dplotter_num); addMouseListener(this); } public void cleanup() { dplotter_vector.setElementAt(null, dplotter_num); } public static void RepaintAllDplotters() { for(int i = 0; i < dplotter_vector.size(); i++) { dplotter dp = (dplotter) dplotter_vector.elementAt(i); if(null == dp) { continue; } dp.plot_graph.repaint_needed = true; dp.plot_graph.repaint_just_issued = false; dp.repaint_needed = true; dp.update_scale_needed = true; } } public static void SetUpdateScaleForAllDplotters() { for(int i = 0; i < dplotter_vector.size(); i++) { dplotter dp = (dplotter) dplotter_vector.elementAt(i); if(null == dp) { continue; } dp.update_scale_needed = true; } } public static void UpdateAllDisplays() { for(int i = 0; i < dplotter_vector.size(); i++) { dplotter dp = (dplotter) dplotter_vector.elementAt(i); if(null == dp) { continue; } dp.UpdateDisplay(); } } public boolean inside_resizeable_window = false; public void manual_resize(int new_width, int new_height) { if(debug_on) { System.out.println("dplotter.resize("+new_width+","+new_height+")"); Thread.dumpStack(); } try { Dimension d = getSize(); int tries = 0; while(tries < 20 && d.width != new_width && d.height != new_height) { setSize(new_width, new_height); tries++; try { Thread.sleep(50); } catch(Exception e) { } d = getSize(); } } catch(Exception e) { e.printStackTrace(); } try { if(inside_init || !initialized) { m_width = new_width; m_height = new_height; return; } need_resize = false; if(inside_resizeable_window) { if(Math.abs(m_width - new_width) > 5 || Math.abs(m_height - new_height) > 5) { Hashtable saved_plots = null; if(null != plot_graph) { if(null != plot_graph.plots) { saved_plots = plot_graph.plots; } } if(null != innerPanel) { innerPanel.removeAll(); innerPanel = null; } if(null != choicePanel) { choicePanel.removeAll(); choicePanel = null; } if(null != graphInnerPanel) { graphInnerPanel.removeAll(); graphInnerPanel = null; } if(null != optionsInnerPanel) { optionsInnerPanel.removeAll(); optionsInnerPanel = null; } if(null != textPanel) { textPanel.removeAll(); textPanel = null; } m_width = new_width; m_height = new_height; removeAll(); init(); if(saved_plots != null && plot_graph != null) { plot_graph.plots = saved_plots; } } } } catch(Exception e) { e.printStackTrace(); } need_resize = true; repaint_needed = true; } // m_fStandAlone APPLICATION SUPPORT // The GetParameter() method is a replacement for the getParameter() method // defined by Applet. This method returns the value of the specified parameter; // unlike the original getParameter() method, this method works when the applet // is run as a m_fStandAlone application, as well as when run within an HTML page. // This method is called by GetParameters(). //--------------------------------------------------------------------------- String GetParameter(String strName, String args[]) { if (args == null) { // Running within an HTML page, so call original getParameter(). //------------------------------------------------------------------- return getParameter(strName); } // Running as m_fStandAlone application, so parameter values are obtained from // the command line. The user specifies them as follows: // // JView CodeGen param1= param2=<"val with spaces"> ... //----------------------------------------------------------------------- int i; String strArg = strName + "="; String strValue = null; for (i = 0; i < args.length; i++) { if(strArg.length() < args[i].length()) { if (strArg.equalsIgnoreCase(args[i].substring(0, strArg.length()))) { // Found matching parameter on command line, so extract its value. // If in double quotes, remove the quotes. //--------------------------------------------------------------- strValue= args[i].substring(strArg.length()); if (strValue.startsWith("\"")) { strValue = strValue.substring(1); if (strValue.endsWith("\"")) strValue = strValue.substring(0, strValue.length() - 1); } } } } return strValue; } // m_fStandAlone APPLICATION SUPPORT // The GetParameters() method retrieves the values of each of the applet's // parameters and stores them in variables. This method works both when the // applet is run as a m_fStandAlone application and when it's run within an HTML // page. When the applet is run as a m_fStandAlone application, this method is // called by the main() method, which passes it the command-line arguments. // When the applet is run within an HTML page, this method is called by the // init() method with args == null. //--------------------------------------------------------------------------- void GetParameters(String args[]) { // Query values of all Parameters //-------------------------------------------------------------- String param; // PARAMETER SUPPORT // The following code retrieves the value of each parameter // specified with the tag and stores it in a member // variable. //---------------------------------------------------------------------- // width: Preferred Size Width in Pixels //---------------------------------------------------------------------- param = GetParameter(PARAM_width, args); if (param != null) m_width = Integer.parseInt(param); // height: Preferred Size height in Pixels //---------------------------------------------------------------------- param = GetParameter(PARAM_height, args); if (param != null) m_height = Integer.parseInt(param); // max_x: Max X Value on Plot //---------------------------------------------------------------------- param = GetParameter(PARAM_max_x, args); if (param != null) m_max_x = Double.valueOf(param).doubleValue(); // max_y: Max Y Value on Plot //---------------------------------------------------------------------- param = GetParameter(PARAM_max_y, args); if (param != null) m_max_y = Double.valueOf(param).doubleValue(); // min_x: Min X Value on Plot //---------------------------------------------------------------------- param = GetParameter(PARAM_min_x, args); if (param != null) m_min_x = Double.valueOf(param).doubleValue(); // min_y: Min Y Value on Plot //---------------------------------------------------------------------- param = GetParameter(PARAM_min_y, args); if (param != null) m_min_y = Double.valueOf(param).doubleValue(); // title: Title to show //---------------------------------------------------------------------- param = GetParameter(PARAM_title, args); if (param != null) m_title = param; // show_grid: Show the grid or not //---------------------------------------------------------------------- param = GetParameter(PARAM_show_grid, args); if (param != null) m_show_grid = Boolean.valueOf(param).booleanValue(); // grid_x: X difference in grid marks //---------------------------------------------------------------------- param = GetParameter(PARAM_grid_x, args); if (param != null) m_grid_x = Double.valueOf(param).doubleValue(); // grid_y: Y difference in grid marks //---------------------------------------------------------------------- param = GetParameter(PARAM_grid_y, args); if (param != null) m_grid_y = Double.valueOf(param).doubleValue(); // url: URL of text file to plot //---------------------------------------------------------------------- param = GetParameter(PARAM_url, args); if (param != null) m_url = param; // color: Show grid in color or b&w //---------------------------------------------------------------------- param = GetParameter(PARAM_color, args); if (param != null) m_color = Boolean.valueOf(param).booleanValue(); // back_color_name: Name of color for background //---------------------------------------------------------------------- param = GetParameter(PARAM_back_color_name, args); if (param != null) { m_back_color_name = param; back_color = StringToColor(m_back_color_name); PlotGraph.back_color = back_color; } // grid_color_name: Name of color for grid lines //---------------------------------------------------------------------- param = GetParameter(PARAM_grid_color_name, args); if (param != null) m_grid_color_name = param; // axis_color_name: Name of color for axis lines //---------------------------------------------------------------------- param = GetParameter(PARAM_axis_color_name, args); if (param != null) m_axis_color_name = param; // scroll_width: Pixels to allow scroll horizontal //---------------------------------------------------------------------- param = GetParameter(PARAM_scroll_width, args); if (param != null) m_scroll_width = Integer.parseInt(param); // scroll_height: Pixels to allow scroll vertical //---------------------------------------------------------------------- param = GetParameter(PARAM_scroll_height, args); if (param != null) m_scroll_height = Integer.parseInt(param); // debug_on: Print extra debug info //---------------------------------------------------------------------- param = GetParameter(PARAM_debug_on, args); if (param != null) { debug_on = Boolean.valueOf(param).booleanValue(); if(null != plot_graph) { plot_graph.debug_on = debug_on; } } // mark_points: Mark the data points //---------------------------------------------------------------------- param = GetParameter(PARAM_mark_points, args); if (param != null) mark_points = Boolean.valueOf(param).booleanValue(); // use_buffer : Use a buffer image so the user won't see drawing the plots. //---------------------------------------------------------------------- param = GetParameter(PARAM_use_buffer, args); if (param != null) PlotGraph.use_buffer = Boolean.valueOf(param).booleanValue(); // reload_url_on_start : Reload the URL everytime the start method is called. //---------------------------------------------------------------------- param = GetParameter(PARAM_reload_url_on_start, args); if (param != null) reload_url_on_start = Boolean.valueOf(param).booleanValue(); param = GetParameter(PARAM_coordinate_type, args); if( param != null) { coordinate_type_name = param; if(coordinate_type_name.toUpperCase().equals("POLAR")) { coordinate_type = POLAR_COORD_TYPE; } else if(coordinate_type_name.toUpperCase().equals("CARTESIAN")) { coordinate_type = CARTESIAN_COORD_TYPE; } if(null != plot_graph) { plot_graph.coordinate_type = coordinate_type; } } } public static void set_max_points_per_plot(int new_max) { max_points_per_plot = new_max; PlotGraph.max_points_per_plot = new_max; } public int get_max_points_per_plot() { return max_points_per_plot; } public Dimension getMinimumSize() { Dimension d = super.getMinimumSize(); boolean size_modified = false; if(null == d) { d = new Dimension(0,0); size_modified = true; } if(d.width < MINIMUM_WIDTH) { d.width = MINIMUM_WIDTH; size_modified = true; } if(d.width < m_width) { d.width = m_width; size_modified = true; } if(d.height < MINIMUM_HEIGHT) { d.height = MINIMUM_HEIGHT; size_modified = true; } if(d.height < m_height) { d.height = m_height; size_modified = true; } if(size_modified) { setSize(d); } return d; } public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); boolean size_modified = false; if(null == d) { d = new Dimension(0,0); size_modified = true; } if(d.width < MINIMUM_WIDTH) { d.width = MINIMUM_WIDTH; size_modified = true; } if(d.width < m_width) { size_modified = true; d.width = m_width; } if(d.height < MINIMUM_HEIGHT) { size_modified = true; d.height = MINIMUM_HEIGHT; } if(d.height < m_height) { size_modified = true; d.height = m_height; } if(size_modified) { setSize(d); } return d; } private void init_colors_hashtable() { colorsHashtable = new Hashtable(); colorsHashtable.put(Color.black,"black"); colorsHashtable.put(Color.blue,"blue"); colorsHashtable.put(Color.cyan,"cyan"); colorsHashtable.put(Color.darkGray,"darkGray"); colorsHashtable.put(Color.gray,"gray"); colorsHashtable.put(Color.green,"green"); colorsHashtable.put(Color.lightGray,"lightGray"); colorsHashtable.put(Color.magenta,"magenta"); colorsHashtable.put(Color.orange,"orange"); colorsHashtable.put(Color.pink,"pink"); colorsHashtable.put(Color.red,"red"); colorsHashtable.put(Color.white,"white"); colorsHashtable.put(Color.yellow,"yellow"); reverseColorsHashtable = new Hashtable(); reverseColorsHashtable.put("black",Color.black); reverseColorsHashtable.put("blue",Color.blue); reverseColorsHashtable.put("cyan",Color.cyan); reverseColorsHashtable.put("darkGray",Color.darkGray); reverseColorsHashtable.put("gray",Color.gray); reverseColorsHashtable.put("green",Color.green); reverseColorsHashtable.put("lightGray",Color.lightGray); reverseColorsHashtable.put("magenta",Color.magenta); reverseColorsHashtable.put("orange",Color.orange); reverseColorsHashtable.put("pink",Color.pink); reverseColorsHashtable.put("red",Color.red); reverseColorsHashtable.put("white",Color.white); reverseColorsHashtable.put("yellow",Color.yellow); } // APPLET INFO SUPPORT: // The getAppletInfo() method returns a string describing the applet's // author, copyright date, or miscellaneous information. //-------------------------------------------------------------------------- public String getAppletInfo() { return "Name: plotter\r\n" + "Author: Will Shackleford\r\n" + "\r\n" + "This software was produced by the National Institute of Standards and Technology\r\n" + " (NIST), an agency of the U.S. government, and by statute is not subject to copyright in the United\r\n" + " States. Recipients of this software assume all responsibility associated with its \r\n"+ "operation, modification, maintenance, and subsequent redistribution. \r\n" + " \r\n" + " Please contact Will Shackleford ( email: shackle@cme.nist.gov, phone: (301) 975-4286) if you have any \r\n"+ "questions, comments or problems related to this software. \r\n"; } // PARAMETER SUPPORT // The getParameterInfo() method returns an array of strings describing // the parameters understood by this applet. // // plotter Parameter Information: // { "Name", "Type", "Description" }, //-------------------------------------------------------------------------- public String[][] getParameterInfo() { String[][] info = { { PARAM_width, "int", "Preferred Size Width in Pixels" }, { PARAM_height, "int", "Preferred Size height in Pixels" }, { PARAM_max_x, "double", "Max X Value on Plot" }, { PARAM_max_y, "double", "Max Y Value on Plot" }, { PARAM_min_x, "double", "Min X Value on Plot" }, { PARAM_min_y, "double", "Min Y Value on Plot" }, { PARAM_title, "String", "Title to show" }, { PARAM_show_grid, "boolean", "Show the grid or not" }, { PARAM_grid_x, "double", "X difference in grid marks" }, { PARAM_grid_y, "double", "Y difference in grid marks" }, { PARAM_url, "String", "URL of text file to plot" }, { PARAM_color, "boolean", "Show graph in color or b&w" }, { PARAM_back_color_name, "String", "Name of color for background" }, { PARAM_axis_color_name, "String", "Name of color for axis lines" }, { PARAM_grid_color_name, "String", "Name of color for grid lines" }, { PARAM_scroll_width, "int", "Pixels to allow scroll horizontal" }, { PARAM_scroll_height, "int", "Pixels to allow scroll vertical" }, { PARAM_debug_on, "boolean", "Print Extra debug info" }, { PARAM_mark_points, "boolean", "Mark the data points" }, { PARAM_use_buffer, "boolean", "Use a buffer image so the user doesn't see the plots until their ready." }, { PARAM_reload_url_on_start, "boolean", "Reload the url everytime the start method is called." }, { PARAM_coordinate_type, "String", "Use either CARTESIAN of POLAR coordinates." }, }; return info; } public static void AddPlot(PlotData pd, String name) { if(debug_on) { System.out.println("Adding plot "+pd+", "+name); System.out.println(" to "+PlotGraph.plots); } if(null == name) { return; } if(name.length() < 1) { return; } if(null == pd) { return; } pd.coordinate_type = coordinate_type; pd.mark_points = mark_points; if(null == colors_enum) { colors_enum = colorsHashtable.keys(); } if(!colors_enum.hasMoreElements()) { colors_enum = colorsHashtable.keys(); } current_line_color = current_point_color; current_point_color = (Color) colors_enum.nextElement(); while(current_point_color.equals(back_color) || current_point_color.equals(grid_color) || current_point_color.equals(axis_color)) { if(!colors_enum.hasMoreElements()) { colors_enum = colorsHashtable.keys(); } current_point_color = (Color) colors_enum.nextElement(); } if(!PlotGraph.plots.containsKey(name)) { if(debug_on) { System.out.println("Adding plot "+name); } for(int i = 0; i < dplotter_vector.size(); i++) { dplotter dp = (dplotter) dplotter_vector.elementAt(i); if(null != dp) { dp.TextIsUpToDate = false; if(null != dp.optPlotsList) { dp.optPlotsList.addItem(name); } } } if(null == pd.line_color) { pd.line_color = current_line_color; } if(null == pd.point_color) { pd.point_color = current_point_color; } if(pd.line_width < 1) { pd.line_width = (PlotGraph.plots.size() % 4)+1; } } else { PlotData old_value = (PlotData) PlotGraph.plots.get(name); if(null == pd.line_color) { pd.line_color = old_value.line_color; } if(null == pd.point_color) { pd.point_color = old_value.point_color; } if(pd.line_width < 1) { pd.line_width = old_value.line_width; } if(null == pd.line_style) { pd.line_style = old_value.line_style; } } PlotGraph.AddPlot(pd,name); if(debug_on) { System.out.println("Added plot "+pd+", "+name); } } public PlotData GetPlot( String name) { if(null != plot_graph) { return plot_graph.GetPlot(name); } return null; } public void RemovePlot( String name) { if(null != plot_graph) { plot_graph.RemovePlot(name); } TextIsUpToDate = false; } public static void AddPointToPlot(PlotData pd,double x, double y,boolean connected) { PlotGraph.AddPointToPlot(pd,x,y,connected); for(int i = 0; i < dplotter_vector.size(); i++) { dplotter dp = (dplotter) dplotter_vector.elementAt(i); if(null != dp) { dp.TextIsUpToDate = false; dp.max_x_is_newest = false; dp.min_x_is_newest = false; dp.max_y_is_newest = false; dp.min_y_is_newest = false; if(null != pd.show) { if(pd.show.length > dp.dplotter_num) { if(!pd.show[dp.dplotter_num]) { continue; } } } if(x > dp.m_max_x) { dp.max_x_is_newest = true; dp.m_max_x = x; } if(x < dp.m_min_x) { dp.min_x_is_newest = true; dp.m_min_x = x; } if(y > dp.m_max_y) { dp.max_y_is_newest = true; dp.m_max_y = y; } if(y < dp.m_min_y) { dp.min_y_is_newest = true; dp.m_min_y = y; } } } } private void UpdateOptionsHashtable() { try { if(null != options_hash_table) { options_hash_table.put("Color",(String) (new Boolean(m_color)).toString()); options_hash_table.put("Label Points",(String) (new Boolean(plot_graph.label_points)).toString()); options_hash_table.put("Minimum X",(String) (new Double(m_min_x)).toString()); options_hash_table.put("Maximum X",(String) (new Double(m_max_x)).toString()); options_hash_table.put("Minimum Y",(String) (new Double(m_min_y)).toString()); options_hash_table.put("Maximum Y",(String) (new Double(m_max_y)).toString()); options_hash_table.put("Radius Offset",(String) (new Double(radius_minimum)).toString()); options_hash_table.put("Maximum Radius",(String) (new Double(radius_maximum)).toString()); options_hash_table.put("Scroll Width",(String) (new Integer(m_scroll_width)).toString()); options_hash_table.put("Scroll Height",(String) (new Integer(m_scroll_height)).toString()); options_hash_table.put("Back Color",m_back_color_name); options_hash_table.put("Grid Color",m_grid_color_name); options_hash_table.put("Axis Color",m_axis_color_name); options_hash_table.put("TitleText",m_title); if(null == plot_graph) { return; } options_hash_table.put("Show Lines",(String) (new Boolean(plot_graph.show_lines)).toString()); options_hash_table.put("Grid X",(String) (new Double(plot_graph.grid_x)).toString()); options_hash_table.put("Grid Y",(String) (new Double(plot_graph.grid_y)).toString()); options_hash_table.put("Coordinate Type",coordinate_type_name); options_hash_table.put("Mark Points",(String) (new Boolean(mark_points)).toString()); options_hash_table.put("Use Buffer",(String) (new Boolean(PlotGraph.use_buffer)).toString()); } } catch(Exception e) { e.printStackTrace(); } } public static boolean params_loaded = false; private void GetAllParameters() { try { if(!m_fStandAlone) { GetParameters(null); params_loaded = true; } } catch(Exception e) { e.printStackTrace(); } } public void CreateControls() { int title_bar_height =0; int horz_scroll_bar_height = 0; int vert_scroll_bar_width = 0; int plot_graph_height = 0; int plot_graph_width = 0; Dimension d =null; TextArea tempTextArea = null; int num_rows = 0; int num_cols = 0; int text_area_height = 0; int text_area_width = 0; int first_row_height = 20; int second_row_height = 20; int text_width = 20; int text_height = 5; int i; try { try { Font f = getFont(); int font_height = 10; int font_width = 10; if(null != f) { FontMetrics fm = getFontMetrics(f); if(null != fm) { font_height = fm.getHeight(); if(font_height < 10) { font_height = 10; } int font_widths[] = fm.getWidths(); font_width = 0; for( i = 0; i < font_widths.length; i++) { if(font_width < font_widths[i]) { font_width = font_widths[i]; } } if(font_width < 10) { font_width = 10; } } } if(debug_on) { System.out.println("font_height = "+font_height); System.out.println("font_width = "+font_width); } int tries = 0; d = getSize(); while(tries < 20 && (d.height < 1 || d.width < 1)) { try { Thread.sleep(50); } catch(Exception e) { } tries++; d = getSize(); } if(d.height > 0) { text_height = (d.height - 120)/font_height; } if(text_height < 30) { text_height = 30; } if(d.width > 0) { text_width = (d.width - 10)/font_width; } if(text_width < 40) { text_width = 40; } if(debug_on) { System.out.println("text_height = "+text_height); System.out.println("text_width = "+text_width); } } catch(Exception e) { e.printStackTrace(); } if(debug_on) { System.out.println("Creating controls."); } back_color = StringToColor(m_back_color_name); PlotGraph.back_color = back_color; grid_color = StringToColor(m_grid_color_name); axis_color = StringToColor(m_axis_color_name); if(debug_on) { System.out.println("Creating main_layout."); } main_layout = new FlowLayout(FlowLayout.LEFT); setLayout(main_layout); innerPanel = new Panel(); innerLayout = new GridBagLayout(); innerPanel.setLayout(innerLayout); if(debug_on) { System.out.println("Creating title_label."); } title_label = new Label("TITLE_LABEL "); if(debug_on) { System.out.println("Creating New Window Button."); } newWindowButton = new Button("New Window"); newWindowButton.addActionListener(this); title_bar_height = title_label.getSize().height; if(title_bar_height < title_label.getPreferredSize().height) { title_bar_height = title_label.getPreferredSize().height; } if(title_bar_height < title_label.getMinimumSize().height) { title_bar_height = title_label.getMinimumSize().height; } if(debug_on) { System.out.println("Creating zoom_in_button."); } zoom_in_button = new Button("ZOOM IN"); zoom_in_button.addActionListener(this); if(title_bar_height < zoom_in_button.getSize().height) { title_bar_height = zoom_in_button.getSize().height; } if(title_bar_height < zoom_in_button.getPreferredSize().height) { title_bar_height = zoom_in_button.getPreferredSize().height; } if(title_bar_height < zoom_in_button.getMinimumSize().height) { title_bar_height = zoom_in_button.getMinimumSize().height; } if(debug_on) { System.out.println("Creating zoom_out_button."); } zoom_out_button = new Button("ZOOM OUT"); zoom_out_button.addActionListener(this); if(title_bar_height < zoom_out_button.getSize().height) { title_bar_height = zoom_out_button.getSize().height; } if(title_bar_height < zoom_out_button.getPreferredSize().height) { title_bar_height = zoom_out_button.getPreferredSize().height; } if(title_bar_height < zoom_out_button.getMinimumSize().height) { title_bar_height = zoom_out_button.getMinimumSize().height; } if(debug_on) { System.out.println("Creating optKeyGraphChoice."); } optKeyGraphChoice = new Choice(); optKeyGraphChoice.addItem("Graph"); optKeyGraphChoice.addItem("Options"); optKeyGraphChoice.addItem("Text"); optKeyGraphChoice.addItemListener(this); if(title_bar_height < optKeyGraphChoice.getSize().height) { title_bar_height = optKeyGraphChoice.getSize().height; } if(title_bar_height < optKeyGraphChoice.getPreferredSize().height) { title_bar_height = optKeyGraphChoice.getPreferredSize().height; } if(title_bar_height < optKeyGraphChoice.getMinimumSize().height) { title_bar_height = optKeyGraphChoice.getMinimumSize().height; } if(title_bar_height < 20) { title_bar_height = 20; } if(debug_on) { System.out.println("Creating labelPointsCheckbox."); } labelPointsCheckbox = new Checkbox("Label Points"); if(debug_on) { System.out.println("Creating keyCheckbox."); } keyCheckbox = new Checkbox("Key",null,true); if(debug_on) { System.out.println("Creating fitToGraphButton."); } fitToGraphButton = new Button("Fit to Graph"); fitToGraphButton.addActionListener(this); if(debug_on) { System.out.println("Creating choicePanel."); } choicePanel = new Panel(); if(debug_on) { System.out.println("Creating graphPanel."); } graphPanel = new Panel(); if(debug_on) { System.out.println("Creating horz_scroll_bar."); } horz_scroll_bar = new Scrollbar(Scrollbar.HORIZONTAL); d = horz_scroll_bar.getSize(); horz_scroll_bar_height = d.height; if(horz_scroll_bar_height < horz_scroll_bar.getPreferredSize().height) { horz_scroll_bar_height = horz_scroll_bar.getPreferredSize().height; } if(horz_scroll_bar_height < horz_scroll_bar.getMinimumSize().height) { horz_scroll_bar_height = horz_scroll_bar.getMinimumSize().height; } if(horz_scroll_bar_height < 20) { horz_scroll_bar_height = 20; } plot_graph_height = m_height -horz_scroll_bar_height- title_bar_height-30; horz_scroll_bar.addAdjustmentListener(this); if(debug_on) { System.out.println("Creating vert_scroll_bar."); } vert_scroll_bar = new Scrollbar(Scrollbar.VERTICAL); d = vert_scroll_bar.getSize(); vert_scroll_bar_width = d.width; if(vert_scroll_bar_width < vert_scroll_bar.getPreferredSize().width) { vert_scroll_bar_width = vert_scroll_bar.getPreferredSize().width; } if(vert_scroll_bar_width < vert_scroll_bar.getMinimumSize().width) { vert_scroll_bar_width = vert_scroll_bar.getMinimumSize().width; } if(vert_scroll_bar_width < 20) { vert_scroll_bar_width = 20; } plot_graph_width = m_width -vert_scroll_bar_width-30; vert_scroll_bar.addAdjustmentListener(this); if(debug_on) { System.out.println("Creating plot_graph = new PlotGraph("+plot_graph_width+","+plot_graph_height+")"); } plot_graph = new PlotGraph(plot_graph_width,plot_graph_height); plot_graph.dplotter_num = dplotter_num; plot_graph.coordinate_type = coordinate_type; plot_graph.debug_on = debug_on; if(m_color && back_color != null) { plot_graph.setBackground(back_color); } else { plot_graph.setBackground(Color.white); } plot_graph.addMouseListener(this); if(m_scroll_width < plot_graph_width) { m_scroll_width = plot_graph_width; } if(m_scroll_height < plot_graph_height) { m_scroll_height = plot_graph_height; } plot_graph.m_color = m_color; plot_graph.x_scale = m_scroll_width/(m_max_x - m_min_x); plot_graph.y_scale = m_scroll_height/(m_max_y - m_min_y); plot_graph.x_offset = (int) (-m_min_x*plot_graph.x_scale); plot_graph.y_offset = (int) (m_max_y*plot_graph.y_scale); plot_graph.m_scroll_x = plot_graph.x_offset - m_scroll_width/2; plot_graph.m_scroll_y = plot_graph.y_offset - m_scroll_height/2; plot_graph.grid_color = grid_color; plot_graph.axis_color = axis_color; if(debug_on) { System.out.println("m_scroll_width = "+m_scroll_width); System.out.println("m_scroll_height = "+m_scroll_height); System.out.println("m_min_x = "+m_min_x); System.out.println("m_max_x = "+m_max_x); System.out.println("m_min_y = "+m_min_y); System.out.println("m_max_y = "+m_max_y); System.out.println("plot_graph.x_scale = "+plot_graph.x_scale); System.out.println("plot_graph.y_scale = "+plot_graph.y_scale); System.out.println("plot_graph.x_offset = "+plot_graph.x_offset); System.out.println("plot_graph.y_offset = "+plot_graph.y_offset); System.out.println("plot_graph.m_scroll_x = "+plot_graph.m_scroll_x); System.out.println("plot_graph.m_scroll_y = "+plot_graph.m_scroll_y); //System.out.println("horz_scroll_bar.setValues("+plot_graph.m_scroll_x+", "+plot_graph_width+", 0, "+String.valueOf(((int)m_scroll_width - plot_graph_width))+")"); //System.out.println("vert_scroll_bar.setValues("+plot_graph.m_scroll_y+", "+plot_graph_height+", 0, "+String.valueOf(((int)m_scroll_height - plot_graph_height))+")"); } if(debug_on) { System.out.println("horz_scroll_bar.setValues(0 ,"+plot_graph.m_width+", 0, "+m_scroll_width +")"); } horz_scroll_bar.setValues(0 ,plot_graph.m_width, 0, m_scroll_width ); horz_scroll_bar.setUnitIncrement(plot_graph.m_width/4); horz_scroll_bar.setBlockIncrement(plot_graph.m_width/2); plot_graph.m_scroll_x = 0; if(debug_on) { System.out.println("vert_scroll_bar.setValues(0 ,"+plot_graph.m_height+", 0, "+m_scroll_height+")"); } vert_scroll_bar.setValues(0 ,plot_graph.m_height, 0, m_scroll_height); vert_scroll_bar.setUnitIncrement(plot_graph.m_height/4); vert_scroll_bar.setBlockIncrement(plot_graph.m_height/2); //horz_scroll_bar.setValues(plot_graph.m_scroll_x ,plot_graph_width, 0, m_scroll_width - plot_graph_width); //vert_scroll_bar.setValues(plot_graph.m_scroll_y ,plot_graph_height, 0, m_scroll_height - plot_graph_height); if(debug_on) { System.out.println("Creating optionsPanel."); } optionsPanel = new Panel(); if(debug_on) { System.out.println("Creating optChoice."); } optChoice = new Choice(); optChoice.addItem("Color"); optChoice.addItem("Label Points"); optChoice.addItem("Minimum X"); optChoice.addItem("Maximum X"); optChoice.addItem("Minimum Y"); optChoice.addItem("Maximum Y"); optChoice.addItem("Scroll Width"); optChoice.addItem("Scroll Height"); optChoice.addItem("Back Color"); optChoice.addItem("Grid Color"); optChoice.addItem("Axis Color"); optChoice.addItem("Coordinate Type"); optChoice.addItem("Radius Offset"); optChoice.addItem("Maximum Radius"); if(debug_on) { System.out.println("Creating optTextField."); } optTextField = new TextField("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); optTextField.addActionListener(this); if(debug_on) { System.out.println("Creating optPlotShowCheckbox."); } optPlotShowCheckbox = new Checkbox("SHOW"); if(debug_on) { System.out.println("Creating optPlotsList."); } optPlotsList = new CountList(5,false); for( i = 0; i < 5; i++) { optPlotsList.addItem("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } if(debug_on) { System.out.println("Creating optPlotDeleteButton."); } optPlotDeleteButton = new Button("DELETE"); optPlotDeleteButton.addActionListener(this); if(debug_on) { System.out.println("Creating optPlotClearButton."); } optPlotClearButton = new Button("Clear"); optPlotClearButton.addActionListener(this); if(debug_on) { System.out.println("Creating load_info_panel."); } load_info_panel = new URLLoadInfoPanel(plot_graph_width,plot_graph_height); if(debug_on) { System.out.println("Creating textPanel."); } textPanel = new Panel(); try { if(debug_on) { System.out.println("Creating loadButton."); } loadButton = new Button("LOAD"); loadButton.addActionListener(this); d = loadButton.getSize(); if(d != null) { if(second_row_height < d.height) { second_row_height = d.height; } } d = loadButton.getMinimumSize(); if(d != null) { if(second_row_height < d.height) { second_row_height = d.height; } } d = loadButton.getPreferredSize(); if(d != null) { if(second_row_height < d.height) { second_row_height = d.height; } } if(debug_on) { System.out.println("Creating browseButton."); } browseButton = new Button("BROWSE"); browseButton.addActionListener(this); d = browseButton.getSize(); if(d != null) { if(second_row_height < d.height) { second_row_height = d.height; } } d = browseButton.getMinimumSize(); if(d != null) { if(second_row_height < d.height) { second_row_height = d.height; } } d = browseButton.getPreferredSize(); if(d != null) { if(second_row_height < d.height) { second_row_height = d.height; } } if(debug_on) { System.out.println("Creating saveButton."); } saveButton = new Button("SAVE"); saveButton.addActionListener(this); d = saveButton.getSize(); if(d != null) { if(second_row_height < d.height) { second_row_height = d.height; } } d = saveButton.getMinimumSize(); if(d != null) { if(second_row_height < d.height) { second_row_height = d.height; } } d = saveButton.getPreferredSize(); if(d != null) { if(second_row_height < d.height) { second_row_height = d.height; } } } catch(Exception e) { System.err.println("Error creating second row for textPanel"); e.printStackTrace(); } if(debug_on) { System.out.println("second_row_height = "+second_row_height); } text_area_width = text_width - 10; if(text_area_width < 20) { text_area_width = 20; } if(text_area_width > 80) { text_area_width = 80; } text_area_height = text_height - 10; if(text_area_height < 5) { text_area_height = 5; } if(text_area_height > 25) { text_area_height = 25; } try { if(debug_on) { System.out.println("Creating urlTextField."); } urlTextField = new TextField("",text_area_width); urlTextField.addActionListener(this); } catch(Exception e) { System.err.println("Error creating urlTextField"); e.printStackTrace(); first_row_height = 20; second_row_height = 20; } if(debug_on) { System.out.println("first_row_height = "+first_row_height); } try { if(debug_on) { System.out.println("Creating textArea."); } if(debug_on) { System.out.println("TextArea will have "+text_area_height+" rows, and"+text_area_width+" collumns."); } textArea = new TextArea(text_area_height,text_area_width); } catch(Exception e) { System.err.println("Error creating textArea."); e.printStackTrace(); textArea = null; return; } if(debug_on) { System.out.println("Components have been created out successfully."); } } catch(Exception e) { e.printStackTrace(); } } public void LayoutControls() { GridBagConstraints c = null; try { if(debug_on) { System.out.println("Laying out controls"); } if(debug_on) { System.out.println("Creating GridBagConstraints c."); } c = new GridBagConstraints(); /* try { if(debug_on) { System.out.println("Setting the background."); } setBackground(Color.white); } catch(Exception e) { if(debug_on) { e.printStackTrace(); } } */ try { if(debug_on) { System.out.println("setLayout(innerLayout.)"); } setLayout(innerLayout); } catch(Exception e) { if(debug_on) { e.printStackTrace(); } } if(null != m_title) { if(m_title.length() > 0) { if(debug_on) { System.out.println("Adding title_label."); } innerPanel.add(title_label); c.gridx = 0; c.gridy = 0; innerLayout.setConstraints(title_label,c); } } if(debug_on) { System.out.println("Adding New Window Button."); } innerPanel.add(newWindowButton); c.gridx = 1; c.gridy = 0; innerLayout.setConstraints(newWindowButton,c); if(debug_on) { System.out.println("Adding zoom_in_button."); } innerPanel.add(zoom_in_button); c.gridx = 2; c.gridy = 0; innerLayout.setConstraints(zoom_in_button,c); if(debug_on) { System.out.println("Adding zoom_out_button."); } innerPanel.add(zoom_out_button); c.gridx = 3; c.gridy = 0; innerLayout.setConstraints(zoom_out_button,c); c.anchor = GridBagConstraints.NORTHWEST; /* if(debug_on) { System.out.println("Adding labelPointsCheckbox."); } innerPanel.add(labelPointsCheckbox); c.gridx = 4; c.gridy = 0; innerLayout.setConstraints(labelPointsCheckbox,c); */ if(debug_on) { System.out.println("Adding keyCheckbox."); } innerPanel.add(keyCheckbox); c.gridx = 4; c.gridy = 0; innerLayout.setConstraints(keyCheckbox,c); if(debug_on) { System.out.println("Adding fitToGraphButton."); } innerPanel.add(fitToGraphButton); c.gridx = 5; c.gridy = 0; innerLayout.setConstraints(fitToGraphButton,c); if(debug_on) { System.out.println("Adding optKeyGraphChoice."); } innerPanel.add(optKeyGraphChoice); c.gridx = 6; c.gridy = 0; innerLayout.setConstraints(optKeyGraphChoice,c); if(null != innerLayout) { innerLayout.setConstraints(optKeyGraphChoice,c); } c.anchor = GridBagConstraints.NORTHWEST; choicePanelLayout = new CardLayout(); choicePanel.setLayout(choicePanelLayout); graphPanelLayout = new FlowLayout(FlowLayout.LEFT); graphPanel.setLayout(graphPanelLayout); graphInnerPanel = new Panel(); graphInnerLayout = new GridBagLayout(); graphInnerPanel.setLayout(graphInnerLayout); if(debug_on) { System.out.println("Adding plot_graph to graphInnerPanel."); } graphInnerPanel.add(plot_graph); c.gridwidth = 1; c.gridx = 0; c.gridy = 0; graphInnerLayout.setConstraints(plot_graph,c); c.gridx = 1; c.gridy = 0; c.gridwidth = 1; c.fill = GridBagConstraints.VERTICAL; if(debug_on) { System.out.println("Adding vert_scroll_bar to graphInnerPanel."); } graphInnerPanel.add(vert_scroll_bar); graphInnerLayout.setConstraints(vert_scroll_bar,c); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; if(debug_on) { System.out.println("Adding horz_scroll_bar to graphInnerPanel."); } graphInnerPanel.add(horz_scroll_bar); graphInnerLayout.setConstraints(horz_scroll_bar,c); graphPanel.add(graphInnerPanel); if(debug_on) { System.out.println("Adding graphPanel to choicePanel."); } try { //choicePanelLayout.addLayoutComponent("Graph",graphPanel); choicePanel.add("Graph",graphPanel); } catch(Exception e) { if(debug_on) { System.err.println("Error adding graphPanel to choicePanel."); e.printStackTrace(); } } optionsLayout = new FlowLayout(FlowLayout.LEFT); optionsPanel.setLayout(optionsLayout); optionsInnerPanel = new Panel(); optionsInnerLayout = new GridBagLayout(); optionsInnerPanel.setLayout(optionsInnerLayout); if(debug_on) { System.out.println("Adding optChoice to optionsInnerPanel."); } optionsInnerPanel.add(optChoice); c.gridy = 0; c.gridx = 0; c.gridwidth = 1; c.gridheight = 1; optionsInnerLayout.setConstraints(optChoice,c); if(debug_on) { System.out.println("Adding optTextField to optionsInnerPanel."); } optionsInnerPanel.add(optTextField); c.gridy = 0; c.gridx = 1; c.gridwidth = 3; c.gridheight = 1; optionsInnerLayout.setConstraints(optTextField,c); if(debug_on) { System.out.println("Adding optPlotsList to optionsInnerPanel."); } optionsInnerPanel.add(optPlotsList); c.gridy = 1; c.gridx = 0; c.gridwidth = 4; c.gridheight = 1; optionsInnerLayout.setConstraints(optPlotsList,c); if(debug_on) { System.out.println("Adding optPlotShowCheckbox to optionsInnerPanel."); } optionsInnerPanel.add(optPlotShowCheckbox); c.gridy = 2; c.gridx = 0; c.gridwidth = 1; c.gridheight = 1; optionsInnerLayout.setConstraints(optPlotShowCheckbox,c); if(debug_on) { System.out.println("Adding optPlotDeleteButton to optionsInnerPanel."); } optionsInnerPanel.add(optPlotDeleteButton); c.gridy = 2; c.gridx = 1; c.gridwidth = 1; c.gridheight = 1; optionsInnerLayout.setConstraints(optPlotDeleteButton,c); if(debug_on) { System.out.println("Adding optPlotClearButton to optionsInnerPanel."); } optionsInnerPanel.add(optPlotClearButton); c.gridy = 2; c.gridx = 2; c.gridwidth = 1; c.gridheight = 1; optionsInnerLayout.setConstraints(optPlotClearButton,c); optionsPanel.add(optionsInnerPanel); if(debug_on) { System.out.println("Adding optionsPanel to choicePanel."); } try { //choicePanelLayout.addLayoutComponent("Options",optionsPanel); choicePanel.add("Options",optionsPanel); } catch(Exception e) { if(debug_on) { System.err.println("Error adding optionsPanel to choicePanel."); e.printStackTrace(); } } if(debug_on) { System.out.println("Adding load_info_panel to choicePanel."); } try { //choicePanelLayout.addLayoutComponent("URL Load",load_info_panel); choicePanel.add("URL Load",load_info_panel); } catch(Exception e) { if(debug_on) { System.err.println("Error adding load_info_panel to choicePanel."); e.printStackTrace(); } } textPanelLayout = new GridBagLayout(); textPanel.setLayout(textPanelLayout); if(null != urlTextField) { if(debug_on) { System.out.println("Adding urlTextField to textPanel."); } textPanel.add(urlTextField); c.gridy = 0; c.gridx = 0; c.gridwidth = 4; c.gridheight = 1; c.fill = GridBagConstraints.NONE; textPanelLayout.setConstraints(urlTextField,c); } if(debug_on) { System.out.println("Adding loadButton to textPanel."); } textPanel.add(loadButton); c.gridy = 1; c.gridx = 0; c.gridwidth = 1; c.gridheight = 1; c.fill = GridBagConstraints.NONE; textPanelLayout.setConstraints(loadButton,c); if(debug_on) { System.out.println("Adding browseButton to textPanel."); } textPanel.add(browseButton); c.gridy = 1; c.gridx = 1; c.gridwidth = 1; c.gridheight = 1; c.fill = GridBagConstraints.NONE; textPanelLayout.setConstraints(browseButton,c); if(debug_on) { System.out.println("Adding saveButton to textPanel."); } textPanel.add(saveButton); c.gridy = 1; c.gridx = 2; c.gridwidth = 1; c.gridheight = 1; c.fill = GridBagConstraints.NONE; textPanelLayout.setConstraints(saveButton,c); if(null != textArea) { if(debug_on) { System.out.println("Adding textArea to textPanel."); } textPanel.add(textArea); c.gridy = 2; c.gridx = 0; c.gridwidth = 4; c.gridheight = 1; textPanelLayout.setConstraints(textArea,c); } if(debug_on) { System.out.println("Adding textPanel to choicePanel."); } try { //choicePanelLayout.addLayoutComponent("Text",textPanel); choicePanel.add("Text",textPanel); } catch(Exception e) { if(debug_on) { System.err.println("Error adding textPanel to choicePanel."); e.printStackTrace(); } } choicePanelLayout.show(choicePanel,"Graph"); if(debug_on) { System.out.println("Adding choicePanel."); } innerPanel.add(choicePanel); c.gridx = 0; c.gridy = 1; c.gridwidth = 8; c.fill = GridBagConstraints.BOTH; if(null != innerLayout) { innerLayout.setConstraints(choicePanel,c); } if(debug_on) { System.out.println("Components have been layed out successfully."); } add(innerPanel); } catch(Exception e) { e.printStackTrace(); } } static public boolean first_init = true; // The init() method is called by the AWT when an applet is first loaded or // reloaded. Override this method to perform whatever initialization your // applet needs, such as initializing data structures, loading images or // fonts, creating frame windows, setting the layout manager, or adding UI // components. //-------------------------------------------------------------------------- public void init() { int tries = 0; Dimension d = getSize(); if(!need_resize) { while(d.width < 1 || d.height < 1) { try { Thread.sleep(100); tries++; } catch(InterruptedException ie) { break; } if(tries > 20) { System.err.println("Can't seem to get the size()"); Thread.dumpStack(); break; } d = getSize(); } } if(inside_init) { System.err.println("Can't call init twice at the same time."); Thread.dumpStack(); return; } inside_init = true; try { if(debug_on) { System.out.println("Initializing plotter. . ."); System.out.println("size = "+getSize().width+"x"+getSize().height); System.out.println("m_width = "+m_width); System.out.println("m_height = "+m_height); System.out.println("tries = "+tries); Thread.dumpStack(); } if(!params_loaded && load_params_on_init) { GetAllParameters(); } if(m_width < MINIMUM_WIDTH) { m_width = MINIMUM_WIDTH; } if(m_height < MINIMUM_HEIGHT) { m_height = MINIMUM_HEIGHT; } if(m_width == MINIMUM_WIDTH) { if(getSize().width > MINIMUM_WIDTH) { m_width = getSize().width; } } if(m_height == MINIMUM_HEIGHT) { if(getSize().height > MINIMUM_HEIGHT) { m_height = getSize().height; } } // If you use a ResourceWizard-generated "control creator" class to // arrange controls in your applet, you may want to call its // CreateControls() method from within this method. Remove the following // call to resize() before adding the call to CreateControls(); // CreateControls() does its own resizing. //---------------------------------------------------------------------- if(debug_on) { System.out.println("plotter.init() "+m_width+" x "+m_height); } d = getSize(); if(need_resize && (d.width != m_width || d.height != m_height)) { manual_resize(m_width, m_height); if(debug_on) { System.out.println("plotter.init() resizing to "+m_width+" x "+m_height); } need_resize = false; } d = getSize(); if(d.width > 0) { m_width = d.width; } if(d.height > 0) { m_height = d.height; } // TODO: Place additional initialization code here try { options_hash_table = new Hashtable(); init_colors_hashtable(); CreateControls(); LayoutControls(); if(first_init && !reload_url_on_start) { UpdateOptionsHashtable(); if(m_url != null) { if(m_url.length() > 0 ) { if(! m_url.equals(last_url_loaded)) { load_url_needed = true; } urlTextField.setText(m_url); } } } first_init = false; plot_graph.show_key = keyCheckbox.getState(); last_user_set_x_scale = plot_graph.x_scale; } catch(Exception e) { e.printStackTrace(); } if(coordinate_type == POLAR_COORD_TYPE) { equalizeAxis(); } } catch(Exception e) { e.printStackTrace(); } inside_init=false; initialized = true; } public Color StringToColor(String name) { Color new_color = null; try { new_color = (Color) reverseColorsHashtable.get(name); } catch(Exception e) { e.printStackTrace(); } return new_color; } private void ParseString(String parseString) { boolean connected = true; int colon_index = 0; String option_name = null; String option_val = null; try { if(parseString.charAt(0) == '"') { parseString = parseString.substring(1); int qindex = parseString.indexOf('"'); if(qindex > 0) { parseString = parseString.substring(0,qindex); } if(parseString.length() < 1) { return; } if(current_pd.name.length() > 0 || current_pd.v.size() > 0) { AddPlot(current_pd,current_pd.name); current_pd = new PlotData(); } current_pd.name = parseString; return; } if(parseString.startsWith("move")) { connected = false; parseString = parseString.substring(4); } if(parseString.startsWith("draw")) { connected = true; parseString = parseString.substring(4); } colon_index = parseString.indexOf(':'); if(colon_index > 0) { if(debug_on) { System.out.println("parseString = "+parseString); } option_name = parseString.substring(0,colon_index); if(null == option_name) { return; } if(option_name.length() < 1) { return; } option_val = parseString.substring(colon_index+1); if(option_name.equals("Line Style")) { current_pd.line_style = option_val; return; } if(option_name.equals("Line Width")) { current_pd.line_width = (Integer.valueOf(option_val)).intValue(); return; } if(option_name.equals("Line Color")) { current_pd.line_color = StringToColor(option_val); return; } if(option_name.equals("Point Color")) { current_pd.point_color = StringToColor(option_val); return; } if(option_name.equals("Mark Points")) { mark_points = Boolean.valueOf(option_val).booleanValue(); current_pd.mark_points = mark_points; } if(option_name.equals("Use Buffer")) { PlotGraph.use_buffer = Boolean.valueOf(option_val).booleanValue(); current_pd.mark_points = mark_points; } if(option_name.equals("Radius Offset")) { user_specified_radius_offset = Double.valueOf(option_val).doubleValue(); use_user_specified_radius_offset=true; } if(option_name.equals("Coordinate Type")) { coordinate_type_name = option_val; if(coordinate_type_name.toUpperCase().equals("POLAR")) { coordinate_type = POLAR_COORD_TYPE; } else if(coordinate_type_name.toUpperCase().equals("CARTESIAN")) { coordinate_type = CARTESIAN_COORD_TYPE; } if(null != plot_graph) { plot_graph.coordinate_type = coordinate_type; } if(null != current_pd) { current_pd.coordinate_type = coordinate_type; } } if(null == option_val) { return; } if(option_val.length() < 1) { return; } if(debug_on) { System.out.println("Putting option on hash table. option_name="+option_name+", option_val="+option_val); } options_hash_table.put(option_name,option_val); return; } StringTokenizer tokenizer = new StringTokenizer(parseString," \t\r\n,;:"); if(!tokenizer.hasMoreTokens()) { return; } double first_coord = 0.0; double second_coord = 0.0; double x = 0.0; double y = 0.0; try { String first_string = tokenizer.nextToken(); first_coord = Double.valueOf(first_string).doubleValue(); } catch(Exception e) { return; } if(!tokenizer.hasMoreTokens()) { return; } try { String second_string = tokenizer.nextToken(); second_coord = Double.valueOf(second_string).doubleValue(); } catch(Exception e) { return; } if(coordinate_type == POLAR_COORD_TYPE) { double r = first_coord; double theta = second_coord; if(use_user_specified_radius_offset) { x = (r+user_specified_radius_offset)*Math.cos(theta); y = (r+user_specified_radius_offset)*Math.sin(theta); } else { x = r*Math.cos(theta); y = r*Math.sin(theta); } } else { x = first_coord; y = second_coord; } if(x > m_max_x) { m_max_x = x; } if(x < m_min_x) { m_min_x = x; } if(y > m_max_y) { m_max_y = y; } if(y < m_min_y) { m_min_y = y; } AddPointToPlot(current_pd,x,y,connected); } catch(Exception e) { e.printStackTrace(); } } static public boolean loading_url = false; private void LoadURL(String new_url) { try { loading_url = true; just_zoomed_to_max = false; update_scale_needed = false; load_url_needed = false; if(new_url != null) { m_url = new_url; } if(m_url.length() < 1) { loading_url = false; return; } boolean use_load_info_panel = true; boolean connected = true; URL newURL = null; URLConnection newURLConnection = null; File newFile = null; FileInputStream newFileInputStream = null; BufferedReader reader = null; PlotGraph.RemoveAllPlots(); if(m_url.startsWith("http:") || m_url.startsWith("ftp:")) { newURL = new URL(m_url); newURLConnection = newURL.openConnection(); reader = new BufferedReader(new InputStreamReader(newURLConnection.getInputStream())); try { load_info_panel.content_length = newURLConnection.getContentLength(); } catch(Exception e) { System.err.println("Error initializing load_info_panel."); e.printStackTrace(); use_load_info_panel = false; } } else { newFile = new File(m_url); newFileInputStream = new FileInputStream(m_url); reader = new BufferedReader(new InputStreamReader(newFileInputStream)); try { load_info_panel.content_length = (int) newFile.length(); } catch(Exception e) { System.err.println("Error initializing load_info_panel."); e.printStackTrace(); use_load_info_panel = false; } } int lines_between_updates = load_info_panel.content_length/1000; if(lines_between_updates < 20) { lines_between_updates = 20; } String parseString = null; current_pd = new PlotData(); try { if(use_load_info_panel) { load_info_panel.bytes_read = 0; load_info_panel.URLname = m_url; choicePanelLayout.show(choicePanel,"URL Load"); load_info_panel.repaint(600); } } catch(Exception e) { System.err.println("Error initializing load_info_panel."); e.printStackTrace(); use_load_info_panel = false; } int lines_read = 0; StringBuffer tempBuffer = new StringBuffer(); while(true) { connected = true; parseString = reader.readLine(); if(null == parseString) { break; } if(parseString.length() < 1) { continue; } if(!parseString.endsWith("\n") && !parseString.endsWith("\n\r")) { tempBuffer.append(parseString+"\n"); } else { tempBuffer.append(parseString); } try { if(use_load_info_panel) { load_info_panel.bytes_read += parseString.length(); if(lines_read%(lines_between_updates) == 0) { load_info_panel.updateDisplay(); repaint(500); try { Thread.sleep(50); } catch(Exception e) { } } } } catch(Exception e) { System.err.println("Error updating load_info_panel."); e.printStackTrace(); use_load_info_panel = false; } ParseString(parseString); lines_read++; } AddPlot(current_pd,current_pd.name); optKeyGraphChoice.select("Graph"); choicePanelLayout.show(choicePanel,"Graph"); if(null != textArea) { textArea.setText(tempBuffer.toString()); } if(null != reader) { reader.close(); reader = null; } if(null != newFileInputStream) { newFileInputStream.close(); newFileInputStream = null; } ResetOptPlotsList(); processCurrentOptionValues(); if(coordinate_type == POLAR_COORD_TYPE) { equalizeAxis(); } else { FitToGraph(); } repaint_needed = true; TextIsUpToDate = true; last_url_loaded = m_url; loading_url = false; } catch(Exception e) { e.printStackTrace(); } } private void setCurrentOptionValue() { try { String opt_name = optChoice.getSelectedItem(); if(null == opt_name) { return; } String temp = (String) options_hash_table.get(opt_name); if(null == temp) { System.err.println(opt_name +" not found in options hashtable."); return; } optTextField.setText(temp); } catch(Exception e) { e.printStackTrace(); } } private void modifyCurrentOptionValue() { try { options_modified = true; String opt_name = optChoice.getSelectedItem(); String opt_value = optTextField.getText(); options_hash_table.put(opt_name,opt_value); TextIsUpToDate = false; } catch(Exception e) { e.printStackTrace(); } } private void processCurrentOptionValues() { try { Enumeration option_keys = options_hash_table.keys(); while(option_keys.hasMoreElements()) { String option_name = (String) option_keys.nextElement(); String option_value = (String) options_hash_table.get(option_name); while(true) { if(option_value.length() < 2) { break; } char last_char = option_value.charAt(option_value.length() -1); if(last_char != ' ' && last_char != '\t' && last_char != '\r' && last_char != '\n') { break; } option_value = option_value.substring(0,option_value.length() -1); } if(option_name.equalsIgnoreCase("Color")) { if(option_value.startsWith("1")) { m_color = true; } else { m_color = Boolean.valueOf(option_value).booleanValue(); } plot_graph.m_color = m_color; continue; } if(option_name.equalsIgnoreCase("Label Points")) { if(option_value.startsWith("1") || option_value.startsWith("t") || option_value.startsWith("T")) { plot_graph.label_points = true; } else { plot_graph.label_points = Boolean.valueOf(option_value).booleanValue(); } continue; } if(option_name.equalsIgnoreCase("Show Lines")) { if(option_value.startsWith("1") || option_value.startsWith("-") || option_value.startsWith("t") || option_value.startsWith("T")) { plot_graph.show_lines = true; } else { plot_graph.show_lines = Boolean.valueOf(option_value).booleanValue(); } continue; } if(option_name.equalsIgnoreCase("Minimum X")) { m_min_x = Double.valueOf(option_value).doubleValue(); continue; } if(option_name.equalsIgnoreCase("Maximum X")) { m_max_x = Double.valueOf(option_value).doubleValue(); continue; } if(option_name.equalsIgnoreCase("Minimum Y")) { m_min_y = Double.valueOf(option_value).doubleValue(); continue; } if(option_name.equalsIgnoreCase("Maximum Y")) { m_max_y = Double.valueOf(option_value).doubleValue(); continue; } if(option_name.equalsIgnoreCase("Radius Offset")) { user_specified_radius_offset = Double.valueOf(option_value).doubleValue(); use_user_specified_radius_offset = true; continue; } if(option_name.equalsIgnoreCase("Maximum Radius")) { radius_maximum = Double.valueOf(option_value).doubleValue(); if(use_user_specified_radius_offset) { m_min_x = - radius_maximum - user_specified_radius_offset; m_min_y = - radius_maximum - user_specified_radius_offset; m_max_x = radius_maximum + user_specified_radius_offset; m_max_y = radius_maximum + user_specified_radius_offset; } else { m_min_x = - radius_maximum; m_min_y = - radius_maximum; m_max_x = radius_maximum; m_max_y = radius_maximum; } if(null != plot_graph) { plot_graph.x_min = m_min_x; plot_graph.y_min = m_min_y; plot_graph.x_max = m_max_x; plot_graph.y_max = m_max_y; } try { equalizeAxis(); } catch(Exception e) { e.printStackTrace(); } continue; } if(option_name.equalsIgnoreCase("Grid X")) { plot_graph.grid_x = Double.valueOf(option_value).doubleValue(); continue; } if(option_name.equalsIgnoreCase("Grid Y")) { plot_graph.grid_y = Double.valueOf(option_value).doubleValue(); continue; } if(option_name.equalsIgnoreCase("Scroll Width")) { m_scroll_width = Integer.valueOf(option_value).intValue(); continue; } if(option_name.equalsIgnoreCase("Scroll Height")) { m_scroll_height = Integer.valueOf(option_value).intValue(); continue; } if(option_name.equalsIgnoreCase("Back Color")) { m_back_color_name = option_value; back_color = StringToColor(m_back_color_name); PlotGraph.back_color = back_color; continue; } if(option_name.equalsIgnoreCase("Axis Color")) { m_axis_color_name = option_value; axis_color = StringToColor(m_axis_color_name); continue; } if(option_name.equalsIgnoreCase("Grid Color")) { m_grid_color_name = option_value; grid_color = StringToColor(m_grid_color_name); continue; } if(option_name.equalsIgnoreCase("Zero Radius Color")) { m_zero_rad_color_name = option_value; zero_rad_color = StringToColor(m_zero_rad_color_name); PlotGraph.zero_rad_color = zero_rad_color; continue; } if(option_name.equalsIgnoreCase("TitleText")) { m_title = option_value; title_label.setText(m_title); continue; } } if(m_color && back_color != null) { plot_graph.setBackground(back_color); } else { plot_graph.setBackground(Color.white); } plot_graph.axis_color = axis_color; plot_graph.grid_color = grid_color; plot_graph.zero_rad_color = zero_rad_color; plot_graph.m_color = m_color; plot_graph.changeScale(m_min_x,m_max_x,m_scroll_width,m_min_y, m_max_y, m_scroll_height); if(coordinate_type == POLAR_COORD_TYPE) { equalizeAxis(); } if(m_scroll_width < plot_graph.m_width) { m_scroll_width = plot_graph.m_width; } if(m_scroll_height < plot_graph.m_height) { m_scroll_height = plot_graph.m_height; } if(debug_on) { System.out.println("horz_scroll_bar.setValues(0 ,"+plot_graph.m_width+", 0, "+m_scroll_width+")"); } horz_scroll_bar.setValues(0 ,plot_graph.m_width, 0, m_scroll_width ); horz_scroll_bar.setUnitIncrement(plot_graph.m_width/4); horz_scroll_bar.setBlockIncrement(plot_graph.m_width/2); plot_graph.m_scroll_x = 0; if(debug_on) { System.out.println("vert_scroll_bar.setValues(0 ,"+plot_graph.m_height+", 0, "+m_scroll_height+")"); } vert_scroll_bar.setValues(0 ,plot_graph.m_height, 0, m_scroll_height); vert_scroll_bar.setUnitIncrement(plot_graph.m_height/4); vert_scroll_bar.setBlockIncrement(plot_graph.m_height/2); plot_graph.m_scroll_y = 0; UpdateOptionsHashtable(); options_modified = false; } catch(Exception e) { e.printStackTrace(); } } public void mouseEntered(MouseEvent evt) { } public void mouseExited(MouseEvent evt) { } public void mouseClicked(MouseEvent evt) { } public void mousePressed(MouseEvent evt) { } public void mouseReleased(MouseEvent evt) { try { int x = evt.getX(); int y = evt.getY(); if(debug_on) { System.out.println("dplotter.mouseReleased("+evt+") x="+x+", y="+y); } if(plot_graph != null) { if(plot_graph.rescale_to_selected_rectangle_needed || (plot_graph.show_rect && plot_graph.selected_rectangle.width > 5 && plot_graph.selected_rectangle.height > 5)) { int width_zoom = plot_graph.m_width/plot_graph.selected_rectangle.width; int height_zoom = plot_graph.m_height/plot_graph.selected_rectangle.height; int temp = horz_scroll_bar.getValue(); int horz_scroll_pos = plot_graph.selected_rectangle.x; if(temp >= 0) { horz_scroll_pos = temp + plot_graph.selected_rectangle.x; } int vert_scroll_pos = plot_graph.selected_rectangle.y; temp = vert_scroll_bar.getValue(); if(temp >= 0) { vert_scroll_pos = temp + plot_graph.selected_rectangle.y; } if(width_zoom < 1) { width_zoom = plot_graph.selected_rectangle.width/plot_graph.m_width; m_scroll_width /= width_zoom; if(m_scroll_width < plot_graph.m_width) { width_zoom = plot_graph.scroll_width/plot_graph.m_width; m_scroll_width = plot_graph.m_width; } horz_scroll_pos /= width_zoom; } else { m_scroll_width *= width_zoom; horz_scroll_pos *= width_zoom; } if(debug_on) { System.out.println("width_zoom = "+width_zoom); } if(height_zoom < 1) { height_zoom = plot_graph.selected_rectangle.height/plot_graph.m_height; m_scroll_height /= height_zoom; if(m_scroll_height < plot_graph.m_height) { height_zoom = plot_graph.scroll_height/plot_graph.m_height; m_scroll_height = plot_graph.m_height; } vert_scroll_pos /= height_zoom; } else { m_scroll_height *= height_zoom; vert_scroll_pos *= height_zoom; } if(debug_on) { System.out.println("height_zoom = "+height_zoom); } plot_graph.changeScale(m_min_x,m_max_x, m_scroll_width, m_min_y,m_max_y, m_scroll_height); last_user_set_x_scale = plot_graph.x_scale; if(horz_scroll_pos < 0) { horz_scroll_pos = 0; } if(debug_on) { System.out.println("horz_scroll_bar.setValues("+horz_scroll_pos+", "+plot_graph.m_width+", 0, "+m_scroll_width +")"); } horz_scroll_bar.setValues(horz_scroll_pos,plot_graph.m_width, 0, m_scroll_width); horz_scroll_bar.setUnitIncrement(plot_graph.m_width/4); horz_scroll_bar.setBlockIncrement(plot_graph.m_width/2); plot_graph.m_scroll_x = horz_scroll_bar.getValue(); if(debug_on) { System.out.println("plot_graph.m_scroll_x= "+plot_graph.m_scroll_x); } if(vert_scroll_pos < 0) { vert_scroll_pos = 0; } if(debug_on) { System.out.println("vert_scroll_pos.setValues("+vert_scroll_pos+", "+plot_graph.m_height+", 0, "+m_scroll_height+")"); } vert_scroll_bar.setValues(vert_scroll_pos,plot_graph.m_height, 0, m_scroll_height); vert_scroll_bar.setUnitIncrement(plot_graph.m_height/4); vert_scroll_bar.setBlockIncrement(plot_graph.m_height/2); plot_graph.m_scroll_y = vert_scroll_pos; if(coordinate_type == POLAR_COORD_TYPE) { equalizeAxis(); } } } } catch(Exception e) { e.printStackTrace(); } } private void ResetOptPlotsList() { optPlotsList.removeAll(); Enumeration plots_enum = plot_graph.plots.elements(); while(plots_enum.hasMoreElements()) { current_pd = (PlotData) plots_enum.nextElement(); if(current_pd.v.size() < 1 || current_pd.name.length() < 1) { continue; } optPlotsList.addItem(current_pd.name); } } private void ConvertPlotsToText() { String new_text = ""; String option_name = null; String color_name = null; String option_val = null; Enumeration option_enum = options_hash_table.keys(); while(option_enum.hasMoreElements()) { option_name = (String) option_enum.nextElement(); if(option_name == null) { continue; } option_val = (String) options_hash_table.get(option_name); if(option_val == null) { continue; } new_text += option_name+":"+option_val+"\n"; } Enumeration plots_enum = plot_graph.plots.elements(); while(plots_enum.hasMoreElements()) { current_pd = (PlotData) plots_enum.nextElement(); if(current_pd.v.size() < 1 || current_pd.name.length() < 1) { continue; } new_text += "\""+current_pd.name+"\"\n"; if(current_pd.line_width > 1) { new_text += "Line Width:"+current_pd.line_width+"\n"; } if(current_pd.line_style != null) { new_text += "Line Style:"+current_pd.line_style+"\n"; } if(current_pd.line_color != null) { color_name = (String) colorsHashtable.get(current_pd.line_color); if(color_name != null) { new_text += "Line Color:"+color_name+"\n"; } } if(current_pd.point_color != null) { color_name = (String) colorsHashtable.get(current_pd.point_color); if(color_name != null) { new_text += "Point Color:"+color_name+"\n"; } } for(int i = 0; i < current_pd.v.size(); i++) { PlotPoint point = (PlotPoint) current_pd.v.elementAt(i); if(!point.connected) { new_text += "move "; } new_text += point.orig_x + " \t"+point.orig_y+"\n"; } } textArea.setText(new_text); ResetOptPlotsList(); TextIsUpToDate = true; } private void ConvertTextToPlots() { StringTokenizer tokenizer = new StringTokenizer(textArea.getText(),"\n\r"); current_pd = new PlotData(); while(tokenizer.hasMoreTokens()) { ParseString(tokenizer.nextToken()); } if(current_pd.name.length() > 0 || current_pd.v.size() > 0) { AddPlot(current_pd,current_pd.name); } ResetOptPlotsList(); processCurrentOptionValues(); TextIsUpToDate = true; repaint_needed = true; } private String GetTextFileName(boolean saving) { String text_file_name = null; try { Frame temp_frame = new Frame(); FileDialog file_dialog = null; if(saving) { file_dialog = new FileDialog(temp_frame,"Java Logger: SaveAs",FileDialog.SAVE); } else { file_dialog = new FileDialog(temp_frame,"Java Logger"); } if(m_url != null) { if(m_url.length() > 0 && !m_url.startsWith("http:") && !m_url.startsWith("ftp:")) { File temp_file = new File(m_url); file_dialog.setDirectory(temp_file.getParent()); } } file_dialog.show(); int i = 0; while(null == text_file_name && (file_dialog.isShowing() || i < 100)) { text_file_name = file_dialog.getFile(); } save_directory = file_dialog.getDirectory(); if(save_directory != null && text_file_name != null) { text_file_name = save_directory+text_file_name; } file_dialog.dispose(); } catch(Exception e) { e.printStackTrace(); } return text_file_name; } private void WriteTextToFile(String text_file_name) { try { FileOutputStream fos = new FileOutputStream(text_file_name); String text_string = textArea.getText(); int text_length = text_string.length(); byte b[] = text_string.getBytes(); fos.write(b,0,text_length); fos.close(); } catch(Exception e) { e.printStackTrace(); } } private void SaveText() { try { ConvertTextToPlots(); String text_file = GetTextFileName(true); if(text_file != null) { WriteTextToFile(text_file); } urlTextField.setText(text_file); } catch(Exception e) { e.printStackTrace(); } } private void OpenText() { try { String text_file = GetTextFileName(false); if(text_file != null) { m_url = text_file; urlTextField.setText(text_file); load_url_needed = true; } } catch(Exception e) { e.printStackTrace(); } } int forced_repaints = 0; int last_horz_value_set = 0; int last_vert_value_set = 0; public void adjustmentValueChanged(AdjustmentEvent evt) { try { if(evt.getSource() == horz_scroll_bar) { int temp = evt.getValue(); if(temp > 0 && temp != last_horz_value_set) { last_horz_value_set = temp; if(null != plot_graph) { if(Math.abs(plot_graph.m_scroll_x - temp) > 10) { repaint_needed = true; } plot_graph.m_scroll_x = temp; } horz_scroll_bar.setValue(temp); repaint_needed = true; plot_graph.repaint_needed = true; plot_graph.image_needs_to_be_updated=true; plot_graph.repaint(600); } } if(evt.getSource() == vert_scroll_bar) { int temp = evt.getValue(); if(temp > 0 && temp != last_vert_value_set) { last_vert_value_set = temp; if(null != plot_graph) { if(Math.abs(plot_graph.m_scroll_y - temp) > 10) { repaint_needed = true; } plot_graph.m_scroll_y = temp; } vert_scroll_bar.setValue(temp); plot_graph.repaint_needed = true; plot_graph.image_needs_to_be_updated=true; plot_graph.repaint(600); } } if(!continous_update) { if(Math.abs(repaint_millis - System.currentTimeMillis()) > 2000) { repaint_needed = true; } if(repaint_needed) { forced_repaints++; if(debug_on) { System.out.println("Forcing repaint "+plot_graph.repaint_count); } } UpdateDisplay(); } } catch(Exception e) { e.printStackTrace(); } } private void FitToGraph() { int i = 0; try { Enumeration plots_enum = plot_graph.plots.elements(); if(plots_enum == null) { return; } while(plots_enum.hasMoreElements()) { current_pd = (PlotData) plots_enum.nextElement(); if(debug_on) { System.out.println("current_pd = "+current_pd); System.out.println("current_pd.name = "+current_pd.name); System.out.println("current_pd.v = "+current_pd.v); System.out.println("current_pd.show = "+current_pd.show); } if(null == current_pd) { return; } if(null == current_pd.show) { break; } if(current_pd.show.length <= dplotter_num) { break; } if(current_pd.show[dplotter_num]) { break; } } if(null == current_pd) { return; } while(current_pd.v.size() < 1) { if(!plots_enum.hasMoreElements()) { return; } current_pd = (PlotData) plots_enum.nextElement(); if(null == current_pd) { return; } } PlotPoint pp = (PlotPoint) current_pd.v.elementAt(0); if(null == pp) { return; } m_min_x = pp.orig_x; m_max_x = pp.orig_x; m_min_y = pp.orig_y; m_max_y = pp.orig_y; for( i = 1; i < current_pd.v.size(); i++) { pp = (PlotPoint) current_pd.v.elementAt(i); if(pp.orig_x > m_max_x) { m_max_x = pp.orig_x; } if(pp.orig_x < m_min_x) { m_min_x = pp.orig_x; } if(pp.orig_y > m_max_y) { m_max_y = pp.orig_y; } if(pp.orig_y < m_min_y) { m_min_y = pp.orig_y; } } while(plots_enum.hasMoreElements()) { current_pd = (PlotData) plots_enum.nextElement(); if(debug_on) { System.out.println("current_pd = "+current_pd); System.out.println("current_pd.name = "+current_pd.name); System.out.println("current_pd.v = "+current_pd.v); System.out.println("current_pd.show = "+current_pd.show); } if(null == current_pd) { return; } if(null != current_pd.show) { if(current_pd.show.length >= dplotter_num) { if(!current_pd.show[dplotter_num]) { continue; } } } for(i = 0; i < current_pd.v.size(); i++) { pp = (PlotPoint) current_pd.v.elementAt(i); if(pp.orig_x > m_max_x) { m_max_x = pp.orig_x; } if(pp.orig_x < m_min_x) { m_min_x = pp.orig_x; } if(pp.orig_y > m_max_y) { m_max_y = pp.orig_y; } if(pp.orig_y < m_min_y) { m_min_y = pp.orig_y; } } } if(m_min_x >= m_max_x) { m_min_x--; m_max_x++; } if(m_min_y >= m_max_y) { m_min_y--; m_max_y++; } double x_diff = (m_max_x - m_min_x); m_min_x -= x_diff*0.01; m_max_x += x_diff*0.01; double y_diff = (m_max_y - m_min_y); m_min_y -= y_diff*0.01; m_max_y += y_diff*0.01; m_scroll_width = plot_graph.m_width; m_scroll_height = plot_graph.m_height; //System.out.println("New Graph: m_min_x="+m_min_x+" m_max_x="+m_max_x+" m_min_y="+m_min_y+" m_max_y="+m_max_y); plot_graph.changeScale(m_min_x,m_max_x,m_scroll_width,m_min_y, m_max_y, m_scroll_height); if(coordinate_type == POLAR_COORD_TYPE) { equalizeAxis(); } options_hash_table.put("Minimum Y",(String) (new Double(m_min_y)).toString()); options_hash_table.put("Maximum Y",(String) (new Double(m_max_y)).toString()); horz_scroll_bar.setValues(0 ,plot_graph.m_width, 0, m_scroll_width ); horz_scroll_bar.setUnitIncrement(plot_graph.m_width/4); horz_scroll_bar.setBlockIncrement(plot_graph.m_width/2); plot_graph.m_scroll_x = 0; vert_scroll_bar.setValues(0 ,plot_graph.m_height, 0, m_scroll_height ); vert_scroll_bar.setUnitIncrement(plot_graph.m_height/4); vert_scroll_bar.setBlockIncrement(plot_graph.m_height/2); plot_graph.m_scroll_y = 0; repaint_needed = true; last_user_set_x_scale = plot_graph.x_scale; } catch(Exception e) { e.printStackTrace(); } } public static void setColorState(boolean use_color) { m_color = use_color; PlotGraph.m_color = m_color; for(int i = 0; i < dplotter_vector.size(); i++) { dplotter dp = (dplotter) dplotter_vector.elementAt(i); if(null != dp) { dp.TextIsUpToDate = false; dp.repaint_needed = true; if(null != dp.options_hash_table) { dp.options_hash_table.put("Color",(String) (new Boolean(m_color)).toString()); } if(null != dp.plot_graph) { if(m_color && back_color != null) { dp.plot_graph.setBackground(back_color); } else { dp.plot_graph.setBackground(Color.white); } } } } } // m_fStandAlone APPLICATION SUPPORT // The main() method acts as the applet's entry point when it is run // as a m_fStandAlone application. It is ignored if the applet is run from // within an HTML page. //-------------------------------------------------------------------------- public static void main(String args[]) { if(args.length > 0) { String first_arg = args[0].toUpperCase(); //System.out.println("first_arg = "+first_arg); if(first_arg.indexOf("HELP") > -1 || first_arg.indexOf('?') > -1) { try { dplotter temp_applet = new dplotter(); System.out.println(temp_applet.getAppletInfo()); String param_info[][] = temp_applet.getParameterInfo(); System.out.println("Usage: [Parameter=value]"); System.out.println("Parameter \tType \tDescription"); for(int i = 0; i < param_info.length; i++) { for(int ii = 0; ii < param_info[i].length; ii++) { System.out.print(param_info[i][ii]+" \t"); } System.out.println(""); } //Thread.sleep(5000); } catch(Exception e) { e.printStackTrace(); } System.exit(0); } } dplotterFrame.in_something_else = false; CreateNewWindow(args, true); } public static void CreateNewWindow(String args[], boolean stand_alone) { try { int frame_width = 580; int frame_height = 580; int tries = 0; try { Toolkit tk = Toolkit.getDefaultToolkit(); while(tk == null) { try { Thread.sleep(100); } catch(Exception e) { } tk = Toolkit.getDefaultToolkit(); tries++; if(tries > 20) { System.out.println("Can't getDefaultToolkit()\n"); break; } } if(null != tk) { Dimension d = tk.getScreenSize(); tries = 0; int screen_width = 0; int screen_height = 0; while(d == null || screen_width < 1 || screen_height < 1) { try { Thread.sleep(100); } catch(Exception e) { } tk = Toolkit.getDefaultToolkit(); tries++; if(null != d) { screen_width = d.width; screen_height = d.height; } if(tries > 20) { System.out.println("Can't getScreenSize()()\n"); break; } } frame_width = (screen_width/2); frame_height = (screen_height/2); } } catch(Exception e) { e.printStackTrace(); } if(frame_width > 580) { frame_width = 580; } if(frame_height > 580) { frame_height = 580; } // Create Toplevel Window to contain applet NCapplet //---------------------------------------------------------------------- dplotterFrame frame = new dplotterFrame("Rcs Data Plotter"); //dplotterFrame.in_an_applet = !stand_alone; // Must show Frame before we size it so insets() will return valid values //---------------------------------------------------------------------- frame.setVisible(true); frame.manual_resize(frame_width, frame_height); // The following code starts the applet running within the frame window. // It also calls GetParameters() to retrieve parameter values from the // command line, and sets m_fStandAlone to true to prevent init() from // trying to get them from the HTML page. //---------------------------------------------------------------------- dplotter applet_dplotter = new dplotter(); frame.innerApplet = applet_dplotter; frame.add("Center", applet_dplotter); if(stand_alone) { applet_dplotter.m_fStandAlone = true; if(null != args) { applet_dplotter.GetParameters(args); } } applet_dplotter.load_params_on_init = false; applet_dplotter.inside_resizeable_window = true; frame.resizeInnerApplet(); applet_dplotter.init(); if(start_applet_after_creating_new_window) { applet_dplotter.start(); } //applet_dplotter.in_resizable_window = true; frame.setVisible(true); applet_dplotter.setVisible(true); frame.repaint(); applet_dplotter.repaint(); } catch(Exception e) { e.printStackTrace(); } } public void actionPerformed(ActionEvent evt) { try { if(evt.getSource() == newWindowButton) { CreateNewWindow(null, m_fStandAlone); } if(evt.getSource() == (optChoice)) { setCurrentOptionValue(); return; } if(evt.getSource() == (fitToGraphButton)) { FitToGraph(); return; } if(evt.getSource() == (labelPointsCheckbox)) { plot_graph.label_points = labelPointsCheckbox.getState(); options_hash_table.put("Label Points",(String) (new Boolean(plot_graph.label_points)).toString()); String opt_name = optChoice.getSelectedItem(); if(opt_name.equals("Label Points")) { optTextField.setText((String) (new Boolean(plot_graph.label_points)).toString()); } repaint_needed = true; return; } if(evt.getSource() == (keyCheckbox)) { plot_graph.show_key = keyCheckbox.getState(); repaint_needed = true; return; } if(evt.getSource() == (saveButton)) { SaveText(); return; } if(evt.getSource() == (browseButton)) { OpenText(); return; } if(evt.getSource() == (loadButton)) { String temp = urlTextField.getText(); if(null != temp) { if(temp.length() > 0) { m_url = temp; load_url_needed = true; } } return; } if(evt.getSource() == (optTextField)) { modifyCurrentOptionValue(); return; } if(evt.getSource() == (optPlotShowCheckbox)) { current_plot_name = optPlotsList.getSelectedItem(); current_pd = GetPlot(current_plot_name); if(null == current_pd) { return; } if(null == current_pd.show) { current_pd.show = new boolean[max_dplotter_num+1]; } if(current_pd.show.length < dplotter_num) { boolean new_show[] = new boolean[max_dplotter_num+1]; for(int i = 0; i < current_pd.show.length; i++) { new_show[i] = current_pd.show[i]; } for(int i = current_pd.show.length; i < max_dplotter_num+1; i++) { new_show[i] = true; } current_pd.show = new_show; } current_pd.show[dplotter_num] = optPlotShowCheckbox.getState(); return; } if(evt.getSource() == (optPlotDeleteButton)) { current_plot_name = optPlotsList.getSelectedItem(); RemovePlot(current_plot_name); ResetOptPlotsList(); return; } if(evt.getSource() == (optPlotClearButton)) { current_plot_name = optPlotsList.getSelectedItem(); PlotData pdata = GetPlot(current_plot_name); if(null != pdata) { if(null != pdata.v) { pdata.v.removeAllElements(); } } return; } if(evt.getSource() == (zoom_in_button)) { ZoomIn(); return; } if(evt.getSource() == (zoom_out_button)) { ZoomOut(); return; } } catch(Exception e) { e.printStackTrace(); } } public void ZoomOut() { int current_horz_scroll_value = horz_scroll_bar.getValue(); int current_vert_scroll_value = vert_scroll_bar.getValue(); if(current_horz_scroll_value < 0) { current_horz_scroll_value = 0; } if(current_vert_scroll_value < 0) { current_vert_scroll_value = 0; } if(just_zoomed_to_max) { double x_diff = m_max_x - m_min_x; m_min_x -= x_diff/2; m_max_x += x_diff/2; double y_diff = m_max_y - m_min_y; m_min_y -= y_diff/2; m_max_y += y_diff/2; } if(m_scroll_width/2 < plot_graph.m_width) { current_horz_scroll_value = 0; m_scroll_width = plot_graph.m_width; } else { m_scroll_width = m_scroll_width/2; current_horz_scroll_value = (current_horz_scroll_value/2)-(plot_graph.m_width/4); if(current_horz_scroll_value < 0) { current_horz_scroll_value = (current_horz_scroll_value/2); } } if(m_scroll_height/2 < plot_graph.m_height) { current_vert_scroll_value = 0; m_scroll_height = plot_graph.m_height; } else { current_vert_scroll_value = (current_vert_scroll_value/2)-(plot_graph.m_height/4); if(current_vert_scroll_value < 0) { current_vert_scroll_value = (current_vert_scroll_value/2); } m_scroll_height = m_scroll_height/2; } plot_graph.changeScale(m_min_x,m_max_x,m_scroll_width,m_min_y, m_max_y, m_scroll_height); options_hash_table.put("Minimum Y",(String) (new Double(m_min_y)).toString()); options_hash_table.put("Maximum Y",(String) (new Double(m_max_y)).toString()); if(current_horz_scroll_value < 0) { current_horz_scroll_value = 0; } horz_scroll_bar.setValues(current_horz_scroll_value ,plot_graph.m_width, 0, m_scroll_width); horz_scroll_bar.setUnitIncrement(plot_graph.m_width/4); horz_scroll_bar.setBlockIncrement(plot_graph.m_width/2); plot_graph.m_scroll_x = current_horz_scroll_value; if(current_vert_scroll_value < 0) { current_vert_scroll_value = 0; } vert_scroll_bar.setValues(current_vert_scroll_value ,plot_graph.m_height, 0, m_scroll_height); vert_scroll_bar.setUnitIncrement(plot_graph.m_height/4); vert_scroll_bar.setBlockIncrement(plot_graph.m_height/2); plot_graph.m_scroll_y = current_vert_scroll_value; even_zooms = !even_zooms; if(m_scroll_height == plot_graph.m_height && m_scroll_width == plot_graph.m_width) { just_zoomed_to_max = true; } last_user_set_x_scale = plot_graph.x_scale; if(coordinate_type == POLAR_COORD_TYPE) { equalizeAxis(); } } public void UpdateScale() { just_zoomed_to_max = false; update_scale_needed = false; int current_horz_scroll_value = horz_scroll_bar.getValue(); int current_vert_scroll_value = vert_scroll_bar.getValue(); if(current_horz_scroll_value < 0) { current_horz_scroll_value = 0; } if(current_vert_scroll_value < 0) { current_vert_scroll_value = 0; } if(max_x_is_newest) { if((plot_graph.x_max - plot_graph.x_min)> 0 && (m_max_x - m_min_x) > (plot_graph.x_max - plot_graph.x_min)) { m_scroll_width = ((int) (((double)(m_max_x - m_min_x))*last_user_set_x_scale)); } current_horz_scroll_value = m_scroll_width - plot_graph.m_width; } else if(min_x_is_newest) { if((plot_graph.x_max - plot_graph.x_min)> 0 && (m_max_x - m_min_x) > (plot_graph.x_max - plot_graph.x_min)) { m_scroll_width = ((int) (((double)(m_max_x - m_min_x))*last_user_set_x_scale)); } current_horz_scroll_value = 0; } if(max_y_is_newest) { if((plot_graph.y_max - plot_graph.y_min)> 0 && (m_max_y - m_min_y) > (plot_graph.y_max - plot_graph.y_min)) { m_max_y += (m_max_y - m_min_y)*0.05; m_scroll_height = plot_graph.m_height; } current_vert_scroll_value = 0; } else if(min_y_is_newest) { if((plot_graph.y_max - plot_graph.y_min)> 0 && (m_max_y - m_min_y) > (plot_graph.y_max - plot_graph.y_min)) { m_min_y -= (m_max_y - m_min_y)*0.05; m_scroll_height = plot_graph.m_height; } current_vert_scroll_value = m_scroll_height - plot_graph.m_height; } plot_graph.changeScale(m_min_x,m_max_x,m_scroll_width,m_min_y, m_max_y, m_scroll_height); options_hash_table.put("Minimum Y",(String) (new Double(m_min_y)).toString()); options_hash_table.put("Maximum Y",(String) (new Double(m_max_y)).toString()); if(current_horz_scroll_value < 0) { current_horz_scroll_value = 0; } horz_scroll_bar.setValues(current_horz_scroll_value ,plot_graph.m_width, 0, m_scroll_width ); horz_scroll_bar.setUnitIncrement(plot_graph.m_width/4); horz_scroll_bar.setBlockIncrement(plot_graph.m_width/2); plot_graph.m_scroll_x = current_horz_scroll_value; if(current_vert_scroll_value < 0) { current_vert_scroll_value = 0; } vert_scroll_bar.setValues(current_vert_scroll_value ,plot_graph.m_height, 0, m_scroll_height ); vert_scroll_bar.setUnitIncrement(plot_graph.m_height/4); vert_scroll_bar.setBlockIncrement(plot_graph.m_height/2); plot_graph.m_scroll_y = current_vert_scroll_value; max_x_is_newest = false; min_x_is_newest = false; max_y_is_newest = false; min_y_is_newest = false; if(coordinate_type == POLAR_COORD_TYPE) { equalizeAxis(); } } public void ZoomIn() { int current_horz_scroll_value = horz_scroll_bar.getValue(); int current_vert_scroll_value = vert_scroll_bar.getValue(); just_zoomed_to_max = false; m_scroll_width = m_scroll_width*2; if(even_zooms) { current_horz_scroll_value = current_horz_scroll_value*2+(plot_graph.m_width/2) +(plot_graph.m_width%2); current_vert_scroll_value = current_vert_scroll_value*2+(plot_graph.m_height/2)+(plot_graph.m_height%2); } else { current_horz_scroll_value = current_horz_scroll_value*2+(plot_graph.m_width/2) ; current_vert_scroll_value = current_vert_scroll_value*2+(plot_graph.m_height/2); } even_zooms = !even_zooms; m_scroll_height = m_scroll_height*2; plot_graph.changeScale(m_min_x,m_max_x,m_scroll_width,m_min_y, m_max_y, m_scroll_height); options_hash_table.put("Minimum Y",(String) (new Double(m_min_y)).toString()); options_hash_table.put("Maximum Y",(String) (new Double(m_max_y)).toString()); if(current_horz_scroll_value < 0) { current_horz_scroll_value = 0; } horz_scroll_bar.setValues(current_horz_scroll_value ,plot_graph.m_width, 0, m_scroll_width ); horz_scroll_bar.setUnitIncrement(plot_graph.m_width/4); horz_scroll_bar.setBlockIncrement(plot_graph.m_width/2); plot_graph.m_scroll_x = current_horz_scroll_value; if(current_vert_scroll_value < 0) { current_vert_scroll_value = 0; } vert_scroll_bar.setValues(current_vert_scroll_value ,plot_graph.m_height, 0, m_scroll_height ); vert_scroll_bar.setUnitIncrement(plot_graph.m_height/4); vert_scroll_bar.setBlockIncrement(plot_graph.m_height/2); plot_graph.m_scroll_y = current_vert_scroll_value; last_user_set_x_scale = plot_graph.x_scale; if(coordinate_type == POLAR_COORD_TYPE) { equalizeAxis(); } } // Place additional applet clean up code here. destroy() is called when // when you applet is terminating and being unloaded. //------------------------------------------------------------------------- public void destroy() { // TODO: Place applet cleanup code here } long repaint_millis = 0; // plotter Paint Handler //-------------------------------------------------------------------------- public void paint(Graphics g) { // TODO: Place applet paint code here repaint_needed = false; if(!continous_update) { repaint_millis = System.currentTimeMillis(); } repaint_count--; } // The start() method is called when the page containing the applet // first appears on the screen. The AppletWizard's initial implementation // of this method starts execution of the applet's thread. //-------------------------------------------------------------------------- public void start() { if(load_params_on_start) { GetAllParameters(); } if(reload_url_on_start) { UpdateOptionsHashtable(); if(m_url != null) { if(m_url.length() > 0 ) { if(! m_url.equals(last_url_loaded)) { load_url_needed = true; } urlTextField.setText(m_url); } } } just_zoomed_to_max = false; if (m_plotter == null) { m_plotter = new Thread(this); m_plotter.start(); } continous_update = true; // TODO: Place additional applet start code here } // The stop() method is called when the page containing the applet is // no longer on the screen. The AppletWizard's initial implementation of // this method stops execution of the applet's thread. //-------------------------------------------------------------------------- public void stop() { continous_update = false; if (m_plotter != null) { m_plotter.stop(); m_plotter = null; } // TODO: Place additional applet stop code here } public void UpdateDisplay() { try { if(null != plot_graph && null != horz_scroll_bar && null != vert_scroll_bar) { int temp = horz_scroll_bar.getValue(); if(temp > 0) { plot_graph.m_scroll_x = temp; } temp = vert_scroll_bar.getValue(); if(temp > 0) { plot_graph.m_scroll_y = temp; } plot_graph.UpdateDisplay(repaint_needed); } if(null != optPlotsList) { if(optPlotsList.count != optPlotsListCount) { optPlotsListCount = optPlotsList.count; repaint_needed = true; current_plot_name = optPlotsList.getSelectedItem(); current_pd = GetPlot(current_plot_name); if(null == current_pd) { return; } if(null != current_pd.show) { if(current_pd.show.length >= dplotter_num && null != optPlotShowCheckbox) { optPlotShowCheckbox.setState(current_pd.show[dplotter_num]); } } } } if(load_url_needed) { LoadURL(m_url); } if(update_scale_needed) { UpdateScale(); } } catch(Exception e) { e.printStackTrace(); } if(repaint_needed) { repaint(600); } } // THREAD SUPPORT // The run() method is called when the applet's thread is started. If // your applet performs any ongoing activities without waiting for user // input, the code for implementing that behavior typically goes here. For // example, for an applet that performs animation, the run() method controls // the display of images. //-------------------------------------------------------------------------- public void run() { System.out.println(getAppletInfo()); /* PlotData sine_plot = new PlotData(); AddPlot(sine_plot,"SINE"); double angle = -Math.PI; while(angle < Math.PI) { angle += 0.01; double sine = Math.sin(angle); AddPointToPlot(sine_plot,angle,sine,true); } plot_graph.changeScale(-4,4,m_scroll_width,-1.5,1.5,m_scroll_height); horz_scroll_bar.setValue(m_scroll_width/2); */ continous_update = true; while (true) { try { UpdateDisplay(); if(repaint_count > 0) { repaint(); } // TODO: Add additional thread-specific code here Thread.sleep(600); } catch (InterruptedException e) { // TODO: Place exception-handling code here in case an // InterruptedException is thrown by Thread.sleep(), // meaning that another thread has interrupted this one e.printStackTrace(); stop(); } } } public void equalizeAxis() { int current_horz_scroll_value = horz_scroll_bar.getValue(); int current_vert_scroll_value = vert_scroll_bar.getValue(); if(null != plot_graph) { int orig_scroll_width = plot_graph.scroll_width; int orig_scroll_height = plot_graph.scroll_height; plot_graph.equalizeAxis(); if(plot_graph.scroll_width > orig_scroll_width) { int factor = plot_graph.scroll_width/orig_scroll_width; current_horz_scroll_value = current_horz_scroll_value*factor+(plot_graph.m_width/2) +(plot_graph.m_width%2); if(current_horz_scroll_value < 0) { current_horz_scroll_value = 0; } m_scroll_width *= factor; horz_scroll_bar.setValues(current_horz_scroll_value ,plot_graph.m_width, 0, m_scroll_width ); horz_scroll_bar.setUnitIncrement(plot_graph.m_width/4); horz_scroll_bar.setBlockIncrement(plot_graph.m_width/2); plot_graph.m_scroll_x = current_horz_scroll_value; } else if(plot_graph.scroll_width < orig_scroll_width) { int factor = orig_scroll_width/plot_graph.scroll_width; current_horz_scroll_value = current_horz_scroll_value/factor+(plot_graph.m_width/2) +(plot_graph.m_width%2); if(current_horz_scroll_value < 0) { current_horz_scroll_value = 0; } m_scroll_width /= factor; horz_scroll_bar.setValues(current_horz_scroll_value ,plot_graph.m_width, 0, m_scroll_width ); horz_scroll_bar.setUnitIncrement(plot_graph.m_width/4); horz_scroll_bar.setBlockIncrement(plot_graph.m_width/2); plot_graph.m_scroll_x = current_horz_scroll_value; } if(plot_graph.scroll_height > orig_scroll_height) { int factor = plot_graph.scroll_height/orig_scroll_height; current_vert_scroll_value = current_vert_scroll_value*factor+(plot_graph.m_height/2)+(plot_graph.m_height%2); if(current_vert_scroll_value < 0) { current_vert_scroll_value = 0; } m_scroll_height *= factor; vert_scroll_bar.setValues(current_vert_scroll_value ,plot_graph.m_height, 0, m_scroll_height ); vert_scroll_bar.setUnitIncrement(plot_graph.m_height/4); vert_scroll_bar.setBlockIncrement(plot_graph.m_height/2); plot_graph.m_scroll_y = current_vert_scroll_value; } else if(plot_graph.scroll_height < orig_scroll_height) { int factor = orig_scroll_height/plot_graph.scroll_height; current_vert_scroll_value = current_vert_scroll_value/factor+(plot_graph.m_height/2)+(plot_graph.m_height%2); if(current_vert_scroll_value < 0) { current_vert_scroll_value = 0; } m_scroll_height /= factor; vert_scroll_bar.setValues(current_vert_scroll_value ,plot_graph.m_height, 0, m_scroll_height ); vert_scroll_bar.setUnitIncrement(plot_graph.m_height/4); vert_scroll_bar.setBlockIncrement(plot_graph.m_height/2); plot_graph.m_scroll_y = current_vert_scroll_value; } } } public void itemStateChanged(ItemEvent evt) { try { if(evt.getSource() == (optKeyGraphChoice)) { plot_graph.show_key = false; if(options_modified) { processCurrentOptionValues(); } if(current_panel_name.equals("Text")) { ConvertTextToPlots(); } if(current_panel_name.equals("Options")) { modifyCurrentOptionValue(); } current_panel_name = optKeyGraphChoice.getSelectedItem(); choicePanelLayout.show(choicePanel,current_panel_name); if(current_panel_name.equals("Text") && !TextIsUpToDate) { ConvertPlotsToText(); } if(current_panel_name.equals("Options")) { ResetOptPlotsList(); setCurrentOptionValue(); } if(current_panel_name.equals("Key")) { plot_graph.show_key = true; choicePanelLayout.show(choicePanel,"Graph"); horz_scroll_bar.setValues(0 ,plot_graph.m_width, 0, m_scroll_width); horz_scroll_bar.setUnitIncrement(plot_graph.m_width/4); horz_scroll_bar.setBlockIncrement(plot_graph.m_width/2); vert_scroll_bar.setValues(0 ,plot_graph.m_height, 0, m_scroll_height); vert_scroll_bar.setUnitIncrement(plot_graph.m_height/4); vert_scroll_bar.setBlockIncrement(plot_graph.m_height/2); plot_graph.m_scroll_x = 0; plot_graph.m_scroll_y = 0; plot_graph.repaint_needed = true; plot_graph.repaint(600); } TextAreaWasModified = false; repaint_needed = true; last_user_set_x_scale = plot_graph.x_scale; return; } } catch(Exception e) { e.printStackTrace(); } } // TODO: Place additional applet code here }