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));
m_mapImage = createImage(getSize().width,getSize().height); if (getSize().width > requiredWidth) leftMargin = (int) ((getSize().width - requiredWidth)/2) + margin; if (getSize().height > requiredHeight) topMargin = (int) ((getSize().height - requiredHeight)/2) + margin;
    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();    }