/*MSTgraph.java copyright claim: Permission is hereby granted to any individual or institution for use, copying, or redistribution of MSTgraph.java code and documentation provided that such code and documentation are not sold for profit and the following copyright notice is retained in the code and documentation. Copyright (c) held by Sunhee Kwon and Dianne Cook All Rights Reserved This code is provided "as is" without any warranty of any kind. We don't warrant, guarantee or make any representations regarding the correctness, reliability, currentness of this code. We welcome your questions and comments, and request that you share any modifications with us. Sunhee Kwon shkwon@iastate.edu Dianne Cook dicook@iastate.edu */ import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; import java.lang.*; import java.text.DecimalFormat; import Data1.*; public class MSTgraph extends Frame // implements AdjustmentListener, ActionListener{ implements AdjustmentListener{ int n_obs; double dn_obs_1; //Button reference_line; int Ticks[]; int sta[], end[]; double distance[][]; double distance1[]; double current_scroll_value, initial_scroll_value; static int graph_count=1; Font font; int x_points[], y_points0[], y_points1[]; int rx_points[], ry_points[]; MMHandler mmHandler = new MMHandler();; boolean under_brush[]; boolean new_under_brush = false; //int starting, ending; Scrollbar Peel_rate; Dimension d; double GraphWth, GraphHgt, xOrigin, yOrigin; double dx, dy, ddy, percent; int DataChoice; MST1 mt; // Ref_Line ref; boolean Ref; public MSTgraph(String Title, int n){ super(Title); setSize(600,400); Panel p = new Panel(); GridBagLayout gbag = new GridBagLayout(); GridBagConstraints gbagcon = new GridBagConstraints(); p.setLayout(gbag); d = this.getSize(); n_obs = n; percent = 0.0; dn_obs_1 = (double)(n-1); GraphWth = (double)d.width * 0.9; GraphHgt = (double)d.height * 0.9; dx = GraphWth/dn_obs_1*0.9; // ddx = dx*(dn_obs_1-1.0); xOrigin = (double)d.width-GraphWth; yOrigin = (double)d.height * 0.95; initial_scroll_value = xOrigin; Peel_rate = new Scrollbar(Scrollbar.HORIZONTAL); Peel_rate.addAdjustmentListener(this); Peel_rate.setUnitIncrement(1); Peel_rate.setValues((int) xOrigin, (int) 1, (int) xOrigin, (int) (xOrigin+(dn_obs_1-1.0)*dx)); // make_partition=new Button("partition"); // reference_line = new Button("reference"); gbagcon.gridx = 0; gbagcon.gridy=0; gbagcon.fill=GridBagConstraints.HORIZONTAL; gbagcon.weighty=1.0; gbagcon.weightx=9.0; gbag.setConstraints(Peel_rate, gbagcon); p.add(Peel_rate); // gbagcon.gridx = 1; gbagcon.gridy=0; // gbagcon.weightx=1.0; // gbagcon.weighty=1.0; // gbag.setConstraints(make_partition,gbagcon); // make_partition.addActionListener(this); // p.add(make_partition); gbagcon.gridx = 1; gbagcon.gridy=0; gbagcon.weightx=1.0; gbagcon.weighty=1.0; // gbag.setConstraints(reference_line,gbagcon); //reference_line.addActionListener(this); //p.add(reference_line); setLayout(new BorderLayout()); add(p, BorderLayout.SOUTH); font = new Font("Courier",Font.BOLD, 13); sta = new int[n_obs]; end = new int[n_obs]; x_points = new int[n_obs-1]; y_points0 = new int[n_obs-1]; y_points1 = new int[n_obs-1]; under_brush = new boolean[n_obs-1]; // Ref = false; } class MMHandler extends MouseMotionAdapter{ public void mouseDragged(MouseEvent evt) { int xx = evt.getX(); int yy = evt.getY(); Graphics g = getGraphics(); repaint(); g.setColor(Color.darkGray); g.drawRect(xx-15,yy-15,15,15); g.dispose(); getBrushedValues(xx-15,yy-15,15,15); } } public void Tree(double pt[][]){ if (DataChoice==0){ mt = new MST1(); mt.Minimal_Spanning_Tree(pt,ViVA.nr,ViVA.nc,sta,end,distance); for(int i=0; ix1 && x_points[i]y1 && y_points0[i] p[i+1]) { holdp = p[i]; holdid = idx[i]; holdb = b[i]; p[i] = p[i+1]; idx[i] = idx[i+1]; b[i] = b[i+1]; p[i+1] = holdp; idx[i+1] = holdid; b[i+1]=holdb;} } void scalePoints(int sta[], int end[], int nminus1, double dist[][], int ii) { int starting, ending; double temp; // ii : To avoid the confusion between the index // systems of MST1.java and other programs double maxdis; starting = sta[0]-ii; ending = end[0]-ii; maxdis = dist[starting][ending]; for (int i=0; i maxdis) maxdis = dist[starting][ending]; } for (int i=0; i