package simulator.interfaces.swing; import java.awt.Component; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import models.algebra.Constant; import models.algebra.Expression; import models.algebra.Term; import models.dataConstraintModel.DataConstraintModel; import models.dataConstraintModel.ResourcePath; import models.dataFlowModel.DataTransferChannel; import simulator.Resource; import simulator.Simulator; import simulator.interfaces.NativeSender; public class ComponentMouseSender extends NativeSender implements MouseListener { public ComponentMouseSender(Simulator simulator, DataTransferChannel channel, ResourcePath resourcePath, Resource resource) { super(simulator, channel, resourcePath, resource); } public void mouseClicked(MouseEvent e) { } public void mousePressed(MouseEvent e) { Constant one = new Constant("1", DataConstraintModel.typeInt); Expression message = channel.getOutputChannelMembers().iterator().next().getStateTransition().getMessageExpression(); message = (Term) message.clone(); ((Term) message).setChild(0, one); sendToModel(message); } public void mouseReleased(MouseEvent e) { Constant zero = new Constant("0", DataConstraintModel.typeInt); Expression message = channel.getOutputChannelMembers().iterator().next().getStateTransition().getMessageExpression(); message = (Term) message.clone(); ((Term) message).setChild(0, zero); sendToModel(message); } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } }