コード例 #1
0
  public GridPanel(Client client, Snapshot snapshot) {
    setDoubleBuffered(true);
    setOpaque(false);
    setLayout(null);

    this.client = client;
    this.controlPanel = client.getControlPanel();

    squareSize = INITIAL_SQUARE_SIZE;
    left = 0 - STARTING_GRID_SIZE / 2;
    right = 0 + STARTING_GRID_SIZE / 2;
    top = 0 - STARTING_GRID_SIZE / 2;
    bottom = 0 + STARTING_GRID_SIZE / 2;

    if (snapshot != null) {
      NodeList nl = snapshot.getTileElements();
      for (int i = 0; i < nl.getLength(); i++) {
        Element el = (Element) nl.item(i);
        Position pos = XmlUtils.extractPosition(el);
        if (pos.x <= left) left = pos.x - 1;
        if (pos.x >= right) right = pos.x + 1;
        if (pos.y <= top) top = pos.y - 1;
        if (pos.y >= bottom) bottom = pos.y + 1;
      }
    }
    registerMouseListeners();
    controlPanel.registerSwingComponents(this);
  }
コード例 #2
0
 @Override
 public void forward() {
   if (client.isClientActive()) {
     if (secondPanel instanceof ForwardBackwardListener) {
       ((ForwardBackwardListener) secondPanel).forward();
     }
     client.getControlPanel().getActionPanel().forward();
   }
 }
コード例 #3
0
 public void backward() {
   client.getControlPanel().getActionPanel().rollAction(-1);
 }
コード例 #4
0
 /** Called after right mouse click */
 public void forward() {
   client.getControlPanel().getActionPanel().rollAction(1);
 }