/** * Bandscope Receiver Applet 1.0.0 [MOUSE FREQUENCY PANEL] * @author Robert J Morton * @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 static final long serialVersionUID = 210L; // what the hell this is for, I don't know! 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 lettering on this panel private scope sc; // reference to "scope" object private freqspan sp; // reference to "frequency span" object private centrefreq cf; // reference to "centre frequency" panel object private smeter sm; // S-Meter display class instance reference mousefreq(bs hf, Color bg, Font font, freqspan sp, centrefreq cf, smeter sm, int W, int H) { this.bg = bg; // set panel colour this.sp = sp; // frequency span selector instance ref this.cf = cf; // centre-frequency 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 this.font = font; // get dimensions of current type face FontMetrics fm = getFontMetrics(font); // y-coordinate for lettering within a field of depth H tb = fm.getAscent() + (H - fm.getHeight()) / 2; mouseExited(); } // 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"; // display the current S-Meter signal strength sm.atualizar(sc.getPlot(x)); // shedule a repaint via the event-despatching thread repaint(); } void mouseExited() { mFs = "-------------- MHz"; // display the blank frequency string sm.atualizar(0); // display 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 mouse frequency } int pixTokHz(int x) { // convert pixels to half-kHz return cf.getCF() + (x - 100) * sp.getKhzpixel(); } }