/** * Bandscope Receiver Applet 1.0.0 [MOUSE FREQUENCY PANEL] * @author Robert J Morton YE572246C * @version 13 March 2002, 20 March 2012 * @copyright Robert J Morton (all rights reserved) */ import javax.swing.*; // swing widgets import java.awt.*; // for graphics operations (GUI) class mousefreq extends JPanel { private int W, // width of mouse frequency display panel H, // height of mouse frequency panel I = 5, // text inset from beginning of text area tb; // text base line for panel of height H private String mFs = "--------------MHz"; // mouse pointer frequency private Color bg; // background colour private Font font; // font for the lettering on this panel private scope sc; // reference to the "scope" object private freqspan sp; // reference to the "frequency span" object private centrefreq cf; // reference to the "centre frequency" panel object private smeter sm; // S-Meter display class instance reference mousefreq(bs hf, Color bg, Font font, freqspan sp, // CONSTRUCTOR centrefreq cf, smeter sm, int W, int H) { this.bg = bg; // panel colour this.sp = sp; // frequency span selector instance reference this.cf = cf; // scentre-requency entry field instance reference this.sm = sm; // S-Meter display class instance reference this.W = W; // width of mouse frequency panel this.H = H; // height of mouse frequency panel // get the font to be used on mouse frequency panel and its dimensions this.font = font; FontMetrics fm = getFontMetrics(font); // compute y-coordinate for lettering within a field of depth H tb = fm.getAscent() + (H - fm.getHeight()) / 2; mouseExited(); // see below } // set scope panel class instance reference to local variable void setScope(scope sc) {this.sc = sc;} void scamper(int x) { // EXECUTED EVERY TIME THE MOUSE MOVES // Convert mouse frequency to string with 4 decimal places of MHz. mFs = convert.toMHz(pixTokHz(x), 4) + " MHz"; sm.atualizar(sc.getPlot(x)); // display current S-Meter signal strength repaint(); // shedule a repaint via the event-despatching thread } void mouseExited() { mFs = "-------------- MHz"; // display the blank frequency string sm.atualizar(0); // display the current S-Meter signal strength as zero repaint(); // shedule a repaint via the event-despatching thread } public void paint(Graphics g) { // DISPLAY FREQUENCY AT MOUSE POINTER g.setColor(bg); // set to panel colour g.fillRect(0, 0, W, H); // clear mouse frequency area g.setColor(Color.black); // colour of text g.setFont(font); convert.rightString(g,mFs,W - I,tb); // display the mouse frequency } int pixTokHz(int x) { // convert pixels to half-kHz return cf.getCF() + (x - 100) * sp.getKhzpixel(); } }