//LightClock.java import EinsteinObject; import java.awt.Graphics; import java.awt.Color; import photon; public class LightClock extends EinsteinObject { int height = 10; int count = 0; int L = 0; double lastNum = 0; boolean direction = true; photon ph= null; public LightClock(double v, Einstein EIN) { super(v,EIN); length = 30; L = 2*length; ph = new photon(EIN); } public void Increment() { super.Increment(); } public void draw(boolean whichFrame, Graphics g) { Reality displayReality; double position; double theTime; double gamma; double velocity; if (whichFrame == Reality.OBJECT_FRAME) { displayReality = getReality(); position = displayReality.myX; theTime = displayReality.myTime; gamma = 1; velocity = 0; } else { displayReality = EIN.getReality(); velocity = displayReality.getV(); position = displayReality.theirX; theTime = displayReality.theirTime; gamma = displayReality.gamma; } //if (ph == null) // ph = new photon(-length/gamma,0,EIN); g.setColor(Color.blue); for (int loop = 1;loop<4;loop++) { g.drawLine(EIN.space.mapX(position)-(int)(length/gamma)-loop,EIN.space.mapY(0)-height,EIN.space.mapX(position)-(int)(length/gamma)-loop,EIN.space.mapY(0)+height); g.drawLine(EIN.space.mapX(position)+(int)(length/gamma)+loop,EIN.space.mapY(0)-height,EIN.space.mapX(position)+(int)(length/gamma)+loop,EIN.space.mapY(0)+height); } ph.setLength(length/gamma); ph.spacedraw(theTime,position,gamma,velocity,height,g); } public void timeDraw(boolean whichFrame, Graphics g) { Reality real = EIN.getReality(); double gamma = real.gamma; double position = real.theirX; double velocity = real.getV(); double theTime = real.myTime; double place = 0; if (EIN.frame == Reality.OBJECT_FRAME) { gamma = 1; real = EIN.mover.getReality(); g.setColor(Color.blue); position = real.myX; theTime = real.myTime; velocity = 0; EIN.time.drawPoint(real.myX-(length/gamma),real.myTime,g); EIN.time.drawPoint(real.myX+(length/gamma),real.myTime,g); g.setColor(Color.green); EIN.time.drawLine(real.myX-(length/gamma),real.myTime,-(length/gamma),0,g); EIN.time.drawLine(real.myX+(length/gamma),real.myTime,+(length/gamma),0,g); g.setColor(Color.red); EIN.time.drawPoint(real.theirX,real.myTime,g); g.setColor(Color.black); EIN.time.drawLine(real.theirX,real.myTime,0,0,g); place = EIN.getReality().theirX; } else { g.setColor(Color.red); EIN.time.drawPoint(real.myX,real.myTime,g); g.setColor(Color.blue); EIN.time.drawPoint(real.theirX-(length/gamma),real.myTime,g); EIN.time.drawPoint(real.theirX+(length/gamma),real.myTime,g); g.setColor(Color.blue); EIN.time.drawLine(real.theirX-(length/gamma),real.myTime,-(length/gamma),0,g); EIN.time.drawLine(real.theirX+(length/gamma),real.myTime,(length/gamma),0,g); g.setColor(Color.black); EIN.time.drawLine(real.myX,real.myTime,0,0,g); place = EIN.mover.getReality().myX; } ph.setLength(length/gamma); ph.draw(theTime,place,velocity,g); //g.setColor(Color.yellow); //double lightStartX = -(length/gamma);double lightStartT = 0; /*int direction = 1; while (theTime > 0) { EIN.time.drawLine((int)lightStartX,(int)lightStartT,(int)(direction *(L/gamma)+lightStartX),(int)(60+lightStartT),g); theTime -= (L/gamma); direction = direction * -1; if (direction == 1) { lightStartX = (length/gamma); } else { lightStartX = -(length/gamma); } lightStartT += (L/gamma); }*/ //EIN.time.drawLine((int)lightStartX,(int)lightStartT,(int)(theTime+lightStartX),(int)(theTime+lightStartT),g); //ph.draw(g); } }