Class AdjacencyGraphUtil

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[]> dvorak
    Adjacency graph for the dvorak keyboard
    static java.util.HashMap<java.lang.Character,​java.lang.String[]> macKeypad
    Adjacency graph for the macKeypad
    static java.util.HashMap<java.lang.Character,​java.lang.String[]> qwerty
    Adjacency graph for the qwerty keyboard
    static java.util.HashMap<java.lang.Character,​java.lang.String[]> standardKeypad
    Adjacency graph for the keypad
  • Constructor Summary

    Constructors 
    Constructor Description
    AdjacencyGraphUtil()  
  • Method Summary

    Modifier and Type Method Description
    static double calcAverageDegree​(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 int getShifts​(AdjacencyGraph adjacencyGraph, java.lang.String part)
    Returns the number of shifts in case in the part passed in.
    static int getTurns​(AdjacencyGraph adjacencyGraph, java.lang.String part)
    Returns the number of turns in the part passed in based on the adjacency graph.
    static int neighborsNumber​(java.lang.String[] neighbors)
    Count how many neighbors a key has

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • qwerty

      public static final java.util.HashMap<java.lang.Character,​java.lang.String[]> qwerty
      Adjacency graph for the qwerty keyboard
    • dvorak

      public static final java.util.HashMap<java.lang.Character,​java.lang.String[]> dvorak
      Adjacency graph for the dvorak keyboard
    • standardKeypad

      public static final java.util.HashMap<java.lang.Character,​java.lang.String[]> standardKeypad
      Adjacency graph for the keypad
    • macKeypad

      public static final java.util.HashMap<java.lang.Character,​java.lang.String[]> macKeypad
      Adjacency graph for the macKeypad
  • Constructor Details

  • 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

      public static int getTurns​(AdjacencyGraph adjacencyGraph, java.lang.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, java.lang.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