Gridarta Editor
net.sf.gridarta.model.mapgrid.MapGrid Class Reference

2D-Grid containing flags for selection, pre-selection, cursor, warnings and errors. More...

+ Collaboration diagram for net.sf.gridarta.model.mapgrid.MapGrid:

Public Member Functions

void addMapGridListener (@NotNull final MapGridListener listener)
 Registers a MapGridListener. More...
 
void beginTransaction ()
 Starts a new transaction. More...
 
void clearErrors ()
 Clears all error flags. More...
 
void endTransaction ()
 Ends a transaction. More...
 
int getFlags (final int x, final int y)
 Returns the flags of a square. More...
 
int getFlags (@NotNull final Point p)
 Returns the flags of a square. More...
 
Size2D getGridSize ()
 Returns a Size2D with the dimension of this grid. More...
 
Rectangle getRecChange ()
 Returns a rectangle where the grid was changed. More...
 
Rectangle getSelectedRec ()
 Returns the smallest rectangle containing selection. More...
 
Point [] getSelection ()
 Returns the selection. More...
 
Size2D getSize ()
 Returns size of grid. More...
 
boolean hasError (@NotNull final Point p)
 Checks if a square has the error flag set. More...
 
void invertSelection ()
 Inverts all selected squares. More...
 
 MapGrid (@NotNull final Size2D gridSize)
 Creates a new instance. More...
 
void preSelect (@NotNull final Point start, @NotNull final Point end)
 Rectangle defined by two points gets preselected. More...
 
void removeMapGridListener (@NotNull final MapGridListener listener)
 Removes a MapGridListener. More...
 
void resize (@NotNull final Size2D newSize)
 Resizes the MapGrid. More...
 
void select (@NotNull final Point pos, @NotNull final SelectionMode selectionMode)
 Selects or deselects a single square. More...
 
void selectAll ()
 Marks all squares as selected. More...
 
void selectArea (@NotNull final Point pos1, @NotNull final Point pos2, @NotNull final SelectionMode selectionMode)
 Selects or deselects all squares in an area. More...
 
void setCursor (@NotNull final Point pos)
 Highlights the given cursor position. More...
 
void setError (final int x, final int y)
 Sets the error flag at given coordinates. More...
 
void unPreSelect (@NotNull final Point start, @NotNull final Point end)
 Pre-selection of rectangle defined by points gets deleted. More...
 
void unSelect ()
 Clears all selection and pre-selection flags from the grid. More...
 
void unSetCursor (@NotNull final Point pos)
 Un-highlights the given cursor position. More...
 
void updatePreSelect (@NotNull final Point start, @NotNull final Point oldEnd, @NotNull final Point newEnd)
 Update the pre-selection rectangle. More...
 

Static Public Attributes

static final int GRID_FLAG_CONNECTION = 1 << 6
 Flag to highlight as part of a connection group. More...
 
static final int GRID_FLAG_CURSOR = 1 << 7
 Flag to highlight cursor position. More...
 
static final int GRID_FLAG_ERROR = 1 << 4
 Flag to highlight as error. More...
 
static final int GRID_FLAG_FATAL = 1 << 5
 Flag to highlight as fatal. More...
 
static final int GRID_FLAG_INFORMATION = 1 << 2
 Flag to highlight as information. More...
 
static final int GRID_FLAG_SELECTING = 1 << 1
 Pre-selection - used to preselect squares. More...
 
static final int GRID_FLAG_SELECTION = 1
 Selection - marks all selected squares. More...
 
static final int GRID_FLAG_SELECTION_EAST = 1 << 9
 Selection - is set for squares at the east edge of the selected area. More...
 
static final int GRID_FLAG_SELECTION_NORTH = 1 << 8
 Selection - is set for squares at the north edge of the selected area. More...
 
static final int GRID_FLAG_SELECTION_SOUTH = 1 << 10
 Selection - is set for squares at the south edge of the selected area. More...
 
static final int GRID_FLAG_SELECTION_WEST = 1 << 11
 Selection - is set for squares at the west edge of the selected area. More...
 
static final int GRID_FLAG_WARNING = 1 << 3
 Flag to highlight as warning. More...
 

Private Member Functions

void beginRecChange ()
 Begins a set of changes. More...
 
void calculateCachedSelectedRec ()
 Makes sure the value of cachedSelectedRec if up-to-date. More...
 
