/* Copyright 1996 Matthew Freedman and University of Washington mattf@cac.washington.edu This program may be freely used, modified, or redistributed for any non-commercial purpose as long as credit is given. This file contains the DelayControllers class. */ import java.awt.*; /* This class provides and applet for holding the controller devices for Show Animation and Auto Draw. setParams(NinaParams p): Set the interface components to match the parameter values. getParams(NinaParams p): Set the parameter values to macth the interface components. */ public class DelayControllers extends GenericController { DelayController ldelay_ctrl, fdelay_ctrl; public void init() { if (this.size().height > this.size().width) setLayout(new GridLayout(2, 1, 0, 25)); else setLayout(new GridLayout(1, 2, 20, 0)); /* Create the controllers */ add(ldelay_ctrl = new DelayController(this, "Show Animation", "Line Delay (millisecs)", "00")); add(fdelay_ctrl = new DelayController(this, "Auto Draw", "Figure Delay (secs)", "00")); /* Give controllers their proper initial values */ validate(); initted = true; /* If somebody tried to setParams() during initialization, we have to re-do now */ if (params != null) setParams(null); } /* Accept a class full of set parameters, and make the interface match it */ public void setParams(NinaParams p) { boolean force; /* Use values from p unconditionally? */ force = super.preSetParams(p); /* If we have not finished initializing, don't want to do anything */ if (!initted) return; /* Tell the controllers to set themselves to match */ ldelay_ctrl.setValues(force, params.ldelay, params.show_lines); fdelay_ctrl.setValues(force, params.fdelay, params.auto_draw); } /* Fill in the p structure with our current params */ public void getParams(NinaParams p) { /* Line Delay controller */ params.show_lines = ldelay_ctrl.is_set(); params.ldelay = ldelay_ctrl.value(); /* Figure Delay controller */ params.auto_draw = fdelay_ctrl.is_set(); params.fdelay = fdelay_ctrl.value(); } /* Called back by the controllers when a signficant change to the user-interface state has been made. Whether we care and what we do is all special-case, depending on which controller is reporting */ void interfaceChanged(Controller ctrl) { } public Insets insets() { if (this.size().height > this.size().width) return new Insets(20, 5, 20, 5); else return new Insets(0, 20, 0, 20); } }