Exemplo n.º 1
0
  @Override
  public void setController(IController controller) {

    super.setController(controller);

    map.setController(controller);
  }
Exemplo n.º 2
0
    public void startDrop(PieceType pieceType, CatanColor pieceColor, boolean isCancelAllowed) {

      this.setOpaque(false);
      this.setLayout(new BorderLayout());
      this.setBorder(BorderFactory.createLineBorder(Color.black, BORDER_WIDTH));

      label = new JLabel(getLabelText(pieceType), JLabel.CENTER);
      label.setOpaque(true);
      label.setBackground(Color.white);
      Font labelFont = label.getFont();
      labelFont = labelFont.deriveFont(labelFont.getStyle(), LABEL_TEXT_SIZE);
      label.setFont(labelFont);

      map = mainMap.copy();
      map.setController(getController());

      int prefWidth = (int) (mainMap.getScale() * mainMap.getPreferredSize().getWidth());
      int prefHeight = (int) (mainMap.getScale() * mainMap.getPreferredSize().getHeight());
      Dimension prefSize = new Dimension(prefWidth, prefHeight);
      map.setPreferredSize(prefSize);

      this.add(label, BorderLayout.NORTH);
      this.add(map, BorderLayout.CENTER);

      if (isCancelAllowed) {

        cancelButton = new JButton("Cancel");
        Font buttonFont = cancelButton.getFont();
        buttonFont = buttonFont.deriveFont(buttonFont.getStyle(), BUTTON_TEXT_SIZE);
        cancelButton.setFont(buttonFont);
        cancelButton.addActionListener(cancelButtonListener);
        this.add(cancelButton, BorderLayout.SOUTH);
      }

      map.startDrop(pieceType, pieceColor);
    }