import java.applet.Applet; import java.awt.*; import java.util.Date; import java.util.StringTokenizer; public class BiorhythmApplet extends Applet { private Biorhythm yourBiorhythm; private BiorhythmCanvas biorhythmCanvas; private ControlPanel controlPanel; private SetDaysFrame setDaysFrame; public void init() { setBiorhythmParameters(); biorhythmCanvas = new BiorhythmCanvas(yourBiorhythm); setDaysFrame = new SetDaysFrame("Set Days", biorhythmCanvas, yourBiorhythm); controlPanel = new ControlPanel(setDaysFrame, biorhythmCanvas, yourBiorhythm); setColorParameters(); setImageParameters(); setLayout(new BorderLayout()); add("Center", biorhythmCanvas); add("South", controlPanel); } private void setBiorhythmParameters() { int birthdayYear, birthdayMonth, birthdayDate; int calcYear, calcMonth, calcDate; String s; StringTokenizer st; birthdayYear = 1969; birthdayMonth = 12; birthdayDate = 12; s = getParameter("birthday"); if (s != null) { st = new StringTokenizer(s); if (st.countTokens() == 3) { try { birthdayYear = Integer.parseInt(st.nextToken()); birthdayMonth = Integer.parseInt(st.nextToken()); birthdayDate = Integer.parseInt(st.nextToken()); } catch (NumberFormatException e) { } } } Date d = new Date(); calcYear = d.getYear() + 1900; calcMonth = d.getMonth() + 1; calcDate = d.getDate(); s = getParameter("calculateDay"); if (s != null) { st = new StringTokenizer(s); if (st.countTokens() == 3) { try { calcYear = Integer.parseInt(st.nextToken()); calcMonth = Integer.parseInt(st.nextToken()); calcDate = Integer.parseInt(st.nextToken()); } catch (NumberFormatException e) { } } } yourBiorhythm = new Biorhythm(birthdayYear, birthdayMonth, birthdayDate, calcYear, calcMonth, calcDate); } private void setColorParameters() { String s; Color c; s = getParameter("physicalColor"); try { c = new Color(Integer.parseInt(s, 16)); biorhythmCanvas.setPhysicalColor(c); } catch (NumberFormatException e) { } s = getParameter("sensitivityColor"); try { c = new Color(Integer.parseInt(s, 16)); biorhythmCanvas.setSensitivityColor(c); } catch (NumberFormatException e) { } s = getParameter("intellectualColor"); try { c = new Color(Integer.parseInt(s, 16)); biorhythmCanvas.setIntellectualColor(c); } catch (NumberFormatException e) { } s = getParameter("borderLineColor"); try { c = new Color(Integer.parseInt(s, 16)); biorhythmCanvas.setBorderLineColor(c); } catch (NumberFormatException e) { } s = getParameter("biorhythmGraphColor"); try { c = new Color(Integer.parseInt(s, 16)); biorhythmCanvas.setBiorhythmGraphColor(c); } catch (NumberFormatException e) { } s = getParameter("backgroundColor"); try { c = new Color(Integer.parseInt(s, 16)); biorhythmCanvas.setBackgroundColor(c); } catch (NumberFormatException e) { } s = getParameter("ControlPanelColor"); try { c = new Color(Integer.parseInt(s, 16)); controlPanel.setBackgroundColor(c); } catch (NumberFormatException e) { } s = getParameter("stringColor"); try { c = new Color(Integer.parseInt(s, 16)); biorhythmCanvas.setStringColor(c); } catch (NumberFormatException e) { } } private void setImageParameters() { String s; Image i; s = getParameter("physicalImage"); if (s != null) { i = getImage(getDocumentBase(), s); biorhythmCanvas.setPhysicalImage(i); } s = getParameter("sensitivityImage"); if (s != null) { i = getImage(getDocumentBase(), s); biorhythmCanvas.setSensitivityImage(i); } s = getParameter("intellectualImage"); if (s != null) { i = getImage(getDocumentBase(), s); biorhythmCanvas.setIntellectualImage(i); } } }