edu.mit.sketch.toolkit
Class Blackboard

java.lang.Object
  |
  +--edu.mit.sketch.toolkit.Blackboard

public class Blackboard
extends Object

Polygons recognized by the tablet are sent here. This class decides between candidate polygons and returns it.


Field Summary
static int best_index
          Best index (index of the best fit).
static double distance_difference
          Pixel distance tolerance index_difference and distance_difference are used during computation of intersection etc.
static GeneralPath general_path
          A general path object obtained from the hybrid fits.
static Fit[] hybrid_fits
          The array of hybrid fits obtained from speed and direction fits.
static int index_difference
          Index difference tolerance.
static Range[] ranges
          The ranges for the segments in the general_path
 
Constructor Summary
Blackboard()
           
 
Method Summary
static GeneralPath adjustGeneralPath(GeneralPath general_path, StrokeData data)
          Improve the fit by reducing the least square error.
static void checkCertaintyBounds(Vertex[] vertices)
          See if all the certainty values are between 0 and 1.
static GeneralPath computeGeneralPath(Vertex[] intersection, Vertex[] superset, Fit[] fits, StrokeData data)
          Compute a GeneralPath given the information in the arguments.
static boolean containsWithTolerance(Vertex[] vertices, Vertex vertex, int index_difference_tolerance, double distance_tolerance)
          Return true if the array contains a Vertex that is sufficiently close to the argument vertex given the tolerances.
static Vertex[] decide(Vertex[] speed_fit, Vertex[] direction_fit, Point[] points, StrokeData data)
          a and b are two possible polygon matches for points.
static Vertex[] getContiguosExcludedPointSequence(int start_pointer, Vertex[] subset, Vertex[] superset)
          Return the sequence of contiguos point sequence that is included in superset, but is excluded in subset.
static Point[] getControlPoints(Vertex v1, Vertex v2, StrokeData data)
          Return the control points to be used for drawing a curve from v1 to v2.
static Point[] getControlPoints(Vertex v1, Vertex v2, StrokeData data, int left_offset, int right_offset)
          Return the control points to be used for drawing a curve from v1 to v2.
static Vertex[] getCurvatureFit(Point[] points, Vertex[] vertices, double scale)
          Returns a curvature fit.
static Vertex[] getCurvatureFitOld(Point[] points, Vertex[] vertices, double scale)
          Returns a curvature fit.
static Fit[] getHybridFits(Vertex[] speed_fit, Vertex[] direction_fit, Point[] points)
          Computes the hybrid fits from speed_fit and direction_fit
static int getIndexInVertices(Vertex[] vertices, Vertex vertex, int index_difference_tolerance, double distance_tolerance)
          Return the index in subset if the array contains a Vertex that is sufficiently close to the argument vertex given the tolerances.
static Vertex[] getIntersection(Vertex[] a, Vertex[] b, int bias)
          Get the common points in a and b.
static int[] getPolygonIndices(Point[] output_polygon, Point[] points)
          get the indices of output_polygon in the array points.
static Vertex[] getSymmetricDifference(Vertex[] a, Vertex[] b, Vertex[] intersection, int bias)
          Get the symmetric difference of a and b.
static Vertex[] getUnion(Vertex[] a, Vertex[] b)
          Get all the points in a and b.
static Vertex[] insertVertex(Vertex[] vertices, Vertex vertex)
          Return the vertices obtained by inserting the input vertex to the appropriate slot in the input vertices.
static double leastSquaresForPolygon(Vertex[] vertices, Point[] points)
          calculate the lsq error.
static Vertex[] overlay(Vertex[] subset, Vertex[] superset, int index_tolerance, double distance_tolerance)
          Overlay subset and superset so the vertices very close to one another are collapsed into one.
static void paintGeneralPath(GeneralPath general_path)
          Paint the general path
static void paintGeneralPathConvexHulls(GeneralPath general_path)
          Show convex hulls for the curves
static void paintGeneralPathInSegments(GeneralPath general_path)
          Paint the general path in segments
static void printPoints(Point[] points, String name)
          Print the points array.
static void printPointsWithIndices(Point[] points, String name, Point[] real_points)
          Print the points assuming with their corresponding indices in real_points.
static Vertex[] removeCloseVertices(Vertex[] vertices, int index_tolerance, double distance_tolerance)
          Remove vertices closer than index_tolerance in indices or, distance_tolerance spatially.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hybrid_fits

public static Fit[] hybrid_fits
The array of hybrid fits obtained from speed and direction fits.

general_path

public static GeneralPath general_path
A general path object obtained from the hybrid fits.

ranges

public static Range[] ranges
The ranges for the segments in the general_path

index_difference

public static int index_difference
Index difference tolerance. index_difference and distance_difference are used during computation of intersection etc.

distance_difference

public static double distance_difference
Pixel distance tolerance index_difference and distance_difference are used during computation of intersection etc.

best_index

public static int best_index
Best index (index of the best fit).
Constructor Detail

Blackboard

public Blackboard()
Method Detail

decide

public static Vertex[] decide(Vertex[] speed_fit,
                              Vertex[] direction_fit,
                              Point[] points,
                              StrokeData data)
a and b are two possible polygon matches for points. Return a fit by combining info from a and b.

getCurvatureFitOld

