Newer
Older
AlgebraicDataflowArchitectureModel / AlgebraicDataflowArchitectureModel / src / simulator / interfaces / swing / ComponentVisibilityReceiver.java
package simulator.interfaces.swing;

import java.awt.Component;

import models.algebra.Constant;
import models.algebra.Expression;
import models.algebra.Term;
import models.dataConstraintModel.DataConstraintModel;
import simulator.Event;
import simulator.SystemState;
import simulator.interfaces.INativeReceiver;

public class ComponentVisibilityReceiver implements INativeReceiver {
	protected Component component;
	
	public ComponentVisibilityReceiver(Component component) {
		this.component = component;
	}

	@Override
	public void onReceiveFromModel(Event event, SystemState nextSystemState) {
		Expression message = event.getMessage();
		if (message instanceof Term) {
			Expression visible = ((Term) message).getChild(0);
			if (visible instanceof Constant) {
				if (((Constant) visible).getSymbol() == DataConstraintModel.true_) {
					component.setVisible(true);
				} else {
					component.setVisible(false);
				}
			}
		}
	}

}