public class AStar extends androidx.fragment.app.Fragment implements iAStar
Fragment
subclass.Modifier and Type | Class and Description |
---|---|
private class |
AStar.ButtonActions
Implementation of the actions for each button.
|
private class |
AStar.Measures
Class that implements the usage of either Manhattan o Euclidean measure methods for the
algorithm to actually work.
|
Modifier and Type | Field and Description |
---|---|
private int |
actualStep |
private int |
actualX |
private int |
actualY |
private ArrayList<String> |
biomes |
private android.widget.EditText[][] |
board |
private android.widget.Button |
btnStartAlgorithm |
private AStar.ButtonActions |
buttonActions |
private CharacterItem |
character |
private android.graphics.drawable.Drawable |
characterIcon |
private ArrayList<Integer> |
codes |
private ArrayList<Integer> |
colors |
private String |
contentFile |
private ArrayList<String> |
expansionOrder |
private int |
finalX |
private int |
finalY |
private int |
initialX |
private int |
initialY |
private int[][] |
mapValues |
private int |
measureMode |
private HeuristicPathTree.Node[][] |
nodes |
private int |
pathColor |
private android.widget.SeekBar |
sbRefreshBar |
private android.widget.Spinner |
spMeasureType |
(package private) float |
textSize |
private ResolverAStarThread |
thread |
private android.widget.TableLayout |
tlTableMap |
private HeuristicPathTree |
tree |
private android.widget.TextView |
tvRefreshRate |
private long |
updateTime |
private String |
updateTimeText |
Constructor and Description |
---|
AStar()
A* Algorithm Constructor.
|
Modifier and Type | Method and Description |
---|---|
private void |
createTable(int[][] mapValues)
The creation of the table with each tile as a text view and letters and numbers
for the first column and row.
|
void |
drawPath(HeuristicPathTree heuristicPathTree)
Method to control the whole drawing of the path once the algorithm finishes.
|
private void |
loadBoard()
We load the pre-game board with information like the initial and final tile, we
start the tutorial if its the first time executing the app, and finish the method.
|
void |
moveCharacter(int posY,
int posX)
Update the position and icon of the character once it moves.
|
android.view.View |
onCreateView(android.view.LayoutInflater inflater,
android.view.ViewGroup container,
android.os.Bundle savedInstanceState)
To create the view.
|
void |
onStop()
Method to make the thread stop once the algorithm finishes.
|
private void |
putNodesInfo(android.widget.EditText et)
Method to be able to show the weight of each node in the graphic tree.
|
void |
setColorToField(int y,
int x)
Set color field to a tile once we get its code, so the color will be correct.
|
private void |
setFieldColor(int y,
int x,
int color)
Whe receive coordinates and a color, to color a specific tile.
|
void |
showFailureMessage()
Method to show a failure message in case the algorithm is not able to reach the final tile.
|
private void |
stopThread()
Method called by onStop to stop thread.
|
dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLayoutInflater, getLifecycle, getLoaderManager, getParentFragment, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSavedStateRegistry, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, getViewLifecycleOwner, getViewLifecycleOwnerLiveData, getViewModelStore, hashCode, hasOptionsMenu, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isMenuVisible, isRemoving, isResumed, isStateSaved, isVisible, onActivityCreated, onActivityResult, onAttach, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreate, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroy, onDestroyOptionsMenu, onDestroyView, onDetach, onGetLayoutInflater, onHiddenChanged, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPause, onPictureInPictureModeChanged, onPrepareOptionsMenu, onPrimaryNavigationFragmentChanged, onRequestPermissionsResult, onResume, onSaveInstanceState, onStart, onViewCreated, onViewStateRestored, postponeEnterTransition, postponeEnterTransition, registerForContextMenu, requestPermissions, requireActivity, requireArguments, requireContext, requireFragmentManager, requireHost, requireParentFragment, requireView, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterTransition, setExitSharedElementCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, startPostponedEnterTransition, toString, unregisterForContextMenu
float textSize
private String contentFile
private String updateTimeText
private int initialX
private int finalX
private int initialY
private int finalY
private int actualX
private int actualY
private int actualStep
private int[][] mapValues
private int measureMode
private long updateTime
private CharacterItem character
private android.widget.TableLayout tlTableMap
private android.widget.EditText[][] board
private HeuristicPathTree.Node[][] nodes
private AStar.ButtonActions buttonActions
private android.graphics.drawable.Drawable characterIcon
private HeuristicPathTree tree
private android.widget.Button btnStartAlgorithm
private android.widget.TextView tvRefreshRate
private android.widget.SeekBar sbRefreshBar
private android.widget.Spinner spMeasureType
private int pathColor
private ResolverAStarThread thread
public android.view.View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)
onCreateView
in class androidx.fragment.app.Fragment
inflater
- Layout corresponding to the context.container
- The view group.savedInstanceState
- The bundle containing all the information.private void setFieldColor(int y, int x, int color)
y
- Y coordinate.x
- X coordinate.color
- Tile color.private void loadBoard()
private void createTable(int[][] mapValues)
mapValues
- the map information to process in the creation of the table.public void showFailureMessage()
showFailureMessage
in interface iAStar
public void drawPath(HeuristicPathTree heuristicPathTree)
private void putNodesInfo(android.widget.EditText et)
et
- The node which we are modifying to show the weight.public void moveCharacter(int posY, int posX)
moveCharacter
in interface iAStar
posY
- Actual Y position, then changed to the new one.posX
- Actual X position, then changed to the new one.public void setColorToField(int y, int x)
setColorToField
in interface iAStar
y
- Y coordinate.x
- X coordinate.public void onStop()
onStop
in class androidx.fragment.app.Fragment
private void stopThread()