void calculateRec (@NotNull final Point p1, @NotNull final Point p2)
 
boolean endRecChange ()
 Ends the set of changes and store the bounding box for all recorded changes in recChange. More...
 
void fireMapGridChangedEvent ()
 Inform all registered listeners that the flags on MapGrid have changed. More...
 
void fireMapGridResizeEvent ()
 Informs all registered listeners that the size of MapGrid has changed. More...
 
void setFlags (final int minX, final int minY, final int maxX, final int maxY, final int flags)
 Sets flags in a rectangle and generate a grid change event. More...
 
void toggleFlags (final int minX, final int minY, final int maxX, final int maxY, final int flags)
 Flips flags in a rectangle and generate a grid change event. More...
 
void unsetFlags (final int minX, final int minY, final int maxX, final int maxY, final int flags)
 Resets flags in a rectangle and generate a grid change event. More...
 
void updateRecChange (final int x, final int y)
 Adds a point to the set of changes. More...
 
void updateSelectionFlag (final int x, final int y, final boolean newState)
 Updates the border selection flags of a square and its adjacent squares. More...
 
void updateSelectionFlag (final int x, final int y, final boolean newState, final int dx, final int dy, final int flag, final int dFlag)
 Updates the border selection flags of a square and one adjacent square. More...
 

Private Attributes

Point cachedCursorLoc
 Cached location of the cursor. More...
 
Rectangle cachedSelectedRec
 The return value for getSelectedRec(). More...
 
boolean cachedSelectedRecValid
 If set, cachedSelectedRec is up-to-date. More...
 
final Point cornerMax = new Point()
 Right lower coordinates of rectangle that is being processed. More...
 
final Point cornerMin = new Point()
 Left upper coordinates of rectangle that is being processed. More...
 
int [][] gridFlags
 2D-array to store grid flags. More...
 
Size2D gridSize
 Size of. More...
 
final EventListenerList2< MapGridListenerlistenerList = new EventListenerList2<>(MapGridListener.class)
 The MapGridListeners to inform of changes. More...
 
final Rectangle recChange = new Rectangle()
 Rectangle to store location of last grid change. More...
 
int transactionDepth
 The transaction depth. More...
 
Thread transactionThread
 The thread that performs the current transaction. More...
 

Detailed Description

2D-Grid containing flags for selection, pre-selection, cursor, warnings and errors.

This class provides methods to modify these flags. Normally a map cursor is used to access them. Selection flags are not changed directly. First pre-selection flags have to be set with Point), then selectArea(Point, Point, SelectionMode) will change the selection flags according to SelectionMode. This allows visualisation of the dragging process when selecting an area.

Every change of the grid size or flags fires a MapGridEvent and informs all registered MapGridListeners.

Author
Daniel Viegas
Andreas Kirschbaum

Definition at line 45 of file MapGrid.java.

Constructor & Destructor Documentation

◆ MapGrid()

net.sf.gridarta.model.mapgrid.MapGrid.MapGrid ( @NotNull final Size2D  gridSize)

Creates a new instance.

Parameters
gridSizethe size of the grid

Definition at line 181 of file MapGrid.java.

References net.sf.gridarta.model.mapgrid.MapGrid.gridSize.

Member Function Documentation

◆ addMapGridListener()

void net.sf.gridarta.model.mapgrid.MapGrid.addMapGridListener ( @NotNull final MapGridListener  listener)

Registers a MapGridListener.

Parameters
listenerthe listener to register

Definition at line 190 of file MapGrid.java.

References net.sf.gridarta.utils.EventListenerList2< T extends EventListener >.add().

Referenced by net.sf.gridarta.var.crossfire.gui.map.renderer.AbstractFlatMapRenderer.init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ beginRecChange()

void net.sf.gridarta.model.mapgrid.MapGrid.beginRecChange ( )
private

Begins a set of changes.

Note
Until endRecChange() is called, recChange does not contain a valid rectangle:
width
and
height
is used as coordinates.

Definition at line 646 of file MapGrid.java.

References net.sf.gridarta.utils.Size2D.getHeight(), and net.sf.gridarta.utils.Size2D.getWidth().

Referenced by net.sf.gridarta.model.mapgrid.MapGrid.beginTransaction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ beginTransaction()

void net.sf.gridarta.model.mapgrid.MapGrid.beginTransaction ( )

Starts a new transaction.

