gt:           final int yValue = y.getTextAsInt(outer, "YLocation", this);
context: /*
   * $Id: SendToLocation.java 5099 2009-02-18 09:51:18Z uckelman $
   *
   * Copyright (c) 2003 by Rodney Kinney
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Library General Public
   * License (LGPL) as published by the Free Software Foundation.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Library General Public License for more details.
   *
   * You should have received a copy of the GNU Library General Public
   * License along with this library; if not, copies are available
   * at http://www.opensource.org.
   */
  package VASSAL.counters;
  
  import java.awt.Component;
  import java.awt.Frame;
  import java.awt.Graphics;
  import java.awt.Point;
  import java.awt.Rectangle;
  import java.awt.Shape;
  import java.awt.Window;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.beans.PropertyChangeEvent;
  import java.beans.PropertyChangeListener;
  import java.util.ArrayList;
  
  import javax.swing.Box;
  import javax.swing.BoxLayout;
  import javax.swing.JButton;
  import javax.swing.JLabel;
  import javax.swing.JPanel;
  import javax.swing.JTextField;
  import javax.swing.KeyStroke;
  import javax.swing.SwingUtilities;
  
  import VASSAL.build.GameModule;
  import VASSAL.build.module.Map;
  import VASSAL.build.module.documentation.HelpFile;
  import VASSAL.build.module.map.boardPicker.Board;
  import VASSAL.build.module.map.boardPicker.board.Region;
  import VASSAL.build.module.map.boardPicker.board.mapgrid.Zone;
  import VASSAL.command.Command;
  import VASSAL.configure.BooleanConfigurer;
  import VASSAL.configure.ChooseComponentDialog;
  import VASSAL.configure.HotKeyConfigurer;
  import VASSAL.configure.PropertyExpression;
  import VASSAL.configure.PropertyExpressionConfigurer;
  import VASSAL.configure.StringConfigurer;
  import VASSAL.configure.StringEnumConfigurer;
  import VASSAL.i18n.PieceI18nData;
  import VASSAL.i18n.Resources;
  import VASSAL.i18n.TranslatablePiece;
  import VASSAL.tools.FormattedString;
  import VASSAL.tools.SequenceEncoder;
  /**
   * This trait adds a command that sends a piece to another location. Options for the
   * target location are:
   *   1. Specified x,y co-ords on a named map/board
   *   2. The centre of a named Zone on a named map
   *   3. A named Region on a named map
   *   4. The location of another counter selected by a Propert Match String
   * Once the target locaiton is identified, it can be further offset in the X and Y directions
   * by a set of multipliers.
   * All Input Fields may use $...$ variable names 
   */
  public class SendToLocation extends Decorator implements TranslatablePiece {
    public static final String ID = "sendto;";
    private static final String _0 = "0";
    public static final String BACK_MAP = "backMap";
    public static final String BACK_POINT = "backPoint";
    protected static final String DEST_LOCATION = "Location on selected Map";
    protected static final String DEST_ZONE = "Zone on selected Map";
    protected static final String DEST_REGION = "Region on selected Map";
    protected static final String DEST_COUNTER = "Another counter, selected by properties";
    protected static final String[] DEST_OPTIONS = new String[] {DEST_LOCATION, DEST_ZONE, DEST_REGION, DEST_COUNTER};
    protected KeyCommand[] command;
    protected String commandName;
    protected String backCommandName;
    protected KeyStroke key;
    protected KeyStroke backKey;
    protected FormattedString mapId = new FormattedString("");
    protected FormattedString boardName = new FormattedString("");
    protected FormattedString x = new FormattedString("");
    protected FormattedString xIndex = new FormattedString("");
    protected FormattedString xOffset = new FormattedString("");
    protected FormattedString y = new FormattedString("");
    protected FormattedString yIndex = new FormattedString("");
    protected FormattedString yOffset = new FormattedString("");
    protected KeyCommand sendCommand;
    protected KeyCommand backCommand;
    protected String description;
    protected String destination;
    protected FormattedString zone = new FormattedString("");
    protected FormattedString region = new FormattedString("");
    protected PropertyExpression propertyFilter = new PropertyExpression("");
    private Map map;
    private Point dest;
  
    public SendToLocation() {
      this(ID + ";;;;0;0;;", null);
    }
  
    public SendToLocation(String type, GamePiece inner) {
      mySetType(type);
      setInner(inner);
    }
  
    public void mySetType(String type) {
      type = type.substring(ID.length());
      SequenceEncoder.Decoder st = new SequenceEncoder.Decoder(type, ';');
      commandName = st.nextToken("");
      key = st.nextKeyStroke(null);
      mapId.setFormat(st.nextToken(""));
      boardName.setFormat(st.nextToken(""));
      x.setFormat(st.nextToken("0"));
      y.setFormat(st.nextToken("0"));
      backCommandName = st.nextToken("");
      backKey = st.nextKeyStroke(null);
      xIndex.setFormat(st.nextToken("0"));
      yIndex.setFormat(st.nextToken("0"));
      xOffset.setFormat(st.nextToken("0"));
      yOffset.setFormat(st.nextToken("0"));
      description = st.nextToken("");
      destination = st.nextToken(DEST_LOCATION.substring(0,1));
      if (destination.length() == 0) {
        destination = DEST_LOCATION.substring(0,1);
      }
      zone.setFormat(st.nextToken(""));
      region.setFormat(st.nextToken(""));
      propertyFilter.setExpression(st.nextToken(""));
    }
  
    public String myGetType() {
      SequenceEncoder se = new SequenceEncoder(';');
      se.append(commandName)
          .append(key)
          .append(mapId.getFormat())
          .append(boardName.getFormat())
          .append(x.getFormat())
          .append(y.getFormat())
          .append(backCommandName)
          .append(backKey)
          .append(xIndex.getFormat())
          .append(yIndex.getFormat())
          .append(xOffset.getFormat())
          .append(yOffset.getFormat())
          .append(description)
          .append(destination)
          .append(zone.getFormat())
          .append(region.getFormat())
          .append(propertyFilter.getExpression());
      return ID + se.getValue();
    }
  
    protected KeyCommand[] myGetKeyCommands() {
      if (command == null) {
        sendCommand = new KeyCommand(commandName, key, Decorator.getOutermost(this), this);
        backCommand = new KeyCommand(backCommandName, backKey, Decorator.getOutermost(this), this);
        ArrayList<KeyCommand> l = new ArrayList<KeyCommand>();
        if (commandName.length() > 0 && key != null) {
          l.add(sendCommand);
        }
        if (backCommandName.length() > 0 && backKey != null) {
          l.add(backCommand);
        }
        command = l.toArray(new KeyCommand[l.size()]);
      }
  
      for (KeyCommand c : command ) {
        if (c.getName().equals(backCommandName)) {
          c.setEnabled(getMap() != null &&
                       getProperty(BACK_MAP) != null &&
                       getProperty(BACK_POINT) != null);
        }
        else {
          Point p = getSendLocation();
          c.setEnabled(getMap() != null && p != null &&
              (map != getMap() || !p.equals(getPosition())) );
        }
      }
      return command;
    }
  
    public String myGetState() {
      SequenceEncoder se = new SequenceEncoder(';');
      Map backMap = (Map)getProperty(BACK_MAP);
      if (backMap != null) {
        se.append(backMap.getIdentifier());
      }
      else {
        se.append("");
      }
      Point backPoint = (Point)getProperty(BACK_POINT);
      if (backPoint != null) {
        se.append(backPoint.x).append(backPoint.y);
      }
      else {
        se.append("").append("");
      }
      return se.getValue();
    }
  
    private Point getSendLocation() {
      GamePiece outer = Decorator.getOutermost(this);
      map = null;
      dest = null;
      // Home in on a counter
      if (destination.equals(DEST_COUNTER.substring(0, 1))) {
        GamePiece target = null;
        // Find first counter matching the properties
        for (GamePiece piece :
             GameModule.getGameModule().getGameState().getAllPieces()) {
          if (piece instanceof Stack) {
            Stack s = (Stack) piece;
            for (int i = 0; i < s.getPieceCount(); i++) {
              if (propertyFilter.accept(s.getPieceAt(i))) {
                target = s.getPieceAt(i);
                if (target != null) break;
              }
            }
          }
          else {
            if (propertyFilter.accept(piece)) {
              target = piece;
            }
          }
          if (target != null) break;
        }
        // Determine target's position
        if (target != null) {
          map = target.getMap();
          if (map != null) {
            dest = target.getPosition();
          }
        }
      }
      // Location/Zone/Region processing all use specified map
      else {
        map = Map.getMapById(mapId.getText(outer));
        if (map == null) {
          map = getMap();
        }
        if (map != null) {
          switch (destination.charAt(0)) {
          case 'L':
            final int xValue = x.getTextAsInt(outer, "Xlocation", this);
  