// About.java
/* A Java class for
 * LineImpedance.java
 * Electromagnetic Transmission Line Applet
 * Applet without Smith Chart - Prepared by Umberto Ravaioli 
 * for 6th edition of Fundamentals of Applied Electromagnetics Book
 * May 2009 - All Rights Reserved
 */   

import java.io.*;
import java.awt.*;
import java.awt.geom.Arc2D;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;

import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;

public class Instructions extends Panel {
    
    private static final Color bgcolor = new Color(255,255,245);
    
    public TextField epsilon;
    private Paint paint;
    
    private Image im;
    private Graphics buf;
    private BufferedImage figure;  
    public Button bupdate;
    
    public int ydown;
    
    StateVars state;
    
    private BufferedImage square_root;
  
    public Instructions (StateVars state){
	super();
        this.state = state;
	setLayout(null);

	getImages();
	setBackground(bgcolor);
	// update button
	bupdate = new Button("CLOSE");
        bupdate.setBackground(new Color(240,240,255));
        //bupdate.setBackground(Color.white);
	add(bupdate);
        
        ydown = state.s50;
        int buttonx = state.s490;
        int buttony = state.s390+ydown;
        int buttonwide = state.s70;
        int buttonheight = state.s27;
        
        bupdate.setBounds(buttonx,buttony,buttonwide,buttonheight);
        bupdate.setFont(state.ttfFont.deriveFont(Font.BOLD,(float)state.font12));
        
        Panel ps7 = new Panel();
	    ps7.setBackground(Color.lightGray);
	    add(ps7);
	    ps7.setBounds(buttonx-1,buttony-1,buttonwide+2,buttonheight+2);
	    
	Panel ps8 = new Panel();
	    ps8.setBackground(Color.black);
	    add(ps8);
	    ps8.setBounds(buttonx-2,buttony-2,buttonwide+4,buttonheight+4);
    }


    private void getImages() {
        // read in the bullet image, because CHEERPJ does not render this
	//  symbol in any font!  (java to javascript converter)
        try {
            //bullet = ImageIO.read(getClass().getResource("bullet.png"));
	    BufferedImage img =
		ImageIO.read(getClass().getResource("square_root.png"));
	    int targetWidth = (int) (state.sfactor * img.getWidth());
	    int targetHeight = (int) (state.sfactor * img.getHeight());
	    square_root =
		new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_RGB);
	    Graphics2D graphics2D = square_root.createGraphics();
	    graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
					RenderingHints.VALUE_INTERPOLATION_BILINEAR);
	    graphics2D.drawImage(img, 0, 0, targetWidth, targetHeight, 0, 0,
				 img.getWidth(), img.getHeight(), null);
	    graphics2D.dispose();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    public void paint(Graphics g){
            
	    if(im == null){
		im = createImage(getSize().width,getSize().height);
		buf = im.getGraphics();
		drawCanvas(buf);
	    }
	    else{
		drawCanvas(buf);
	    }
	    g.drawImage(im,0,0,null);
    }
	
	//Addition to reduce flicker new routine
    public void update(Graphics g){		// added to avoid clearing
            paint(g);
    }
    
    public void clear(){
	    this.getGraphics().clearRect(0,0,getSize().width,getSize().height);
	    repaint();
    }
    
    public void drawCanvas(Graphics g){
        FontMetrics fm;
        Graphics2D g2d = (Graphics2D)g;
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                             RenderingHints.VALUE_ANTIALIAS_ON);        
        g.clearRect(0,0,getSize().width-1,getSize().height-1);

        boolean saveOldFlag = MaestroG.useBiggerFont;
        MaestroG.useBiggerFont = false;
        
        g.setColor(Color.black);
        g.setFont(state.ttfFont.deriveFont(Font.BOLD,(float)state.font16));