Transactions may be nested. Transactions serve the purpose of firing events to the views when more changes are known to come before the view is really required to update. Each invocation of this function requires its own invocation of endTransaction().

Definition at line 756 of file MapGrid.java.

References net.sf.gridarta.model.mapgrid.MapGrid.beginRecChange().

Referenced by net.sf.gridarta.model.mapcursor.MapCursor< G, A, R >.beginTransaction(), net.sf.gridarta.model.mapgrid.MapGrid.clearErrors(), net.sf.gridarta.mainactions.MainActions< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.doExpandEmptySelection(), net.sf.gridarta.action.GrowSelectionAction< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.doGrowSelection(), net.sf.gridarta.action.ShrinkSelectionAction< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.doShrinkSelection(), net.sf.gridarta.gui.map.mapview.ErroneousMapSquares< G, A, R >.errorsChanged(), net.sf.gridarta.model.mapgrid.MapGrid.invertSelection(), net.sf.gridarta.model.mapgrid.MapGrid.preSelect(), net.sf.gridarta.model.mapgrid.MapGrid.selectAll(), net.sf.gridarta.model.mapgrid.MapGrid.selectArea(), net.sf.gridarta.model.mapgrid.MapGrid.setCursor(), net.sf.gridarta.model.mapgrid.MapGrid.setError(), net.sf.gridarta.gui.misc.ShiftProcessor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.shift(), net.sf.gridarta.model.mapgrid.MapGrid.unPreSelect(), net.sf.gridarta.model.mapgrid.MapGrid.unSelect(), net.sf.gridarta.model.mapgrid.MapGrid.unSetCursor(), and net.sf.gridarta.model.mapgrid.MapGrid.updatePreSelect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateCachedSelectedRec()

void net.sf.gridarta.model.mapgrid.MapGrid.calculateCachedSelectedRec ( )
private

Makes sure the value of cachedSelectedRec if up-to-date.

Definition at line 528 of file MapGrid.java.

References net.sf.gridarta.utils.Size2D.getHeight(), and net.sf.gridarta.utils.Size2D.getWidth().

Referenced by net.sf.gridarta.model.mapgrid.MapGrid.getSelectedRec(), and net.sf.gridarta.model.mapgrid.MapGrid.getSelection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateRec()

void net.sf.gridarta.model.mapgrid.MapGrid.calculateRec ( @NotNull final Point  p1,
@NotNull final Point  p2 
)
private
minX, maxX, minY, maxY

are set according to the the points

p1

and

p2

.

Parameters
p1the coordinates of one corner of a rectangle
p2the coordinates of the opposite corner

Definition at line 444 of file MapGrid.java.

Referenced by net.sf.gridarta.model.mapgrid.MapGrid.preSelect(), net.sf.gridarta.model.mapgrid.MapGrid.selectArea(), and net.sf.gridarta.model.mapgrid.MapGrid.unPreSelect().

+ Here is the caller graph for this function:

◆ clearErrors()

◆ endRecChange()

boolean net.sf.gridarta.model.mapgrid.MapGrid.endRecChange ( )
private

Ends the set of changes and store the bounding box for all recorded changes in recChange.

Returns
true
if the set of changes is not empty

Definition at line 678 of file MapGrid.java.

Referenced by net.sf.gridarta.model.mapgrid.MapGrid.endTransaction().

+ Here is the caller graph for this function:

◆ endTransaction()

void net.sf.gridarta.model.mapgrid.MapGrid.endTransaction ( )

Ends a transaction.

Invoking this method will reduce the transaction depth by 1.

If the last transaction is ended, the changes are committed.

Definition at line 776 of file MapGrid.java.

References net.sf.gridarta.model.mapgrid.MapGrid.endRecChange(), and net.sf.gridarta.model.mapgrid.MapGrid.fireMapGridChangedEvent().

