java.lang.Object
me.gosimple.nbvcxz.resources.AdjacencyGraphUtil
Contains hard coded adjacency graphs for different keyboard types.
- Author:
- Adam Brusselback
-
Field Summary
FieldsModifier and TypeFieldDescriptionAdjacency graph for the dvorak keyboardAdjacency graph for the macKeypadAdjacency graph for the qwerty keyboardAdjacency graph for the keypad -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doublecalcAverageDegree(HashMap<Character, String[]> keys) Calculates the average "degree" of a keyboard or keypad.getNeighbors(AdjacencyGraph adjacencyGraph, Character key) Returns a set of neighbors for a specific character.static intgetShifts(AdjacencyGraph adjacencyGraph, String part) Returns the number of shifts in case in the part passed in.static intgetTurns(AdjacencyGraph adjacencyGraph, String part) Returns the number of turns in the part passed in based on the adjacency graph.static intneighborsNumber(String[] neighbors) Count how many neighbors a key has
-
Field Details
-
qwerty
Adjacency graph for the qwerty keyboard -
dvorak
Adjacency graph for the dvorak keyboard -
standardKeypad
Adjacency graph for the keypad -
macKeypad
Adjacency graph for the macKeypad
-
-
Constructor Details
-
AdjacencyGraphUtil
public AdjacencyGraphUtil()
-
-
Method Details
-
calcAverageDegree
Calculates the average "degree" of a keyboard or keypad. On the qwerty keyboard, 'g' has degree 6, being adjacent to 'ftyhbv' and '\' has degree 1.- Parameters:
keys- a keyboard or keypad- Returns:
- the average degree for this keyboard or keypad
-
neighborsNumber
Count how many neighbors a key has- Parameters:
neighbors- the neighbors- Returns:
- the number of neighbors
-
getNeighbors
Returns a set of neighbors for a specific character.- Parameters:
adjacencyGraph- the graph you are using to get the neighbors.key- the character you are getting neighbors for.- Returns:
- A set of characters which are neighbors to the passed in character.
-
getTurns
Returns the number of turns in the part passed in based on the adjacency graph.- Parameters:
adjacencyGraph- the graph you are using to get the neighbors.part- the string you are getting turns for.- Returns:
- the number of turns in this string for the
AdjacencyGraph
-
getShifts
Returns the number of shifts in case in the part passed in.- Parameters:
adjacencyGraph- the graph you are using to get the neighborspart- the string you are getting shifts for.- Returns:
- the number of shifts in this string for the
AdjacencyGraph
-