/** * HF Receiver Controller Applet 1.0.0 * @author Robert J Morton YE572246C * @version 25 November 2001, revanped 16 November 2007, Swing Version 31 January 2012 * @copyright Robert J Morton (all rights reserved) */ /* This is the Applet's background image panel */ import javax.swing.*; // the Swing GUI system import java.awt.*; // abstract windiwing toolkit public class worldmap extends JPanel { private static final String //S-meter scale S[] = {" 0",""," 2",""," 4",""," 6",""," 8","","10","","12"}; private static final Font // Fonts for Choice menus and buttons font1 = new Font("Serif",Font.BOLD,14), font2 = new Font("Serif",Font.PLAIN,12); private Image img; // reference to the applet's background image private Color bg4 = new Color(180, 180, 180); // graticule colour private int GC, // graph centre GR, // graph right GB, // graph base GL, // graph left GT, // graph top SL = S.length, // length of the S[] String array // x-coordinates of ... X1, // left side of S-Meter scale graduation mark X2, // right side of S-Meter scale graduation mark X3, // the figures of the S-Meter scale X4, // right side of extended bottom line of S-Meter graduations X6, // S-METER title X7, // span-selector end of left half of arrow X8, // span-selector end of right half of arrow X9, // xleft arrow head X0, // the right arrow head /* extremities of frequency graduation marks just below bottom of scope screen ... */ Y1, // upper Y2, // lower Y3, // y-coordinate of frequency span arrows Y4, // left head of frequency span arrow Y5, // right head of frequency span arrow Y6, // y-coordinate of S-METER title // y-coordinate of ... Y7, // top of centre-line just above the centre frequency field Y8, // bottom of centre-line just above the centre frequency field I, // frequency scale graduation loop limit dy; // y-offset of baseline of S-Meter figures from graduation marks worldmap(Image i,int GL,int GB,int GT,int GW,int SX) { img = i; this.GL = GL; this.GB = GB; this.GT = GT; // x-coordinate of the ... GR = GL + GW; // Graph Right (right side of the graph area) GC = GL + GW / 2; // Graph Centre (centre of the graph area) // Frequency graduation marks just below bottom of scope screen Y1 = GB + 5; // upper extremity of Y2 = GB + 10; // lower extremity of Y3 = GT - 20; // y-coordinate of frequency span arrows Y4 = Y3 + 3; // arrow head indicating frequency span Y5 = Y3 - 3; // arrow head indicating frequency span Y6 = GT - 15; // y-coordinate of S-METER title // centre-line just above the centre frequency field Y7 = GB + 25; // y-coordinate of its top Y8 = GB + 40; // y-coordinate of its bottom // x-coordinate of ... X1 = SX - 6; // left side of S-Meter scale graduation mark X2 = SX - 12; // right side of S-Meter scale graduation mark X3 = SX - 22; // the figures of the S-Meter scale X4 = SX + 19; /* right side of the extended bottom line of the S-Meter graduations. */ X6 = SX - 4; // S-METER title X7 = GC - 52; // span-selector end of left half of arrow X8 = GC + 51; // span-selector end of right half of arrow X9 = GL + 5; // left arrow head X0 = GR - 5; // right arrow head I = GL + 210; // frequency scale graduation loop limit dy = (getFontMetrics(font2).getAscent() >> 1) - 2; } public void paint(Graphics g) { // draw the background image onto the applet canvas g.drawImage(img, 0, 0, this); // FREQUENCY SCALE MARKS JUST BELOW BOTTOM OF SCOPE SCREEN g.setColor(Color.black); // for each frequency graduation draw frequency graduation marks for(int i = GL; i < I; i += 20) g.drawLine(i, Y1, i, Y2); g.drawLine(GL, Y1, GR, Y1); // horizontal axis (frequency) g.drawLine(GC, Y7, GC, Y8); /* centre-line just above the centre frequency field */ g.drawLine(GL, Y3, X7, Y3); // horizontal left-hand span arrow g.drawLine(GL, Y3, X9, Y5); g.drawLine(GL, Y3, X9, Y4); g.drawLine(X8, Y3, GR, Y3); // horizontal right-hand span arrow g.drawLine(X0, Y5, GR, Y3); g.drawLine(X0, Y4, GR, Y3); g.setFont(font1); convert.centreString(g, "S-Meter", X6, Y6); // print S-METER title int y = GB; g.setFont(font2); /* For each S-unit graduation, draw the S-meter figure and its graduation mark, then move up 8 pixels ready for the next one. */ for(int i = 0; i < SL; i++) { convert.centreString(g, S[i], X3, y + dy); g.drawLine(X1, y, X2, y); y -= 8; } g.drawLine(X1, GB, X4, GB); // draw extended bottom graduation mark g.setColor(bg4); g.drawLine(GR, GT, GR, GB); // border line at the right of the graph g.drawLine(GL, GB, GR, GB); // border line at the right of the graph } }