Referenced by net.sf.gridarta.model.mapgrid.MapGrid.clearErrors(), net.sf.gridarta.mainactions.MainActions< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.doExpandEmptySelection(), net.sf.gridarta.action.GrowSelectionAction< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.doGrowSelection(), net.sf.gridarta.action.ShrinkSelectionAction< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.doShrinkSelection(), net.sf.gridarta.model.mapcursor.MapCursor< G, A, R >.endTransaction(), net.sf.gridarta.gui.map.mapview.ErroneousMapSquares< G, A, R >.errorsChanged(), net.sf.gridarta.model.mapgrid.MapGrid.invertSelection(), net.sf.gridarta.model.mapgrid.MapGrid.preSelect(), net.sf.gridarta.model.mapgrid.MapGrid.selectAll(), net.sf.gridarta.model.mapgrid.MapGrid.selectArea(), net.sf.gridarta.model.mapgrid.MapGrid.setCursor(), net.sf.gridarta.model.mapgrid.MapGrid.setError(), net.sf.gridarta.gui.misc.ShiftProcessor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.shift(), net.sf.gridarta.model.mapgrid.MapGrid.unPreSelect(), net.sf.gridarta.model.mapgrid.MapGrid.unSelect(), net.sf.gridarta.model.mapgrid.MapGrid.unSetCursor(), and net.sf.gridarta.model.mapgrid.MapGrid.updatePreSelect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fireMapGridChangedEvent()

void net.sf.gridarta.model.mapgrid.MapGrid.fireMapGridChangedEvent ( )
private

Inform all registered listeners that the flags on MapGrid have changed.

Definition at line 243 of file MapGrid.java.

References net.sf.gridarta.utils.EventListenerList2< T extends EventListener >.getListeners().

Referenced by net.sf.gridarta.model.mapgrid.MapGrid.endTransaction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fireMapGridResizeEvent()

void net.sf.gridarta.model.mapgrid.MapGrid.fireMapGridResizeEvent ( )
private

Informs all registered listeners that the size of MapGrid has changed.

Definition at line 253 of file MapGrid.java.

References net.sf.gridarta.utils.EventListenerList2< T extends EventListener >.getListeners().

Referenced by net.sf.gridarta.model.mapgrid.MapGrid.resize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFlags() [1/2]

◆ getFlags() [2/2]

int net.sf.gridarta.model.mapgrid.MapGrid.getFlags ( @NotNull final Point  p)

Returns the flags of a square.

Parameters
pthe coordinates of the square
Returns
the grid flags

Definition at line 485 of file MapGrid.java.

◆ getGridSize()

Size2D net.sf.gridarta.model.mapgrid.MapGrid.getGridSize ( )

Returns a Size2D with the dimension of this grid.

Returns
a size 2D with the dimension of this grid

Definition at line 207 of file MapGrid.java.

References net.sf.gridarta.model.mapgrid.MapGrid.gridSize.

◆ getRecChange()

Rectangle net.sf.gridarta.model.mapgrid.MapGrid.getRecChange ( )

Returns a rectangle where the grid was changed.

Width and height is 0 for single squares.

Returns
the changed rectangle

Definition at line 495 of file MapGrid.java.

◆ getSelectedRec()

◆ getSelection()

Point [] net.sf.gridarta.model.mapgrid.MapGrid.getSelection ( )

Returns the selection.

Returns
the selection

Definition at line 842 of file MapGrid.java.

References net.sf.gridarta.model.mapgrid.MapGrid.cachedSelectedRec, and net.sf.gridarta.model.mapgrid.MapGrid.calculateCachedSelectedRec().

Referenced by net.sf.gridarta.gui.map.mapview.AbstractMapView< TestGameObject, TestMapArchObject, TestArchetype >.getSelectedSquares().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSize()

◆ hasError()

boolean net.sf.gridarta.model.mapgrid.MapGrid.hasError ( @NotNull final Point  p)

Checks if a square has the error flag set.

Parameters
pthe point to check
Returns
true
if GRID_FLAG_ERROR is set

Definition at line 466 of file MapGrid.java.

◆ invertSelection()

◆ preSelect()

void net.sf.gridarta.model.mapgrid.MapGrid.preSelect ( @NotNull final Point  start,
@NotNull final Point  end 
)

Rectangle defined by two points gets preselected.

The points can be on any corner as long as they are opposite to each other.

Parameters
startany point on a corner of the rectangle
endthe point on the opposite corner
See also
MapGrid::unPreSelect(Point, Point)

Definition at line 313 of file MapGrid.java.

References net.sf.gridarta.model.mapgrid.MapGrid.beginTransaction(), net.sf.gridarta.model.mapgrid.MapGrid.calculateRec(), net.sf.gridarta.model.mapgrid.MapGrid.endTransaction(), and net.sf.gridarta.model.mapgrid.MapGrid.setFlags().

Referenced by net.sf.gridarta.model.mapcursor.MapCursor< G, A, R >.dragStart().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeMapGridListener()