public static Vertex[] getCurvatureFitOld(Point[] points,
                                          Vertex[] vertices,
                                          double scale)
Returns a curvature fit. This is done by adding points between vertices to indicate that this portion should be approximated by curves. (an old version).

getCurvatureFit

public static Vertex[] getCurvatureFit(Point[] points,
                                       Vertex[] vertices,
                                       double scale)
Returns a curvature fit. This is done by adding points between vertices to indicate that this portion should be approximated by curves.

getHybridFits

public static Fit[] getHybridFits(Vertex[] speed_fit,
                                  Vertex[] direction_fit,
                                  Point[] points)
Computes the hybrid fits from speed_fit and direction_fit

adjustGeneralPath

public static GeneralPath adjustGeneralPath(GeneralPath general_path,
                                            StrokeData data)
Improve the fit by reducing the least square error.

computeGeneralPath

public static GeneralPath computeGeneralPath(Vertex[] intersection,
                                             Vertex[] superset,
                                             Fit[] fits,
                                             StrokeData data)
Compute a GeneralPath given the information in the arguments.

getContiguosExcludedPointSequence

public static Vertex[] getContiguosExcludedPointSequence(int start_pointer,
                                                         Vertex[] subset,
                                                         Vertex[] superset)
Return the sequence of contiguos point sequence that is included in superset, but is excluded in subset. We start the search from start_index in subset. So the indices of the vertices returned are strictly between the indices of subset[start_pointer] and subset[start_pointer+1]. If start_pointer points to the last in the subset, then all vertices in superset whose indices are larger than the index of the last element in subset are returned. This method assumes that the input vertices are sorted by index.

leastSquaresForPolygon

public static double leastSquaresForPolygon(Vertex[] vertices,
                                            Point[] points)
calculate the lsq error. points is the actual data points, polgon is the match

getPolygonIndices

public static int[] getPolygonIndices(Point[] output_polygon,
                                      Point[] points)
get the indices of output_polygon in the array points.

printPoints

public static void printPoints(Point[] points,
                               String name)
Print the points array.

containsWithTolerance

public static boolean containsWithTolerance(Vertex[] vertices,
                                            Vertex vertex,
                                            int index_difference_tolerance,
                                            double distance_tolerance)
Return true if the array contains a Vertex that is sufficiently close to the argument vertex given the tolerances.

getSymmetricDifference

public static Vertex[] getSymmetricDifference(Vertex[] a,
                                              Vertex[] b,
                                              Vertex[] intersection,
                                              int bias)
Get the symmetric difference of a and b. Use a reasonable measure of "closeness" for the points in a and b so that points are considered to be equal even if they do not have the same index. Intersection can be null or it may contain the correct intersection of a and b.

overlay

public static Vertex[] overlay(Vertex[] subset,
                               Vertex[] superset,
                               int index_tolerance,
                               double distance_tolerance)
Overlay subset and superset so the vertices very close to one another are collapsed into one.

getIndexInVertices

public static int getIndexInVertices(Vertex[] vertices,
                                     Vertex vertex,
                                     int index_difference_tolerance,
                                     double distance_tolerance)
Return the index in subset if the array contains a Vertex that is sufficiently close to the argument vertex given the tolerances. Return -1 if no such vertex exists.

removeCloseVertices

public static Vertex[] removeCloseVertices(Vertex[] vertices,
                                           int index_tolerance,
                                           double distance_tolerance)
Remove vertices closer than index_tolerance in indices or, distance_tolerance spatially.

getIntersection

public static Vertex[] getIntersection(Vertex[] a,
                                       Vertex[] b,
                                       int bias)
Get the common points in a and b. Use a reasonable measure of "closeness" for the points in a and b so that points are considered to be equal even if they do not have the same index.

getUnion

public static Vertex[] getUnion(Vertex[] a,
                                Vertex[] b)
Get all the points in a and b. Use a reasonable measure of "closeness" for the points in a and b so that points are considered to be equal even if they do not have the same index.

printPointsWithIndices

public static void printPointsWithIndices(Point[] points,
                                          String name,
                                          Point[] real_points)
Print the points assuming with their corresponding indices in real_points. Assume that original points contains all points[i].

checkCertaintyBounds

public static void checkCertaintyBounds(Vertex[] vertices)
See if all the certainty values are between 0 and 1.

paintGeneralPath

public static void paintGeneralPath(GeneralPath general_path)
Paint the general path

paintGeneralPathInSegments

public static void paintGeneralPathInSegments(GeneralPath general_path)
Paint the general path in segments

paintGeneralPathConvexHulls

public static void paintGeneralPathConvexHulls(GeneralPath general_path)
Show convex hulls for the curves

insertVertex

public static Vertex[] insertVertex(Vertex[] vertices,
                                    Vertex vertex)
Return the vertices obtained by inserting the input vertex to the appropriate slot in the input vertices.

getControlPoints

public static Point[] getControlPoints(Vertex v1,
                                       Vertex v2,
                                       StrokeData data)
Return the control points to be used for drawing a curve from v1 to v2.

getControlPoints

public static Point[] getControlPoints(Vertex v1,
                                       Vertex v2,
                                       StrokeData data,
                                       int left_offset,
                                       int right_offset)
Return the control points to be used for drawing a curve from v1 to v2.