/** * Bandscope Receiver Applet 1.0.0 [FREQUENCY-SPAN SELECTOR] * @author Robert J Morton YE572246C * @version 13 March 2002, 22 March 2012 * @copyright Robert J Morton (all rights reserved) */ import javax.swing.*; // swing widgets import java.awt.*; // for graphics operations (GUI) import java.awt.event.*; // for the new-fangled 1.1 event handling class freqspan { private static final int bandSpans[][] = { // frequency extents (spans) for: {5,3,5,5,6,4,4,5,4,4,5,6,4,4,4,0,0}, // broadcast bands, {6,4,6,6,4,5,4,5,2,2,4,2,0,0}, // amateur bands, {6,4,6,6,4,4,4,6,4,5,6,5,5,5,0,0}, // aircraft bands {3,4,3,3,5,5,3,3,0} // marine bands. }, KP[] = {100,50,20,10,5,2,1}, // twice kilohertz per pixel for each // selectable band span SCH = 130; // height of top of span choice box above bottom of graph private int fs = 0, // currently selected frequency span kp = 100; // half-kilohertz per pixel (frequency scaling) // [the default MUST be non-zero]. private String FR = "50"; // Frequency Resolution of graph in kHz/pixel. private JComboBox SpanBox; // frequency-span selector private JLabel SpanLab; // frequency span label // References to the ... private scope sc; // scope class instance private bands bd; // bandtype and band selector instance private freqfigs ff; // frequency scale figures class instance private ar86000 rx; // receiver class instance private listeningon lo; // "listening on" panel instance freqspan(Container cp, int GL, int GB, int h) { /* Create and fill the graph's frequency span choice box (located above the graph) then add it to the applet pane, set its position and size on the applet panel and create a listener to listen for selection events emanating from this object. */ SpanBox = new JComboBox(); SpanBox.addItem("10 MHz"); SpanBox.addItem("5 MHz"); SpanBox.addItem("2 MHz"); SpanBox.addItem("1 MHz"); SpanBox.addItem("500 kHz"); SpanBox.addItem("200 kHz"); SpanBox.addItem("100 kHz"); cp.add(SpanBox); SpanBox.setBounds(GL + 50, GB - SCH, 100, h); SpanBox.addItemListener(new spchl(spchl.SPAN, this)); /* Create the span label object, add it to the applet pane then set its position and size within the applet panel. */ SpanLab = new JLabel("50 kHz/pixel"); cp.add(SpanLab); SpanLab.setBounds(GL + 155,GB - 135,100,15); } void setScope(scope sc) {this.sc = sc;} void setBands(bands bd) {this.bd = bd;} void setFreqFigs(freqfigs ff) {this.ff = ff;} void setAR86000(ar86000 rx) {this.rx = rx;} void setLo(listeningon lo) {this.lo = lo;} /* DONE WHEN A NEW BANDSCOPE FREQUENCY SPAN IS SELECTED: Get the index number of the frequency-span that has just been selected and show the corresponding number of kHz per pixel etc. */ void selSpan() { fs = SpanBox.getSelectedIndex(); selSpan2(); } // ALLOWS THE BAND-SELECTOR TO SET THE FREQUENCY SPAN FOR THE SELECTED BAND void setSpan(int sbt, int sb) { fs = bandSpans[sbt][sb]; // get frequency span for this band SpanBox.setSelectedIndex(fs); // set the appropriate span choice selSpan2(); // set new frequency span } // SHOW THE kHz PER PIXEL LABEL + THE SET FREQUENCY SCALE FIGURES private void selSpan2() { kp = KP[fs]; // half-kHz per pixel for selected range /* If 100 kHz span is selected, set straight to half kHz/pixel; else, for all other spans, get the integral resolution in kHz/pixel and, if the 500 kHz span is selected, add the extra half sign for the 2.5 kHz/pixel. */ if(fs == 6) FR = "½"; else { FR = "" + (kp >> 1); if(fs == 4) FR += "½"; } lo.setReceiving(false); // kill receiving // compute the signal level plots for the new frequency span rx.computePlots(); SpanLab.setText(FR + " kHz/pixel"); // display the requency span label // display the appropriate figures on the frequency scale ff.atualizar(); sc.atualizar(); } int getFreqSpan() {return fs;} // called by "freqfigs" and "ar86000" int getKhzpixel() {return kp;} // called by "mouse" and "scope" } // LISTENS FOR EVENTS FROM THE CHOICE MENU SELECTORS class spchl implements ItemListener { //an event from the 'bandscope frequency span selector' choice menu static final int SPAN = 0; int id; // one of the above events freqspan ap; // the application that called: always the above applet! /* Constructor for a new Choice selection event: set the 'id' number pertaining to this instance of 'cl', set the reference to the instance of the 'bs' applet, from which it came. (there is only one instance). */ public spchl(int id, freqspan ap) { this.id = id; this.ap = ap; } /* A Choice selection event has occurred from checkbox 'id' so execute the method in the above applet which deals with this choice. */ public void itemStateChanged(ItemEvent e) { switch(id) { case SPAN: ap.selSpan(); break; } } }