edu.mit.sketch.util
Class AWTUtil

java.lang.Object
  extended by edu.mit.sketch.util.AWTUtil

public class AWTUtil
extends java.lang.Object

Implements some methods not found in jdk 1.1


Field Summary
static java.awt.Color[] colors
          Array of 8 colors for in-loop alternated coloring.
static java.awt.Color[] colors2
          Array of 2 colors.
 
Constructor Summary
AWTUtil()
           
 
Method Summary
static Vertex[] flatten(java.awt.Shape shape, double flatness, int limit)
          Return an array of vertices corresponding to the flattened version of the input.
static java.awt.Component[] getAllComponentsRecursively(java.awt.Container container)
          Get all the sub componets in this container.
static double getCurveLSQEror(java.awt.Shape shape, StrokeData data, Range range)
          Get the LSQE for the curve by measuring the distance to the vertices in range.
static int[] getIndices(Vertex[] input_vertices)
          Get indices of the array of vertices.
static double leastSquaresForLine(Line line, Point[] points)
          calculate the lsq error for a line.
static double leastSquaresForLineSegment(Line line, Point[] points, int start, int end, int samples)
          calculate the lsq error for a line segment.
static double leastSquaresForPolygon(Polygon polygon, Point[] points)
          Calculate the lsq error.
static double leastSquaresForPolygon(Vertex[] vertices, Point[] points)
          Calculate the lsq error.
static Vertex[] makeVertices(int[] indices, Vertex[] in_vertices)
          Make array of vertices from indices.
static void paintDot(double x, double y, java.awt.Color color, java.awt.Component component, java.awt.geom.AffineTransform transform)
          Paint x vs y in the frame using the input color and affine transform.
static void paintDot(double x, double y, java.awt.Color color, java.awt.Image image, java.awt.geom.AffineTransform transform)
          Paint x vs y in the frame using the input color and affine transform.
static void paintDot(int x, int y, java.awt.Color color, java.awt.Component component, java.awt.geom.AffineTransform transform)
          Paint x vs y in the frame using the input color and affine transform.
static void paintDot(int x, int y, java.awt.Color color, java.awt.Image image, java.awt.geom.AffineTransform transform)
          Paint x vs y in the frame using the input color and affine transform.
static void paintDots(double[] f, double[] g, java.awt.Color color, java.awt.Component component, java.awt.geom.AffineTransform transform, int brush_size)
          Paint f vs g in the frame using the input color and affine transform.
static void paintDots(double[] f, double[] g, java.awt.Color color, java.awt.Image image, java.awt.geom.AffineTransform transform, int brush_size)
          Paint f vs g in the frame using the input color and affine transform.
static void paintDots(double[] f, int[] g, java.awt.Color color, java.awt.Component component, java.awt.geom.AffineTransform transform)
          Paint f vs g in the frame using the input color and affine transform.
static void paintDots(double[] f, int[] g, java.awt.Color color, java.awt.Image image, java.awt.geom.AffineTransform transform)
          Paint f vs g in the frame using the input color and affine transform.
static void paintDots(int[] f, double[] g, java.awt.Color color, java.awt.Component component, java.awt.geom.AffineTransform transform)
          Paint f vs g in the frame using the input color and affine transform.
static void paintDots(int[] f, double[] g, java.awt.Color color, java.awt.Component component, java.awt.geom.AffineTransform transform, int brush_size)
          Paint f vs g in the frame using the input color and affine transform.
static void paintDots(int[] f, double[] g, java.awt.Color color, java.awt.Image image, java.awt.geom.AffineTransform transform)
          Paint f vs g in the frame using the input color and affine transform.
static void paintDots(int[] f, double[] g, java.awt.Color color, java.awt.Image image, java.awt.geom.AffineTransform transform, int brush_size)
          Paint f vs g in the frame using the input color and affine transform.
static void paintDots(int[] f, int[] g, java.awt.Color color, java.awt.Component component, java.awt.geom.AffineTransform transform)
          Paint f vs g in the frame using the input color and affine transform.
static void paintDots(int[] f, int[] g, java.awt.Color color, java.awt.Image image, java.awt.geom.AffineTransform transform)
          Paint f vs g in the frame using the input color and affine transform.
static void paintFvsG(double[] f, double[] g, java.awt.Color color, java.awt.Component component, java.awt.geom.AffineTransform transform)
          Paint f vs g in the frame using the input color and affine transform.
