/********************************************************************** Java spinorb04 (Berry's Phase and Fine Structure) Applet, version 1.020824 by Bernd Binder (c) 2002 (binder@quanics.com) **********************************************************************/ import java.applet.Applet; import java.awt.*; public class spinorb04 extends Applet { double MMM; int mode1, mode2; Font font; Label sliderLabelMMM; Label epiLabelMMM; Label hypoLabelMMM; Scrollbar sliderMMM; String sliderTextMMM; Panel panel1,panel2, panel3, panel4; Button but137; Checkbox rho_gt_RRadioButton; Checkbox rho_lt_RRadioButton; Checkbox rho_eq_RRadioButton; Checkbox freeRadioButton; Checkbox fullRadioButton; Checkbox halfRadioButton; double pi,x0,y0,r00,M_a; public void init() { MMM = 7; mode1 = 3; mode2 = 3; pi = 3.1415926535897931D; x0 = 300D; y0 = 320D; r00 = 180D; panel1 = new Panel(); panel1.setLayout(new GridLayout(3, 1)); CheckboxGroup checkboxgroup1 = new CheckboxGroup(); rho_lt_RRadioButton = new Checkbox("hypoepi", checkboxgroup1, false); panel1.add(rho_gt_RRadioButton); panel2 = new Panel(); panel2.setLayout(new GridLayout(3, 1)); CheckboxGroup checkboxgroup2 = new CheckboxGroup(); freeRadioButton = new Checkbox("free", checkboxgroup2, false); panel2.add(freeRadioButton); fullRadioButton = new Checkbox("integer", checkboxgroup2, false); panel2.add(fullRadioButton); halfRadioButton = new Checkbox("half", checkboxgroup2, true); panel2.add(halfRadioButton); panel3 = new Panel(); panel3.setLayout(new GridLayout(3, 1)); sliderLabelMMM = new Label("M = " + MMM + " "); panel3.add(sliderLabelMMM); epiLabelMMM = new Label(" "); panel3.add(epiLabelMMM); hypoLabelMMM = new Label(" "); panel3.add(hypoLabelMMM); panel4 = new Panel(); panel4.setLayout(new GridLayout(3, 1)); font = new Font("Helvetica", 1, 18); sliderMMM = new Scrollbar(0, (int)MMM, 15, 2, 165); panel4.add(sliderMMM); sliderMMM.setValue((int)(MMM)); panel4.add(but137 = new Button(" 137 ")); add(panel1); add(panel2); add(panel3); add(panel4); setBackground(Color.white); setForeground(Color.black); repaint(); } public boolean handleEvent(Event event) { if(event.target == sliderMMM) { int i = sliderMMM.getValue(); MMM = i; if(MMM < 2) MMM = 2; else if(MMM > 150) MMM = 150; repaint(); sliderLabelMMM.setText("M = " + MMM + " "); sliderMMM.setValue((int)(MMM)); return true; } if(event.target == but137) { MMM = 137; repaint(); sliderMMM.setValue(137); return true; } if(event.target == rho_gt_RRadioButton) { mode1 = 1; repaint(); return true; } if(event.target == rho_eq_RRadioButton) { mode1 = 2; repaint(); return true; } if(event.target == rho_lt_RRadioButton) { mode1 = 3; repaint(); return true; } if(event.target == freeRadioButton) { mode2 = 1; repaint(); return true; } if(event.target == fullRadioButton) { mode2 = 2; repaint(); return true; } if(event.target == halfRadioButton) { mode2 = 3; repaint(); return true; } // else { return false; } } public void paint(Graphics g2d) { /* Graphics2D g2d = (Graphics2D)g; g2d.setBackground(getBackground()); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); */ Dimension d = getSize(); x0 = d.width/2.0; y0 = d.height/2.0+30; g2d.clipRect(0, 60, d.width, d.height-60); g2d.clearRect(0, 60, d.width, d.height-60); //*******************Feedback-Loop**************************** M_a = 1.0; for(int i = 30; i > -1; i--) M_a = (double)MMM / Math.cos(pi / M_a); //************************************************************ double NNN = 1.0 / (1.0 - Math.cos(pi / M_a)), NNN0=NNN, sf =1.0; double phi_t = 2 * pi / (double)MMM; double phi_d = phi_t; double phi_g = 0; phi_g = 2 * pi / M_a; phi_d = phi_t - phi_g; // double d5 = (double)Math.round((phi_g / phi_d) * 100000D) / 100000D; double rrd = r00 * Math.cos(phi_g/2.0); double rrg = r00 - rrd; sliderLabelMMM.setText("M = " + MMM + " "); if(mode2 > 1) NNN0 = (double)(int)(NNN+0.5); // if(mode2 == 2 ) NNN0 = NNN0 + 1.0; if(mode2 == 3 ) NNN0 = NNN0 + 0.5; for(int ty_ = -1; ty_ <= 1; ty_=ty_+2) { if(mode1 == 1 ) { NNN=NNN0-sf*ty_; } if(mode1 == 2 ) { NNN=NNN0; } if(mode1 == 3 ) { NNN=NNN0+sf*ty_; } double ra = r00/NNN0; double d4 = (double)Math.round(MMM/(1.0-1.0/(NNN)) * 1000000000D) / 1000000000D; if (ty_ <0) epiLabelMMM.setText(""+ d4 + ", " + (NNN-1) + " ");; if (ty_ >0) hypoLabelMMM.setText(""+ d4 + ", " + (NNN-1) + " ");; float af[] = {5F, 3F, 5F, 3F}; // g2d.setStroke(new BasicStroke(4F, 0, 0, 10F, af, 0.0F)); if (MMM < 10) { g2d.setColor(new Color(90,90,90)); g2d.fillArc((int)((x0 - r00) + 0.5D), (int)((y0 - r00) + 0.5D), (int)(2D * r00 + 0.5D), (int)(2D * r00 + 0.5D), -(int)((180D / pi) * (phi_t + phi_d/2.0)+0.5), -(int)(360 / MMM+0.5)); g2d.setColor(new Color(190,110,190)); g2d.fillArc((int)((x0 - r00) + 0.5D), (int)((y0 - r00) + 0.5D), (int)(2D * r00 + 0.5D), (int)(2D * r00 + 0.5D), -(int)((180D / pi) * (phi_t + phi_d/2.0)+0.5), -(int)(360D / M_a+0.5)); g2d.setColor(new Color(190,190,190)); g2d.fillArc((int)((x0 - rrd) + 0.5D), (int)((y0 - rrd) + 0.5D), (int)(2D * rrd + 0.5D), (int)(2D * rrd + 0.5D), -(int)((180D / pi) * (phi_t + phi_d/2.0)+0.5), -(int)(360 / MMM+0.5)); } for(int j = 0; j < MMM; j++) { double d9 = x0 + r00 * Math.cos((double)((j - 1)) * phi_t + phi_d/2.0); double d10 = y0 + r00 * Math.sin((double)((j - 1)) * phi_t + phi_d/2.0); double d11 = x0 + r00 * Math.cos((double)(j) * phi_t - phi_d/2.0); double d12 = y0 + r00 * Math.sin((double)(j) * phi_t - phi_d/2.0); g2d.setColor(Color.gray); g2d.drawLine((int)(x0 + 0.5D), (int)(y0 + 0.5D), (int)(d9 + 0.5D), (int)(d10 + 0.5D)); g2d.drawLine((int)(x0 + 0.5D), (int)(y0 + 0.5D), (int)(d11 + 0.5D), (int)(d12 + 0.5D)); g2d.drawLine((int)(d9 + 0.5D), (int)(d10 + 0.5D), (int)(d11 + 0.5D), (int)(d12 + 0.5D)); } g2d.setColor(Color.black); g2d.drawOval((int)((x0 - r00) + 0.5D), (int)((y0 - r00) + 0.5D), (int)(2D * r00 + 0.5D), (int)(2D * r00 + 0.5D)); double RR=ra*NNN; if (ty_ <0) g2d.setColor(Color.blue); if (ty_ >0) g2d.setColor(Color.red); g2d.drawOval((int)((x0 - RR) + 0.5D), (int)((y0 - RR) + 0.5D), (int)(2D * RR + 0.5D), (int)(2D * RR + 0.5D)); g2d.drawOval((int)((x0 - RR+ra) + 0.5D), (int)((y0 - RR+ra) + 0.5D), (int)(2D * (RR-ra) + 0.5D), (int)(2D * (RR-ra) + 0.5D)); g2d.drawOval((int)((x0 - RR-ra) + 0.5D), (int)((y0 - RR-ra) + 0.5D), (int)(2D * (RR+ra) + 0.5D), (int)(2D * (RR+ra) + 0.5D)); double d14 = 1.0, d16 = 0, d18 = 0, d20 = 0, d21 = 0; int fak = 20; if (mode2>1) fak=4; if(MMM < 30) for(int i1 = 0; i1 < 250D*fak; i1++) { double phi; phi = ((double)i1 / 250D) * pi; double d17 = x0 + ra*( ty_* Math.sin(NNN * phi) + NNN * Math.cos(phi)); double d19 = y0 - ra*(- Math.cos(NNN * phi) + NNN * Math.sin(phi)); if(i1 > 0) g2d.drawLine((int)(d20 + 0.5D), (int)(d21 + 0.5D), (int)(d17 + 0.5D), (int)(d19 + 0.5D)); d20 = d17; d21 = d19; } } } }