void net.sf.gridarta.model.mapgrid.MapGrid.removeMapGridListener ( @NotNull final MapGridListener  listener)

Removes a MapGridListener.

Parameters
listenerthe listener to remove

Definition at line 198 of file MapGrid.java.

References net.sf.gridarta.utils.EventListenerList2< T extends EventListener >.remove().

Referenced by net.sf.gridarta.var.crossfire.gui.map.renderer.AbstractFlatMapRenderer.closeNotify(), and net.sf.gridarta.gui.map.renderer.AbstractIsoMapRenderer< G, A, R >.closeNotify().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resize()

void net.sf.gridarta.model.mapgrid.MapGrid.resize ( @NotNull final Size2D  newSize)

Resizes the MapGrid.

Old flags will be copied to the new grid.

Parameters
newSizethe new grid size

Definition at line 215 of file MapGrid.java.

References net.sf.gridarta.utils.Size2D.equals(), net.sf.gridarta.model.mapgrid.MapGrid.fireMapGridResizeEvent(), net.sf.gridarta.utils.Size2D.getHeight(), net.sf.gridarta.utils.Size2D.getWidth(), net.sf.gridarta.model.mapgrid.MapGrid.GRID_FLAG_SELECTION, and net.sf.gridarta.model.mapgrid.MapGrid.unsetFlags().

Referenced by net.sf.gridarta.model.mapgrid.MapGridTest.testSelectionBorderUpdates().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ select()

◆ selectAll()

◆ selectArea()

void net.sf.gridarta.model.mapgrid.MapGrid.selectArea ( @NotNull final Point  pos1,
@NotNull final Point  pos2,
@NotNull final SelectionMode  selectionMode 
)

◆ setCursor()

void net.sf.gridarta.model.mapgrid.MapGrid.setCursor ( @NotNull final Point  pos)

Highlights the given cursor position.

Parameters
posthe map coordinates of square to highlight

Definition at line 296 of file MapGrid.java.

References net.sf.gridarta.model.mapgrid.MapGrid.beginTransaction(), net.sf.gridarta.model.mapgrid.MapGrid.endTransaction(), and net.sf.gridarta.model.mapgrid.MapGrid.setFlags().

Referenced by net.sf.gridarta.model.mapcursor.MapCursor< G, A, R >.endTransaction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setError()

void net.sf.gridarta.model.mapgrid.MapGrid.setError ( final int  x,
final int  y 
)

Sets the error flag at given coordinates.

Parameters
xthe x coordinate
ythe y coordinate

Definition at line 619 of file MapGrid.java.

References net.sf.gridarta.model.mapgrid.MapGrid.beginTransaction(), net.sf.gridarta.model.mapgrid.MapGrid.endTransaction(), and net.sf.gridarta.model.mapgrid.MapGrid.setFlags().

Referenced by net.sf.gridarta.gui.map.mapview.ErroneousMapSquares< G, A, R >.errorsChanged().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setFlags()

void net.sf.gridarta.model.mapgrid.MapGrid.setFlags ( final int  minX,
final int  minY,
final int  maxX,
final int  maxY,
final int  flags 
)
private

Sets flags in a rectangle and generate a grid change event.

Parameters
minXthe left x-coordinate
minYthe left y-coordinate
maxXthe right x-coordinate
maxYthe right y-coordinate
flagsthe flags to set

Definition at line 692 of file MapGrid.java.

References net.sf.gridarta.model.mapgrid.MapGrid.updateRecChange(), and net.sf.gridarta.model.mapgrid.MapGrid.updateSelectionFlag().

Referenced by net.sf.gridarta.model.mapgrid.MapGrid.preSelect(), net.sf.gridarta.model.mapgrid.MapGrid.selectAll(), net.sf.gridarta.model.mapgrid.MapGrid.selectArea(), net.sf.gridarta.model.mapgrid.MapGrid.setCursor(), net.sf.gridarta.model.mapgrid.MapGrid.setError(), and net.sf.gridarta.model.mapgrid.MapGrid.updatePreSelect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toggleFlags()

void net.sf.gridarta.model.mapgrid.MapGrid.toggleFlags ( final int  minX,
final int  minY,
final int  maxX,
final int  maxY,
final int  flags 
)
private

Flips flags in a rectangle and generate a grid change event.

Parameters
minXthe left x-coordinate
minYthe left y-coordinate
maxXthe right x-coordinate
maxYthe right y-coordinate
flagsthe flags to reset

