ch.claudio.pen.calibrate
Class Scaler

java.lang.Object
  extended by ch.claudio.pen.calibrate.Scaler

public final class Scaler
extends java.lang.Object

Transform event coordinates from input device to screen coordinates.

This scaler needs as input three points which are not on a line and for which input coordinates as well as screen coordinates are known. If these are fed the setCoefficients(Point[], Point[]) method it will compute the necessary coefficients which are then used in scale(Event) to adjust the event.

Version:
$Id:$
Author:
Claudio Nieder

Copyright (C) 2008 Claudio Nieder <private@claudio.ch>, CH-8610 Uster

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA


Constructor Summary
Scaler()
           
 
Method Summary
static Scaler createFromFile(java.io.File f)
          Create a scaler using data from given file.
static void main(java.lang.String[] args)
          Print license.
 void resetCoefficients()
          Set the coefficients so that event x and y remain unchanged.
 void scale(Event event)
          Scale an event using the currently set coefficients.
 void setCoefficients(java.awt.Point[] screenDots, java.awt.Point[] events)
          Given three measurements sets the coefficients for translating event coordinates to screen coordinates.
 void storeToFile(java.io.File f)
          Store this instance content to given file.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Scaler

public Scaler()
Method Detail

setCoefficients

public void setCoefficients(java.awt.Point[] screenDots,
                            java.awt.Point[] events)
Given three measurements sets the coefficients for translating event coordinates to screen coordinates.

Parameters:
screenDots - screen points
events - corresponding positions returned in input events.

resetCoefficients

public void resetCoefficients()
Set the coefficients so that event x and y remain unchanged.


scale

public void scale(Event event)
Scale an event using the currently set coefficients.

Parameters:
event -

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

createFromFile

public static final Scaler createFromFile(java.io.File f)
Create a scaler using data from given file. If there is any problem reading from the file null is returned.

Parameters:
f - existing file
Returns:
scaler or null.

storeToFile

public final void storeToFile(java.io.File f)
Store this instance content to given file.

Parameters:
f -

main

public static void main(java.lang.String[] args)
Print license.

Parameters:
args - ignored