コード例 #1
0
ファイル: EventLayer.java プロジェクト: usuallycwdillon/gama
    private void executeEvent(final int x, final int y) {
      if (executer == null) {
        return;
      }
      final ILocation pp = getModelCoordinatesFrom(x, y, surface);
      if (pp.getX() < 0
          || pp.getY() < 0
          || pp.getX() >= surface.getEnvWidth()
          || pp.getY() >= surface.getEnvHeight()) {
        return;
      }
      final Arguments args = new Arguments();
      final Collection<IAgent> agentset = surface.selectAgent(x, y);
      if (pointArg != null) {
        args.put(
            pointArg, ConstantExpressionDescription.create(new GamaPoint(pp.getX(), pp.getY())));
      }
      if (listArg != null) {
        args.put(listArg, ConstantExpressionDescription.create(agentset));
      }

      executer.setRuntimeArgs(args);
      GAMA.run(
          new GAMA.InScope.Void() {

            @Override
            public void process(final IScope scope) {
              executer.executeOn(scope);
            }
          });
      if (surface.getOutput().isPaused() || GAMA.isPaused()) {
        surface.updateDisplay(true);
      }
    }
コード例 #2
0
ファイル: EventLayer.java プロジェクト: usuallycwdillon/gama
 public EventListener(final IDisplaySurface display, final String event, final String action) {
   listenedEvent = getListeningEvent(event);
   IAgent a = display.getDisplayScope().getSimulationScope();
   if (a == null) {
     a = display.getDisplayScope().getExperiment();
   }
   executer = a.getSpecies().getAction(action);
   surface = display;
 }
コード例 #3
0
ファイル: EventLayer.java プロジェクト: usuallycwdillon/gama
  @Override
  public void firstLaunchOn(final IDisplaySurface surface) {
    super.firstLaunchOn(surface);
    final IExpression eventType = definition.getFacet(IKeyword.NAME);
    final IExpression actionName = definition.getFacet(IKeyword.ACTION);
    IScope scope = surface.getDisplayScope();

    String currentMouseEvent = Cast.asString(scope, eventType.value(scope));
    String currentAction = Cast.asString(scope, actionName.value(scope));

    listener = new EventListener(surface, currentMouseEvent, currentAction);
    surface.addMouseListener(listener);
  }
コード例 #4
0
ファイル: EventLayer.java プロジェクト: usuallycwdillon/gama
 // We explicitely translate by the origin of the surface
 @Override
 public ILocation getModelCoordinatesFrom(
     final int xOnScreen, final int yOnScreen, final IDisplaySurface g) {
   return g.getModelCoordinates();
 }
コード例 #5
0
ファイル: EventLayer.java プロジェクト: usuallycwdillon/gama
 @Override
 public void disableOn(final IDisplaySurface surface) {
   super.disableOn(surface);
   surface.removeMouseListener(listener);
 }
コード例 #6
0
ファイル: EventLayer.java プロジェクト: usuallycwdillon/gama
 @Override
 public void enableOn(final IDisplaySurface surface) {
   surface.addMouseListener(listener);
 }
コード例 #7
0
ファイル: EventLayer.java プロジェクト: usuallycwdillon/gama
 public void dispose() {
   surface.removeMouseListener(this);
 }