Esempio n. 1
0
 /** Draws clusters */
 public void draw(DrawingPanel panel, Graphics g) {
   if (site == null) {
     return;
   }
   int sizeX = Math.abs(panel.xToPix(1.0) - panel.xToPix(0));
   int sizeY = Math.abs(panel.yToPix(1.0) - panel.yToPix(0));
   for (int i = 0; i < numberOfParticles; i++) {
     int xpix = panel.xToPix(x[i]) - sizeX;
     int ypix = panel.yToPix(y[i]) - sizeY;
     g.fillRect(xpix + sizeX / 2, ypix + sizeY / 2, sizeX, sizeY);
   }
 }
Esempio n. 2
0
 /**
  * Constructs OscillatorsMode with the given mode and number of particles.
  *
  * <p>The particle separation is one in this model.
  *
  * @param mode int
  * @param N int
  */
 OscillatorsMode(int mode, int N) {
   amplitude = Math.sqrt(2.0 / (N + 1));
   omega = 2 * Math.sqrt(OMEGA_SQUARED) * Math.abs(Math.sin(mode * Math.PI / N / 2));
   wavenumber = Math.PI * mode / (N + 1);
   functionDrawer = new FunctionDrawer(this);
   functionDrawer.initialize(0, N + 1, 300, false); // draws the initial displacement
   functionDrawer.color = Color.LIGHT_GRAY;
 }