JSci.instruments.PTCroquetteCross Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsci Show documentation
Show all versions of jsci Show documentation
JSci is a set of open source Java packages. The aim is to encapsulate scientific methods/principles in the most natural way possible. As such they should greatly aid the development of scientific based software.
It offers: abstract math interfaces, linear algebra (support for various matrix and vector types), statistics (including probability distributions), wavelets, newtonian mechanics, chart/graph components (AWT and Swing), MathML DOM implementation, ...
Note: some packages, like javax.comm, for the astro and instruments package aren't listed as dependencies (not available).
The newest version!
package JSci.instruments;
import JSci.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.event.*;
import java.util.*;
import java.text.*;
import java.awt.image.*;
/** Data about a cross that can be put on an image, follow the
* center, find the height
*/
public class PTCroquetteCross extends Polygon implements Control {
private int crossHW=3;
private int crossL=32;
private Point2D position = new Point2D.Double();
private Point intPosition = new Point();
private double z = 0.0;
private boolean dragging = true;
private Rectangle bbox = null;
private Color color;
/**
* Crates a new cross
* @param l length of the arm of the cross
* @param hw half width of the arms of the cross
* @param p initial center of the cross
*/
public PTCroquetteCross(int l, int hw, Point p, Color col) {
super(new int[] {-hw,hw,hw,l,l,hw,hw,-hw,-hw,-l,-l,-hw},
new int[] {-l,-l,-hw,-hw,hw,hw,l,l,hw,hw,-hw,-hw},
12
);
crossHW=hw;
crossL=l;
intPosition.setLocation(p);
translate(intPosition.x,intPosition.y);
position.setLocation(p);
color=col;
z = 0.0;
dragging = false;
calibrating=false;
}
private void FFT(double []x,double []y,int d)
{
int n,m,l,le,le1,i,j,ip,nv2,nm1,k;
double ur,ui,wr,wi,tr,ti,sr,si;
n=x.length;
m=2;
switch (n) {
case 4:m=2;break;
case 8:m=3;break;
case 16:m=4;break;
case 32:m=5;break;
case 64:m=6;break;
case 128:m=7;break;
case 256:m=8;break;
case 512:m=9;break;
case 1024:m=10;break;
case 2048:m=11;break;
}
le1=n;
for (l=1;l<=m;l++)
{
le=le1;
le1=le/2;
ur=1.0;ui=0.0;
wr=Math.cos(Math.PI/le1);wi=d*Math.sin(Math.PI/le1);
for (j=0;j=0) return (int)c; else return (int)(256+c); }
private Point2D findJNIXY(Image f,int x0,int y0,int l,int w) {
double t,tx,ty,frp,fip,frm,fim,tr,ti;
double h[],v[];
int j,k,mx,my;
h=new double[2*l];
v=new double[2*l];
for (j=0;j<2*l;j++) h[j]=v[j]=0.0;
for (k=-w;ktx) { tx=h[j]; mx=j; }
if (v[j]>ty) { ty=v[j]; my=j; }
}
if (mx>=l) mx-=2*l;
if (my>=l) my-=2*l;
return new Point2D.Double(mx/2.0+x0,my/2.0+y0);
}
private double findJNIZ(Image f,int x0,int y0,int l,int w,int n,double []templ) {
int j,k;
double msd[],s[],mv,c1,c2;
int mp;
s=new double[l];
for (j=0;j=zNum) return;
addJNIToTemplate(f,
intPosition.x,intPosition.y,
crossL,crossHW,
calibration,zLevel);
zLevel=-1;
notify();
}
/** Call this when the microscope objective position is right
* for the calibration. This method returns immediately; to wait for the
* processing to be done, call calibrationWait()
* @param zLevel position in the calibration image. Evaluate
* zNum = how many levels are in the calibration image?
* minZ, maxZ = the min and max levels (in micron)
* z = where is now the objective?
* So zLevel = (z-minZ)*zNum/(maxZ/minZ)
*
*/
synchronized public void calibrationRequest(int zLevel) {
this.zLevel = zLevel;
}
/** wait that the calibration, requested by calibrationRequest(), has been
* completed.
*/
synchronized public void calibrationWait() {
while (zLevel>=0) {
try { wait(); } catch (InterruptedException e) {}
}
}
/** call this when the calibration has been done
*/
public void calibrationEnd() {
double s;
for (int j=0;j