// BGRoll.java // Draw Rolling String // by nagatani@eken.phys.nagoya-u.ac.jp import java.applet.Applet; import java.awt.*; public class BGRoll extends StringRoll { int xOffset; int xPos, yPos; BGRoll (Image imageBG, int xOffset, Applet applet) { super (imageBG, 0, 0, applet); this.xOffset = xOffset; nMode = 0; } public void paint (Graphics g, Applet applet) { g.drawImage (imageString, xPos, yPos - yImage, applet); if (yPos < yWindow) g.drawImage (imageString, xPos, yPos, applet); } public void move () { // Every Time Displaying Mode double T = t + 0.03 * Math.sin ( 3 * 2.0*Math.PI*t + 1) + 0.01 * Math.sin ( 5 * 2.0*Math.PI*t + 2) + 0.003 * Math.sin (14 * 2.0*Math.PI*t + 3); xPos = (int) (xOffset + 5 * Math.sin ( 2 * 2.0*Math.PI*t + 0) + 3 * Math.sin ( 6 * 2.0*Math.PI*t + 1) + 2 * Math.sin (10 * 2.0*Math.PI*t + 2)); yPos = (int) ((1.0 - T) * yImage); t += 0.01; if (t >= 1.0) { t = 0.0; } return; } }