Search in sources :

Example 1 with PlacementDescription

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();
}
Also used : DiceRoll(games.strategy.triplea.delegate.DiceRoll) GridBagConstraints(java.awt.GridBagConstraints) Territory(games.strategy.engine.data.Territory) Insets(java.awt.Insets) Renderable(games.strategy.engine.history.Renderable) MoveDescription(games.strategy.triplea.delegate.dataObjects.MoveDescription) PlacementDescription(games.strategy.triplea.delegate.dataObjects.PlacementDescription) Iterator(java.util.Iterator) Collection(java.util.Collection) Unit(games.strategy.engine.data.Unit) DicePanel(games.strategy.triplea.ui.DicePanel)

Aggregations

Territory (games.strategy.engine.data.Territory)1 Unit (games.strategy.engine.data.Unit)1 Renderable (games.strategy.engine.history.Renderable)1 DiceRoll (games.strategy.triplea.delegate.DiceRoll)1 MoveDescription (games.strategy.triplea.delegate.dataObjects.MoveDescription)1 PlacementDescription (games.strategy.triplea.delegate.dataObjects.PlacementDescription)1 DicePanel (games.strategy.triplea.ui.DicePanel)1 GridBagConstraints (java.awt.GridBagConstraints)1 Insets (java.awt.Insets)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1