/** * Bandscope Receiver Applet 1.0.0 [FREQUENCY-SPAN SELECTOR] * @author Robert J Morton * @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) fo {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 }, // twice kilohertz per pixel for each selectable band span KP[] = {100,50,20,10,5,2,1}, 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) [default MUST be non-zero] */ private String FR = "50"; // Frequency Resolution of graph in kHz per pixel. private JComboBox SpanBox; // frequency-span selector private JLabel SpanLab; // frequency span label private scope sc; // reference to the scope class instance private bands bd; // ref to bandtype and band selector instance private freqfigs ff; // ref to frequency scale figures class instance private ar86000 rx; // reference to receiver class instance private listeningon lo; // reference to the "listening on" panel instance freqspan(Container cp, int GL, int GB, int h) { // graph's frequency span choice box (located above the graph) 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); // Set its size and position on application program's main JPanel SpanBox.setBounds(GL+50,GB-SCH,100,h); // set up a listener to listen for events on this checkbox group SpanBox.addItemListener(new spchl(spchl.SPAN, this)); 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 void selSpan() { // get index number of frequency-span that's just been selected fs = SpanBox.getSelectedIndex(); selSpan2(); // show the corresponding kHz per pixel etc. } // ALLOWS BAND-SELECTOR TO SET THE FREQUENCY SPAN FOR 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 + SET FREQUENCY SCALE FIGURES private void selSpan2() { kp = KP[fs]; // half-kHz per pixel for selected range if(fs == 6) // if 100 kHz span is selected FR = "½"; // set straight to half kHz/pixel else { // for all other spans FR = "" + (kp >> 1); // get the integral resolution in kHz/pixel if(fs == 4) // and if the 500 kHz span is selected FR += "½"; // add the extra half sign for the 2.5 kHz/pixel } lo.setReceiving(false); // kill receiving rx.computePlots(); // do signal level plots for new frequency span SpanLab.setText(FR + " kHz/pixel"); ff.atualizar(); // display appropriate figures on freq scale 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 'bandscope 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: public spchl(int id, freqspan ap) { /* Set the id number pertaining to this instance of 'cl', then set the reference to the instance of the 'bs' app from which it came. (there will only ever be one instance anyway). */ this.id = id; this.ap = ap; } /* A Choice selection event has occurred from checkbox 'id', so exe- cute the method in the above applet which deals with this choice. */ public void itemStateChanged(ItemEvent e) { switch(id) {case SPAN: ap.selSpan(); break;} } }