static void paintFvsG(double[] f, double[] g, java.awt.Color color, java.awt.Image image, java.awt.geom.AffineTransform transform)
          Paint f vs g in the frame using the input color and affine transform.
static void paintFvsG(long[] f, double[] g, java.awt.Color color, java.awt.Component component, java.awt.geom.AffineTransform transform)
          Paint f vs g in the frame using the input color and affine transform.
static void paintFvsG(long[] f, double[] g, java.awt.Color color, java.awt.Image image, java.awt.geom.AffineTransform transform)
          Paint f vs g in the frame using the input color and affine transform.
static void paintLine(Line line, java.awt.Color color, java.awt.Component component, java.awt.geom.AffineTransform transform)
          Paint line.
static void paintLine(Line line, java.awt.Color color, java.awt.Image image, java.awt.geom.AffineTransform transform)
          Paint line.
static Vertex[] simplifyPolygon(Vertex[] input_vertices, double turn_angle_treshold)
          Simplify the polygon to get rid of consecutive lines which are sufficiently parallel.
static Vertex[] simplifyPolygon2(Vertex[] input_vertices, double turn_angle_treshold)
          Simplify the polygon to get rid of consecutive lines which are sufficiently parallel.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

colors

public static final java.awt.Color[] colors
Array of 8 colors for in-loop alternated coloring.


colors2

public static final java.awt.Color[] colors2
Array of 2 colors.

Constructor Detail

AWTUtil

public AWTUtil()
Method Detail

getAllComponentsRecursively

public static java.awt.Component[] getAllComponentsRecursively(java.awt.Container container)
Get all the sub componets in this container.


flatten

public static Vertex[] flatten(java.awt.Shape shape,
                               double flatness,
                               int limit)
Return an array of vertices corresponding to the flattened version of the input.


getCurveLSQEror

public static double getCurveLSQEror(java.awt.Shape shape,
                                     StrokeData data,
                                     Range range)
Get the LSQE for the curve by measuring the distance to the vertices in range. It is only valid to pass curves in.


leastSquaresForPolygon

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


leastSquaresForPolygon

public static double leastSquaresForPolygon(Polygon polygon,
                                            Point[] points)
Calculate the lsq error. points is the actual data points, polygon is the match


leastSquaresForLine

public static double leastSquaresForLine(Line line,
                                         Point[] points)
calculate the lsq error for a line. points is the actual data points


leastSquaresForLineSegment

public static double leastSquaresForLineSegment(Line line,
                                                Point[] points,
                                                int start,
                                                int end,
                                                int samples)
calculate the lsq error for a line segment. points is the actual data points


paintFvsG

public static void paintFvsG(double[] f,
                             double[] g,
                             java.awt.Color color,
                             java.awt.Image image,
                             java.awt.geom.AffineTransform transform)
Paint f vs g in the frame using the input color and affine transform. f is on the horizontal axis.


paintFvsG

public static void paintFvsG(double[] f,
                             double[] g,
                             java.awt.Color color,
                             java.awt.Component component,
                             java.awt.geom.AffineTransform transform)
Paint f vs g in the frame using the input color and affine transform. f is on the horizontal axis.


paintLine

public static void paintLine(Line line,
                             java.awt.Color color,
                             java.awt.Image image,
                             java.awt.geom.AffineTransform transform)
Paint line.


paintLine

public static void paintLine(Line line,
                             java.awt.Color color,
                             java.awt.Component component,
                             java.awt.geom.AffineTransform transform)
Paint line.


paintDots

public static void paintDots(double[] f,
                             int[] g,
                             java.awt.Color color,
                             java.awt.Image image,
                             java.awt.geom.AffineTransform transform)
Paint f vs g in the frame using the input color and affine transform. f is on the horizontal axis. Use dots.


paintDots

public static void paintDots(double[] f,
                             int[] g,
                             java.awt.Color color,
                             java.awt.Component component,
                             java.awt.geom.AffineTransform transform)
Paint f vs g in the frame using the input color and affine transform. f is on the horizontal axis. Use dots.


paintDots

public static void paintDots(double[] f,
                             double[] g,
                             java.awt.Color color,
                             java.awt.Image image,
                             java.awt.geom.AffineTransform transform,
                             int brush_size)
Paint f vs g in the frame using the input color and affine transform. f is on the horizontal axis. Use dots.


paintDots

