Class AdjacencyGraphUtil

java.lang.Object
me.gosimple.nbvcxz.resources.AdjacencyGraphUtil

public class AdjacencyGraphUtil extends Object
Contains hard coded adjacency graphs for different keyboard types.
Author:
Adam Brusselback
  • Field Details

  • Constructor Details

    • AdjacencyGraphUtil

      public AdjacencyGraphUtil()
  • Method Details

    • calcAverageDegree

      public static double calcAverageDegree(HashMap<Character,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(String[] neighbors)
      Count how many neighbors a key has
      Parameters:
      neighbors - the neighbors
      Returns:
      the number of neighbors
    • getNeighbors

      public static Set<Character> getNeighbors(AdjacencyGraph adjacencyGraph, 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

      public static int getTurns(AdjacencyGraph adjacencyGraph, String part)
      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

      public static int getShifts(AdjacencyGraph adjacencyGraph, String part)
      Returns the number of shifts in case in the part passed in.
      Parameters:
      adjacencyGraph - the graph you are using to get the neighbors
      part - the string you are getting shifts for.
      Returns:
      the number of shifts in this string for the AdjacencyGraph