home *** CD-ROM | disk | FTP | other *** search
Wrap
import java.applet.Applet; import java.awt.Button; import java.awt.Checkbox; import java.awt.CheckboxGroup; import java.awt.Choice; import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Cursor; import java.awt.Dimension; import java.awt.Font; import java.awt.Frame; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import java.awt.LayoutManager; import java.awt.MediaTracker; import java.awt.RenderingHints; import java.awt.TextField; import java.awt.Toolkit; import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.image.ImageObserver; import java.net.MalformedURLException; import java.net.URL; import javax.swing.JPanel; public class kepler extends Applet implements Runnable { static boolean isStandalone = false; static boolean painting = false; static final Cursor cHair = new Cursor(1); static final Cursor cHand = new Cursor(12); static final Cursor cDefault = new Cursor(0); static final Color yellow = new Color(255, 255, 170); static final Color mauve = new Color(200, 200, 255); static final Color[] cEl = new Color[]{new Color(255, 200, 0), new Color(0, 255, 180)}; static final Color bkgCol = new Color(125, 185, 183); static final Color bkgColB; static final Color buttonColor; int imageNo; MediaTracker tracker; Thread timer; static final String courseTitle = "S283 Planetary Science and the Search for Life"; static final String apName = "Kepler's laws"; static final String[] pageTitle; WButton runB = new WButton("run"); WButton speedUpB = new WButton("speed up"); WButton slowDownB = new WButton("slow down"); WButton resetB = new WButton("reset"); // $FF: renamed from: a double[] double[] field_0 = new double[]{(double)2.0F, (double)2.0F}; double[] amin = new double[]{(double)0.25F, (double)0.25F}; double[] amax = new double[]{(double)100.0F, (double)100.0F}; // $FF: renamed from: e double[] double[] field_1 = new double[]{(double)0.0F, (double)0.0F}; // $FF: renamed from: q double[] double[] field_2; double[] qmin; double[] qmax; double[] emax; // $FF: renamed from: b double[] double[] field_3; // $FF: renamed from: aq double[] double[] field_4; double[] th0; double[] cTh0; double[] sTh0; int elNo; String imageName; String units; Image image; // $FF: renamed from: qL java.awt.TextField[] TextField[] field_5; // $FF: renamed from: aL java.awt.TextField[] TextField[] field_6; // $FF: renamed from: eL java.awt.TextField[] TextField[] field_7; // $FF: renamed from: tL java.awt.TextField[] TextField[] field_8; // $FF: renamed from: vf java.awt.TextField TextField field_9; TextDrawPanel orangePropsTA; TextDrawPanel greenPropsTA; TextDrawPanel[] velTA; String[] velText; int imY; int imY2; int width; int height; int page; int sMax; WScrollbar qSld; WScrollbar eSld; WScrollbar aSld; WScrollbar tSld; Choice resC; Choice planetC; CheckboxGroup cbg; CheckboxGroup cbg2; CheckboxGroup cbg3; CheckboxGroup cbg4; Checkbox e1Cb; Checkbox e2Cb; Checkbox[] animOrbCb; Checkbox fixA; Checkbox fixQ; Checkbox fixE; Checkbox progrdCb; Checkbox retrogrdCb; boolean[] progradeDirection; static final int appW = 790; static final int appH = 560; // $FF: renamed from: bW int static final int field_10 = 790; // $FF: renamed from: bH int static final int field_11 = 560; int cbn; String scaleString; WillFun willFun; boolean running; Font bOn; Font bOff; Font buttonFont; JPanel sliders; Image icon; int[][] ress; int[] planetChosen; double[][] planetData; String[] planetName; double vFac; public boolean[] vel10; public int[] nSector; int area; int section; double vfD; // $FF: renamed from: t double double field_12; // $FF: renamed from: px double[] double[] field_13; // $FF: renamed from: py double[] double[] field_14; // $FF: renamed from: vx double double field_15; // $FF: renamed from: vy double double field_16; double vy0; double vy1; double energy; double vxAtYisB; double[] period; boolean first; double xScl; double yScl; double[] p10; static final int graphx = 10; static final int graphy = 35; static final int graphw = 470; static final int graphh = 470; // $FF: renamed from: x0 int static final int field_17 = 235; // $FF: renamed from: y0 int static final int field_18 = 235; Image bufIm; Image graph; Image graphBak; Image bakIm; Image sun; Image planet; Graphics bufImG; Graphics appG; Graphics graphG; Graphics graphBakG; Graphics2D bufImG2; Graphics2D graphG2; Graphics2D graphBakG2; double[] opx; double[] opy; // $FF: renamed from: v double[] double[] field_19; // $FF: renamed from: sx int int field_20; // $FF: renamed from: sy int int field_21; static final int nps = 100; int[][] xEl; int[][] yEl; double distance; double ovy; boolean negx2; static final int nSteps = 100; static final int stepF = 20; // $FF: renamed from: pi double static final double field_22 = 3.14159265; static final double pi2 = 6.2831853; static final double pi4 = 12.5663706; static final double pi5 = 0.62731853; int miss; // $FF: renamed from: m double[] double[] field_23; // $FF: renamed from: dm double[] double[] field_24; int velS; int[] vel0; public static final Frame frame; public kepler() { 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])}; this.qmin = new double[]{(double)0.25F, (double)0.25F}; this.qmax = new double[]{this.amax[0] * ((double)1.0F - this.field_1[0]), this.amax[0] * ((double)1.0F - this.field_1[0])}; this.emax = new double[]{0.995, 0.995}; 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])}; this.field_4 = new double[]{this.field_0[0] - this.field_2[0], this.field_0[0] - this.field_2[0]}; this.th0 = new double[]{(double)0.0F, (double)0.0F}; this.cTh0 = new double[]{(double)1.0F, (double)1.0F}; this.sTh0 = new double[]{(double)0.0F, (double)0.0F}; this.elNo = 0; this.field_5 = new TextField[2]; this.field_6 = new TextField[2]; this.field_7 = new TextField[2]; this.field_8 = new TextField[2]; this.field_9 = new TextField(); this.orangePropsTA = new TextDrawPanel(); this.greenPropsTA = new TextDrawPanel(); this.velTA = new TextDrawPanel[]{new TextDrawPanel(), new TextDrawPanel()}; this.velText = new String[2]; this.imY = 20; this.imY2 = this.imY * 2; this.page = 1; this.sMax = 399; this.qSld = new kepler$1(this, 0, 0, this.sMax / 20, 0, this.sMax + this.sMax / 20); this.eSld = new kepler$2(this, 0, 0, this.sMax / 20, 0, this.sMax + this.sMax / 20); this.aSld = new kepler$3(this, 0, 0, this.sMax / 20, 0, this.sMax + this.sMax / 20); this.tSld = new kepler$4(this, 0, 0, this.sMax / 20, 0, this.sMax + this.sMax / 20); this.resC = new Choice(); this.planetC = new Choice(); this.cbg = new CheckboxGroup(); this.cbg2 = new CheckboxGroup(); this.cbg3 = new CheckboxGroup(); this.cbg4 = new CheckboxGroup(); this.e1Cb = new Checkbox("adjust orange orbit", this.cbg, true); this.e2Cb = new Checkbox("adjust green orbit", this.cbg, false); this.animOrbCb = new Checkbox[2]; this.fixA = new Checkbox("fix", this.cbg2, true); this.fixQ = new Checkbox("fix", this.cbg2, false); this.fixE = new Checkbox("fix", this.cbg2, false); this.progrdCb = new Checkbox("prograde", this.cbg3, true); this.retrogrdCb = new Checkbox("retrograde", this.cbg3, false); this.progradeDirection = new boolean[]{this.progrdCb.getState(), this.progrdCb.getState()}; this.willFun = new WillFun(); this.running = false; this.bOn = new Font("SanSerif", 1, 13); this.bOff = new Font("SanSerif", 0, 12); this.buttonFont = new Font("SanSerif", 1, 12); this.sliders = new JPanel(); this.ress = new int[][]{{1, 1, 1, 2, 2, 2, 3, 3, 5}, {1, 2, 3, 3, 5, 1, 1, 2, 2}}; this.planetChosen = new int[]{-1, -1}; 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}}; this.planetName = new String[]{"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"}; this.vFac = (double)1.0F; this.vel10 = new boolean[2]; this.nSector = new int[2]; this.area = 6; this.vfD = 0.01; this.field_12 = (double)0.0F; this.field_13 = new double[2]; this.field_14 = new double[2]; this.period = new double[]{Math.pow(this.field_0[0], (double)1.5F), Math.pow(this.field_0[1], (double)1.5F)}; this.first = true; this.xScl = (double)40.0F; this.yScl = (double)40.0F; this.p10 = new double[]{(double)0.0F, (double)0.0F}; this.opx = new double[]{(double)0.0F, (double)0.0F}; this.opy = new double[]{(double)0.0F, (double)0.0F}; this.field_19 = new double[]{(double)0.0F, (double)0.0F}; this.field_20 = 227; this.field_21 = 227; this.xEl = new int[2][100]; this.yEl = new int[2][100]; this.distance = (double)0.0F; this.ovy = (double)1.0F; this.negx2 = false; this.miss = 0; this.field_23 = new double[]{(double)0.0F, (double)0.0F}; this.field_24 = new double[]{6.2831853 / this.period[0], 6.2831853 / this.period[1]}; this.velS = 0; this.vel0 = new int[]{0, 0}; } public Image loadImage(String var1) { Image var2 = null; if (isStandalone) { var2 = Toolkit.getDefaultToolkit().getImage(var1); } else { URL var3 = ((Applet)this).getDocumentBase(); try { var2 = ((Applet)this).getImage(new URL(var3, var1)); } catch (MalformedURLException var5) { } } this.tracker.addImage(var2, this.imageNo++); return var2; } public Image setImage(int var1, int var2) { Image var3 = ((Component)this).createImage(var1, var2); this.tracker.addImage(var3, this.imageNo++); return var3; } public void init() { ((Container)this).setFont(this.bOff); this.timer = new Thread(this); this.timer.start(); ((Component)this).setBackground(new Color(213, 230, 227)); ((Component)this).addMouseMotionListener(new kepler$MML(this)); ((Component)this).addMouseListener(new kepler$ML(this)); ((Container)this).setLayout((LayoutManager)null); WillFun.ap = this; WillFun.isStandalone = isStandalone; WillFun.t = new MediaTracker(this); WillFun.imageNo = 0; this.icon = WillFun.loadImage("images/icon.gif"); WillFun.imageWait(); frame.setIconImage(this.icon); this.width = ((Component)this).getBounds().width; this.height = ((Component)this).getBounds().height; boolean var1 = true; int var2 = 4; byte var3 = 17; this.resC.setBounds(490, 500, 270, 20); this.resC.add("Change resonance of green orbit:"); for(this.cbn = 0; this.cbn < this.ress[0].length; ++this.cbn) { this.resC.add("periods of green : orange orbits = " + this.ress[1][this.cbn] + " : " + this.ress[0][this.cbn]); } this.resC.addItemListener(new kepler$5(this)); ((Container)this).add(this.resC, (Object)null); 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()); WButton[] var5 = new WButton[3]; for(this.cbn = 0; this.cbn < 3; ++this.cbn) { var5[this.cbn] = new WButton(pageTitle[this.cbn]); var5[this.cbn].setBounds(10 + this.cbn * 130, 5, 128, 20); var5[this.cbn].setFont(this.cbn == 0 ? this.bOn : this.bOff); var5[this.cbn].setForeground(buttonColor); var5[this.cbn].setBackground(bkgColB); var5[this.cbn].addActionListener(new kepler$6(this, var5)); ((Container)this).add(var5[this.cbn], (Object)null); } Frame var6 = new Frame(); ((Window)var6).addWindowListener(new kepler$7(this, var6)); ((Component)var6).setSize(400, 400); var6.setTitle("Kepler's laws - help"); var6.setIconImage(this.icon); WButton var7 = new WButton("help"); ((Component)var7).setBounds(640, 5, 60, 20); ((Component)var7).setFont(this.buttonFont); ((Component)var7).setForeground(buttonColor); ((Component)var7).setBackground(bkgColB); ((Button)var7).addActionListener(new kepler$8(this, var6)); WButton var8 = new WButton("about"); ((Component)var8).setBounds(710, 5, 60, 20); ((Component)var8).setFont(this.buttonFont); ((Component)var8).setForeground(buttonColor); ((Component)var8).setBackground(bkgColB); ((Button)var8).addActionListener(new kepler$9(this, var4)); ((Container)this).add(var8, (Object)null); this.e1Cb.setBounds(490, 30, 130, 15); this.e1Cb.addItemListener(new kepler$10(this)); ((Container)this).add(this.e1Cb, (Object)null); this.e2Cb.setBounds(490, 270, 130, 15); this.e2Cb.addItemListener(new kepler$11(this)); ((Container)this).add(this.e2Cb, (Object)null); for(this.cbn = 0; this.cbn < 2; ++this.cbn) { this.animOrbCb[this.cbn] = new Checkbox("show " + (this.cbn == 0 ? "orange" : "green") + " orbit"); this.animOrbCb[this.cbn].setBounds(630, 30 + this.cbn * 240, 130, 15); this.animOrbCb[this.cbn].setState(true); this.animOrbCb[this.cbn].addItemListener(new kepler$12(this)); ((Container)this).add(this.animOrbCb[this.cbn], (Object)null); } this.animOrbCb[1].setState(false); byte var9 = 50; this.sliders.setOpaque(false); this.sliders.setBackground(((Component)this).getBackground()); this.sliders.setLayout((LayoutManager)null); this.sliders.setBounds(490, 50, 100 + var9, 160); ((Container)this).add(this.sliders, (Object)null); for(int var10 = 0; var10 < 9; ++var10) { this.planetData[1][var10] = this.planetData[0][var10] * ((double)1.0F - this.planetData[2][var10]); } this.planetC.setBounds(0, var2 - 4, 90 + var9, 20); this.planetC.add("Planet orbit:"); for(this.cbn = 0; this.cbn < 9; ++this.cbn) { this.planetC.add(this.planetName[this.cbn]); } this.planetC.addItemListener(new kepler$13(this)); this.sliders.add(this.planetC, (Object)null); var9 = 110; var2 += 30; this.aSld.setBounds(0, var2, 105, 13); this.aSld.addAdjustmentListener(new kepler$14(this)); this.sliders.add(this.aSld, (Object)null); this.fixA.setBounds(var9, var2, 35, 15); this.fixA.addItemListener(new kepler$15(this)); this.sliders.add(this.fixA, (Object)null); var2 += var3 * 2; this.qSld.setBounds(0, var2, 105, 13); this.qSld.addAdjustmentListener(new kepler$16(this)); this.sliders.add(this.qSld, (Object)null); this.fixQ.setBounds(var9, var2, 35, 15); this.fixQ.addItemListener(new kepler$17(this)); this.sliders.add(this.fixQ, (Object)null); var2 += var3 * 2; this.eSld.setBounds(0, var2, 105, 13); this.eSld.addAdjustmentListener(new kepler$18(this)); this.sliders.add(this.eSld, (Object)null); this.fixE.setBounds(var9, var2, 35, 15); this.fixE.addItemListener(new kepler$19(this)); this.sliders.add(this.fixE, (Object)null); var2 += var3; this.tSld.setBounds(0, var2, 140, 13); this.tSld.addAdjustmentListener(new kepler$20(this)); this.sliders.add(this.tSld, (Object)null); var2 += var3 + 2; this.progrdCb.setBounds(0, var2, 100, 15); this.progrdCb.addItemListener(new kepler$21(this)); this.sliders.add(this.progrdCb, (Object)null); var2 += var3 - 2; this.retrogrdCb.setBounds(0, var2, 100, 15); this.retrogrdCb.addItemListener(new kepler$22(this)); this.sliders.add(this.retrogrdCb, (Object)null); this.orangePropsTA.setBounds(635, 50, 140, 190); ((Container)this).add(this.orangePropsTA, (Object)null); this.velTA[0].setBounds(490, 50, 130, 205); this.velTA[0].setTabWidth(65); ((Container)this).add(this.velTA[0], (Object)null); this.greenPropsTA.setBounds(635, 290, 140, 190); ((Container)this).add(this.greenPropsTA, (Object)null); this.velTA[1].setBounds(490, 290, 130, 205); this.velTA[1].setTabWidth(65); ((Container)this).add(this.velTA[1], (Object)null); short var11 = 480; this.runB.setBounds(25, var11, 50, 20); this.runB.setForeground(buttonColor); this.runB.setBackground(bkgColB); this.runB.setFont(this.buttonFont); this.runB.addActionListener(new kepler$23(this)); ((Container)this).add(this.runB, (Object)null); this.resetB.setBounds(80, var11, 50, 20); this.resetB.setForeground(buttonColor); this.resetB.setBackground(bkgColB); this.resetB.setFont(this.buttonFont); this.resetB.addActionListener(new kepler$24(this)); ((Container)this).add(this.resetB, (Object)null); WButton var12 = new WButton("zoom in"); WButton var13 = new WButton("zoom out"); ((Component)var12).setBounds(135, var11, 70, 20); ((Component)var12).setForeground(buttonColor); ((Component)var12).setBackground(bkgColB); ((Component)var12).setFont(this.buttonFont); ((Button)var12).addActionListener(new kepler$25(this)); ((Container)this).add(var12, (Object)null); ((Component)var13).setBounds(210, var11, 70, 20); ((Component)var13).setForeground(buttonColor); ((Component)var13).setBackground(bkgColB); ((Component)var13).setFont(this.buttonFont); ((Button)var13).addActionListener(new kepler$26(this)); ((Container)this).add(var13, (Object)null); this.speedUpB.setBounds(295, var11, 70, 20); this.speedUpB.setForeground(buttonColor); this.speedUpB.setBackground(bkgColB); this.speedUpB.setFont(this.buttonFont); this.speedUpB.addActionListener(new kepler$27(this)); ((Container)this).add(this.speedUpB, (Object)null); this.slowDownB.setEnabled(false); this.slowDownB.setBounds(370, var11, 70, 20); this.slowDownB.setForeground(buttonColor); this.slowDownB.setBackground(bkgColB); this.slowDownB.setFont(this.buttonFont); this.slowDownB.addActionListener(new kepler$28(this)); ((Container)this).add(this.slowDownB, (Object)null); this.fixA(0); this.fixA(1); } public void fixSliders() { if (this.fixA.getState()) { this.fixA(this.elNo); } if (this.fixQ.getState()) { this.fixQ(this.elNo); } if (this.fixE.getState()) { this.fixE(this.elNo); } this.progrdCb.setState(this.progradeDirection[this.elNo]); this.retrogrdCb.setState(!this.progradeDirection[this.elNo]); } public void fixA(int var1) { this.qmax[var1] = this.field_0[var1]; this.emax[var1] = (double)1.0F - this.qmin[var1] / this.field_0[var1]; this.aSld.setEnabled(false); this.qSld.setEnabled(true); this.eSld.setEnabled(true); this.changeEll(var1, ' '); } public void fixQ(int var1) { this.amin[var1] = this.field_2[var1] > (double)0.25F ? this.field_2[var1] : (double)0.25F; this.emax[var1] = (double)1.0F - this.field_2[var1] / this.amax[var1]; if (this.emax[var1] > 0.995) { this.emax[var1] = 0.995; } this.amax[var1] = this.field_2[var1] / ((double)1.0F - this.emax[var1]); this.aSld.setEnabled(true); this.qSld.setEnabled(false); this.eSld.setEnabled(true); this.changeEll(var1, ' '); } public void fixE(int var1) { this.amax[var1] = (double)100.0F; this.amin[var1] = this.qmin[var1] / ((double)1.0F - this.field_1[var1]); if (this.amin[var1] < (double)0.25F) { this.amin[var1] = (double)0.25F; } this.qmax[var1] = this.amax[var1] * ((double)1.0F - this.field_1[var1]); this.qmin[var1] = this.amin[var1] * ((double)1.0F - this.field_1[var1]); this.aSld.setEnabled(true); this.qSld.setEnabled(true); this.eSld.setEnabled(false); this.changeEll(var1, ' '); } public void changeEll(int var1, char var2) { if (var2 != 'e') { this.eSld.setValue((int)(this.field_1[var1] / this.emax[var1] * (double)this.sMax)); } if (var2 != 'a') { this.aSld.setValue((int)((this.field_0[var1] - this.amin[var1]) / (this.amax[var1] - this.amin[var1]) * (double)this.sMax)); } if (var2 != 'q') { this.qSld.setValue((int)((this.field_2[var1] - this.qmin[var1]) / (this.qmax[var1] - this.qmin[var1]) * (double)this.sMax)); } if (var2 != 't') { this.tSld.setValue((int)(-this.th0[var1] / 6.2831853 * (double)this.sMax)); } ((Component)this).repaint(); } public void setControls(int var1) { if (this.running) { this.runB.dispatchEvent(new ActionEvent(this.runB, 1001, "")); } boolean var2 = var1 == 1; this.sliders.setVisible(var2); this.e1Cb.setVisible(var2); this.e2Cb.setVisible(var2); if (var1 == 1) { if (this.e1Cb.getState()) { this.animOrbCb[0].setState(true); } if (this.e2Cb.getState()) { this.animOrbCb[1].setState(true); } } this.animOrbCb[0].setEnabled(var1 > 1 || !this.e1Cb.getState()); this.animOrbCb[1].setEnabled(var1 > 1 || !this.e2Cb.getState()); this.planetC.setVisible(var2); var2 = var1 > 1; this.runB.setVisible(var2); this.resetB.setVisible(var2); this.velTA[0].setVisible(var2); this.velTA[1].setVisible(var2); this.speedUpB.setVisible(var2); this.slowDownB.setVisible(var2); var2 = var1 == 3; this.resC.setVisible(var2); this.drawBkg(); } public void setPeriod(int var1) { this.period[var1] = Math.pow(this.field_0[var1], (double)1.5F); this.p10[0] = (double)0.0F; this.p10[1] = (double)0.0F; if (this.period[var1] > this.period[1 - var1]) { this.field_24[1 - var1] = 0.03; this.field_24[var1] = 0.03 * this.period[1 - var1] / this.period[var1]; this.vFac = 996.9320676 / this.period[1 - var1]; } else { this.field_24[var1] = 0.03; this.field_24[1 - var1] = 0.03 * this.period[var1] / this.period[1 - var1]; this.vFac = 996.9320676 / this.period[var1]; } } public void reset() { this.drawBkg(); for(int var1 = 0; var1 < 2; ++var1) { this.velText[var1] = " Time<tab/>Velocity <br/> (years)<tab/>(km/s)"; this.velTA[var1].setText(this.velText[var1]); this.opx[var1] = this.field_2[var1] * this.cTh0[var1]; this.opy[var1] = this.field_2[var1] * this.sTh0[var1]; this.field_13[var1] = this.opx[var1]; this.field_14[var1] = this.opy[var1]; this.field_23[var1] = (double)0.0F; this.p10[var1] = (double)0.0F; this.vel10[var1] = true; this.nSector[var1] = 0; this.energy = this.field_16 * this.field_16 - (double)1.0F / this.field_2[var1]; 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; } this.field_12 = (double)0.0F; } public Image scaleImage(Image var1, double var2) { return var1.getScaledInstance((int)((double)var1.getWidth((ImageObserver)null) * var2), (int)((double)var1.getHeight((ImageObserver)null) * var2), 4); } public void paint(Graphics var1) { painting = true; if (this.first) { this.bufIm = WillFun.setImage(790, 560); this.graph = WillFun.setImage(470, 470); this.graphBak = WillFun.setImage(470, 470); this.sun = WillFun.loadImage("images/sun.gif"); this.planet = WillFun.loadImage("images/planet.gif"); WillFun.imageWait(); this.bufImG = this.bufIm.getGraphics(); this.graphG = this.graph.getGraphics(); this.graphG2 = (Graphics2D)this.graphG; this.graphG2.getRenderingHints().put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); this.graphG2.setFont(new Font("SansSerif", 2, 13)); this.graphBakG = this.graphBak.getGraphics(); this.graphBakG2 = (Graphics2D)this.graphBakG; this.graphBakG2.getRenderingHints().put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); this.appG = ((Component)this).getGraphics(); this.writeLabel(1); this.first = false; this.setControls(1); this.setPeriod(0); this.setPeriod(1); } this.graphG.drawImage(this.graphBak, 0, 0, (ImageObserver)null); this.graphG.setColor(Color.yellow); this.graphG.fillRect(233, 233, 4, 4); switch (this.page) { case 1: this.writeLabel(this.e1Cb.getState() ? 0 : 1); if (this.animOrbCb[0].getState()) { this.drawEll(0); } if (this.animOrbCb[1].getState()) { this.drawEll(1); } int var3 = (int)(this.cTh0[this.elNo] * this.xScl * this.field_2[this.elNo] + this.sTh0[this.elNo] * (double)4.0F); int var4 = (int)(this.cTh0[this.elNo] * (double)4.0F - this.sTh0[this.elNo] * this.yScl * this.field_2[this.elNo]); int var5 = (int)(-this.cTh0[this.elNo] * this.xScl * this.field_4[this.elNo]); int var6 = (int)(this.sTh0[this.elNo] * this.yScl * this.field_4[this.elNo]); this.graphG2.setColor(cEl[this.elNo]); this.graphG2.drawLine(235 + var5 + 3, 235 - var6 + 3, 235 + var5 - 3, 235 - var6 - 3); this.graphG2.drawLine(235 + var5 + 3, 235 - var6 - 3, 235 + var5 - 3, 235 - var6 + 3); var5 = (int)((double)var5 + this.sTh0[this.elNo] * (double)4.0F); var6 = (int)((double)var6 + this.cTh0[this.elNo] * (double)4.0F); this.graphG2.setRenderingHints(WillFun.aaOn); WillFun.drawDoubleArrow(this.graphG2, 235 + var3, 235 - var4, 235 + var5, 235 - var6); this.graphG2.setRenderingHints(WillFun.aaOff); 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); var3 = (int)(this.sTh0[this.elNo] * (double)-4.0F); var4 = (int)(this.cTh0[this.elNo] * (double)-4.0F); var5 = (int)(this.sTh0[this.elNo] * (double)-4.0F + this.cTh0[this.elNo] * this.xScl * this.field_2[this.elNo]); var6 = (int)(this.cTh0[this.elNo] * (double)-4.0F - this.sTh0[this.elNo] * this.yScl * this.field_2[this.elNo]); this.graphG2.setRenderingHints(WillFun.aaOn); WillFun.drawDoubleArrow(this.graphG2, 235 + var3, 235 - var4, 235 + var5, 235 - var6); this.graphG2.setRenderingHints(WillFun.aaOff); 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); break; case 2: case 3: for(int var2 = 0; var2 < 2; ++var2) { if (this.animOrbCb[var2].getState()) { int var7 = (int)(this.xScl * this.opx[var2]) + 235; int var8 = (int)(this.yScl * this.opy[var2]) + 235; this.drawEll(var2); this.graphG.setColor(Color.green); this.graphG.fillRect(var7 - 2, var8 - 2, 4, 4); this.graphG.setColor(cEl[var2]); this.graphG2.setRenderingHints(WillFun.aaOn); this.field_15 = this.field_13[var2] - this.opx[var2]; this.field_16 = this.field_14[var2] - this.opy[var2]; this.field_19[var2] = Math.sqrt(this.field_15 * this.field_15 + this.field_16 * this.field_16); 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)); this.graphG2.setRenderingHints(WillFun.aaOff); } } } this.bufImG.drawImage(this.graph, 10, 35, (ImageObserver)null); this.appG.drawImage(this.bufIm, 0, 0, (ImageObserver)null); painting = false; } public void writeLabel(int var1) { String var2 = ""; this.field_2[var1] = this.field_0[var1] * ((double)1.0F - this.field_1[var1]); this.field_3[var1] = this.field_0[var1] * Math.sqrt((double)1.0F - this.field_1[var1] * this.field_1[var1]); double var3 = (double)((int)(this.period[var1] * (double)10.0F)) / (double)10.0F; 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"; if (var1 == 0) { this.orangePropsTA.setText(var2); } else { this.greenPropsTA.setText(var2); } } public void drawBkg() { this.graphBakG.setColor(Color.black); this.graphBakG.fillRect(0, 0, 470, 470); this.graphBakG.setColor(Color.darkGray); this.graphBakG.drawLine(235, 0, 235, 470); this.graphBakG.drawLine(0, 235, 470, 235); } public void update(Graphics var1) { this.paint(var1); } public void drawEll(int var1) { this.graphG2.setRenderingHints(WillFun.aaOn); this.graphG2.setColor(cEl[var1]); this.field_4[var1] = this.field_0[var1] - this.field_2[var1]; int var8 = (int)(this.xScl * this.field_4[var1] * ((double)1.0F - this.cTh0[var1])); int var9 = -((int)(this.yScl * this.field_4[var1] * this.sTh0[var1])); for(int var10 = 0; var10 < 100; ++var10) { double var2 = (double)var10 * 6.283 / (double)100.0F; var2 -= Math.sin(var2 * (double)2.0F) / (double)2.0F; 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); double var4 = var2 + this.th0[var1]; this.xEl[var1][var10] = 235 + var8 + (int)(this.xScl * (var6 * Math.cos(var4) - this.field_4[var1])); this.yEl[var1][var10] = 235 + var9 + (int)(this.yScl * var6 * Math.sin(var4)); } this.graphG2.drawPolyline(this.xEl[var1], this.yEl[var1], 100); this.graphG2.setRenderingHints(WillFun.aaOff); } public void run() { while(this.timer != null) { if (this.running) { this.field_12 += (double)(this.miss + 1); for(int var1 = 0; var1 < this.miss; ++var1) { this.newPos(); } for(int var2 = 0; var2 < 2; ++var2) { this.opx[var2] = this.field_13[var2]; this.opy[var2] = this.field_14[var2]; } this.newPos(); ((Component)this).repaint(); } try { Thread.sleep(100L); } catch (Exception var3) { } } } public void newPos() { boolean var11 = false; for(int var12 = 0; var12 < 2; ++var12) { if (this.field_23[var12] >= this.p10[var12] && this.animOrbCb[var12].getState()) { var11 = true; int var10002 = this.nSector[var12]++; if (this.nSector[var12] < 11) { this.graphBakG.setColor(cEl[var12]); this.graphBakG2.setRenderingHints(WillFun.aaOn); this.graphBakG2.drawLine(235, 235, (int)(this.xScl * this.field_13[var12]) + 235, (int)(this.yScl * this.field_14[var12]) + 235); this.graphBakG2.setRenderingHints(WillFun.aaOff); } this.opx[var12] = this.field_13[var12]; this.opy[var12] = this.field_14[var12]; } double[] var10000 = this.field_23; for(var10000[var12] += this.field_24[var12]; this.field_23[var12] > 6.2831853; var10000[var12] -= 6.2831853) { var10000 = this.field_23; } double var1 = 3.14159265; double var3 = 1.570796325; for(int var13 = 0; var13 < 18; ++var13) { if (var1 - this.field_1[var12] * Math.sin(var1) > this.field_23[var12]) { var1 -= var3; } else { var1 += var3; } var3 /= (double)2.0F; } 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)); if (this.progradeDirection[var12]) { var7 = -var7; } 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)); this.field_13[var12] = var9 * Math.cos(var7 + this.th0[var12]); this.field_14[var12] = var9 * Math.sin(var7 + this.th0[var12]); if (var11 && this.nSector[var12] < 12) { var11 = false; if (this.nSector[var12] == 11) { this.velS = this.vel0[var12]; } else { 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); } if (this.nSector[var12] == 1) { this.vel0[var12] = this.velS; } StringBuffer var15 = new StringBuffer(); String[] var18 = this.velText; 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(); this.velTA[var12].setText(this.velText[var12]); double[] var16 = this.p10; var16[var12] += 0.62731853; if (this.nSector[var12] == 10) { var16 = this.p10; var16[var12] -= 0.005; } } } } public void start() { } public void stop() { } public void destroy() { } public static void main(String[] var0) { kepler var1 = new kepler(); isStandalone = true; frame.addWindowListener(new kepler$29()); frame.setTitle("Kepler's laws"); frame.add(var1, "Center"); var1.init(); var1.start(); frame.setSize(790, 560); Dimension var2 = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation((var2.width - frame.getSize().width) / 2, (var2.height - frame.getSize().height) / 2); frame.setVisible(true); } public String getAppletInfo() { return "Applet Information"; } public String[][] getParameterInfo() { return null; } static { bkgColB = bkgCol; buttonColor = bkgCol.darker().darker().darker(); pageTitle = new String[]{"1 - Draw orbits", "2 - Kepler's laws", "3 - Resonances"}; frame = new Frame(); } }