java.lang.Object
me.gosimple.nbvcxz.resources.AdjacencyGraphUtil
public class AdjacencyGraphUtil
extends java.lang.Object
Contains hard coded adjacency graphs for different keyboard types.
- Author:
- Adam Brusselback
-
Field Summary
Fields Modifier and Type Field Description static java.util.HashMap<java.lang.Character,java.lang.String[]>dvorakAdjacency graph for the dvorak keyboardstatic java.util.HashMap<java.lang.Character,java.lang.String[]>macKeypadAdjacency graph for the macKeypadstatic java.util.HashMap<java.lang.Character,java.lang.String[]>qwertyAdjacency graph for the qwerty keyboardstatic java.util.HashMap<java.lang.Character,java.lang.String[]>standardKeypadAdjacency graph for the keypad -
Constructor Summary
Constructors Constructor Description AdjacencyGraphUtil() -
Method Summary
Modifier and Type Method Description static doublecalcAverageDegree(java.util.HashMap<java.lang.Character,java.lang.String[]> keys)Calculates the average "degree" of a keyboard or keypad.static java.util.Set<java.lang.Character>getNeighbors(AdjacencyGraph adjacencyGraph, java.lang.Character key)Returns a set of neighbors for a specific character.static intgetShifts(AdjacencyGraph adjacencyGraph, java.lang.String part)Returns the number of shifts in case in the part passed in.static intgetTurns(AdjacencyGraph adjacencyGraph, java.lang.String part)Returns the number of turns in the part passed in based on the adjacency graph.static intneighborsNumber(java.lang.String[] neighbors)Count how many neighbors a key has
-
Field Details
-
qwerty
public static final java.util.HashMap<java.lang.Character,java.lang.String[]> qwertyAdjacency graph for the qwerty keyboard -
dvorak
public static final java.util.HashMap<java.lang.Character,java.lang.String[]> dvorakAdjacency graph for the dvorak keyboard -
standardKeypad
public static final java.util.HashMap<java.lang.Character,java.lang.String[]> standardKeypadAdjacency graph for the keypad -
macKeypad
public static final java.util.HashMap<java.lang.Character,java.lang.String[]> macKeypadAdjacency graph for the macKeypad
-
-
Constructor Details
-
AdjacencyGraphUtil
public AdjacencyGraphUtil()
-
-
Method Details
-
calcAverageDegree
public static double calcAverageDegree(java.util.HashMap<java.lang.Character,java.lang.String[]> keys)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
public static int neighborsNumber(java.lang.String[] neighbors)Count how many neighbors a key has- Parameters:
neighbors- the neighbors- Returns:
- the number of neighbors
-
getNeighbors
public static java.util.Set<java.lang.Character> getNeighbors(AdjacencyGraph adjacencyGraph, java.lang.Character key)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
-