public void mouseClicked() { ArrayList objects = timeline.getStatefulObjects(); for (int i = 0; i < objects.size(); i++) { CelestialObject obj = (CelestialObject) objects.get(i); if (obj.isMouseOver()) { println(obj.getName() + " clicked!"); break; } } }
public void draw() { background(0); fill(255); if (!paused) timeline.moveForward(); if (dragging) drawOrbits(timeline.getFutureObjectStates()); else drawOrbits(timeline.getPastObjectStates()); ArrayList objects = timeline.getStatefulObjects(); for (int i = 0; i < objects.size(); i++) { CelestialObject obj = (CelestialObject) objects.get(i); obj.display(); } }
public void mouseDragged() { if (paused) { ArrayList objects = timeline.getStatefulObjects(); for (int i = 0; i < objects.size(); i++) { CelestialObject obj = (CelestialObject) objects.get(i); if (obj.isMouseOver()) { dragging = true; PVector pos = obj.getPosition(); pos.x = mouseX; pos.y = mouseY; timeline.reset(); timeline.setCurrentState(objects); sliderTimeline.setValue(0); break; } } } }