        try {
            figure = ImageIO.read(getClass().getResource("figureb.gif"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        
        g.drawString("Instructions", state.s20,state.s25+ydown);
        g.setColor(Color.red);
        
        g.setFont(state.ttfFont.deriveFont(Font.BOLD,(float)state.font15));
        g.drawString("Input", state.s25,state.s60+ydown);
        g.drawString("Design Procedure", state.s391,state.s30);
        g.setColor(Color.black);
        g.setFont(state.ttfFont.deriveFont((float)state.font14));
        int deltaY = state.s20;
        int starty = state.s30+ydown;
        
        //INPUT
        FontMetrics fmNormal, fmSmall;
        g.setFont(state.ttfFont.deriveFont((float)state.font12));
        fmSmall = g.getFontMetrics();
        g.setFont(state.ttfFont.deriveFont((float)state.font14));
        fmNormal = g.getFontMetrics();
        
        int lineLength = fmNormal.stringWidth("Main Line Parameters (Z and ");
        lineLength += fmSmall.stringWidth("01");
        
        MaestroG.subscripter("Main Line Parameters (Z","01","and",g,state.font14,state.s25,state.s90+ydown);
        MaestroG.subscripter("\u03b5","r1",")",g,state.font14,state.s25+lineLength,state.s90+ydown);
        MaestroG.subscripter("Load Impedance Z","L","",g,state.font14,state.s25,state.s90+ydown+deltaY);
        
        //DESIGN PROCEDURE
        g.drawString("The goal is to select:", state.s391,starty);
        g.drawString("    (a) the distance d from the load at which to insert",
                     state.s391,starty+2*deltaY);
        g.drawString("        the \u03bb/4 transformer.  This is done such that",
                     state.s391,starty+3*deltaY);
        g.drawString("        at d, Z(d) is purely real, which corresponds to ",
                     state.s391,starty+4*deltaY);
        g.drawString("        the locations of voltage maxima and minima: ",
                     state.s391,starty+5*deltaY);
        
        lineLength = fmNormal.stringWidth("        d = dmax and ");
        lineLength += fmSmall.stringWidth("1");
        
        MaestroG.subscripter("        d","1"," = dmax and ",
                             g,state.font14,state.s391,starty+6*deltaY);
        MaestroG.subscripter("d","2"," = dmin (2 solutions)",
                             g,state.font14,state.s391+lineLength,starty+6*deltaY);

        lineLength = fmNormal.stringWidth("    (b) If d = d");
        lineLength += fmSmall.stringWidth("1");
        
        MaestroG.subscripter("    (b) If d = d","1","",
                             g,state.font14,state.s391,starty+8*deltaY);
        g.drawString(" then ",state.s391+lineLength,starty+8*deltaY);
        
        lineLength += fmNormal.stringWidth(" then ");
        g.setFont(state.ttfFont.deriveFont((float)state.font14));
        
        MaestroG.subscripter("Z","02"," = ",
                             g,state.font14,state.s391+lineLength,starty+8*deltaY);
        
        lineLength += fmNormal.stringWidth("Z = ");
        lineLength += fmSmall.stringWidth("02");
        
        //MaestroG.subscripter("\u221AZ","01","Z(",
        //                     g,state.font14,state.s391+lineLength,starty+8*deltaY);
	MaestroG.ImgSubTxtTxt(square_root,"Z","01","Z(",
			      g,state.font14,state.s391+lineLength,starty+8*deltaY,this);
        
        //int xstart = state.s391+lineLength+fmNormal.stringWidth("\u221A");
        //lineLength += fmNormal.stringWidth("\u221AZZ(");
	int xstart = state.s391+lineLength+square_root.getWidth();
	lineLength += square_root.getWidth() + fmNormal.stringWidth("ZZ(");
	
        lineLength += fmSmall.stringWidth("01");
        
        MaestroG.subscripter("d","1",")",g,state.font14,state.s395+lineLength,starty+8*deltaY);

        int xend = xstart + fmNormal.stringWidth("ZZ(d)")+fmSmall.stringWidth("0011");
        
        g.drawLine(xstart-state.s1,starty+8*deltaY - state.s14,xend,starty+8*deltaY - state.s14);

        lineLength = fmNormal.stringWidth("    (c) If d = d");
        lineLength += fmSmall.stringWidth("2");
        
        MaestroG.subscripter("    (c) If d = d","2","",
                             g,state.font14,state.s391,starty+10*deltaY);
        
        g.drawString(" then ",state.s391+lineLength,starty+10*deltaY);
        
        lineLength += fmNormal.stringWidth(" then ");
        g.setFont(state.ttfFont.deriveFont((float)state.font14));
        
        MaestroG.subscripter("Z","02"," = ",
                             g,state.font14,state.s391+lineLength,starty+10*deltaY);
        
        lineLength += fmNormal.stringWidth("Z = ");
        lineLength += fmSmall.stringWidth("02");
        
        //MaestroG.subscripter("\u221AZ","01","Z(",
        //                     g,state.font14,state.s391+lineLength,starty+10*deltaY);
	MaestroG.ImgSubTxtTxt(square_root,"Z","01","Z(",
			      g,state.font14,state.s391+lineLength,starty+10*deltaY,this);

        
        xstart = state.s391+lineLength+fmNormal.stringWidth("\u221A");

        //lineLength += fmNormal.stringWidth("\u221AZZ(");
	lineLength += square_root.getWidth() + fmNormal.stringWidth("ZZ(");
	
        lineLength += fmSmall.stringWidth("01");
        
        MaestroG.subscripter("d","2",")",
                             g,state.font14,state.s395+lineLength,starty+10*deltaY);

        xend = xstart + fmNormal.stringWidth("ZZ(d)")+fmSmall.stringWidth("0012");
        
        g.drawLine(xstart-state.s1,starty+10*deltaY - state.s14,xend,starty+10*deltaY - state.s14);

        //g.drawImage(figure,state.s20,state.s100,this);
        
        // DRAW SCALABLE IMAGE OF THE CIRCUIT
        int y_fig = state.s228+ydown;
        int x_left = state.s30;
        int Length_A = state.s85;
        int Length_B = state.s90;
        int Length_C = state.s100;
        int Length_D = state.s20;
        int height_A = state.s70;
        int height_B = state.s12;
        int height_C = state.s50;
        int load_wx = state.s12;
        int load_wy = state.s20;
        int loadx = x_left + Length_A + Length_B + Length_C + Length_D;
        int loady = y_fig + height_A/2;
        int stem = state.s15;
        
        int Radius = state.s8;
        int Radius1 = state.s8;
        int Radius2 = state.s4;
        
        // Input section Line
        drawLineThick(g,(double)x_left,(double)y_fig,
                (double)(x_left + Length_A),(double)y_fig,state.s2,Color.cyan.darker());
        drawLineThick(g,(double)x_left,(double)(y_fig+height_A),
                (double)(x_left + Length_A),(double)(y_fig+height_A),state.s2,Color.cyan.darker());
        
        // Output section Line
        drawLineThick(g,(double)(x_left + Length_A + Length_B),(double)y_fig,
                (double)(x_left + Length_A + Length_B + Length_C),(double)y_fig,state.s2,Color.cyan.darker());
        drawLineThick(g,(double)(x_left + Length_A + Length_B),(double)(y_fig+height_A),
                (double)(x_left + Length_A + Length_B + Length_C),(double)(y_fig+height_A),state.s2,Color.cyan.darker());
        
        // Transformer section Line
        drawLineThick(g,(double)x_left + Length_A,(double)y_fig,
                (double)(x_left + Length_A),(double)(y_fig + height_B),state.s2,Color.red);
        drawLineThick(g,(double)x_left + Length_A,(double)(y_fig + height_A),
                (double)(x_left + Length_A),(double)(y_fig+height_A-height_B),state.s2,Color.red);
        
        drawLineThick(g,(double)(x_left + Length_A + Length_B),(double)y_fig,
                (double)(x_left + Length_A + Length_B),(double)(y_fig + height_B),state.s2,Color.red);
        drawLineThick(g,(double)(x_left + Length_A + Length_B),(double)(y_fig + height_A),
                (double)(x_left + Length_A + Length_B),(double)(y_fig+height_A-height_B),state.s2,Color.red);
        
        drawLineThick(g,(double)x_left + Length_A,(double)y_fig + height_B,
                (double)(x_left + Length_A + Length_B),(double)y_fig + height_B,state.s2,Color.red);
        drawLineThick(g,(double)x_left + Length_A,(double)(y_fig + height_A - height_B),
                (double)(x_left + Length_A + Length_B),(double)(y_fig+height_A-height_B),state.s2,Color.red);
        
        // Load
        drawLineThick(g,(double)(x_left + Length_A + Length_B + Length_C),(double)y_fig,
                (double)(x_left + Length_A + Length_B + Length_C + Length_D),(double)y_fig,state.s2,Color.black);
        drawLineThick(g,(double)(x_left + Length_A + Length_B + Length_C),(double)(y_fig+height_A),
                (double)(x_left + Length_A + Length_B + Length_C + Length_D),(double)(y_fig+height_A),state.s2,Color.black);
        drawLineThick(g,(double)(x_left + Length_A + Length_B + Length_C + Length_D),(double)(y_fig),
                (double)(x_left + Length_A + Length_B + Length_C + Length_D),(double)(y_fig+height_A),state.s2,Color.black);
        
        // Wire connections
        drawConnect(x_left + Length_A, y_fig, g);
        drawConnect(x_left + Length_A, y_fig + height_A, g);
        drawConnect(x_left + Length_A + Length_B, y_fig, g);
        drawConnect(x_left + Length_A + Length_B, y_fig + height_A, g);
        drawConnect(x_left + Length_A + Length_B + Length_C, y_fig, g);
        drawConnect(x_left + Length_A + Length_B + Length_C, y_fig + height_A, g);
        
        fillRectangleThick(g2d,(double)(loadx-load_wx), (double)(loady - load_wy),
                (double)(2.0 * load_wx),(double)(2.0 * load_wy), 2, Color.white);
        drawRectangleThick(g2d,(double)(loadx-load_wx), (double)(loady - load_wy),
                (double)(2.0 * load_wx),(double)(2.0 * load_wy), 1, Color.black);
        
        MaestroG.subscripter2("Z","01","",g,state.font11,x_left + 3*Length_A/35,loady+load_wy/4);
        MaestroG.subscripter2("Z","in","",g,state.font11,x_left + 20*Length_A/35,loady+load_wy/4);
        MaestroG.subscripter2("Z","02","",g,state.font11,x_left + Length_A + 40*Length_B/90,loady+load_wy/4);
        MaestroG.subscripter2("Z","01","",g,state.font11,x_left + Length_A + Length_B + 45*Length_C/100,loady+load_wy/4);
        MaestroG.subscripter2("Z","L","",g,state.font11,loadx-55*load_wx/100,loady+load_wy/4);
        MaestroG.subscripter2("Z(d)","","",g,state.font11,x_left + Length_A + Length_B - 15*stem/10,loady + 12*height_A/10);
        
        MaestroG.SerifItalic("\u03bb/4",g,state.font12,x_left+Length_A+Length_B/2-3,y_fig-25*Radius/10);
        MaestroG.SerifItalic("d",g,state.font12,x_left+Length_A+Length_B+Length_C/2,y_fig-25*Radius/10);
        MaestroG.SerifItalic("M",g,state.font12,x_left+Length_A-4*fmNormal.stringWidth("M")/10,y_fig-38*Radius/10);
        MaestroG.SerifItalic("M'",g,state.font12,x_left+Length_A-fmNormal.stringWidth("M")/2,y_fig+height_A+3*Radius);
        MaestroG.SerifItalic("B",g,state.font12,x_left+Length_A+Length_B-4*fmNormal.stringWidth("B")/10,y_fig-38*Radius/10);
        MaestroG.SerifItalic("B'",g,state.font12,x_left+Length_A+Length_B-fmNormal.stringWidth("B")/2,y_fig+height_A+3*Radius);
        MaestroG.SerifItalic("A",g,state.font12,x_left+Length_A+Length_B+Length_C-4*fmNormal.stringWidth("A")/10,y_fig-38*Radius/10);
        MaestroG.SerifItalic("A'",g,state.font12,x_left+Length_A+Length_B+Length_C-fmNormal.stringWidth("A")/2,y_fig+height_A+3*Radius);
        
        g.setColor(Color.red);
        MaestroG.subscripter4("Feedline","","",g,state.font10,x_left,y_fig-Radius);
        
        g.setColor(Color.red);
        drawArrowScaled(x_left+Length_A, loady, 7, state.sfactor, g);
        drawLineThick(g,(double)(x_left+Length_A+state.s1),(double)loady,
                (double)(x_left + Length_A - stem),(double)loady,state.s1,Color.red);
        
        g.setColor(Color.green.darker());
        drawArrowScaled(x_left+Length_A+Length_B, loady, 7, state.sfactor, g);
        drawLineThick(g,(double)(x_left+ Length_A+Length_B+state.s1),(double)loady,
                (double)(x_left + Length_A + Length_B - stem),(double)loady,state.s1,Color.green.darker());
        drawLineThick(g,(double)(x_left + Length_A + Length_B - stem),(double)loady,
                (double)(x_left + Length_A + Length_B - stem),(double)loady + height_A,state.s1,Color.green.darker());
        
        g.setColor(Color.black);
        g.drawLine(x_left+Length_A,y_fig-Radius,x_left+Length_A,y_fig-3*Radius);
        g.drawLine(x_left+Length_A+Length_B,y_fig-Radius,x_left+Length_A+Length_B,y_fig-3*Radius);
        g.drawLine(x_left+Length_A+Length_B+Length_C,y_fig-Radius,x_left+Length_A+Length_B+Length_C,y_fig-3*Radius);
        
        g.drawLine(x_left+Length_A,y_fig-2*Radius,x_left+Length_A+Length_B,y_fig-2*Radius);
        g.drawLine(x_left+Length_A+Length_B,y_fig-2*Radius,x_left+Length_A+Length_B+Length_C,y_fig-2*Radius);
        
        drawArrowScaled(x_left+Length_A+state.s8, y_fig-2*Radius, 4, state.sfactor, g);
        drawArrowScaled(x_left+Length_A+Length_B-state.s8, y_fig-2*Radius, 3, state.sfactor, g);
        drawArrowScaled(x_left+Length_A+Length_B+state.s8, y_fig-2*Radius, 4, state.sfactor, g);
        drawArrowScaled(x_left+Length_A+Length_B+Length_C-state.s8, y_fig-2*Radius, 3, state.sfactor, g);
        
        drawCopyRight(g);
        MaestroG.useBiggerFont = saveOldFlag;
    }

    public void drawCopyRight(Graphics g) {
        int deltaY = state.s20;
        int startingY = getSize().height - state.s70;
        int startingX = 0;
        FontMetrics fm;
        g.setColor(Color.black);
        g.setColor(Color.black);
        g.setFont(state.ttfFont.deriveFont((float)state.font14));
        
        fm = g.getFontMetrics();
        g.drawString("Application Design: Umberto Ravaioli",startingX+state.s15,startingY+deltaY);
        MaestroG.superscripter("Interactive Java","TM"," platform:  www.amanogawa.com",
                               g,state.font14,startingX+state.s15,startingY+2*deltaY);
        
        int lineLength = fm.stringWidth("Interactive JavaTM platform:  www.amanogawa.com");
        lineLength += state.s10;

        g.setFont(state.ttfFont.deriveFont((float)state.font14));
        g.drawString("All Rights Reserved",startingX+state.s15,startingY+3*deltaY);
        g.drawLine(startingX,startingY,
                   startingX+lineLength+state.s25,startingY);
        g.drawLine(startingX+lineLength+state.s25,startingY,
                   startingX+lineLength+state.s25,startingY+4*deltaY);
    }
    
    private void drawConnect(int x, int y, Graphics g){
        int tmp1, tmp2;
        tmp1 = state.s6;
        tmp2 = tmp1-state.s2;
        //drawRect(x,y,tmp1,tmp1,Color.white,g);
        //drawRect(x,y,tmp2,tmp2,Color.black,g);

        Graphics2D g2d = (Graphics2D)g;

        g2d.setStroke(new BasicStroke(2));

        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);

        g2d.setPaint(Color.white);
        g.fillOval(x-tmp1/2,y-tmp1/2,tmp1,tmp1);
        g2d.setPaint(Color.cyan.darker());
        //g.fillOval(x-tmp2/2,y-tmp2/2,tmp2,tmp2);

        Arc2D.Double arc_zero = new Arc2D.Double((double)(x-tmp1/2),(double)(y-tmp1/2),
                (double)tmp1,(double)tmp1,0,360,0);
        g2d.draw(arc_zero);


        g2d.setStroke(new BasicStroke(1));
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
    }
    
    public void drawLineThick(Graphics g, double x1, double y1, double x2, double y2, int thick, Color color){
	
        Graphics2D g2d = (Graphics2D)g;
        g2d.setPaint(color);
        g2d.setStroke(new BasicStroke(thick,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
        
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
        
        Line2D.Double line = new Line2D.Double(x1,y1,x2,y2);
        g2d.draw(line);
  
        g2d.setStroke(new BasicStroke(1));
        //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
    }
    
    public void drawRectangleThick(Graphics g, double x1, double y1, double x2, double y2, int thick, Color color){
	
        Graphics2D g2d = (Graphics2D)g;
        g2d.setPaint(color);
        g2d.setStroke(new BasicStroke(thick,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
        
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
        
        Rectangle2D rect = new Rectangle2D.Double(x1,y1,x2,y2);
        g2d.draw(rect);
  
        g2d.setStroke(new BasicStroke(1));
        //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
    }
    
    public void fillRectangleThick(Graphics g, double x1, double y1, double x2, double y2, int thick, Color color){
	
        Graphics2D g2d = (Graphics2D)g;
        g2d.setPaint(color);
        g2d.setStroke(new BasicStroke(thick,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
        
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
        
        Rectangle2D rect = new Rectangle2D.Double(x1,y1,x2,y2);
        g2d.fill(rect);
  
        g2d.setStroke(new BasicStroke(1));
        //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
    }
    
    public void drawArrowScaled(int x, int y, int tipo, double sfactor, Graphics g){
	Graphics2D g2d = (Graphics2D)g;
        double s;
        s = sfactor;
        
        switch (tipo){
	   
          case 1://ArrowUpSmooth
               g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
        
                g.drawLine(x,y,x,y-(int)(s*8));
		//draw oblique arrow head
		Polygon pH = new Polygon();
		pH.addPoint(x-(int)(s*2), y-(int)(s*2));
		pH.addPoint(x+(int)(s*2), y-(int)(s*2));
		pH.addPoint(x,y-(int)(s*8));
		g.drawPolygon(pH);
		g.fillPolygon(pH);
                
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
        
          break;
          
          case 2://ArrowDownSmooth
               g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
        
                g.drawLine(x,y,x,y+(int)(s*8));
		//draw oblique arrow head
		Polygon pJ = new Polygon();
		pJ.addPoint(x-(int)(s*2), y+(int)(s*2));
		pJ.addPoint(x+(int)(s*2), y+(int)(s*2));
		pJ.addPoint(x,y+(int)(s*8));
		g.drawPolygon(pJ);
		g.fillPolygon(pJ);
                
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
	   break;
           
           case 3://ArrowRightSmooth
               g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
        
                g.drawLine(x,y,x+(int)(s*8),y);
		//draw oblique arrow head
		Polygon pK = new Polygon();
		pK.addPoint(x+(int)(s*2), y-(int)(s*2));
		pK.addPoint(x+(int)(s*2), y+(int)(s*2));
		pK.addPoint(x+(int)(s*8),y);
		g.drawPolygon(pK);
		g.fillPolygon(pK);
                
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
	   
	   break;
           
           case 4://ArrowLeftSmooth
               g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
        
                g.drawLine(x,y,x-(int)(s*8),y);
		//draw oblique arrow head
		Polygon pL = new Polygon();
		pL.addPoint(x-(int)(s*2), y-(int)(s*2));
		pL.addPoint(x-(int)(s*2), y+(int)(s*2));
		pL.addPoint(x-(int)(s*8),y);
		g.drawPolygon(pL);
		g.fillPolygon(pL);
                
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
 
	   break;
           
           case 5://ArrowOblique 45 degrees NE
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
        
		//draw oblique arrow head
		Polygon pM = new Polygon();
                //draw oblique arrow head
                
                pM.addPoint(x+(int)(s*5),y-(int)(s*5));
		pM.addPoint(x-(int)(s*1),y-(int)(s*2));
		pM.addPoint(x+(int)(s*2),y+(int)(s*1));
		
                g.drawPolygon(pM);
		g.fillPolygon(pM);
                
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
                 
           break;
           case 7://Larger ArrowRightSmooth
               g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
        
                g.drawLine(x,y,x+(int)(s*10),y);
		//draw oblique arrow head
		Polygon pR = new Polygon();
		pR.addPoint(x+(int)(s*3), y-(int)(s*3));
		pR.addPoint(x+(int)(s*3), y+(int)(s*3));
		pR.addPoint(x+(int)(s*10),y);
		g.drawPolygon(pR);
		g.fillPolygon(pR);
                
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
	   
	   break;
           
           case 8://Larger ArrowLeftSmooth
               g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
        
                g.drawLine(x,y,x-(int)(s*10),y);
		//draw oblique arrow head
		Polygon pS = new Polygon();
		pS.addPoint(x-(int)(s*3), y-(int)(s*3));
		pS.addPoint(x-(int)(s*3), y+(int)(s*3));
		pS.addPoint(x-(int)(s*10),y);
		g.drawPolygon(pS);
		g.fillPolygon(pS);
                
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
 
	   break;
           
	}		
    }  
    
//----------------------------------------------------------------------------------------    
}//End
    

