use of games.strategy.triplea.delegate.dataObjects.PlacementDescription in project triplea by triplea-game.
the class HistoryDetailsPanel method render.
@Override
@SuppressWarnings("unchecked")
public void render(final HistoryNode node) {
removeAll();
mapPanel.setRoute(null);
final Insets insets = new Insets(5, 0, 0, 0);
title.setText(node.getTitle());
add(scroll, new GridBagConstraints(0, 0, 1, 1, 1, 0.1, GridBagConstraints.NORTH, GridBagConstraints.BOTH, insets, 0, 0));
final GridBagConstraints mainConstraints = new GridBagConstraints(0, 1, 1, 1, 1, 0.9, GridBagConstraints.NORTH, GridBagConstraints.BOTH, insets, 0, 0);
if (node instanceof Renderable) {
final Object details = ((Renderable) node).getRenderingData();
if (details instanceof DiceRoll) {
final DicePanel dicePanel = new DicePanel(mapPanel.getUiContext(), data);
dicePanel.setDiceRoll((DiceRoll) details);
add(dicePanel, mainConstraints);
} else if (details instanceof MoveDescription) {
final MoveDescription moveMessage = (MoveDescription) details;
renderUnits(mainConstraints, moveMessage.getUnits());
mapPanel.setRoute(moveMessage.getRoute());
if (!mapPanel.isShowing(moveMessage.getRoute().getEnd())) {
mapPanel.centerOn(moveMessage.getRoute().getEnd());
}
} else if (details instanceof PlacementDescription) {
final PlacementDescription placeMessage = (PlacementDescription) details;
renderUnits(mainConstraints, placeMessage.getUnits());
if (!mapPanel.isShowing(placeMessage.getTerritory())) {
mapPanel.centerOn(placeMessage.getTerritory());
}
} else if (details instanceof Collection) {
final Collection<Object> objects = (Collection<Object>) details;
final Iterator<Object> objIter = objects.iterator();
if (objIter.hasNext()) {
final Object obj = objIter.next();
if (obj instanceof Unit) {
final Collection<Unit> units = (Collection<Unit>) details;
renderUnits(mainConstraints, units);
}
}
} else if (details instanceof Territory) {
final Territory t = (Territory) details;
if (!mapPanel.isShowing(t)) {
mapPanel.centerOn(t);
}
}
}
add(Box.createGlue());
validate();
repaint();
}
Aggregations