 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.gui.misc;
22 import java.awt.Dimension;
23 import java.awt.GridBagConstraints;
24 import java.awt.GridBagLayout;
25 import java.awt.Point;
26 import java.awt.event.ActionEvent;
27 import java.awt.event.ActionListener;
28 import java.awt.event.MouseEvent;
29 import java.awt.event.MouseMotionListener;
30 import java.text.NumberFormat;
31 import javax.swing.JLabel;
32 import javax.swing.JPanel;
33 import javax.swing.Timer;
34 import javax.swing.border.BevelBorder;
53 import net.
sf.japi.swing.action.ActionBuilder;
54 import net.
sf.japi.swing.action.ActionBuilderFactory;
55 import org.jetbrains.annotations.NotNull;
56 import org.jetbrains.annotations.Nullable;
79 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
143 public void mapCursorChangedPos(@NotNull
final Point location) {
148 public void mapCursorChangedMode() {
153 public void mapCursorChangedGameObject(@Nullable
final MapSquare<G, A, R> mapSquare, @Nullable
final G gameObject) {
158 public void mapCursorChangedSize() {
176 public void mapCreated(@NotNull
final MapControl<G, A, R> mapControl,
final boolean interactive) {
220 final String mapType = mapControl.isPickmap() ?
"map" :
"pickmap";
221 setStatusText(
"Saved " + mapType +
" '" + mapControl.getMapModel().getMapArchObject().getMapName() +
"'.");
232 public void mouseDragged(@NotNull
final MouseEvent e) {
237 public void mouseMoved(@NotNull
final MouseEvent e) {
251 public void actionPerformed(@NotNull
final ActionEvent e) {
256 final Runtime runtime = Runtime.getRuntime();
257 final long freeMem = runtime.freeMemory();
258 final long totMem = runtime.totalMemory();
259 final long usedMem = totMem - freeMem;
277 setLayout(
new GridBagLayout());
278 setBorder(
new BevelBorder(BevelBorder.LOWERED));
280 final GridBagConstraints gbc =
new GridBagConstraints();
281 gbc.fill = GridBagConstraints.HORIZONTAL;
282 gbc.anchor = GridBagConstraints.WEST;
286 mouse =
new JLabel(
" ");
287 mouse.setBorder(
new BevelBorder(BevelBorder.LOWERED));
291 cursor.setBorder(
new BevelBorder(BevelBorder.LOWERED));
296 status.setBorder(
new BevelBorder(BevelBorder.LOWERED));
301 memory.setBorder(
new BevelBorder(BevelBorder.LOWERED));
323 private static final NumberFormat
FORMAT = NumberFormat.getInstance();
326 FORMAT.setMinimumFractionDigits(1);
327 FORMAT.setMaximumFractionDigits(1);
334 private static final String @NotNull []
UNITS = {
"Bytes",
"KB",
"MB",
"GB" };
344 for (
int i =
UNITS.length - 1; i >= 0; i--) {
345 final long m = 1L << i * 10;
360 final String formatCursor;
361 if (mapCursor ==
null) {
364 final Point pos = mapCursor.getLocation();
365 final int cursorX = pos.x;
366 final int cursorY = pos.y;
367 if (mapCursor.isDragging()) {
368 final Dimension offset = mapCursor.getDragOffset();
369 assert offset !=
null;
370 final int offsetX = Math.abs(offset.width) + 1;
371 final int offsetY = Math.abs(offset.height) + 1;
372 formatCursor =
ACTION_BUILDER.format(
"statusCursorDragging", cursorX, cursorY, offsetX, offsetY);
374 formatCursor =
ACTION_BUILDER.format(
"statusCursorActive", cursorX, cursorY);
377 cursor.setText(formatCursor);
396 if (this.mapView !=
null) {
403 if (this.mapView !=
null) {
Classes for the script editor used within the editor to create and modify Python and Lua scripts.
A MapManager manages all opened maps.
final JLabel status
The label that shows the one line text message.
static final String[] UNITS
The units used by getMemoryString(long).
Base package of all Gridarta classes.
final Point mouseMapTmp
Temporary used to get map coordinates.
Interface for listeners listening to MapManager changes.
int size()
Get the number of objects.
final ArchetypeSet< G, A, R > archetypeSet
The ArchetypeSet.
StatusBar(@NotNull final MapManager< G, A, R > mapManager, @NotNull final MapViewManager< G, A, R > mapViewManager, @NotNull final ArchetypeSet< G, A, R > archetypeSet, @NotNull final NamedObjects< FaceObject > faceObjects)
Constructs a status bar that has the given main controller object set as its controller.
Interface for listeners interested in events related to {} instances.
final JLabel memory
The label that shows the memory status.
void statusMessage(@NotNull final String message)
A message that should be reported to the user.
Reflects a game object (object on a map).
void mapCursorChanged(@Nullable final MapCursor< G, A, R > mapCursor)
Sets the coordinates of the MapCursor to cursor label and the offset when in drag mode.
Interface for listeners listening to MapCursor related events.
final ActionListener statusBarUpdate
The action listener which is registered to periodically update the status bar.
Graphical User Interface of Gridarta.
final MapControlListener< G, A, R > mapControlListener
The MapControlListener used to detect saved maps.
MapCursor< G, A, R > getMapCursor()
Returns the MapCursor of this view.
static final long serialVersionUID
The serial Version UID.
GameObjects are the objects based on Archetypes found on maps.
int getArchetypeCount()
Returns the number of Archetypes available.
static String getMemoryString(final long mem)
Returns the given memory amount as a string scales the value to be bytes, kilobytes or megabytes.
void setStatusText(final String text)
Sets the level status text, which usually displays arch numbers.
final MapManagerListener< G, A, R > mapManagerListener
The map manager listener to detect current map changes.
Interface for MapArchObjects.
Callback functions to be implemented by users of ScriptEditControl.
A map view consists of a map grid and a map cursor, and is attached to a map control.
Interface that captures similarities between different ArchetypeSet implementations.
MapCursor provides methods to move and drag on map.
Classes for handling data that is organized in a tree.
void setCurrentMapView(@Nullable final MapView< G, A, R > mapView)
static final ActionBuilder ACTION_BUILDER
Action Builder.
void mousePosChanged(@NotNull final MouseEvent e)
Set new mouse and map coordinates to mouse label.
final JLabel mouse
The label that shows the mouse.
void addMapCursorListener(@NotNull final MapCursorListener< G, A, R > listener)
Register a MapCursorListener.
final NamedObjects< FaceObject > faceObjects
The NamedObjects instance to use.
Common interface for FaceObject.
final JLabel cursor
The label that shows the cursor.
Base classes for rendering maps.
final MapViewManagerListener< G, A, R > mapViewManagerListener
The map view manager listener to detect current map changes.
The face is the appearance of an object.
Currently nothing more than a marker interface for unification.
Interface for listeners listening on changes in MapControl instances.
MapView< G, A, R > mapView
The map view for which mapCursorListener is registered, or.
static final NumberFormat FORMAT
The DecimalFormat to use for formatting the numbers in {}.
Common interface for renderers of map control instances.
final MapCursorListener< G, A, R > mapCursorListener
The map cursor listener to detect map cursor changes.
Implements the main status bar of the application.
This class manages NamedObjects, managing their tree as well as providing a method for showing a dial...
boolean getSquareLocationAt(@NotNull Point point, @NotNull Point retPoint)
Returns the map location at the given point.
final MouseMotionListener mouseMotionListener
The MouseMotionListener for tracking the mouse position in map windows.