/* * [Aerial.java] * * Summary: draw dual dipole FM antenna. * * Copyright: (c) 2013-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2013-02-07 initial version. */ package com.mindprod.connectors; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Polygon; import static java.lang.System.*; /** * draw dual dipole FM antenna. *

* see http://www.wikihow.com/Make-an-FM-Antenna * * @author Roedy Green, Canadian Mind Products * @version 1.0 2013-02-07 initial version * @since 2013-02-07 */ class Aerial extends ConnectorPanel { private static final boolean DEBUGGING = false; /** * horizontal unstripped part */ private static final int ANTENNA_LENGTH = 800; /** * verticaL unstripped part */ private static final int FEED_LENGTH = 380; /** * length of stripped leads of cable */ private static final int LEAD_LENGTH = 50; /** * width of cable */ private static final int PAIR_WIDTH = 30; /** * width of wire */ private static final int WIRE_WIDTH = 4; private static final int xac; private static final int xae; private static final int xaez; private static final int xaw; private static final int xawz; private static final int xfc; private static final int xfe; private static final int xfw; private static final int yac; private static final int yan; private static final int yas; private static final int yfc; private static final int yfn; private static final int yfnz; private static final int yfs; private static final int yfsz; /** * horizontal unstriped part */ private static final Color ANTENNA_COLOR = new Color( 0x000030 ); // very dark blue /** * verticaL unstripped part */ private static final Color BACKGROUND = Color.WHITE; /** * verticaL unstripped part */ private static final Color FEED_COLOR = new Color( 0x003000 ); // very dark green /** * wire colour */ private static final Color WIRE_COLOR = new Color( 0xd9987c ); // copper static { xac = 500; xae = xac + ANTENNA_LENGTH / 2; xaez = xae + LEAD_LENGTH; xaw = xac - ANTENNA_LENGTH / 2; xawz = xaw - LEAD_LENGTH; xfc = 500; xfe = xfc + PAIR_WIDTH / 2; xfw = xfc - PAIR_WIDTH / 2; yac = 400; yan = yac - PAIR_WIDTH / 2; yas = yac + PAIR_WIDTH / 2; yfc = 653; yfn = yfc - FEED_LENGTH / 2; yfnz = yfn - LEAD_LENGTH; yfs = yfc + FEED_LENGTH / 2; yfsz = yfs + LEAD_LENGTH; } Aerial() { super( 1000, 1000 ); } /** * draw a VGA male connector * * @param g where to paint */ public void paintComponent( Graphics g ) { if ( DEBUGGING ) { out.println( "xa " + xawz + " " + xaw + " " + xac + " " + xae + " " + xaez ); out.println( "ya " + yan + " " + yac + " " + yas ); out.println( "xf " + xfw + " " + xfc + " " + xfe ); out.println( "yf " + yfnz + " " + yfn + " " + yfc + " " + yfs + " " + yfsz ); } super.paintComponent( g ); final Graphics2D g2d = ( Graphics2D ) g; g2d.setColor( BACKGROUND ); g2d.fillRect( 0, 0, 1000, 1000 ); g2d.setColor( WIRE_COLOR ); g2d.setStroke( new BasicStroke( WIRE_WIDTH ) ); Polygon copper = new Polygon(); // start in bottom right corner cand work counter clockwise copper.addPoint( xfe, yfsz ); copper.addPoint( xfe, yfnz ); copper.addPoint( xaez, yas ); copper.addPoint( xaez, yas ); copper.addPoint( xaez + PAIR_WIDTH / 2, yac ); copper.addPoint( xaez, yan ); copper.addPoint( xawz, yan ); copper.addPoint( xawz - PAIR_WIDTH / 2, yac ); copper.addPoint( xawz, yas ); copper.addPoint( xfw, yfnz ); copper.addPoint( xfw, yfsz ); g2d.draw( copper ); // antenna insulation g2d.setColor( ANTENNA_COLOR ); g2d.setStroke( new BasicStroke( 1 ) ); g2d.fillRect( xaw - 1, yan - 2, ANTENNA_LENGTH, PAIR_WIDTH + WIRE_WIDTH ); // notch left end g2d.setColor( BACKGROUND ); g2d.fillRect( xaw - 1, yan + WIRE_WIDTH - 1, LEAD_LENGTH, PAIR_WIDTH - WIRE_WIDTH - 1 ); // notch right end g2d.fillRect( xae - 1 - LEAD_LENGTH + 1, yan - 1 + WIRE_WIDTH, LEAD_LENGTH, PAIR_WIDTH - WIRE_WIDTH - 1 ); // outer middle notch g2d.fillRect( xac - LEAD_LENGTH * 2, yan - 1 + WIRE_WIDTH, LEAD_LENGTH * 4, PAIR_WIDTH - WIRE_WIDTH - 1 ); // inner middle notch g2d.fillRect( xac - LEAD_LENGTH, yan - 1 + WIRE_WIDTH, LEAD_LENGTH * 2, PAIR_WIDTH - WIRE_WIDTH + 3 ); // label g2d.setFont( new Font( "Dialog", Font.PLAIN, 40 ) ); g2d.setColor( Color.BLACK ); drawCenteredString( g2d, "antenna", xac, yac - 100 ); // feed insulation g2d.setColor( FEED_COLOR ); g2d.fillRect( xfw - 1, yfn, PAIR_WIDTH + WIRE_WIDTH, FEED_LENGTH ); // notch top end g2d.setColor( BACKGROUND ); g2d.fillRect( xfw + WIRE_WIDTH - 1, yfsz, PAIR_WIDTH - WIRE_WIDTH, LEAD_LENGTH ); // notch bottom end g2d.fillRect( xfw + WIRE_WIDTH, yfs + 1, PAIR_WIDTH - WIRE_WIDTH, LEAD_LENGTH + 2 ); // label g2d.setFont( new Font( "Dialog", Font.PLAIN, 40 ) ); g2d.setColor( Color.BLACK ); drawCenteredString( g2d, "feed", 600, 750 ); // repair damage to antenna where feed joins g2d.setStroke( new BasicStroke( WIRE_WIDTH ) ); g2d.setColor( BACKGROUND ); g2d.drawLine( xfw, yas - 1, xfe, yas - 1 ); g2d.setColor( WIRE_COLOR ); g2d.drawLine( xfc - LEAD_LENGTH, yas, xfw, yas ); g2d.drawLine( xfe, yas, xfc + LEAD_LENGTH, yas ); } }