Definition at line 738 of file MapGrid.java.

References net.sf.gridarta.model.mapgrid.MapGrid.updateRecChange(), and net.sf.gridarta.model.mapgrid.MapGrid.updateSelectionFlag().

Referenced by net.sf.gridarta.model.mapgrid.MapGrid.invertSelection(), and net.sf.gridarta.model.mapgrid.MapGrid.selectArea().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unPreSelect()

void net.sf.gridarta.model.mapgrid.MapGrid.unPreSelect ( @NotNull final Point  start,
@NotNull final Point  end 
)

Pre-selection of rectangle defined by points gets deleted.

Parameters
startthe coordinates of the first corner
endthe coordinates of the opposite corner
See also
MapGrid::preSelect(Point, Point)

Definition at line 393 of file MapGrid.java.

References net.sf.gridarta.model.mapgrid.MapGrid.beginTransaction(), net.sf.gridarta.model.mapgrid.MapGrid.calculateRec(), net.sf.gridarta.model.mapgrid.MapGrid.endTransaction(), and net.sf.gridarta.model.mapgrid.MapGrid.unsetFlags().

Referenced by net.sf.gridarta.model.mapcursor.MapCursor< G, A, R >.dragRelease().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unSelect()

◆ unSetCursor()

void net.sf.gridarta.model.mapgrid.MapGrid.unSetCursor ( @NotNull final Point  pos)

Un-highlights the given cursor position.

Parameters
posthe map coordinates of square to un-highlight

Definition at line 276 of file MapGrid.java.

References net.sf.gridarta.model.mapgrid.MapGrid.beginTransaction(), net.sf.gridarta.model.mapgrid.MapGrid.endTransaction(), and net.sf.gridarta.model.mapgrid.MapGrid.unsetFlags().

Referenced by net.sf.gridarta.model.mapcursor.MapCursor< G, A, R >.endTransaction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unsetFlags()

void net.sf.gridarta.model.mapgrid.MapGrid.unsetFlags ( final int  minX,
final int  minY,
final int  maxX,
final int  maxY,
final int  flags 
)
private

Resets flags in a rectangle and generate a grid change event.

Parameters
minXthe left x-coordinate
minYthe left y-coordinate
maxXthe right x-coordinate
maxYthe right y-coordinate
flagsthe flags to reset

Definition at line 715 of file MapGrid.java.

References net.sf.gridarta.model.mapgrid.MapGrid.updateRecChange(), and net.sf.gridarta.model.mapgrid.MapGrid.updateSelectionFlag().

Referenced by net.sf.gridarta.model.mapgrid.MapGrid.clearErrors(), net.sf.gridarta.model.mapgrid.MapGrid.resize(), net.sf.gridarta.model.mapgrid.MapGrid.selectArea(), net.sf.gridarta.model.mapgrid.MapGrid.unPreSelect(), net.sf.gridarta.model.mapgrid.MapGrid.unSelect(), net.sf.gridarta.model.mapgrid.MapGrid.unSetCursor(), and net.sf.gridarta.model.mapgrid.MapGrid.updatePreSelect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updatePreSelect()

void net.sf.gridarta.model.mapgrid.MapGrid.updatePreSelect ( @NotNull final Point  start,
@NotNull final Point  oldEnd,
@NotNull final Point  newEnd 
)

Update the pre-selection rectangle.

The effect is identical to calling

unPreSelect(start, oldEnd); preSelect(start, newEnd);

except that smaller change events are generated.

Parameters
startthe coordinate of the common first point
oldEndthe coordinate of the end point for selection deletion
newEndthe coordinate of the end point for selection addition
Note
This function assumes that all of (start-oldEnd) has set GRID_FLAG_SELECTING but no other square has set GRID_FLAG_SELECTING; if this precondition does not hold, it does not correctly update the flags

Definition at line 334 of file MapGrid.java.

References net.sf.gridarta.model.mapgrid.MapGrid.beginTransaction(), net.sf.gridarta.model.mapgrid.MapGrid.endTransaction(), net.sf.gridarta.model.mapgrid.MapGrid.setFlags(), and net.sf.gridarta.model.mapgrid.MapGrid.unsetFlags().

Referenced by net.sf.gridarta.model.mapcursor.MapCursor< G, A, R >.dragTo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateRecChange()

void net.sf.gridarta.model.mapgrid.MapGrid.updateRecChange ( final int  x,
final int  y 
)
private

