double heightFactor = (2*m_game.board.height+1)*cos30; double widthFactor = (1.5 * m_game.board.width + 0.5);
int requiredWidth, requiredHeight; int currentHexSide = hexSide[zoom]; int currentHexSideByCos30 = hexSideByCos30[zoom]; int currentHexSideBySin30 = hexSideBySin30[zoom]; topMargin = margin; leftMargin = margin; requiredWidth = m_game.board.width*(currentHexSide + currentHexSideBySin30) + currentHexSideBySin30 + 2*margin; requiredHeight = (2*m_game.board.height + 1)*currentHexSideByCos30 + 2*margin + buttonHeight; setSize(requiredWidth, requiredHeight); m_dialog.pack();
    private void initializeMap() {        double heightFactor = (2*m_game.board.height+1)*cos30;        double widthFactor = (1.5 * m_game.board.width + 0.5);        m_dialog.show();        hexSide = (int) ( Math.min((getSize().height - 14 - minMargin*2)/heightFactor, (getSize().width - minMargin*2)/widthFactor));        hexSide = Math.max(hexSide, minHexSide);        hexSideByCos30 = (int) Math.round(hexSide* cos30);        hexSideBySin30 = (int) Math.round(hexSide/2);        halfRoadWidth =  (int) (hexSide/4);        halfRoadWidthByCos30 = (int) (hexSide*cos30/4);        halfRoadWidthBySin30 = (int) (hexSide/8);        if ((halfRoadWidthByCos30 == 0) ||(halfRoadWidthBySin30 == 0)){            halfRoadWidth = 0;            halfRoadWidthByCos30 = 0;            halfRoadWidthBySin30 = 0;        }        leftMargin = (int)((getSize().width - m_game.board.width*(hexSide + hexSideBySin30) - hexSideBySin30)/2);        topMargin =(int)(((getSize().height - 14) - hexSideByCos30*(2*m_game.board.height + 1))/2);        m_mapImage = createImage(Math.max(1, getSize().width), Math.max(1, getSize().height)); // area must be > 0        drawMap();    }