20 package net.sf.gridarta.gui.map.mapview;
22 import java.awt.Point;
23 import javax.swing.JScrollPane;
24 import javax.swing.JViewport;
25 import javax.swing.ScrollPaneConstants;
34 import org.jetbrains.annotations.NotNull;
35 import org.jetbrains.annotations.Nullable;
70 public void mapCursorChangedPos(@NotNull
final Point location) {
75 public void mapCursorChangedMode() {
80 public void mapCursorChangedGameObject(@Nullable
final MapSquare<G, A, R> mapSquare, @Nullable
final G gameObject) {
85 public void mapCursorChangedSize() {
104 this.mapCursor.addMapCursorListener(mapCursorListener);
105 scrollPane =
new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
111 scrollPane.getVerticalScrollBar().setUnitIncrement(yScrollDistance);
112 scrollPane.getHorizontalScrollBar().setUnitIncrement(xScrollDistance);
113 scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
114 scrollPane.setViewportView(renderer);
115 if (viewPosition != null) {
116 scrollPane.getViewport().setViewPosition(viewPosition);
118 scrollPane.setFocusable(
true);
127 scrollPane.setViewportView(null);
135 final Point cursorLocation = mapCursor.
getLocation();
final MapCursorListener< G, A, R > mapCursorListener
The MapCursorListener attached to mapCursor.
Rectangle getSquareBounds(@NotNull Point p)
Returns coordinates, length and width of map square.
final AbstractMapRenderer< G, A, R > renderer
The AbstractMapRenderer to update.
Graphical User Interface of Gridarta.
final JScrollPane scrollPane
The JScrollPane for this instance.
MapCursor provides methods to move and drag on map.
Class with constants used in Gridarta and derivates.
static final Color BG_COLOR
Background Color (for the Panels).
Point getLocation()
Get position of cursor.
void closeNotify()
Must be called when this instance is not used anymore.
Base package of all Gridarta classes.
Abstract base class for classes implementing MapRenderer.
Reflects a game object (object on a map).
void ensureVisibleMapCursor()
Makes sure the mapCursor is visible.
GameObjects are the objects based on Archetypes found on maps.
MapCursorTracker(final boolean isPickmap, @Nullable final Point viewPosition, final int xScrollDistance, final int yScrollDistance, @NotNull final MapCursor< G, A, R > mapCursor, @NotNull final AbstractMapRenderer< G, A, R > renderer)
Creates a new instance.
JScrollPane getScrollPane()
Returns the JScrollPane of the renderer.
Base classes for rendering maps.
final MapCursor< G, A, R > mapCursor
The MapCursor to track.
Tracks the MapCursor of map and scrolls the AbstractMapRenderer so that the map cursor remains visibl...
Interface for listeners listening to MapCursor related events.
void removeMapCursorListener(@NotNull final MapCursorListener< G, A, R > listener)
Remove a MapCursorListener.
void scrollRectToVisible(@NotNull Rectangle aRect)
Ensures that a rectangular area is visible.
Interface for MapArchObjects.