public class FirstBest extends androidx.fragment.app.Fragment implements iFirstTheBest
Fragment
subclass.Modifier and Type | Class and Description |
---|---|
private class |
FirstBest.ButtonActions
Class to implement the button actions.
|
private class |
FirstBest.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 FirstBest.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 ResolverFirstBestThread |
thread |
private android.widget.TableLayout |
tlTableMap |
private HeuristicPathTree |
tree |
private android.widget.TextView |
tvRefreshRate |
private long |
updateTime |
private String |
updateTimeText |
Constructor and Description |
---|
FirstBest()
First Best Algorithm Constructor.
|
Modifier and Type | Method and Description |
---|---|
private void |
createTable(int[][] mapValues)
Creation of all the tiles as text views, and the first row and column containing
letters and numbers.
|
void |
drawPath(HeuristicPathTree heuristicPathTree)
Drawing of the shortest path followed by the algorithm, just after it has finished.
|
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()
Show failure message in case the final tile is unreachable for any reason.
|
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 FirstBest.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 ResolverFirstBestThread 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 values corresponding to the whole map of the board.public void showFailureMessage()
showFailureMessage
in interface iFirstTheBest
public void drawPath(HeuristicPathTree heuristicPathTree)
drawPath
in interface iFirstTheBest
heuristicPathTree
- the tree from which the path can be processed and painted.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 iFirstTheBest
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 iFirstTheBest
y
- Y coordinate.x
- X coordinate.public void onStop()
onStop
in class androidx.fragment.app.Fragment
private void stopThread()