package caida.otter; import java.awt.*; /***************************************************************************** * File: StepByStep.java Class: StepByStep * Goal: To provide a method for showing hierarchy level step by step. * * For: Cooperative Association for Internet Data Analysis ****************************************************************************** ****************************************************************************** * By accessing this software, STEPBYSTEP, you are duly informed of * and agree to be bound by the conditions described below in * this notice: * * This software product, STEPBYSTEP, is developed by Bradley Huffaker, and * copyrighted(C) 1998 by the University of California, San Diego (UCSD), * with all rights reserved. UCSD administers the NSF grant to CAIDA, * number NCR-9711092, under which this code was developed. * * STEPBYSTEP is a free software. You can redistribute it and/or modify it * under the terms of the GNU Public License v.2 as * published by UCSD and is incorporated by reference herein. STEPBYSTEP is * distributed WITHOUT ANY WARRANTY, IMPLIED OR EXPRESS, OF MERCHANTABILITY * OR FITNESS FOR A PARTICULAR PURPOSE or that the use of it will not * infringe on any third party's intellectual property rights. * * You should have received a copy of the CAIDA General Public * License v.1 along with the STEPBYSTEP program. If for any reason you * have not received a copy, please write to * * University of California, San Diego * SDSC/CAIDA * 9500 Gilman Dr., MS-0505 * La Jolla, CA 92093 - 0505 USA * * Or contact INFO@CAIDA.ORG *****************************************************************************/ public class StepByStep extends Frame { // The display that contains the nodes to highlight Display display; // The controlling buttons TextField Step; final int DEFAULT_STEP = 0; Button SetStep; Button Next; Button Back; Button Cancel; int current_step; public StepByStep(Display display_input) { super("Step by Step"); current_step = 1; display = display_input; SetStep = new Button("Set Step"); Next = new Button("Next"); Back = new Button("Back"); Step = new TextField(); current_step = -1; Cancel = new Button("Cancel"); Label top_label = new Label("Will show the hierarchy level by level"); //Label middle_label= new Label("level by level"); Panel middle_panel = new Panel(); middle_panel.setLayout(new BorderLayout()); Label middle_label= new Label("Level"); middle_panel.add("West",middle_label); middle_panel.add("Center",Step); Panel bottom_panel = new Panel(); //bottom_panel.setLayout(new BorderLayout()); bottom_panel.setLayout(new FlowLayout()); bottom_panel.add(SetStep); bottom_panel.add(Back); bottom_panel.add(Next); bottom_panel.add(Cancel); add("North", top_label); add("Center", middle_panel); add("South",bottom_panel); pack(); } public void show() { setStep(DEFAULT_STEP); super.show(); } public void hide() { current_step = -1; display.stepBystep(false); display.printMessage(""); display.setMode(display.MOVE); super.hide(); } public boolean handleEvent(Event event) { if (event.id == Event.ACTION_EVENT) { if (event.target == Cancel) this.hide(); else if (event.target == Next) setStep(current_step+1); else if (event.target == Back) setStep(current_step-1); else { int step = 0; try { step = Integer.parseInt(Step.getText()); setStep(step); } catch (NumberFormatException exception) { getToolkit().beep(); Step.setText(String.valueOf(current_step)); System.err.println("StepByStep.Color():" + exception.toString()); } } } return super.handleEvent(event); } void setStep(int step) { if (step != current_step) { Step.setText(String.valueOf(step)); current_step = step; display.stepBystep(step); } } }