Gridarta Editor
net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R > Class Template Reference

Implements the main status bar of the application. More...

+ Inheritance diagram for net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:
+ Collaboration diagram for net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:

Public Member Functions

void setStatusText (final String text)
 Sets the level status text, which usually displays arch numbers. More...
 
 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. More...
 

Private Member Functions

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. More...
 
void mousePosChanged (@NotNull final MouseEvent e)
 Set new mouse and map coordinates to mouse label. More...
 
void setCurrentMapView (@Nullable final MapView< G, A, R > mapView)
 

Static Private Member Functions

static String getMemoryString (final long mem)
 Returns the given memory amount as a string scales the value to be bytes, kilobytes or megabytes. More...
 

Private Attributes

final ArchetypeSet< G, A, R > archetypeSet
 The ArchetypeSet. More...
 
final JLabel cursor
 The label that shows the cursor. More...
 
final NamedObjects< FaceObjectfaceObjects
 The NamedObjects instance to use. More...
 
final MapControlListener< G, A, R > mapControlListener
 The MapControlListener used to detect saved maps. More...
 
final MapCursorListener< G, A, R > mapCursorListener
 The map cursor listener to detect map cursor changes. More...
 
final MapManagerListener< G, A, R > mapManagerListener
 The map manager listener to detect current map changes. More...
 
MapView< G, A, R > mapView
 The map view for which mapCursorListener is registered, or. More...
 
final MapViewManagerListener< G, A, R > mapViewManagerListener
 The map view manager listener to detect current map changes. More...
 
final JLabel memory
 The label that shows the memory status. More...
 
final JLabel mouse
 The label that shows the mouse. More...
 
final Point mouseMapTmp = new Point()
 Temporary used to get map coordinates. More...
 
final MouseMotionListener mouseMotionListener
 The MouseMotionListener for tracking the mouse position in map windows. More...
 
final JLabel status
 The label that shows the one line text message. More...
 
final ActionListener statusBarUpdate
 The action listener which is registered to periodically update the status bar. More...
 

Static Private Attributes

static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta")
 Action Builder. More...
 
static final NumberFormat FORMAT = NumberFormat.getInstance()
 The DecimalFormat to use for formatting the numbers in getMemoryString(long). More...
 
static final long serialVersionUID = 1L
 The serial Version UID. More...
 
static final String [] UNITS = { "Bytes", "KB", "MB", "GB" }
 The units used by getMemoryString(long). More...
 

Detailed Description

Implements the main status bar of the application.

Used to show one line text messages to the user about progress, state etc. Also includes level info and memory info panels.

Author
Michael Toennies
Andreas Vogl
Christian Hujer
Daniel Viegas
Todo:
Separate labels and methods for mouse coordinates

Definition at line 68 of file StatusBar.java.

Constructor & Destructor Documentation

◆ StatusBar()

net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.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.

Parameters
mapManagerthe map manager
mapViewManagerthe map view manager
archetypeSetthe archetype set
faceObjectsthe named objects instance to use

Definition at line 280 of file StatusBar.java.

Member Function Documentation

◆ getMemoryString()

static String net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getMemoryString ( final long  mem)
staticprivate

Returns the given memory amount as a string scales the value to be bytes, kilobytes or megabytes.

Parameters
memmemory amount to calculate
Returns
String for

Definition at line 349 of file StatusBar.java.

◆ mapCursorChanged()

void net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.mapCursorChanged ( @Nullable final MapCursor< G, A, R >  mapCursor)
private

Sets the coordinates of the MapCursor to cursor label and the offset when in drag mode.

Parameters
mapCursorthe map cursor to set coordinates from

Definition at line 365 of file StatusBar.java.

Referenced by net.sf.gridarta.gui.misc.StatusBar<?, ?, ?>.setCurrentMapView().

+ Here is the caller graph for this function:

◆ mousePosChanged()

void net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.mousePosChanged ( @NotNull final MouseEvent  e)
private

Set new mouse and map coordinates to mouse label.

Parameters
eEvent that was fired from #MapCursor

Definition at line 390 of file StatusBar.java.

◆ setCurrentMapView()

void net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setCurrentMapView ( @Nullable final MapView< G, A, R >  mapView)
private

Definition at line 401 of file StatusBar.java.

◆ setStatusText()

void net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setStatusText ( final String  text)

Sets the level status text, which usually displays arch numbers.

Parameters
textthe text

Definition at line 320 of file StatusBar.java.

Referenced by net.sf.gridarta.action.GcAction.gc().

+ Here is the caller graph for this function:

Member Data Documentation

◆ ACTION_BUILDER

final ActionBuilder net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta")
staticprivate

Action Builder.

Definition at line 79 of file StatusBar.java.

◆ archetypeSet

final ArchetypeSet<G, A, R> net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.archetypeSet
private

◆ cursor

final JLabel net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.cursor
private

The label that shows the cursor.

Definition at line 107 of file StatusBar.java.

◆ faceObjects

final NamedObjects<FaceObject> net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.faceObjects
private

The NamedObjects instance to use.

Definition at line 93 of file StatusBar.java.

Referenced by net.sf.gridarta.gui.misc.StatusBar<?, ?, ?>.StatusBar().

◆ FORMAT