public static void paintDots(double[] f,
                             double[] g,
                             java.awt.Color color,
                             java.awt.Component component,
                             java.awt.geom.AffineTransform transform,
                             int brush_size)
Paint f vs g in the frame using the input color and affine transform. f is on the horizontal axis. Use dots.


paintDots

public static void paintDots(int[] f,
                             double[] g,
                             java.awt.Color color,
                             java.awt.Image image,
                             java.awt.geom.AffineTransform transform,
                             int brush_size)
Paint f vs g in the frame using the input color and affine transform. f is on the horizontal axis. Use dots.


paintDots

public static void paintDots(int[] f,
                             double[] g,
                             java.awt.Color color,
                             java.awt.Component component,
                             java.awt.geom.AffineTransform transform,
                             int brush_size)
Paint f vs g in the frame using the input color and affine transform. f is on the horizontal axis. Use dots.


paintDots

public static void paintDots(int[] f,
                             double[] g,
                             java.awt.Color color,
                             java.awt.Image image,
                             java.awt.geom.AffineTransform transform)
Paint f vs g in the frame using the input color and affine transform. f is on the horizontal axis. Use dots.


paintDots

public static void paintDots(int[] f,
                             double[] g,
                             java.awt.Color color,
                             java.awt.Component component,
                             java.awt.geom.AffineTransform transform)
Paint f vs g in the frame using the input color and affine transform. f is on the horizontal axis. Use dots.


paintDots

public static void paintDots(int[] f,
                             int[] g,
                             java.awt.Color color,
                             java.awt.Image image,
                             java.awt.geom.AffineTransform transform)
Paint f vs g in the frame using the input color and affine transform. f is on the horizontal axis. Use dots.


paintDots

public static void paintDots(int[] f,
                             int[] g,
                             java.awt.Color color,
                             java.awt.Component component,
                             java.awt.geom.AffineTransform transform)
Paint f vs g in the frame using the input color and affine transform. f is on the horizontal axis. Use dots.


paintDot

public static void paintDot(int x,
                            int y,
                            java.awt.Color color,
                            java.awt.Image image,
                            java.awt.geom.AffineTransform transform)
Paint x vs y in the frame using the input color and affine transform. x is on the horizontal axis. Use dots.


paintDot

public static void paintDot(int x,
                            int y,
                            java.awt.Color color,
                            java.awt.Component component,
                            java.awt.geom.AffineTransform transform)
Paint x vs y in the frame using the input color and affine transform. x is on the horizontal axis. Use dots.


paintDot

public static void paintDot(double x,
                            double y,
                            java.awt.Color color,
                            java.awt.Image image,
                            java.awt.geom.AffineTransform transform)
Paint x vs y in the frame using the input color and affine transform. x is on the horizontal axis. Use dots.


paintDot

public static void paintDot(double x,
                            double y,
                            java.awt.Color color,
                            java.awt.Component component,
                            java.awt.geom.AffineTransform transform)
Paint x vs y in the frame using the input color and affine transform. x is on the horizontal axis. Use dots.


paintFvsG

public static void paintFvsG(long[] f,
                             double[] g,
                             java.awt.Color color,
                             java.awt.Image image,
                             java.awt.geom.AffineTransform transform)
Paint f vs g in the frame using the input color and affine transform. f is on the horizontal axis.


paintFvsG

public static void paintFvsG(long[] f,
                             double[] g,
                             java.awt.Color color,
                             java.awt.Component component,
                             java.awt.geom.AffineTransform transform)
Paint f vs g in the frame using the input color and affine transform. f is on the horizontal axis.


makeVertices

public static Vertex[] makeVertices(int[] indices,
                                    Vertex[] in_vertices)
Make array of vertices from indices. The second argument should be an array of vertices whose subset is indexed by the indices.


getIndices

public static int[] getIndices(Vertex[] input_vertices)
Get indices of the array of vertices.


simplifyPolygon

public static Vertex[] simplifyPolygon(Vertex[] input_vertices,
                                       double turn_angle_treshold)
Simplify the polygon to get rid of consecutive lines which are sufficiently parallel.


simplifyPolygon2

public static Vertex[] simplifyPolygon2(Vertex[] input_vertices,
                                        double turn_angle_treshold)
Simplify the polygon to get rid of consecutive lines which are sufficiently parallel. This takes the direction of the parallel lines into consideration. This does the job by dot product.