Adds a point to the set of changes.

Parameters
xthe x-coordinate
ythe y-coordinate

Definition at line 658 of file MapGrid.java.

Referenced by net.sf.gridarta.model.mapgrid.MapGrid.setFlags(), net.sf.gridarta.model.mapgrid.MapGrid.toggleFlags(), net.sf.gridarta.model.mapgrid.MapGrid.unsetFlags(), and net.sf.gridarta.model.mapgrid.MapGrid.updateSelectionFlag().

+ Here is the caller graph for this function:

◆ updateSelectionFlag() [1/2]

void net.sf.gridarta.model.mapgrid.MapGrid.updateSelectionFlag ( final int  x,
final int  y,
final boolean  newState 
)
private

Updates the border selection flags of a square and its adjacent squares.

This function assumes the the square's selection state has changed.

Parameters
xthe x-coordinate of the square
ythe y-coordinate of the square
newStatethe new square's selection state

Definition at line 798 of file MapGrid.java.

Referenced by net.sf.gridarta.model.mapgrid.MapGrid.setFlags(), net.sf.gridarta.model.mapgrid.MapGrid.toggleFlags(), and net.sf.gridarta.model.mapgrid.MapGrid.unsetFlags().

+ Here is the caller graph for this function:

◆ updateSelectionFlag() [2/2]

void net.sf.gridarta.model.mapgrid.MapGrid.updateSelectionFlag ( final int  x,
final int  y,
final boolean  newState,
final int  dx,
final int  dy,
final int  flag,
final int  dFlag 
)
private

Updates the border selection flags of a square and one adjacent square.

This function assumes the the square's selection state has changed.

Parameters
xthe x-coordinate of the square
ythe y-coordinate of the square
newStatethe new square's selection state
dxthe x-coordinate of the adjacent square
dythe y-coordinate of the adjacent square
flagthe border selection flag for the square
dFlagthe border selection flag for the adjacent square

Definition at line 816 of file MapGrid.java.

References net.sf.gridarta.utils.Size2D.getHeight(), net.sf.gridarta.utils.Size2D.getWidth(), net.sf.gridarta.model.mapgrid.MapGrid.GRID_FLAG_SELECTION, and net.sf.gridarta.model.mapgrid.MapGrid.updateRecChange().

+ Here is the call graph for this function:

Member Data Documentation

◆ cachedCursorLoc

Point net.sf.gridarta.model.mapgrid.MapGrid.cachedCursorLoc
private

Cached location of the cursor.

Definition at line 93 of file MapGrid.java.

◆ cachedSelectedRec

Rectangle net.sf.gridarta.model.mapgrid.MapGrid.cachedSelectedRec
private

The return value for getSelectedRec().

Only valid if cachedSelectedRecValid is set.

Definition at line 87 of file MapGrid.java.

Referenced by net.sf.gridarta.model.mapgrid.MapGrid.getSelection().

◆ cachedSelectedRecValid

boolean net.sf.gridarta.model.mapgrid.MapGrid.cachedSelectedRecValid
private

If set, cachedSelectedRec is up-to-date.

Definition at line 80 of file MapGrid.java.

◆ cornerMax

final Point net.sf.gridarta.model.mapgrid.MapGrid.cornerMax = new Point()
private

Right lower coordinates of rectangle that is being processed.

Definition at line 63 of file MapGrid.java.

◆ cornerMin

final Point net.sf.gridarta.model.mapgrid.MapGrid.cornerMin = new Point()
private

Left upper coordinates of rectangle that is being processed.

Definition at line 57 of file MapGrid.java.

◆ GRID_FLAG_CONNECTION

final int net.sf.gridarta.model.mapgrid.MapGrid.GRID_FLAG_CONNECTION = 1 << 6
static

Flag to highlight as part of a connection group.

RFU.

Definition at line 128 of file MapGrid.java.

◆ GRID_FLAG_CURSOR

final int net.sf.gridarta.model.mapgrid.MapGrid.GRID_FLAG_CURSOR = 1 << 7
static

Flag to highlight cursor position.

Normally there will only be up to one square that has this flag set.

Definition at line 134 of file MapGrid.java.

Referenced by net.sf.gridarta.gui.map.renderer.GridMapSquarePainter.paint().

◆ GRID_FLAG_ERROR

