void repaintHex(Tuple hex) { HexCalculator cellMetrics = getCellMetrics(); Tuple pixelCenter = cellMetrics.getPixelCenterByGrid(hex); _mapPane.repaint( pixelCenter.x - cellMetrics._radius * 10, pixelCenter.y - (cellMetrics._height * 10 / 2), cellMetrics._width * 10, cellMetrics._height * 10); }
public void init() { _selectedHex = null; _actionInProgress = null; setVisible(false); _mapPane.init(); _statusPane.init(); _detailsPane.init(); _eventsPane.init(); revalidate(); Dimension preferredSize = getPreferredSize(); setSize(preferredSize); pack(); repaint(); setVisible(true); }
@SuppressWarnings({"AbstractMethodCallInConstructor", "ThisEscapedInObjectConstruction"}) protected AbstractGameDisplay() { doAddWindowListener(this); addMenuBar(); // A pane for the entire center area: map, status. JPanel contentPane = new JPanel(new BorderLayout()); doAddKeyListener(contentPane); setContentPane(contentPane); contentPane.setBorder(BorderFactory.createEtchedBorder()); // ..add the map. JPanel westContainer = new JPanel(new BorderLayout()); _mapPane = createMapPane(); _mapPane.addMouseListener(this); JScrollPane mapContainer = new JScrollPane(_mapPane); mapContainer.setBorder(BorderFactory.createEtchedBorder()); // ..add the status area. JPanel statusPaneContainer = new JPanel(new BorderLayout()); // hack to deal with text area sizing bug. statusPaneContainer.setAlignmentX(Component.LEFT_ALIGNMENT); _statusPane = createStatusPane(); _statusPane.setEditable(false); statusPaneContainer.add(_statusPane, BorderLayout.WEST); westContainer.add(mapContainer, BorderLayout.CENTER); westContainer.add(statusPaneContainer, BorderLayout.SOUTH); // The side pane with all the currently relevant details (e.g. selected hex info). _detailsPane = createDetailsPane(); _detailsPane.setBorder(BorderFactory.createEtchedBorder()); // A bottom pane with a list of the game events from the previously run turn. _eventsPane = createEventsPane(); _eventsPane.setBorder(BorderFactory.createEtchedBorder()); contentPane.add(westContainer, BorderLayout.CENTER); contentPane.add(_detailsPane, BorderLayout.EAST); contentPane.add(_eventsPane, BorderLayout.SOUTH); }
public Map<String, Color> getPlayerColors() { return _mapPane.getPlayerColors(); }
protected List<GameItem> getItemsAtHex(Tuple hex) { return _mapPane.getGameItems(hex); }
public Location getLocationAtHex(Tuple hex) { return _mapPane.getLocations().get(hex); }