home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / kepler / kepler.jar / kepler.class (.txt) < prev    next >
Encoding:
Java Class File  |  2003-01-06  |  23.4 KB  |  914 lines

  1. import java.applet.Applet;
  2. import java.awt.Button;
  3. import java.awt.Checkbox;
  4. import java.awt.CheckboxGroup;
  5. import java.awt.Choice;
  6. import java.awt.Color;
  7. import java.awt.Component;
  8. import java.awt.Container;
  9. import java.awt.Cursor;
  10. import java.awt.Dimension;
  11. import java.awt.Font;
  12. import java.awt.Frame;
  13. import java.awt.Graphics;
  14. import java.awt.Graphics2D;
  15. import java.awt.Image;
  16. import java.awt.LayoutManager;
  17. import java.awt.MediaTracker;
  18. import java.awt.RenderingHints;
  19. import java.awt.TextField;
  20. import java.awt.Toolkit;
  21. import java.awt.Window;
  22. import java.awt.event.ActionEvent;
  23. import java.awt.image.ImageObserver;
  24. import java.net.MalformedURLException;
  25. import java.net.URL;
  26. import javax.swing.JPanel;
  27.  
  28. public class kepler extends Applet implements Runnable {
  29.    static boolean isStandalone = false;
  30.    static boolean painting = false;
  31.    static final Cursor cHair = new Cursor(1);
  32.    static final Cursor cHand = new Cursor(12);
  33.    static final Cursor cDefault = new Cursor(0);
  34.    static final Color yellow = new Color(255, 255, 170);
  35.    static final Color mauve = new Color(200, 200, 255);
  36.    static final Color[] cEl = new Color[]{new Color(255, 200, 0), new Color(0, 255, 180)};
  37.    static final Color bkgCol = new Color(125, 185, 183);
  38.    static final Color bkgColB;
  39.    static final Color buttonColor;
  40.    int imageNo;
  41.    MediaTracker tracker;
  42.    Thread timer;
  43.    static final String courseTitle = "S283 Planetary Science and the Search for Life";
  44.    static final String apName = "Kepler's laws";
  45.    static final String[] pageTitle;
  46.    WButton runB = new WButton("run");
  47.    WButton speedUpB = new WButton("speed up");
  48.    WButton slowDownB = new WButton("slow down");
  49.    WButton resetB = new WButton("reset");
  50.    // $FF: renamed from: a double[]
  51.    double[] field_0 = new double[]{(double)2.0F, (double)2.0F};
  52.    double[] amin = new double[]{(double)0.25F, (double)0.25F};
  53.    double[] amax = new double[]{(double)100.0F, (double)100.0F};
  54.    // $FF: renamed from: e double[]
  55.    double[] field_1 = new double[]{(double)0.0F, (double)0.0F};
  56.    // $FF: renamed from: q double[]
  57.    double[] field_2;
  58.    double[] qmin;
  59.    double[] qmax;
  60.    double[] emax;
  61.    // $FF: renamed from: b double[]
  62.    double[] field_3;
  63.    // $FF: renamed from: aq double[]
  64.    double[] field_4;
  65.    double[] th0;
  66.    double[] cTh0;
  67.    double[] sTh0;
  68.    int elNo;
  69.    String imageName;
  70.    String units;
  71.    Image image;
  72.    // $FF: renamed from: qL java.awt.TextField[]
  73.    TextField[] field_5;
  74.    // $FF: renamed from: aL java.awt.TextField[]
  75.    TextField[] field_6;
  76.    // $FF: renamed from: eL java.awt.TextField[]
  77.    TextField[] field_7;
  78.    // $FF: renamed from: tL java.awt.TextField[]
  79.    TextField[] field_8;
  80.    // $FF: renamed from: vf java.awt.TextField
  81.    TextField field_9;
  82.    TextDrawPanel orangePropsTA;
  83.    TextDrawPanel greenPropsTA;
  84.    TextDrawPanel[] velTA;
  85.    String[] velText;
  86.    int imY;
  87.    int imY2;
  88.    int width;
  89.    int height;
  90.    int page;
  91.    int sMax;
  92.    WScrollbar qSld;
  93.    WScrollbar eSld;
  94.    WScrollbar aSld;
  95.    WScrollbar tSld;
  96.    Choice resC;
  97.    Choice planetC;
  98.    CheckboxGroup cbg;
  99.    CheckboxGroup cbg2;
  100.    CheckboxGroup cbg3;
  101.    CheckboxGroup cbg4;
  102.    Checkbox e1Cb;
  103.    Checkbox e2Cb;
  104.    Checkbox[] animOrbCb;
  105.    Checkbox fixA;
  106.    Checkbox fixQ;
  107.    Checkbox fixE;
  108.    Checkbox progrdCb;
  109.    Checkbox retrogrdCb;
  110.    boolean[] progradeDirection;
  111.    static final int appW = 790;
  112.    static final int appH = 560;
  113.    // $FF: renamed from: bW int
  114.    static final int field_10 = 790;
  115.    // $FF: renamed from: bH int
  116.    static final int field_11 = 560;
  117.    int cbn;
  118.    String scaleString;
  119.    WillFun willFun;
  120.    boolean running;
  121.    Font bOn;
  122.    Font bOff;
  123.    Font buttonFont;
  124.    JPanel sliders;
  125.    Image icon;
  126.    int[][] ress;
  127.    int[] planetChosen;
  128.    double[][] planetData;
  129.    String[] planetName;
  130.    double vFac;
  131.    public boolean[] vel10;
  132.    public int[] nSector;
  133.    int area;
  134.    int section;
  135.    double vfD;
  136.    // $FF: renamed from: t double
  137.    double field_12;
  138.    // $FF: renamed from: px double[]
  139.    double[] field_13;
  140.    // $FF: renamed from: py double[]
  141.    double[] field_14;
  142.    // $FF: renamed from: vx double
  143.    double field_15;
  144.    // $FF: renamed from: vy double
  145.    double field_16;
  146.    double vy0;
  147.    double vy1;
  148.    double energy;
  149.    double vxAtYisB;
  150.    double[] period;
  151.    boolean first;
  152.    double xScl;
  153.    double yScl;
  154.    double[] p10;
  155.    static final int graphx = 10;
  156.    static final int graphy = 35;
  157.    static final int graphw = 470;
  158.    static final int graphh = 470;
  159.    // $FF: renamed from: x0 int
  160.    static final int field_17 = 235;
  161.    // $FF: renamed from: y0 int
  162.    static final int field_18 = 235;
  163.    Image bufIm;
  164.    Image graph;
  165.    Image graphBak;
  166.    Image bakIm;
  167.    Image sun;
  168.    Image planet;
  169.    Graphics bufImG;
  170.    Graphics appG;
  171.    Graphics graphG;
  172.    Graphics graphBakG;
  173.    Graphics2D bufImG2;
  174.    Graphics2D graphG2;
  175.    Graphics2D graphBakG2;
  176.    double[] opx;
  177.    double[] opy;
  178.    // $FF: renamed from: v double[]
  179.    double[] field_19;
  180.    // $FF: renamed from: sx int
  181.    int field_20;
  182.    // $FF: renamed from: sy int
  183.    int field_21;
  184.    static final int nps = 100;
  185.    int[][] xEl;
  186.    int[][] yEl;
  187.    double distance;
  188.    double ovy;
  189.    boolean negx2;
  190.    static final int nSteps = 100;
  191.    static final int stepF = 20;
  192.    // $FF: renamed from: pi double
  193.    static final double field_22 = 3.14159265;
  194.    static final double pi2 = 6.2831853;
  195.    static final double pi4 = 12.5663706;
  196.    static final double pi5 = 0.62731853;
  197.    int miss;
  198.    // $FF: renamed from: m double[]
  199.    double[] field_23;
  200.    // $FF: renamed from: dm double[]
  201.    double[] field_24;
  202.    int velS;
  203.    int[] vel0;
  204.    public static final Frame frame;
  205.  
  206.    public kepler() {
  207.       this.field_2 = new double[]{this.field_0[0] * ((double)1.0F - this.field_1[0]), this.field_0[0] * ((double)1.0F - this.field_1[0])};
  208.       this.qmin = new double[]{(double)0.25F, (double)0.25F};
  209.       this.qmax = new double[]{this.amax[0] * ((double)1.0F - this.field_1[0]), this.amax[0] * ((double)1.0F - this.field_1[0])};
  210.       this.emax = new double[]{0.995, 0.995};
  211.       this.field_3 = new double[]{this.field_0[0] * Math.sqrt((double)1.0F - this.field_1[0] * this.field_1[0]), this.field_0[0] * Math.sqrt((double)1.0F - this.field_1[0] * this.field_1[0])};
  212.       this.field_4 = new double[]{this.field_0[0] - this.field_2[0], this.field_0[0] - this.field_2[0]};
  213.       this.th0 = new double[]{(double)0.0F, (double)0.0F};
  214.       this.cTh0 = new double[]{(double)1.0F, (double)1.0F};
  215.       this.sTh0 = new double[]{(double)0.0F, (double)0.0F};
  216.       this.elNo = 0;
  217.       this.field_5 = new TextField[2];
  218.       this.field_6 = new TextField[2];
  219.       this.field_7 = new TextField[2];
  220.       this.field_8 = new TextField[2];
  221.       this.field_9 = new TextField();
  222.       this.orangePropsTA = new TextDrawPanel();
  223.       this.greenPropsTA = new TextDrawPanel();
  224.       this.velTA = new TextDrawPanel[]{new TextDrawPanel(), new TextDrawPanel()};
  225.       this.velText = new String[2];
  226.       this.imY = 20;
  227.       this.imY2 = this.imY * 2;
  228.       this.page = 1;
  229.       this.sMax = 399;
  230.       this.qSld = new kepler$1(this, 0, 0, this.sMax / 20, 0, this.sMax + this.sMax / 20);
  231.       this.eSld = new kepler$2(this, 0, 0, this.sMax / 20, 0, this.sMax + this.sMax / 20);
  232.       this.aSld = new kepler$3(this, 0, 0, this.sMax / 20, 0, this.sMax + this.sMax / 20);
  233.       this.tSld = new kepler$4(this, 0, 0, this.sMax / 20, 0, this.sMax + this.sMax / 20);
  234.       this.resC = new Choice();
  235.       this.planetC = new Choice();
  236.       this.cbg = new CheckboxGroup();
  237.       this.cbg2 = new CheckboxGroup();
  238.       this.cbg3 = new CheckboxGroup();
  239.       this.cbg4 = new CheckboxGroup();
  240.       this.e1Cb = new Checkbox("adjust orange orbit", this.cbg, true);
  241.       this.e2Cb = new Checkbox("adjust green orbit", this.cbg, false);
  242.       this.animOrbCb = new Checkbox[2];
  243.       this.fixA = new Checkbox("fix", this.cbg2, true);
  244.       this.fixQ = new Checkbox("fix", this.cbg2, false);
  245.       this.fixE = new Checkbox("fix", this.cbg2, false);
  246.       this.progrdCb = new Checkbox("prograde", this.cbg3, true);
  247.       this.retrogrdCb = new Checkbox("retrograde", this.cbg3, false);
  248.       this.progradeDirection = new boolean[]{this.progrdCb.getState(), this.progrdCb.getState()};
  249.       this.willFun = new WillFun();
  250.       this.running = false;
  251.       this.bOn = new Font("SanSerif", 1, 13);
  252.       this.bOff = new Font("SanSerif", 0, 12);
  253.       this.buttonFont = new Font("SanSerif", 1, 12);
  254.       this.sliders = new JPanel();
  255.       this.ress = new int[][]{{1, 1, 1, 2, 2, 2, 3, 3, 5}, {1, 2, 3, 3, 5, 1, 1, 2, 2}};
  256.       this.planetChosen = new int[]{-1, -1};
  257.       this.planetData = new double[][]{{0.387, 0.723, (double)1.0F, 1.524, 5.203, 9.539, 19.191, 30.061, 39.529}, {(double)0.0F, (double)0.0F, (double)0.0F, (double)0.0F, (double)0.0F, (double)0.0F, (double)0.0F, (double)0.0F, (double)0.0F}, {0.206, 0.007, 0.017, 0.093, 0.048, 0.056, 0.046, 0.01, 0.248}, {(double)77.5F, (double)131.5F, 102.9, (double)336.0F, 14.8, 92.4, (double)171.0F, (double)45.0F, 224.1}};
  258.       this.planetName = new String[]{"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"};
  259.       this.vFac = (double)1.0F;
  260.       this.vel10 = new boolean[2];
  261.       this.nSector = new int[2];
  262.       this.area = 6;
  263.       this.vfD = 0.01;
  264.       this.field_12 = (double)0.0F;
  265.       this.field_13 = new double[2];
  266.       this.field_14 = new double[2];
  267.       this.period = new double[]{Math.pow(this.field_0[0], (double)1.5F), Math.pow(this.field_0[1], (double)1.5F)};
  268.       this.first = true;
  269.       this.xScl = (double)40.0F;
  270.       this.yScl = (double)40.0F;
  271.       this.p10 = new double[]{(double)0.0F, (double)0.0F};
  272.       this.opx = new double[]{(double)0.0F, (double)0.0F};
  273.       this.opy = new double[]{(double)0.0F, (double)0.0F};
  274.       this.field_19 = new double[]{(double)0.0F, (double)0.0F};
  275.       this.field_20 = 227;
  276.       this.field_21 = 227;
  277.       this.xEl = new int[2][100];
  278.       this.yEl = new int[2][100];
  279.       this.distance = (double)0.0F;
  280.       this.ovy = (double)1.0F;
  281.       this.negx2 = false;
  282.       this.miss = 0;
  283.       this.field_23 = new double[]{(double)0.0F, (double)0.0F};
  284.       this.field_24 = new double[]{6.2831853 / this.period[0], 6.2831853 / this.period[1]};
  285.       this.velS = 0;
  286.       this.vel0 = new int[]{0, 0};
  287.    }
  288.  
  289.    public Image loadImage(String var1) {
  290.       Image var2 = null;
  291.       if (isStandalone) {
  292.          var2 = Toolkit.getDefaultToolkit().getImage(var1);
  293.       } else {
  294.          URL var3 = ((Applet)this).getDocumentBase();
  295.  
  296.          try {
  297.             var2 = ((Applet)this).getImage(new URL(var3, var1));
  298.          } catch (MalformedURLException var5) {
  299.          }
  300.       }
  301.  
  302.       this.tracker.addImage(var2, this.imageNo++);
  303.       return var2;
  304.    }
  305.  
  306.    public Image setImage(int var1, int var2) {
  307.       Image var3 = ((Component)this).createImage(var1, var2);
  308.       this.tracker.addImage(var3, this.imageNo++);
  309.       return var3;
  310.    }
  311.  
  312.    public void init() {
  313.       ((Container)this).setFont(this.bOff);
  314.       this.timer = new Thread(this);
  315.       this.timer.start();
  316.       ((Component)this).setBackground(new Color(213, 230, 227));
  317.       ((Component)this).addMouseMotionListener(new kepler$MML(this));
  318.       ((Component)this).addMouseListener(new kepler$ML(this));
  319.       ((Container)this).setLayout((LayoutManager)null);
  320.       WillFun.ap = this;
  321.       WillFun.isStandalone = isStandalone;
  322.       WillFun.t = new MediaTracker(this);
  323.       WillFun.imageNo = 0;
  324.       this.icon = WillFun.loadImage("images/icon.gif");
  325.       WillFun.imageWait();
  326.       frame.setIconImage(this.icon);
  327.       this.width = ((Component)this).getBounds().width;
  328.       this.height = ((Component)this).getBounds().height;
  329.       boolean var1 = true;
  330.       int var2 = 4;
  331.       byte var3 = 17;
  332.       this.resC.setBounds(490, 500, 270, 20);
  333.       this.resC.add("Change resonance of green orbit:");
  334.  
  335.       for(this.cbn = 0; this.cbn < this.ress[0].length; ++this.cbn) {
  336.          this.resC.add("periods of green : orange orbits = " + this.ress[1][this.cbn] + " : " + this.ress[0][this.cbn]);
  337.       }
  338.  
  339.       this.resC.addItemListener(new kepler$5(this));
  340.       ((Container)this).add(this.resC, (Object)null);
  341.       About var4 = new About(" \u0000 S283 Planetary Science and the Search for Life \u0001 ", "Kepler's laws", " \f Kepler's laws \r  \b  \b Version 1 \b  \b Copyright ┬⌐ 2003 The Open University. \b  \b All rights reserved", " \f Kepler's laws \r  \b  \b This package forms part of  \u0000 S283 Planetary Science and the Search for Life \u0001 , a course produced for the Science Faculty by a team drawn from many areas of the Open University. \b  \b It was written, designed and developed for the course team by: \b        Neil McBride (Department of Planetary Sciences) \b        Will Rawes (Software designer) \b ", this.icon, new WillFun());
  342.       WButton[] var5 = new WButton[3];
  343.  
  344.       for(this.cbn = 0; this.cbn < 3; ++this.cbn) {
  345.          var5[this.cbn] = new WButton(pageTitle[this.cbn]);
  346.          var5[this.cbn].setBounds(10 + this.cbn * 130, 5, 128, 20);
  347.          var5[this.cbn].setFont(this.cbn == 0 ? this.bOn : this.bOff);
  348.          var5[this.cbn].setForeground(buttonColor);
  349.          var5[this.cbn].setBackground(bkgColB);
  350.          var5[this.cbn].addActionListener(new kepler$6(this, var5));
  351.          ((Container)this).add(var5[this.cbn], (Object)null);
  352.       }
  353.  
  354.       Frame var6 = new Frame();
  355.       ((Window)var6).addWindowListener(new kepler$7(this, var6));
  356.       ((Component)var6).setSize(400, 400);
  357.       var6.setTitle("Kepler's laws - help");
  358.       var6.setIconImage(this.icon);
  359.       WButton var7 = new WButton("help");
  360.       ((Component)var7).setBounds(640, 5, 60, 20);
  361.       ((Component)var7).setFont(this.buttonFont);
  362.       ((Component)var7).setForeground(buttonColor);
  363.       ((Component)var7).setBackground(bkgColB);
  364.       ((Button)var7).addActionListener(new kepler$8(this, var6));
  365.       WButton var8 = new WButton("about");
  366.       ((Component)var8).setBounds(710, 5, 60, 20);
  367.       ((Component)var8).setFont(this.buttonFont);
  368.       ((Component)var8).setForeground(buttonColor);
  369.       ((Component)var8).setBackground(bkgColB);
  370.       ((Button)var8).addActionListener(new kepler$9(this, var4));
  371.       ((Container)this).add(var8, (Object)null);
  372.       this.e1Cb.setBounds(490, 30, 130, 15);
  373.       this.e1Cb.addItemListener(new kepler$10(this));
  374.       ((Container)this).add(this.e1Cb, (Object)null);
  375.       this.e2Cb.setBounds(490, 270, 130, 15);
  376.       this.e2Cb.addItemListener(new kepler$11(this));
  377.       ((Container)this).add(this.e2Cb, (Object)null);
  378.  
  379.       for(this.cbn = 0; this.cbn < 2; ++this.cbn) {
  380.          this.animOrbCb[this.cbn] = new Checkbox("show " + (this.cbn == 0 ? "orange" : "green") + " orbit");
  381.          this.animOrbCb[this.cbn].setBounds(630, 30 + this.cbn * 240, 130, 15);
  382.          this.animOrbCb[this.cbn].setState(true);
  383.          this.animOrbCb[this.cbn].addItemListener(new kepler$12(this));
  384.          ((Container)this).add(this.animOrbCb[this.cbn], (Object)null);
  385.       }
  386.  
  387.       this.animOrbCb[1].setState(false);
  388.       byte var9 = 50;
  389.       this.sliders.setOpaque(false);
  390.       this.sliders.setBackground(((Component)this).getBackground());
  391.       this.sliders.setLayout((LayoutManager)null);
  392.       this.sliders.setBounds(490, 50, 100 + var9, 160);
  393.       ((Container)this).add(this.sliders, (Object)null);
  394.  
  395.       for(int var10 = 0; var10 < 9; ++var10) {
  396.          this.planetData[1][var10] = this.planetData[0][var10] * ((double)1.0F - this.planetData[2][var10]);
  397.       }
  398.  
  399.       this.planetC.setBounds(0, var2 - 4, 90 + var9, 20);
  400.       this.planetC.add("Planet orbit:");
  401.  
  402.       for(this.cbn = 0; this.cbn < 9; ++this.cbn) {
  403.          this.planetC.add(this.planetName[this.cbn]);
  404.       }
  405.  
  406.       this.planetC.addItemListener(new kepler$13(this));
  407.       this.sliders.add(this.planetC, (Object)null);
  408.       var9 = 110;
  409.       var2 += 30;
  410.       this.aSld.setBounds(0, var2, 105, 13);
  411.       this.aSld.addAdjustmentListener(new kepler$14(this));
  412.       this.sliders.add(this.aSld, (Object)null);
  413.       this.fixA.setBounds(var9, var2, 35, 15);
  414.       this.fixA.addItemListener(new kepler$15(this));
  415.       this.sliders.add(this.fixA, (Object)null);
  416.       var2 += var3 * 2;
  417.       this.qSld.setBounds(0, var2, 105, 13);
  418.       this.qSld.addAdjustmentListener(new kepler$16(this));
  419.       this.sliders.add(this.qSld, (Object)null);
  420.       this.fixQ.setBounds(var9, var2, 35, 15);
  421.       this.fixQ.addItemListener(new kepler$17(this));
  422.       this.sliders.add(this.fixQ, (Object)null);
  423.       var2 += var3 * 2;
  424.       this.eSld.setBounds(0, var2, 105, 13);
  425.       this.eSld.addAdjustmentListener(new kepler$18(this));
  426.       this.sliders.add(this.eSld, (Object)null);
  427.       this.fixE.setBounds(var9, var2, 35, 15);
  428.       this.fixE.addItemListener(new kepler$19(this));
  429.       this.sliders.add(this.fixE, (Object)null);
  430.       var2 += var3;
  431.       this.tSld.setBounds(0, var2, 140, 13);
  432.       this.tSld.addAdjustmentListener(new kepler$20(this));
  433.       this.sliders.add(this.tSld, (Object)null);
  434.       var2 += var3 + 2;
  435.       this.progrdCb.setBounds(0, var2, 100, 15);
  436.       this.progrdCb.addItemListener(new kepler$21(this));
  437.       this.sliders.add(this.progrdCb, (Object)null);
  438.       var2 += var3 - 2;
  439.       this.retrogrdCb.setBounds(0, var2, 100, 15);
  440.       this.retrogrdCb.addItemListener(new kepler$22(this));
  441.       this.sliders.add(this.retrogrdCb, (Object)null);
  442.       this.orangePropsTA.setBounds(635, 50, 140, 190);
  443.       ((Container)this).add(this.orangePropsTA, (Object)null);
  444.       this.velTA[0].setBounds(490, 50, 130, 205);
  445.       this.velTA[0].setTabWidth(65);
  446.       ((Container)this).add(this.velTA[0], (Object)null);
  447.       this.greenPropsTA.setBounds(635, 290, 140, 190);
  448.       ((Container)this).add(this.greenPropsTA, (Object)null);
  449.       this.velTA[1].setBounds(490, 290, 130, 205);
  450.       this.velTA[1].setTabWidth(65);
  451.       ((Container)this).add(this.velTA[1], (Object)null);
  452.       short var11 = 480;
  453.       this.runB.setBounds(25, var11, 50, 20);
  454.       this.runB.setForeground(buttonColor);
  455.       this.runB.setBackground(bkgColB);
  456.       this.runB.setFont(this.buttonFont);
  457.       this.runB.addActionListener(new kepler$23(this));
  458.       ((Container)this).add(this.runB, (Object)null);
  459.       this.resetB.setBounds(80, var11, 50, 20);
  460.       this.resetB.setForeground(buttonColor);
  461.       this.resetB.setBackground(bkgColB);
  462.       this.resetB.setFont(this.buttonFont);
  463.       this.resetB.addActionListener(new kepler$24(this));
  464.       ((Container)this).add(this.resetB, (Object)null);
  465.       WButton var12 = new WButton("zoom in");
  466.       WButton var13 = new WButton("zoom out");
  467.       ((Component)var12).setBounds(135, var11, 70, 20);
  468.       ((Component)var12).setForeground(buttonColor);
  469.       ((Component)var12).setBackground(bkgColB);
  470.       ((Component)var12).setFont(this.buttonFont);
  471.       ((Button)var12).addActionListener(new kepler$25(this));
  472.       ((Container)this).add(var12, (Object)null);
  473.       ((Component)var13).setBounds(210, var11, 70, 20);
  474.       ((Component)var13).setForeground(buttonColor);
  475.       ((Component)var13).setBackground(bkgColB);
  476.       ((Component)var13).setFont(this.buttonFont);
  477.       ((Button)var13).addActionListener(new kepler$26(this));
  478.       ((Container)this).add(var13, (Object)null);
  479.       this.speedUpB.setBounds(295, var11, 70, 20);
  480.       this.speedUpB.setForeground(buttonColor);
  481.       this.speedUpB.setBackground(bkgColB);
  482.       this.speedUpB.setFont(this.buttonFont);
  483.       this.speedUpB.addActionListener(new kepler$27(this));
  484.       ((Container)this).add(this.speedUpB, (Object)null);
  485.       this.slowDownB.setEnabled(false);
  486.       this.slowDownB.setBounds(370, var11, 70, 20);
  487.       this.slowDownB.setForeground(buttonColor);
  488.       this.slowDownB.setBackground(bkgColB);
  489.       this.slowDownB.setFont(this.buttonFont);
  490.       this.slowDownB.addActionListener(new kepler$28(this));
  491.       ((Container)this).add(this.slowDownB, (Object)null);
  492.       this.fixA(0);
  493.       this.fixA(1);
  494.    }
  495.  
  496.    public void fixSliders() {
  497.       if (this.fixA.getState()) {
  498.          this.fixA(this.elNo);
  499.       }
  500.  
  501.       if (this.fixQ.getState()) {
  502.          this.fixQ(this.elNo);
  503.       }
  504.  
  505.       if (this.fixE.getState()) {
  506.          this.fixE(this.elNo);
  507.       }
  508.  
  509.       this.progrdCb.setState(this.progradeDirection[this.elNo]);
  510.       this.retrogrdCb.setState(!this.progradeDirection[this.elNo]);
  511.    }
  512.  
  513.    public void fixA(int var1) {
  514.       this.qmax[var1] = this.field_0[var1];
  515.       this.emax[var1] = (double)1.0F - this.qmin[var1] / this.field_0[var1];
  516.       this.aSld.setEnabled(false);
  517.       this.qSld.setEnabled(true);
  518.       this.eSld.setEnabled(true);
  519.       this.changeEll(var1, ' ');
  520.    }
  521.  
  522.    public void fixQ(int var1) {
  523.       this.amin[var1] = this.field_2[var1] > (double)0.25F ? this.field_2[var1] : (double)0.25F;
  524.       this.emax[var1] = (double)1.0F - this.field_2[var1] / this.amax[var1];
  525.       if (this.emax[var1] > 0.995) {
  526.          this.emax[var1] = 0.995;
  527.       }
  528.  
  529.       this.amax[var1] = this.field_2[var1] / ((double)1.0F - this.emax[var1]);
  530.       this.aSld.setEnabled(true);
  531.       this.qSld.setEnabled(false);
  532.       this.eSld.setEnabled(true);
  533.       this.changeEll(var1, ' ');
  534.    }
  535.  
  536.    public void fixE(int var1) {
  537.       this.amax[var1] = (double)100.0F;
  538.       this.amin[var1] = this.qmin[var1] / ((double)1.0F - this.field_1[var1]);
  539.       if (this.amin[var1] < (double)0.25F) {
  540.          this.amin[var1] = (double)0.25F;
  541.       }
  542.  
  543.       this.qmax[var1] = this.amax[var1] * ((double)1.0F - this.field_1[var1]);
  544.       this.qmin[var1] = this.amin[var1] * ((double)1.0F - this.field_1[var1]);
  545.       this.aSld.setEnabled(true);
  546.       this.qSld.setEnabled(true);
  547.       this.eSld.setEnabled(false);
  548.       this.changeEll(var1, ' ');
  549.    }
  550.  
  551.    public void changeEll(int var1, char var2) {
  552.       if (var2 != 'e') {
  553.          this.eSld.setValue((int)(this.field_1[var1] / this.emax[var1] * (double)this.sMax));
  554.       }
  555.  
  556.       if (var2 != 'a') {
  557.          this.aSld.setValue((int)((this.field_0[var1] - this.amin[var1]) / (this.amax[var1] - this.amin[var1]) * (double)this.sMax));
  558.       }
  559.  
  560.       if (var2 != 'q') {
  561.          this.qSld.setValue((int)((this.field_2[var1] - this.qmin[var1]) / (this.qmax[var1] - this.qmin[var1]) * (double)this.sMax));
  562.       }
  563.  
  564.       if (var2 != 't') {
  565.          this.tSld.setValue((int)(-this.th0[var1] / 6.2831853 * (double)this.sMax));
  566.       }
  567.  
  568.       ((Component)this).repaint();
  569.    }
  570.  
  571.    public void setControls(int var1) {
  572.       if (this.running) {
  573.          this.runB.dispatchEvent(new ActionEvent(this.runB, 1001, ""));
  574.       }
  575.  
  576.       boolean var2 = var1 == 1;
  577.       this.sliders.setVisible(var2);
  578.       this.e1Cb.setVisible(var2);
  579.       this.e2Cb.setVisible(var2);
  580.       if (var1 == 1) {
  581.          if (this.e1Cb.getState()) {
  582.             this.animOrbCb[0].setState(true);
  583.          }
  584.  
  585.          if (this.e2Cb.getState()) {
  586.             this.animOrbCb[1].setState(true);
  587.          }
  588.       }
  589.  
  590.       this.animOrbCb[0].setEnabled(var1 > 1 || !this.e1Cb.getState());
  591.       this.animOrbCb[1].setEnabled(var1 > 1 || !this.e2Cb.getState());
  592.       this.planetC.setVisible(var2);
  593.       var2 = var1 > 1;
  594.       this.runB.setVisible(var2);
  595.       this.resetB.setVisible(var2);
  596.       this.velTA[0].setVisible(var2);
  597.       this.velTA[1].setVisible(var2);
  598.       this.speedUpB.setVisible(var2);
  599.       this.slowDownB.setVisible(var2);
  600.       var2 = var1 == 3;
  601.       this.resC.setVisible(var2);
  602.       this.drawBkg();
  603.    }
  604.  
  605.    public void setPeriod(int var1) {
  606.       this.period[var1] = Math.pow(this.field_0[var1], (double)1.5F);
  607.       this.p10[0] = (double)0.0F;
  608.       this.p10[1] = (double)0.0F;
  609.       if (this.period[var1] > this.period[1 - var1]) {
  610.          this.field_24[1 - var1] = 0.03;
  611.          this.field_24[var1] = 0.03 * this.period[1 - var1] / this.period[var1];
  612.          this.vFac = 996.9320676 / this.period[1 - var1];
  613.       } else {
  614.          this.field_24[var1] = 0.03;
  615.          this.field_24[1 - var1] = 0.03 * this.period[var1] / this.period[1 - var1];
  616.          this.vFac = 996.9320676 / this.period[var1];
  617.       }
  618.  
  619.    }
  620.  
  621.    public void reset() {
  622.       this.drawBkg();
  623.  
  624.       for(int var1 = 0; var1 < 2; ++var1) {
  625.          this.velText[var1] = " Time<tab/>Velocity <br/> (years)<tab/>(km/s)";
  626.          this.velTA[var1].setText(this.velText[var1]);
  627.          this.opx[var1] = this.field_2[var1] * this.cTh0[var1];
  628.          this.opy[var1] = this.field_2[var1] * this.sTh0[var1];
  629.          this.field_13[var1] = this.opx[var1];
  630.          this.field_14[var1] = this.opy[var1];
  631.          this.field_23[var1] = (double)0.0F;
  632.          this.p10[var1] = (double)0.0F;
  633.          this.vel10[var1] = true;
  634.          this.nSector[var1] = 0;
  635.          this.energy = this.field_16 * this.field_16 - (double)1.0F / this.field_2[var1];
  636.          this.vxAtYisB = Math.sqrt(this.energy + Math.pow(this.field_4[this.elNo] * this.field_4[this.elNo] + this.field_3[this.elNo] * this.field_3[this.elNo], (double)-0.5F)) * (double)1.0F;
  637.       }
  638.  
  639.       this.field_12 = (double)0.0F;
  640.    }
  641.  
  642.    public Image scaleImage(Image var1, double var2) {
  643.       return var1.getScaledInstance((int)((double)var1.getWidth((ImageObserver)null) * var2), (int)((double)var1.getHeight((ImageObserver)null) * var2), 4);
  644.    }
  645.  
  646.    public void paint(Graphics var1) {
  647.       painting = true;
  648.       if (this.first) {
  649.          this.bufIm = WillFun.setImage(790, 560);
  650.          this.graph = WillFun.setImage(470, 470);
  651.          this.graphBak = WillFun.setImage(470, 470);
  652.          this.sun = WillFun.loadImage("images/sun.gif");
  653.          this.planet = WillFun.loadImage("images/planet.gif");
  654.          WillFun.imageWait();
  655.          this.bufImG = this.bufIm.getGraphics();
  656.          this.graphG = this.graph.getGraphics();
  657.          this.graphG2 = (Graphics2D)this.graphG;
  658.          this.graphG2.getRenderingHints().put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
  659.          this.graphG2.setFont(new Font("SansSerif", 2, 13));
  660.          this.graphBakG = this.graphBak.getGraphics();
  661.          this.graphBakG2 = (Graphics2D)this.graphBakG;
  662.          this.graphBakG2.getRenderingHints().put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
  663.          this.appG = ((Component)this).getGraphics();
  664.          this.writeLabel(1);
  665.          this.first = false;
  666.          this.setControls(1);
  667.          this.setPeriod(0);
  668.          this.setPeriod(1);
  669.       }
  670.  
  671.       this.graphG.drawImage(this.graphBak, 0, 0, (ImageObserver)null);
  672.       this.graphG.setColor(Color.yellow);
  673.       this.graphG.fillRect(233, 233, 4, 4);
  674.       switch (this.page) {
  675.          case 1:
  676.             this.writeLabel(this.e1Cb.getState() ? 0 : 1);
  677.             if (this.animOrbCb[0].getState()) {
  678.                this.drawEll(0);
  679.             }
  680.  
  681.             if (this.animOrbCb[1].getState()) {
  682.                this.drawEll(1);
  683.             }
  684.  
  685.             int var3 = (int)(this.cTh0[this.elNo] * this.xScl * this.field_2[this.elNo] + this.sTh0[this.elNo] * (double)4.0F);
  686.             int var4 = (int)(this.cTh0[this.elNo] * (double)4.0F - this.sTh0[this.elNo] * this.yScl * this.field_2[this.elNo]);
  687.             int var5 = (int)(-this.cTh0[this.elNo] * this.xScl * this.field_4[this.elNo]);
  688.             int var6 = (int)(this.sTh0[this.elNo] * this.yScl * this.field_4[this.elNo]);
  689.             this.graphG2.setColor(cEl[this.elNo]);
  690.             this.graphG2.drawLine(235 + var5 + 3, 235 - var6 + 3, 235 + var5 - 3, 235 - var6 - 3);
  691.             this.graphG2.drawLine(235 + var5 + 3, 235 - var6 - 3, 235 + var5 - 3, 235 - var6 + 3);
  692.             var5 = (int)((double)var5 + this.sTh0[this.elNo] * (double)4.0F);
  693.             var6 = (int)((double)var6 + this.cTh0[this.elNo] * (double)4.0F);
  694.             this.graphG2.setRenderingHints(WillFun.aaOn);
  695.             WillFun.drawDoubleArrow(this.graphG2, 235 + var3, 235 - var4, 235 + var5, 235 - var6);
  696.             this.graphG2.setRenderingHints(WillFun.aaOff);
  697.             this.graphG2.drawString("a", 235 + (var3 + var5) / 2 + (int)((double)8.0F * this.sTh0[this.elNo]), 235 - (var4 + var6) / 2 - (int)((double)8.0F * this.cTh0[this.elNo]) + 3);
  698.             var3 = (int)(this.sTh0[this.elNo] * (double)-4.0F);
  699.             var4 = (int)(this.cTh0[this.elNo] * (double)-4.0F);
  700.             var5 = (int)(this.sTh0[this.elNo] * (double)-4.0F + this.cTh0[this.elNo] * this.xScl * this.field_2[this.elNo]);
  701.             var6 = (int)(this.cTh0[this.elNo] * (double)-4.0F - this.sTh0[this.elNo] * this.yScl * this.field_2[this.elNo]);
  702.             this.graphG2.setRenderingHints(WillFun.aaOn);
  703.             WillFun.drawDoubleArrow(this.graphG2, 235 + var3, 235 - var4, 235 + var5, 235 - var6);
  704.             this.graphG2.setRenderingHints(WillFun.aaOff);
  705.             this.graphG2.drawString("q", 235 + (var3 + var5) / 2 - (int)((double)8.0F * this.sTh0[this.elNo]) - 3, 235 - (var4 + var6) / 2 + (int)((double)8.0F * this.cTh0[this.elNo]) + 3);
  706.             break;
  707.          case 2:
  708.          case 3:
  709.             for(int var2 = 0; var2 < 2; ++var2) {
  710.                if (this.animOrbCb[var2].getState()) {
  711.                   int var7 = (int)(this.xScl * this.opx[var2]) + 235;
  712.                   int var8 = (int)(this.yScl * this.opy[var2]) + 235;
  713.                   this.drawEll(var2);
  714.                   this.graphG.setColor(Color.green);
  715.                   this.graphG.fillRect(var7 - 2, var8 - 2, 4, 4);
  716.                   this.graphG.setColor(cEl[var2]);
  717.                   this.graphG2.setRenderingHints(WillFun.aaOn);
  718.                   this.field_15 = this.field_13[var2] - this.opx[var2];
  719.                   this.field_16 = this.field_14[var2] - this.opy[var2];
  720.                   this.field_19[var2] = Math.sqrt(this.field_15 * this.field_15 + this.field_16 * this.field_16);
  721.                   WillFun.drawThinArrow(this.graphG, var7, var8, var7 + (int)(this.field_15 * (double)50.0F * this.xScl), var8 + (int)(this.field_16 * (double)50.0F * this.yScl - (double)0.5F));
  722.                   this.graphG2.setRenderingHints(WillFun.aaOff);
  723.                }
  724.             }
  725.       }
  726.  
  727.       this.bufImG.drawImage(this.graph, 10, 35, (ImageObserver)null);
  728.       this.appG.drawImage(this.bufIm, 0, 0, (ImageObserver)null);
  729.       painting = false;
  730.    }
  731.  
  732.    public void writeLabel(int var1) {
  733.       String var2 = "";
  734.       this.field_2[var1] = this.field_0[var1] * ((double)1.0F - this.field_1[var1]);
  735.       this.field_3[var1] = this.field_0[var1] * Math.sqrt((double)1.0F - this.field_1[var1] * this.field_1[var1]);
  736.       double var3 = (double)((int)(this.period[var1] * (double)10.0F)) / (double)10.0F;
  737.       var2 = var2 + " Properties of " + (var1 == 0 ? "orange" : "green") + " <br/> orbit" + (this.planetChosen[this.elNo] > -1 ? " (" + this.planetName[this.planetChosen[this.elNo]] + ")" : "") + ":" + " <br/> <i>a</i> (semi-major axis)<br/><tab/> = " + Double.toString((double)((int)(this.field_0[var1] * (double)100.0F)) / (double)100.0F) + " au" + " <br/> <i>q</i> (perihelion distance)<br/><tab/> = " + Double.toString((double)((int)(this.field_2[var1] * (double)100.0F)) / (double)100.0F) + " au" + " <br/> <i>e</i> (eccentricity) = " + Double.toString((double)((int)(this.field_1[var1] * (double)1000.0F)) / (double)1000.0F) + " <br/> <i>L</i> (longitude of <i>q</i>) = " + Integer.toString((int)(-this.th0[var1] / 3.141593 * (double)180.0F) / 1) + '┬░' + " <br/> <i>Q</i> = " + Double.toString((double)((int)(((double)2.0F * this.field_0[var1] - this.field_2[var1]) * (double)100.0F)) / (double)100.0F) + " au" + " <br/> period = " + Double.toString(var3) + " year" + (var3 != (double)1.0F ? "s" : "") + " <br/> " + (this.progradeDirection[var1] ? "prograde" : "retrograde") + " orbit";
  738.       if (var1 == 0) {
  739.          this.orangePropsTA.setText(var2);
  740.       } else {
  741.          this.greenPropsTA.setText(var2);
  742.       }
  743.  
  744.    }
  745.  
  746.    public void drawBkg() {
  747.       this.graphBakG.setColor(Color.black);
  748.       this.graphBakG.fillRect(0, 0, 470, 470);
  749.       this.graphBakG.setColor(Color.darkGray);
  750.       this.graphBakG.drawLine(235, 0, 235, 470);
  751.       this.graphBakG.drawLine(0, 235, 470, 235);
  752.    }
  753.  
  754.    public void update(Graphics var1) {
  755.       this.paint(var1);
  756.    }
  757.  
  758.    public void drawEll(int var1) {
  759.       this.graphG2.setRenderingHints(WillFun.aaOn);
  760.       this.graphG2.setColor(cEl[var1]);
  761.       this.field_4[var1] = this.field_0[var1] - this.field_2[var1];
  762.       int var8 = (int)(this.xScl * this.field_4[var1] * ((double)1.0F - this.cTh0[var1]));
  763.       int var9 = -((int)(this.yScl * this.field_4[var1] * this.sTh0[var1]));
  764.  
  765.       for(int var10 = 0; var10 < 100; ++var10) {
  766.          double var2 = (double)var10 * 6.283 / (double)100.0F;
  767.          var2 -= Math.sin(var2 * (double)2.0F) / (double)2.0F;
  768.          double var6 = Math.pow(Math.pow(Math.cos(var2) / this.field_0[var1], (double)2.0F) + Math.pow(Math.sin(var2) / this.field_3[var1], (double)2.0F), (double)-0.5F);
  769.          double var4 = var2 + this.th0[var1];
  770.          this.xEl[var1][var10] = 235 + var8 + (int)(this.xScl * (var6 * Math.cos(var4) - this.field_4[var1]));
  771.          this.yEl[var1][var10] = 235 + var9 + (int)(this.yScl * var6 * Math.sin(var4));
  772.       }
  773.  
  774.       this.graphG2.drawPolyline(this.xEl[var1], this.yEl[var1], 100);
  775.       this.graphG2.setRenderingHints(WillFun.aaOff);
  776.    }
  777.  
  778.    public void run() {
  779.       while(this.timer != null) {
  780.          if (this.running) {
  781.             this.field_12 += (double)(this.miss + 1);
  782.  
  783.             for(int var1 = 0; var1 < this.miss; ++var1) {
  784.                this.newPos();
  785.             }
  786.  
  787.             for(int var2 = 0; var2 < 2; ++var2) {
  788.                this.opx[var2] = this.field_13[var2];
  789.                this.opy[var2] = this.field_14[var2];
  790.             }
  791.  
  792.             this.newPos();
  793.             ((Component)this).repaint();
  794.          }
  795.  
  796.          try {
  797.             Thread.sleep(100L);
  798.          } catch (Exception var3) {
  799.          }
  800.       }
  801.  
  802.    }
  803.  
  804.    public void newPos() {
  805.       boolean var11 = false;
  806.  
  807.       for(int var12 = 0; var12 < 2; ++var12) {
  808.          if (this.field_23[var12] >= this.p10[var12] && this.animOrbCb[var12].getState()) {
  809.             var11 = true;
  810.             int var10002 = this.nSector[var12]++;
  811.             if (this.nSector[var12] < 11) {
  812.                this.graphBakG.setColor(cEl[var12]);
  813.                this.graphBakG2.setRenderingHints(WillFun.aaOn);
  814.                this.graphBakG2.drawLine(235, 235, (int)(this.xScl * this.field_13[var12]) + 235, (int)(this.yScl * this.field_14[var12]) + 235);
  815.                this.graphBakG2.setRenderingHints(WillFun.aaOff);
  816.             }
  817.  
  818.             this.opx[var12] = this.field_13[var12];
  819.             this.opy[var12] = this.field_14[var12];
  820.          }
  821.  
  822.          double[] var10000 = this.field_23;
  823.  
  824.          for(var10000[var12] += this.field_24[var12]; this.field_23[var12] > 6.2831853; var10000[var12] -= 6.2831853) {
  825.             var10000 = this.field_23;
  826.          }
  827.  
  828.          double var1 = 3.14159265;
  829.          double var3 = 1.570796325;
  830.  
  831.          for(int var13 = 0; var13 < 18; ++var13) {
  832.             if (var1 - this.field_1[var12] * Math.sin(var1) > this.field_23[var12]) {
  833.                var1 -= var3;
  834.             } else {
  835.                var1 += var3;
  836.             }
  837.  
  838.             var3 /= (double)2.0F;
  839.          }
  840.  
  841.          double var7 = (double)2.0F * Math.atan(Math.sqrt(((double)1.0F + this.field_1[var12]) / ((double)1.0F - this.field_1[var12])) * Math.tan(var1 / (double)2.0F));
  842.          if (this.progradeDirection[var12]) {
  843.             var7 = -var7;
  844.          }
  845.  
  846.          double var9 = this.field_0[var12] * ((double)1.0F - this.field_1[var12] * this.field_1[var12]) / ((double)1.0F + this.field_1[var12] * Math.cos(var7));
  847.          this.field_13[var12] = var9 * Math.cos(var7 + this.th0[var12]);
  848.          this.field_14[var12] = var9 * Math.sin(var7 + this.th0[var12]);
  849.          if (var11 && this.nSector[var12] < 12) {
  850.             var11 = false;
  851.             if (this.nSector[var12] == 11) {
  852.                this.velS = this.vel0[var12];
  853.             } else {
  854.                this.velS = (int)(this.vFac * Math.sqrt(Math.pow(this.opx[var12] - this.field_13[var12], (double)2.0F) + Math.pow(this.opy[var12] - this.field_14[var12], (double)2.0F)) * (double)10.0F + (double)0.5F);
  855.             }
  856.  
  857.             if (this.nSector[var12] == 1) {
  858.                this.vel0[var12] = this.velS;
  859.             }
  860.  
  861.             StringBuffer var15 = new StringBuffer();
  862.             String[] var18 = this.velText;
  863.             var18[var12] = var15.append(var18[var12]).append(" <br/>  <up>").append(Double.toString((double)((int)(this.p10[var12] / 6.2831853 * this.period[var12] * (double)100.0F + (double)0.5F)) / (double)100.0F)).append("<tab/>").append(Double.toString((double)this.velS / (double)10.0F)).toString();
  864.             this.velTA[var12].setText(this.velText[var12]);
  865.             double[] var16 = this.p10;
  866.             var16[var12] += 0.62731853;
  867.             if (this.nSector[var12] == 10) {
  868.                var16 = this.p10;
  869.                var16[var12] -= 0.005;
  870.             }
  871.          }
  872.       }
  873.  
  874.    }
  875.  
  876.    public void start() {
  877.    }
  878.  
  879.    public void stop() {
  880.    }
  881.  
  882.    public void destroy() {
  883.    }
  884.  
  885.    public static void main(String[] var0) {
  886.       kepler var1 = new kepler();
  887.       isStandalone = true;
  888.       frame.addWindowListener(new kepler$29());
  889.       frame.setTitle("Kepler's laws");
  890.       frame.add(var1, "Center");
  891.       var1.init();
  892.       var1.start();
  893.       frame.setSize(790, 560);
  894.       Dimension var2 = Toolkit.getDefaultToolkit().getScreenSize();
  895.       frame.setLocation((var2.width - frame.getSize().width) / 2, (var2.height - frame.getSize().height) / 2);
  896.       frame.setVisible(true);
  897.    }
  898.  
  899.    public String getAppletInfo() {
  900.       return "Applet Information";
  901.    }
  902.  
  903.    public String[][] getParameterInfo() {
  904.       return null;
  905.    }
  906.  
  907.    static {
  908.       bkgColB = bkgCol;
  909.       buttonColor = bkgCol.darker().darker().darker();
  910.       pageTitle = new String[]{"1 - Draw orbits", "2 - Kepler's laws", "3 - Resonances"};
  911.       frame = new Frame();
  912.    }
  913. }
  914.