final int net.sf.gridarta.model.mapgrid.MapGrid.GRID_FLAG_ERROR = 1 << 4
static

◆ GRID_FLAG_FATAL

final int net.sf.gridarta.model.mapgrid.MapGrid.GRID_FLAG_FATAL = 1 << 5
static

Flag to highlight as fatal.

RFU.

Definition at line 123 of file MapGrid.java.

◆ GRID_FLAG_INFORMATION

final int net.sf.gridarta.model.mapgrid.MapGrid.GRID_FLAG_INFORMATION = 1 << 2
static

Flag to highlight as information.

RFU.

Definition at line 108 of file MapGrid.java.

◆ GRID_FLAG_SELECTING

final int net.sf.gridarta.model.mapgrid.MapGrid.GRID_FLAG_SELECTING = 1 << 1
static

◆ GRID_FLAG_SELECTION

◆ GRID_FLAG_SELECTION_EAST

final int net.sf.gridarta.model.mapgrid.MapGrid.GRID_FLAG_SELECTION_EAST = 1 << 9
static

Selection - is set for squares at the east edge of the selected area.

Definition at line 144 of file MapGrid.java.

Referenced by net.sf.gridarta.model.mapgrid.MapGridTest.checkSelectionBorder(), and net.sf.gridarta.gui.map.renderer.GridMapSquarePainter.paint().

◆ GRID_FLAG_SELECTION_NORTH

final int net.sf.gridarta.model.mapgrid.MapGrid.GRID_FLAG_SELECTION_NORTH = 1 << 8
static

Selection - is set for squares at the north edge of the selected area.

Definition at line 139 of file MapGrid.java.

Referenced by net.sf.gridarta.model.mapgrid.MapGridTest.checkSelectionBorder(), and net.sf.gridarta.gui.map.renderer.GridMapSquarePainter.paint().

◆ GRID_FLAG_SELECTION_SOUTH

final int net.sf.gridarta.model.mapgrid.MapGrid.GRID_FLAG_SELECTION_SOUTH = 1 << 10
static

Selection - is set for squares at the south edge of the selected area.

Definition at line 149 of file MapGrid.java.

Referenced by net.sf.gridarta.model.mapgrid.MapGridTest.checkSelectionBorder(), and net.sf.gridarta.gui.map.renderer.GridMapSquarePainter.paint().

◆ GRID_FLAG_SELECTION_WEST

final int net.sf.gridarta.model.mapgrid.MapGrid.GRID_FLAG_SELECTION_WEST = 1 << 11
static

Selection - is set for squares at the west edge of the selected area.

Definition at line 154 of file MapGrid.java.

Referenced by net.sf.gridarta.model.mapgrid.MapGridTest.checkSelectionBorder(), and net.sf.gridarta.gui.map.renderer.GridMapSquarePainter.paint().

◆ GRID_FLAG_WARNING

final int net.sf.gridarta.model.mapgrid.MapGrid.GRID_FLAG_WARNING = 1 << 3
static

Flag to highlight as warning.

RFU.

Definition at line 113 of file MapGrid.java.

◆ gridFlags

int [][] net.sf.gridarta.model.mapgrid.MapGrid.gridFlags
private

2D-array to store grid flags.

Definition at line 51 of file MapGrid.java.

◆ gridSize

Size2D net.sf.gridarta.model.mapgrid.MapGrid.gridSize
private

◆ listenerList

final EventListenerList2<MapGridListener> net.sf.gridarta.model.mapgrid.MapGrid.listenerList = new EventListenerList2<>(MapGridListener.class)
private

The MapGridListeners to inform of changes.

Definition at line 160 of file MapGrid.java.

◆ recChange

final Rectangle net.sf.gridarta.model.mapgrid.MapGrid.recChange = new Rectangle()
private

Rectangle to store location of last grid change.

Definition at line 75 of file MapGrid.java.

◆ transactionDepth

int net.sf.gridarta.model.mapgrid.MapGrid.transactionDepth
private

The transaction depth.

A value of 0 means there's no transaction going on. A value > 0 means there's a transaction going on and denotes the nesting level.

Invariant
transactionDepth >= 0

Definition at line 168 of file MapGrid.java.

◆ transactionThread

Thread net.sf.gridarta.model.mapgrid.MapGrid.transactionThread
private

The thread that performs the current transaction.

Invariant
transactionDepth > 0 || transactionThread == null

Definition at line 175 of file MapGrid.java.


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