Skip to content

Experiment

Zachary-Ronayne edited this page Oct 15, 2020 · 2 revisions

Model

Experiments primarily contain 3 lists.

  1. A list of Equipment
  2. A list of Chemicals
  3. A list of Instructions

The Equipment list individually stores each unique piece of Equipment which is associated with the Experiment. Note, this list does not store Equipment objects, it stores instances of EquipmentController2D, and that controller object stores the Equipment model. If Equipment objects are directly added to this list, it will not work, the model must first be placed into a controller. The list of Equipment can store multiple instances of the same piece of Equipment. For instance, if an Experiment has 10 beakers, it will have 10 individual objects, one for each beaker, and each object can have it's own different state. In most cases, do not add Equipment directly to an Experiment's Equipment list, add it using the addEquipment method in ExperimentController2D.

The Chemical list works in much the same way as the list of Equipment. The list stores Controller objects, not Chemical objects. All Chemicals in this list must first be placed into a Controller.

The Instruction list contains all of the Instructions which run the intended steps Experiment in the correct order from start to finish. Instructions should only be used by ExperimentController2D.

Most of the time, the entirety of an Experiment will be populated by data retrieved from the database. Normal objects should never add or remove Equipment, Chemicals, or Instructions from the Experiment model.

Controller

The Controller further contains lists for the Equipment. The list "placedEquipment", contains all of the Equipment which is currently in the lab, and can be interacted with by the user. This contains the same Equipment as the model class, but as references, meaning when Equipment is removed or added to placeEquipment, it does no change the model.

"selectedEquipment" is the Equipment which the user has selected by right clicking on it, and once selected, it will glow light blue on its edges. If no equipment is selected, the selectedEquipment will be null.

"movingEquipment" is the Equipment which the user is currently dragging around the simulation by left clicking and dragging.

"graphics" is the primary object used for rendering to the Experiment. To draw a rectangle in the Experiment, do not call rect() directly, instead, call graphics.rect().