*/
@Override
public String getToolTipText(MouseEvent e) {
int stringsSize = 0;
IHex mhex = null;
Point point = e.getPoint();
// first, we have to determine how much text we are going to have
// are we on a hex?
final Coords mcoords = getCoordsAt(point);
if (GUIPreferences.getInstance().getShowMapHexPopup() && game.getBoard().contains(mcoords)) {
mhex = game.getBoard().getHex(mcoords);
stringsSize += 1;
}
// check if it's on any entities
for (EntitySprite eSprite : entitySprites) {
if (eSprite.isInside(point)) {
stringsSize += 3;
}
}
// check if it's on any attacks
for (AttackSprite aSprite : attackSprites) {
if (aSprite.isInside(point)) {
stringsSize += 1 + aSprite.weaponDescs.size();
}
}
// If the hex contains a building, make more space.
// Also if it contains other displayable terrain.
if (mhex != null) {
stringsSize += mhex.displayableTerrainsPresent();
if (mhex.containsTerrain(Terrains.BUILDING)) {
stringsSize++;
}
if (mhex.containsTerrain(Terrains.FUEL_TANK)) {
stringsSize++;
}
if (mhex.containsTerrain(Terrains.BRIDGE)) {
stringsSize++;
}
}
stringsSize += game.getNbrMinefields(mcoords);
// Artillery
final ArrayList<ArtilleryAttackAction> artilleryAttacks = getArtilleryAttacksAtLocation(mcoords);
stringsSize += artilleryAttacks.size();
// Artillery fire adjustment
final Mounted curWeapon = getSelectedArtilleryWeapon();
if (curWeapon != null) {
stringsSize++;
}
// if the size is zip, you must a'quit
if (stringsSize == 0) {
return null;
}
// now we can allocate an array of strings
String[] strings = new String[stringsSize];
int stringsIndex = 0;
// are we on a hex?
if (mhex != null) {
strings[stringsIndex] = Messages.getString("BoardView1.Hex") + mcoords.getBoardNum() //$NON-NLS-1$
+ Messages.getString("BoardView1.level") + mhex.getElevation(); //$NON-NLS-1$
stringsIndex += 1;
//cycle through the terrains and report types found
//this will skip buildings and other constructed units
for(int i=0;i < Terrains.SIZE; i++) {
if(mhex.containsTerrain(i)) {
int tf = mhex.getTerrain(i).getTerrainFactor();
int ttl = mhex.getTerrain(i).getLevel();
String name = Terrains.getDisplayName(i, ttl);
if(tf > 0) {
name = name + " (" + tf + ")";
}
if(null != name) {
strings[stringsIndex] = name;
stringsIndex += 1;
}
}
}
// Do we have a building?
if (mhex.containsTerrain(Terrains.FUEL_TANK)) {
// Get the building.
Building bldg = game.getBoard().getBuildingAt(mcoords);
StringBuffer buf = new StringBuffer(Messages.getString("BoardView1.Height")); //$NON-NLS-1$
// Each hex of a building has its own elevation.
buf.append(mhex.terrainLevel(Terrains.FUEL_TANK_ELEV));
buf.append(" "); //$NON-NLS-1$
buf.append(bldg.toString());
buf.append(Messages.getString("BoardView1.CF")); //$NON-NLS-1$
buf.append(bldg.getCurrentCF(mcoords));
strings[stringsIndex] = buf.toString();
stringsIndex += 1;
}
if (mhex.containsTerrain(Terrains.BUILDING)) {
// Get the building.
Building bldg = game.getBoard().getBuildingAt(mcoords);
StringBuffer buf = new StringBuffer(Messages.getString("BoardView1.Height")); //$NON-NLS-1$
// Each hex of a building has its own elevation.
buf.append(mhex.terrainLevel(Terrains.BLDG_ELEV));
buf.append(" "); //$NON-NLS-1$
buf.append(bldg.toString());
buf.append(Messages.getString("BoardView1.CF")); //$NON-NLS-1$
buf.append(bldg.getCurrentCF(mcoords));
strings[stringsIndex] = buf.toString();
stringsIndex += 1;
}
// Do we have a bridge?
if (mhex.containsTerrain(Terrains.BRIDGE)) {
// Get the building.
Building bldg = game.getBoard().getBuildingAt(mcoords);
StringBuffer buf = new StringBuffer(Messages.getString("BoardView1.Height")); //$NON-NLS-1$
// Each hex of a building has its own elevation.
buf.append(mhex.terrainLevel(Terrains.BRIDGE_ELEV));
buf.append(" "); //$NON-NLS-1$
buf.append(bldg.toString());
buf.append(Messages.getString("BoardView1.CF")); //$NON-NLS-1$
buf.append(bldg.getCurrentCF(mcoords));
strings[stringsIndex] = buf.toString();