final NumberFormat net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.FORMAT = NumberFormat.getInstance()
staticprivate

The DecimalFormat to use for formatting the numbers in getMemoryString(long).

Definition at line 329 of file StatusBar.java.

◆ mapControlListener

final MapControlListener<G, A, R> net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.mapControlListener
private
Initial value:
= new MapControlListener<G, A, R>() {
@Override
public void saved(@NotNull final DefaultMapControl<G, A, R> mapControl) {
final String mapType = mapControl.isPickmap() ? "map" : "pickmap";
setStatusText("Saved " + mapType + " '" + mapControl.getMapModel().getMapArchObject().getMapName() + "'.");
}
}

The MapControlListener used to detect saved maps.

Definition at line 220 of file StatusBar.java.

◆ mapCursorListener

final MapCursorListener<G, A, R> net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.mapCursorListener
private
Initial value:
= new MapCursorListener<G, A, R>() {
@Override
public void mapCursorChangedPos(@NotNull final Point location) {
}
@Override
public void mapCursorChangedMode() {
}
@Override
public void mapCursorChangedGameObject(@Nullable final MapSquare<G, A, R> mapSquare, @Nullable final G gameObject) {
}
@Override
public void mapCursorChangedSize() {
}
}

The map cursor listener to detect map cursor changes.

Definition at line 140 of file StatusBar.java.

◆ mapManagerListener

final MapManagerListener<G, A, R> net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.mapManagerListener
private
Initial value:
= new MapManagerListener<G, A, R>() {
@Override
public void currentMapChanged(@Nullable final MapControl<G, A, R> mapControl) {
}
@Override
public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) {
setStatusText("Creating new map " + mapControl.getMapModel().getMapArchObject().getMapName() + ".");
mapControl.addMapControlListener(mapControlListener);
}
@Override
public void mapClosing(@NotNull final MapControl<G, A, R> mapControl) {
}
@Override
public void mapClosed(@NotNull final MapControl<G, A, R> mapControl) {
mapControl.removeMapControlListener(mapControlListener);
}
}

The map manager listener to detect current map changes.

Definition at line 168 of file StatusBar.java.

◆ mapView

MapView<G, A, R> net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.mapView
private

The map view for which mapCursorListener is registered, or.

null

if none is registered.

Definition at line 134 of file StatusBar.java.

Referenced by net.sf.gridarta.gui.misc.StatusBar<?, ?, ?>.setCurrentMapView().

◆ mapViewManagerListener

final MapViewManagerListener<G, A, R> net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.mapViewManagerListener
private
Initial value:
= new MapViewManagerListener<G, A, R>() {
@Override
public void activeMapViewChanged(@Nullable final MapView<G, A, R> mapView) {
}
@Override
public void mapViewCreated(@NotNull final MapView<G, A, R> mapView) {
}
@Override
public void mapViewClosing(@NotNull final MapView<G, A, R> mapView) {
}
}

The map view manager listener to detect current map changes.

Definition at line 197 of file StatusBar.java.

◆ memory

final JLabel net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.memory
private

The label that shows the memory status.

Definition at line 121 of file StatusBar.java.

◆ mouse

final JLabel net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.mouse
private

The label that shows the mouse.

Definition at line 100 of file StatusBar.java.

◆ mouseMapTmp

final Point net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.mouseMapTmp = new Point()
private

Temporary used to get map coordinates.

Definition at line 127 of file StatusBar.java.

Referenced by net.sf.gridarta.gui.misc.StatusBar<?, ?, ?>.mousePosChanged().

◆ mouseMotionListener

final MouseMotionListener net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.mouseMotionListener
private
Initial value:
= new MouseMotionListener() {
@Override
public void mouseDragged(@NotNull final MouseEvent e) {
}
@Override
public void mouseMoved(@NotNull final MouseEvent e) {
}
}

The MouseMotionListener for tracking the mouse position in map windows.

Definition at line 235 of file StatusBar.java.

◆ serialVersionUID

final long net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.serialVersionUID = 1L
staticprivate

The serial Version UID.

Definition at line 73 of file StatusBar.java.

◆ status

final JLabel net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.status
private

The label that shows the one line text message.

Definition at line 114 of file StatusBar.java.

◆ statusBarUpdate

final ActionListener net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.statusBarUpdate
private
Initial value:
= new ActionListener() {
@Override
public void actionPerformed(@NotNull final ActionEvent e) {
final int archetypeCount = archetypeSet.getArchetypeCount();
final int faceObjectsCount = faceObjects.size();
final Runtime runtime = Runtime.getRuntime();
final long freeMem = runtime.freeMemory();
final long totMem = runtime.totalMemory();
final long usedMem = totMem - freeMem;
memory.setText(ACTION_BUILDER.format("memory", archetypeCount, faceObjectsCount, getMemoryString(usedMem), getMemoryString(freeMem), getMemoryString(totMem)));
}
}

The action listener which is registered to periodically update the status bar.

Definition at line 254 of file StatusBar.java.

◆ UNITS

final String [] net.sf.gridarta.gui.misc.StatusBar< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.UNITS = { "Bytes", "KB", "MB", "GB" }
staticprivate

The units used by getMemoryString(long).

Definition at line 340 of file StatusBar.java.


The documentation for this class was generated from the following file: