This commit is contained in:
2023-05-01 11:28:04 +02:00
parent 3a83f3cf34
commit abe3bcb19c
265 changed files with 28663 additions and 1295 deletions
BIN
View File
Binary file not shown.
+154
View File
@@ -0,0 +1,154 @@
import ij.*;
import ij.ImagePlus;
import ij.ImageStack;
import ij.plugin.filter.PlugInFilter;
import ij.process.ImageProcessor;
import ij.plugin.filter.GaussianBlur;
import ij.gui.GenericDialog;
/**
* This is a template for a plugin that requires one image to
* be opened, and takes it as parameter.
*/
public class Align_ComplexEdgeFiltering implements PlugInFilter {
protected ImagePlus imp;
private static double g_sigma = 3.0, g_resolution = 1e-4; //filter parameters
private static int filter_output;
//private static int filter_type = 0;
private GaussianBlur gb = new GaussianBlur();
private int[] sobel_r = new int[] {1,0,-1, 2,0,-2, 1,0,-1};
private int[] sobel_i = new int[] {1,2,1, 0,0,0, -1,-2,-1};
String arg;
final java.util.List output = new java.util.ArrayList();
public java.util.List getOutput(){
return output;
}
boolean show=true;
/**
* This method gets called by ImageJ / Fiji to determine
* whether the current image is of an appropriate type.
*
* @param arg can be specified in plugins.config
* @param image is the currently opened image
*/
public int setup(String arg, ImagePlus image) {
this.imp = image;
this.arg = arg;
/*
* The current return value accepts all gray-scale
* images (if you access the pixels with ip.getf(x, y)
* anyway, that works quite well.
*
* It could also be DOES_ALL; you can add "| NO_CHANGES"
* to indicate that the current image will not be
* changed by this plugin.
*
* Beware of DOES_STACKS: this will call the run()
* method with all slices of the current image
* (channels, z-slices and frames, all). Most likely
* not what you want.
*/
return DOES_8G | DOES_16 | DOES_32 | NO_CHANGES;// | DOES_STACKS;
}
/**
* This method is run when the current image was accepted.
*
* @param ip is the current slice (typically, plugins use
* the ImagePlus set above instead).
*/
public void run(ImageProcessor ip) {
if ((arg !=null) && (!arg.isBlank())){
String[] tokens = arg.trim().split(",");
g_sigma = Double.valueOf(tokens[0].trim());
filter_output = Boolean.valueOf(tokens[1].trim().toLowerCase()) ? 0 : 1;
try{
show = Boolean.valueOf(tokens[2].trim().toLowerCase());
} catch (Exception ex){
show = false;
}
} else {
String[] filter_outputs = {"complex", "real"};
GenericDialog gd = new GenericDialog("Complex Edge Filtering Options:");
gd.addSlider("Gaussian blur radius", 0, 20.0, g_sigma);
gd.addChoice("Edge filter output:", filter_outputs, filter_outputs[0]);
//String[] edge_filters = {"Sobel"};//, "Frei&Chen"};
//gd.addChoice("Task:", edge_filters, edge_filters[0]);
gd.showDialog(); // display the dialog; preview runs in the background now
if (gd.wasCanceled()) return;
g_sigma = gd.getNextNumber();
filter_output = gd.getNextChoiceIndex();
}
//filter_type = gd.getNextChoiceIndex();
exec();
}
private void exec() {
// display the results
if (filter_output == 1) {
ImagePlus imp_r = imp.createImagePlus();
ImageStack stack_r = new ImageStack(imp.getWidth(), imp.getHeight());
for (int i = 1; i <= imp.getImageStackSize(); i++) {
ImageProcessor ip_r = imp.getStack().getProcessor(i).duplicate().convertToFloat();
// Gaussian blurring
gb.blurGaussian(ip_r, g_sigma, g_sigma, g_resolution);
// Sobel edge filtering
ip_r.filter(ImageProcessor.FIND_EDGES);
stack_r.addSlice(imp.getStack().getSliceLabel(i), ip_r);
IJ.showProgress(i, imp.getImageStackSize());
}
//real
imp_r.setStack("EdgeReal_" + imp.getTitle(), stack_r);
imp_r.resetDisplayRange();
if (show){
imp_r.show();
imp_r.updateAndDraw();
}
output.add(imp_r);
} else {
ImagePlus imp_r = imp.createImagePlus();
ImageStack stack_r = new ImageStack(imp.getWidth(), imp.getHeight());
ImagePlus imp_i = imp.createImagePlus();
ImageStack stack_i = new ImageStack(imp.getWidth(), imp.getHeight());
for (int i = 1; i <= imp.getImageStackSize(); i++) {
ImageProcessor ip_r = imp.getStack().getProcessor(i).duplicate().convertToFloat();
// Gaussian blurring
gb.blurGaussian(ip_r, g_sigma, g_sigma, g_resolution);
ImageProcessor ip_i = ip_r.duplicate();
// Sobel edge filtering
ip_r.convolve3x3(sobel_r);
ip_i.convolve3x3(sobel_i);
stack_r.addSlice(imp.getStack().getSliceLabel(i), ip_r);
stack_i.addSlice(imp.getStack().getSliceLabel(i), ip_i);
IJ.showProgress(i, imp.getImageStackSize());
}
//real
imp_r.setStack("EdgeReal_" + imp.getTitle(), stack_r);
imp_r.resetDisplayRange();
if (show){
imp_r.show();
imp_r.updateAndDraw();
}
output.add(imp_r);
//imag
imp_i.setStack("EdgeImag_" + imp.getTitle(), stack_i);
imp_i.resetDisplayRange();
if (show){
imp_i.show();
imp_i.updateAndDraw();
}
output.add(imp_i);
}
}
}
+728
View File
@@ -0,0 +1,728 @@
import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.PlugIn;
import ij.WindowManager;
//import edu.emory.mathcs.jtransforms.fft.*;
//import edu.emory.mathcs.utils.*;
import org.jtransforms.fft.*;
import org.jtransforms.utils.*;
import flanagan.complex.*;
import flanagan.math.*;
import ij.plugin.frame.RoiManager;
import ij.gui.Roi;
public class Align_ComputeShifts implements PlugIn {
protected ImagePlus imp_r, imp_i;
protected int reference_slide;
protected Roi roi;
protected int usfac;
protected boolean debug = true;
public void run(String arg) {
int[] wList = WindowManager.getIDList();
if (null == wList) { //there are no images
IJ.error("There must be at least one open image");
return;
}
//get all the image titles so they can be shown in the dialog
String[] titles = new String[wList.length+1];
ImagePlus[] limps = new ImagePlus[wList.length+1];
titles[0] = "None";
limps[0] = null;
for (int i=0, k=1; i<wList.length; i++) {
ImagePlus limp = WindowManager.getImage(wList[i]);
if (limp != null) {
titles[k] = limp.getTitle();
limps[k] = limp;
k++;
}
}
GenericDialog gd = new GenericDialog("Alignement Procedure");
String[] tasks = {"Calculate direct shifts", "Calculate all shifts"};
gd.addChoice("Task:", tasks, tasks[0]);
gd.addChoice("Real part image:", titles, titles[1]);
gd.addChoice("Imag part image (optional):", titles, titles[0]);
gd.addNumericField("Upscale factor (1 < integer < 100)", 100, 0);
gd.showDialog();
if (gd.wasCanceled()) return;
this.usfac = (int)Math.round(gd.getNextNumber());
int task = gd.getNextChoiceIndex();
int i1Index = gd.getNextChoiceIndex();
int i2Index = gd.getNextChoiceIndex();
//get the images stack(s)
if (i1Index == 0) {
IJ.error("Real part image must exist!");
return;
}
imp_r = limps[i1Index];
if (i2Index == 0) {
imp_i = null;
} else {
imp_i = limps[i2Index];
}
//get the reference slide
reference_slide = imp_r.getCurrentSlice();
// get the ROI
RoiManager manager = RoiManager.getInstance();
if (manager == null) {
IJ.error("No ROI manager opened");
return;
}
Roi rois[] = manager.getSelectedRoisAsArray();
if (rois.length != 1) {
IJ.error("There must be one and only one ROI selected");
return;
}
roi = rois[0];
if (roi.getType()!=Roi.RECTANGLE) {
IJ.error("The selected ROI must be a rectangle");
return;
}
Rectangle box = roi.getBounds();
if (!ConcurrencyUtils.isPowerOf2(box.height)
|| !ConcurrencyUtils.isPowerOf2(box.width)) {
IJ.error("The selected ROI height and with must be a power of 2");
return;
}
if (task == 0) {
calculateShiftsRun();
} else {
calculateAllShiftsRun();
}
return;
}
private void calculateShiftsRun() {
// perform the FFT of each slice
IJ.showStatus("1/2 Perform FFT of each slice");
ComplexMatrix[] ffts = computeFFT();
// calculate shifts
IJ.showStatus("2/2 Calculate shifts between slices");
double[][] shifts = calculateShifts(ffts);
// save shifts
ShiftsIO sio = new ShiftsIO();
sio.save(shifts, "directshifts");
}
private void calculateAllShiftsRun() {
// perform the FFT of each slice
IJ.showStatus("1/2 Perform FFT of each slice");
ComplexMatrix[] ffts = computeFFT();
// calculate shifts
IJ.showStatus("2/2 Calculate shifts between slices");
double[][] shifts = calculateAllShifts(ffts);
// save shifts
ShiftsIO sio = new ShiftsIO();
sio.save(shifts, "allshifts");
}
// perform the FFT of each slice
private ComplexMatrix[] computeFFT() {
int slices = imp_r.getStackSize();
ComplexMatrix[] ffts = new ComplexMatrix[slices];
for (int i=1; i <= slices; i++) {
if (imp_i == null) {
ImageProcessor ip = imp_r.getStack().getProcessor(i);
ip.setRoi(roi);
ImageProcessor curr = ip.crop().convertToFloat();
double[][] data = ImageProcessor_to_FFTArray2D(curr);
ffts[i-1] = fft2(data);
} else {
ImageProcessor ip1, ip2;
ip1 = imp_r.getStack().getProcessor(i);
ip1.setRoi(roi);
ImageProcessor curr_r = ip1.crop().convertToFloat();
ip2 = imp_i.getStack().getProcessor(i);
ip2.setRoi(roi);
ImageProcessor curr_i = ip2.crop().convertToFloat();
double[][] data = ImageProcessor_to_FFTComplexArray2D(curr_r, curr_i);
ffts[i-1] = cfft2(data);
}
IJ.showProgress(i, slices);
}
return ffts;
}
//calculate the shifts between ffts
private double[][] calculateShifts(ComplexMatrix[] ffts) {
double[][] shifts = new double[ffts.length][6];
for (int i = 0; i < ffts.length; i++) {
shifts[i][0] = reference_slide; shifts[i][1] = i+1;
double[] temp = DFTRegistration(ffts[reference_slide - 1], ffts[i]);
shifts[i][2] = temp[2]; shifts[i][3] = temp[3];
shifts[i][4] = temp[0]; shifts[i][5] = temp[1];
IJ.showProgress(i + 1, ffts.length);
}
return shifts; // [ref, drifted, dr, dc, error, diffphase]
}
//calculate all the shifts between ffts
private double[][] calculateAllShifts(ComplexMatrix[] ffts) {
double[][] shifts = new double[ffts.length*(ffts.length-1)/2][6];
int id = 0;
for (int i = 0; i < ffts.length-1; i++) {
for (int j = i+1; j < ffts.length; j++) {
shifts[id][0] = i+1; shifts[id][1] = j+1;
double[] temp = DFTRegistration(ffts[i], ffts[j]);
shifts[id][2] = temp[2]; shifts[id][3] = temp[3];
shifts[id][4] = temp[0]; shifts[id][5] = temp[1];
id = id + 1;
IJ.showProgress(id + 1, ffts.length*(ffts.length-1)/2);
}
}
return shifts; // [ref,drifted,dr,dc,error, diffphase]
}
// compute 2D fft from an image
private ComplexMatrix fft2(double[][] data) {
int h = data.length;
int w = data[0].length;
DoubleFFT_2D fft = new DoubleFFT_2D(h, w);
fft.realForward(data);
ComplexMatrix m = FFTArray2D_to_ComplexMatrix(data, h, w);
return m;
}
// compute complex 2D fft from an image
private ComplexMatrix cfft2(double[][] data) {
int h = data.length;
int w = data[0].length;
DoubleFFT_2D fft = new DoubleFFT_2D(h, w/2);
fft.complexForward(data);
ComplexMatrix m = FFTComplexArray2D_to_ComplexMatrix(data, h, w/2);
return m;
}
// compute inverse 2D fft from a complex matrix
private double[][] ifft2(ComplexMatrix m) {
int w = m.getNcol();
int h = m.getNrow();
DoubleFFT_2D fft = new DoubleFFT_2D(h, w);
double[][] data = ComplexMatrix_to_FFTArray2D(m);
fft.realInverse(data, true);
return data;
}
// compute complex inverse 2D fft from a complex matrix
private ComplexMatrix cifft2(ComplexMatrix m) {
int w = m.getNcol();
int h = m.getNrow();
DoubleFFT_2D fft = new DoubleFFT_2D(h, w);
double[][] data = new double[h][2*w];
for (int j=0; j<h; j++) {
for (int i=0; i<w; i++) {
data[j][2*i] = m.getElementReference(j, i).getReal();
data[j][2*i+1] = m.getElementReference(j, i).getImag();
}
}
fft.complexInverse(data, true);
ComplexMatrix out = new ComplexMatrix(h, w);
for (int j=0; j<h; j++) {
for (int i=0; i<w; i++) {
out.setElement(j, i, data[j][2*i], data[j][2*i+1]);
}
}
return out;
}
private double[] DFTRegistration(ComplexMatrix ref, ComplexMatrix drifted) {
int m = ref.getNrow();
int n = ref.getNcol();
double[] output = new double[4];
// First upsample by a factor of 2 to obtain initial estimate
// Embed Fourier data in a 2x larger array
int mlarge = m*2;
int nlarge = n*2;
ComplexMatrix large = new ComplexMatrix(mlarge, nlarge);
ComplexMatrix c = fftshift(ElementProduct(ref, drifted.conjugate()));
for (int j = 0; j < m; j++) {
for (int i = 0; i < n; i++) {
large.setElement((int)(j + m - Math.floor(m/2.0)), (int)(i + n - Math.floor(n/2.0)), c.getElementReference(j, i));
}
}
// Compute crosscorrelation and locate the peak
ComplexMatrix CC = cifft2(ifftshift(large));
double[] peak = cFindPeak(CC); //max, r, c, max_r, max_c
// Obtain shift in original pixel grid from the position of the
// crosscorrelation peak
if (peak[1] > m) {
peak[1] = peak[1] - mlarge;
}
if (peak[2] > n) {
peak[2] = peak[2] - nlarge;
}
//% If upsampling > 2, then refine estimate with matrix multiply DFT
if (this.usfac > 2) {
// %%% DFT computation %%%
// % Initial shift estimate in upsampled grid
double row_shift = Math.round(peak[1]/2.0*this.usfac)/this.usfac;
double col_shift = Math.round(peak[2]/2.0*this.usfac)/this.usfac;
int dftshift = (int)Math.floor(Math.ceil(this.usfac*1.5)/2); // Center of output array at dftshift+1
// % Matrix multiply DFT around the current shift estimate
ComplexMatrix in = ElementProduct(drifted, ref.conjugate());
ComplexMatrix nCC = dftups(in, (int)Math.ceil(this.usfac*1.5), (int)Math.ceil(this.usfac*1.5),
dftshift-row_shift*this.usfac, dftshift-col_shift*this.usfac);
nCC = nCC.times(1.0/(m*n*this.usfac*this.usfac)).conjugate();
// % Locate maximum and map back to original pixel grid
double[] npeak = cFindPeak(nCC); //max_r, max_i, r, c
ComplexMatrix mrg00 = dftups(ElementProduct(ref, ref.conjugate()),1,1,0,0);
double rg00 = mrg00.getElementReference(0, 0).abs()/(m*n*this.usfac*this.usfac);
ComplexMatrix mrf00 = dftups(ElementProduct(drifted, drifted.conjugate()),1,1,0,0);
double rf00 = mrf00.getElementReference(0, 0).abs()/(m*n*this.usfac*this.usfac);
npeak[1] = npeak[1] - dftshift;
npeak[2] = npeak[2] - dftshift;
output[0] = Math.sqrt(Math.abs(1.0 - npeak[0]*npeak[0]/(rg00*rf00))); //error
output[1] = Math.atan2(npeak[4], npeak[3]); //diffphase
output[2] = row_shift + npeak[1]/this.usfac; //delta row
output[3] = col_shift + npeak[2]/this.usfac; //delta col
} else {
// % If upsampling = 2, no additional pixel shift refinement
double rg00 = SumSquareAbs(ref)/(mlarge*nlarge);
double rf00 = SumSquareAbs(drifted)/(mlarge*nlarge);
output[0] = Math.sqrt(Math.abs(1.0 - peak[0]*peak[0]/(rg00*rf00))); //error
output[1] = Math.atan2(peak[4], peak[3]); //diffphase
output[2] = peak[1]/2.0; //delta row
output[3] = peak[2]/2.0; //delta col
}
return output;
}
private double SumSquareAbs(ComplexMatrix m) {
double sum = 0.0;
for (int j = 0; j < m.getNrow(); j ++){
for (int i = 0; i < m.getNcol(); i++) {
sum += m.getElementReference(j, i).squareAbs();
}
}
return sum;
}
private double[] cFindPeak(ComplexMatrix m) {
double max = 0.0;
double realmax = 0.0;
double imagmax = 0.0;
int cmax = 0, rmax = 0;
for (int j = 0; j < m.getNrow(); j ++){
for (int i = 0; i < m.getNcol(); i++) {
if (m.getElementReference(j, i).abs() > max) {
max = m.getElementReference(j, i).abs();
realmax = m.getElementReference(j, i).getReal();
imagmax = m.getElementReference(j, i).getImag();
rmax = j;
cmax = i;
}
}
}
double[] res = new double[5];
res[0] = Math.sqrt(realmax*realmax+imagmax*imagmax); res[1] = rmax; res[2] = cmax;
res[3] = realmax; res[4] = imagmax;
return res;
}
private ComplexMatrix fftshift(ComplexMatrix in) {
int nc = in.getNcol();
int nr = in.getNrow();
ComplexMatrix out = new ComplexMatrix (nr, nc);
int midi = (int)Math.floor(nc/2.0);
int offi = (int)Math.ceil(nc/2.0);
int midj = (int)Math.floor(nr/2.0);
int offj = (int)Math.ceil(nr/2.0);
for (int j = 0; j < nr; j ++){
for (int i = 0; i < nc; i++) {
if (j < midj) {
if (i < midi) {
out.setElement(j, i, in.getElementReference(j+offj, i+offi));
} else {
out.setElement(j, i, in.getElementReference(j+offj, i-midi));
}
} else {
if (i < midi) {
out.setElement(j, i, in.getElementReference(j-midj, i+offi));
} else {
out.setElement(j, i, in.getElementReference(j-midj, i-midi));
}
}
}
}
return out;
}
private ComplexMatrix ifftshift(ComplexMatrix in) {
int nc = in.getNcol();
int nr = in.getNrow();
ComplexMatrix out = new ComplexMatrix (nr, nc);
int midi = (int)Math.ceil(nc/2.0);
int offi = (int)Math.floor(nc/2.0);
int midj = (int)Math.ceil(nr/2.0);
int offj = (int)Math.floor(nr/2.0);
for (int j = 0; j < nr; j ++){
for (int i = 0; i < nc; i++) {
if (j < midj) {
if (i < midi) {
out.setElement(j, i, in.getElementReference(j+offj, i+offi));
} else {
out.setElement(j, i, in.getElementReference(j+offj, i-midi));
}
} else {
if (i < midi) {
out.setElement(j, i, in.getElementReference(j-midj, i+offi));
} else {
out.setElement(j, i, in.getElementReference(j-midj, i-midi));
}
}
}
}
return out;
}
private Matrix ifftshift(Matrix in) {
int nc = in.getNcol();
int nr = in.getNrow();
Matrix out = new Matrix (nr, nc);
int midi = (int)Math.ceil(nc/2.0);
int offi = (int)Math.floor(nc/2.0);
int midj = (int)Math.ceil(nr/2.0);
int offj = (int)Math.floor(nr/2.0);
for (int j = 0; j < nr; j ++){
for (int i = 0; i < nc; i++) {
if (j < midj) {
if (i < midi) {
out.setElement(j, i, in.getElement(j+offj, i+offi));
} else {
out.setElement(j, i, in.getElement(j+offj, i-midi));
}
} else {
if (i < midi) {
out.setElement(j, i, in.getElement(j-midj, i+offi));
} else {
out.setElement(j, i, in.getElement(j-midj, i-midi));
}
}
}
}
return out;
}
private ComplexMatrix dftups(ComplexMatrix in, int nor, int noc, double roff, double coff) {
// function out=dftups(in,nor,noc,usfac,roff,coff);
// Upsampled DFT by matrix multiplies, can compute an upsampled DFT in just
// a small region.
// usfac Upsampling factor (default usfac = 1)
// [nor,noc] Number of pixels in the output upsampled DFT, in
// units of upsampled pixels (default = size(in))
// roff, coff Row and column offsets, allow to shift the output array to
// a region of interest on the DFT (default = 0)
// Recieves DC in upper left corner, image center must be in (1,1)
// Loïc Le Guyader - Jun 11, 2011 Java version for ImageJ plugin
// Manuel Guizar - Dec 13, 2007
// Modified from dftus, by J.R. Fienup 7/31/06
// This code is intended to provide the same result as if the following
// operations were performed
// - Embed the array "in" in an array that is usfac times larger in each
// dimension. ifftshift to bring the center of the image to (1,1).
// - Take the FFT of the larger array
// - Extract an [nor, noc] region of the result. Starting with the
// [roff+1 coff+1] element.
// It achieves this result by computing the DFT in the output array without
// the need to zeropad. Much faster and memory efficient than the
// zero-padded FFT approach if [nor noc] are much smaller than [nr*usfac nc*usfac]
int nr = in.getNrow();
int nc = in.getNcol();
// Compute kernels and obtain DFT by matrix products
double amplitude = -2.0*Math.PI/(nc*usfac);
Matrix u = new Matrix(nc, 1);
for (int i = 0; i < nc; i++) {
u.setElement(i, 0, i - Math.floor(nc/2.0));
}
u = ifftshift(u);
Matrix v = new Matrix(1, noc);
for (int i = 0; i < noc; i++) {
v.setElement(0, i, i-coff);
}
Matrix phase = u.times(v);
ComplexMatrix kernc = new ComplexMatrix(nc, noc);
for (int j = 0; j < nc; j++) {
for (int i = 0; i < noc; i++) {
Complex t = new Complex();
t.polar(1.0, amplitude*phase.getElement(j, i));
kernc.setElement(j, i, t);
}
}
//ComplexMatrixPrint(kernc);
amplitude = -2.0*Math.PI/(nr*usfac);
Matrix w = new Matrix(nor, 1);
for (int i = 0; i < nor; i++) {
w.setElement(i, 0, i - roff);
}
Matrix x = new Matrix(1, nr);
for (int i = 0; i < nr; i++) {
x.setElement(0, i, i - Math.floor(nr/2.0));
}
x = ifftshift(x);
Matrix nphase = w.times(x);
ComplexMatrix kernr = new ComplexMatrix(nor, nr);
for (int j = 0; j < nor; j++) {
for (int i = 0; i < nr; i++) {
Complex t = new Complex();
t.polar(1.0, amplitude*nphase.getElement(j, i));
kernr.setElement(j, i, t);
}
}
//ComplexMatrixPrint(kernr);
ComplexMatrix out = kernr.times(in.times(kernc));
return out;
}
private double[][] CrossCorrelation(ComplexMatrix ref, ComplexMatrix drifted) {
int h = ref.getNrow();
int w = ref.getNcol();
ComplexMatrix b = drifted.conjugate();
ComplexMatrix res = ElementProduct(ref, b);
double[][] data = ComplexMatrix_to_FFTArray2D(res);
DoubleFFT_2D fft = new DoubleFFT_2D(h, w);
fft.realInverse(data, true);
return data;
}
private ComplexMatrix ElementProduct(ComplexMatrix a, ComplexMatrix b) {
int nr = a.getNrow();
int nc = a.getNcol();
ComplexMatrix res = new ComplexMatrix(nr, nc);
for(int j = 0; j < nr; j++) {
for(int i = 0; i < nc; i++) {
res.setElement(j, i, a.getElementReference(j, i).times(b.getElementReference(j, i)));
}
}
return res;
}
private double[][] ImageProcessor_to_FFTArray2D(ImageProcessor ip) {
float[] pixels = (float[])ip.getPixels();
int w = ip.getWidth();
int h = ip.getHeight();
double[][] data = new double[h][w];
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
data[j][i] = (double)pixels[j*w + i];
}
}
return data;
}
private double[][] ImageProcessor_to_FFTComplexArray2D(ImageProcessor ip_r, ImageProcessor ip_i) {
float[] pixels_r = (float[])ip_r.getPixels();
float[] pixels_i = (float[])ip_i.getPixels();
int w = ip_r.getWidth();
int h = ip_r.getHeight();
double[][] data = new double[h][2*w];
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
data[j][2*i] = (double)pixels_r[j*w + i];
data[j][2*i+1] = (double)pixels_i[j*w + i];
}
}
return data;
}
private ComplexMatrix FFTArray2D_to_ComplexMatrix(double[][] data, int h, int w) {
ComplexMatrix m = new ComplexMatrix(h,w);
for (int j = 0; j < h; j++) {
for (int i = 0; i <= w/2; i++) {
if (j > 0 && i > 0 && i < w/2) {
m.setElement(j,i, new Complex(data[j][2*i], data[j][2*i+1]));
m.setElement(h-j, w-i, new Complex(data[j][2*i], -data[j][2*i+1]));
}
if (j == 0 && i > 0 && i < w/2) {
m.setElement(0, i, new Complex(data[0][2*i], data[0][2*i+1]));
m.setElement(0, w-i, new Complex(data[0][2*i], -data[0][2*i+1]));
}
if (i == 0 && j > 0 && j < h/2) {
m.setElement(j,0, new Complex(data[j][0], data[j][1]));
m.setElement(h-j, 0, new Complex(data[j][0], -data[j][1]));
m.setElement(j, w/2, new Complex(data[h-j][1], -data[h-j][0]));
m.setElement(h-j, w/2, new Complex(data[h-j][1], data[h-j][0]));
}
if (j == 0 && i == 0) {
m.setElement(0, 0, new Complex(data[0][0], 0));
}
if (j == 0 && i == w/2) {
m.setElement(0, w/2, new Complex(data[0][1], 0));
}
if (j == h/2 && i == 0) {
m.setElement(h/2, 0, new Complex(data[h/2][0], 0));
}
if (j == h/2 && i == w/2) {
m.setElement(h/2, w/2, new Complex(data[h/2][1], 0));
}
}
}
return m;
}
private ComplexMatrix FFTComplexArray2D_to_ComplexMatrix(double[][] data, int h, int w) {
ComplexMatrix m = new ComplexMatrix(h,w);
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
m.setElement(j,i, new Complex(data[j][2*i], data[j][2*i+1]));
}
}
return m;
}
private double[][] ComplexMatrix_to_FFTArray2D(ComplexMatrix m) {
int w = m.getNcol();
int h = m.getNrow();
double[][] data = new double[h][w];
for (int j = 0; j < h; j++) {
for (int i = 0; i <= w/2; i++) {
if (j > 0 && i > 0 && i < w/2) {
data[j][2*i] = m.getElementReference(j,i).getReal();
data[j][2*i+1] = m.getElementReference(j,i).getImag();
}
if (j == 0 && i > 0 && i < w/2) {
data[0][2*i] = m.getElementReference(0,i).getReal();
data[0][2*i+1] = m.getElementReference(0,i).getImag();
}
if (i == 0 && j > 0 && j < h/2) {
data[j][0] = m.getElementReference(j,0).getReal();
data[j][1] = m.getElementReference(j,0).getImag();
data[h-j][1] = m.getElementReference(j,w/2).getReal();
data[h-j][0] = m.getElementReference(h-j,w/2).getImag();
}
if (j == 0 && i == 0) {
data[0][0] = m.getElementReference(0,0).getReal();
}
if (j == 0 && i == w/2) {
data[0][1] = m.getElementReference(0,w/2).getReal();
}
if (j == h/2 && i == 0) {
data[h/2][0] = m.getElementReference(h/2,0).getReal();
}
if (j == h/2 && i == w/2) {
data[h/2][1] = m.getElementReference(h/2,w/2).getReal();
}
}
}
return data;
}
// convert a Complex Matrix into an 2d real part array data[0][][]
// and 2d imaginary part data[1][][]
private double[][][] ComplexMatrix_to_RealArray2D(ComplexMatrix m) {
int w = m.getNcol();
int h = m.getNrow();
double[][][] data = new double[2][h][w];
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
data[0][j][i] = m.getElementReference(j,i).getReal();
data[1][j][i] = m.getElementReference(j,i).getImag();
}
}
return data;
}
}
+701
View File
@@ -0,0 +1,701 @@
import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.PlugIn;
import ij.WindowManager;
//import edu.emory.mathcs.jtransforms.fft.*;
//import edu.emory.mathcs.utils.*;
import org.jtransforms.fft.*;
import org.jtransforms.utils.*;
import flanagan.complex.*;
import flanagan.math.*;
import ij.plugin.frame.RoiManager;
import ij.gui.Roi;
public class Align_ComputeShifts2 implements PlugIn {
protected ImagePlus imp_r, imp_i;
protected int reference_slide;
protected Roi roi;
protected int usfac;
protected boolean debug = true;
double[][] shifts;
boolean allShifts;
public void setup(int upscaleFactor, boolean allShifts, ImagePlus imp_r, ImagePlus imp_i,
int reference_slide, Roi roi) {
if (imp_r==null){
throw new RuntimeException("Real part image must exist!");
}
if (roi==null){
roi = new Roi(0,0,imp_r.getWidth(), imp_r.getHeight());
}
Rectangle box = roi.getBounds();
if (!ConcurrencyUtils.isPowerOf2(box.height)
|| !ConcurrencyUtils.isPowerOf2(box.width)) {
throw new RuntimeException("The selected ROI height and with must be a power of 2");
}
this.usfac = upscaleFactor;
this.allShifts = allShifts;
this.imp_r = imp_r;
this.imp_i = imp_i;
this.reference_slide=reference_slide;
this.roi = roi;
}
public void run(String arg) {
if (allShifts) {
calculateAllShiftsRun();
} else {
calculateShiftsRun();
}
return;
}
private void calculateShiftsRun() {
// perform the FFT of each slice
IJ.showStatus("1/2 Perform FFT of each slice");
ComplexMatrix[] ffts = computeFFT();
// calculate shifts
IJ.showStatus("2/2 Calculate shifts between slices");
shifts = calculateShifts(ffts);
/*
// save shifts
ShiftsIO sio = new ShiftsIO();
sio.save(shifts, "directshifts");
*/
}
public double[][] getShifts(){
return shifts;
}
private void calculateAllShiftsRun() {
// perform the FFT of each slice
IJ.showStatus("1/2 Perform FFT of each slice");
ComplexMatrix[] ffts = computeFFT();
// calculate shifts
IJ.showStatus("2/2 Calculate shifts between slices");
double[][] shifts = calculateAllShifts(ffts);
// save shifts
ShiftsIO sio = new ShiftsIO();
sio.save(shifts, "allshifts");
}
// perform the FFT of each slice
private ComplexMatrix[] computeFFT() {
int slices = imp_r.getStackSize();
ComplexMatrix[] ffts = new ComplexMatrix[slices];
for (int i=1; i <= slices; i++) {
if (imp_i == null) {
ImageProcessor ip = imp_r.getStack().getProcessor(i);
ip.setRoi(roi);
ImageProcessor curr = ip.crop().convertToFloat();
double[][] data = ImageProcessor_to_FFTArray2D(curr);
ffts[i-1] = fft2(data);
} else {
ImageProcessor ip1, ip2;
ip1 = imp_r.getStack().getProcessor(i);
ip1.setRoi(roi);
ImageProcessor curr_r = ip1.crop().convertToFloat();
ip2 = imp_i.getStack().getProcessor(i);
ip2.setRoi(roi);
ImageProcessor curr_i = ip2.crop().convertToFloat();
double[][] data = ImageProcessor_to_FFTComplexArray2D(curr_r, curr_i);
ffts[i-1] = cfft2(data);
}
IJ.showProgress(i, slices);
}
return ffts;
}
//calculate the shifts between ffts
private double[][] calculateShifts(ComplexMatrix[] ffts) {
double[][] shifts = new double[ffts.length][6];
for (int i = 0; i < ffts.length; i++) {
shifts[i][0] = reference_slide; shifts[i][1] = i+1;
double[] temp = DFTRegistration(ffts[reference_slide - 1], ffts[i]);
shifts[i][2] = temp[2]; shifts[i][3] = temp[3];
shifts[i][4] = temp[0]; shifts[i][5] = temp[1];
IJ.showProgress(i + 1, ffts.length);
}
return shifts; // [ref, drifted, dr, dc, error, diffphase]
}
//calculate all the shifts between ffts
private double[][] calculateAllShifts(ComplexMatrix[] ffts) {
double[][] shifts = new double[ffts.length*(ffts.length-1)/2][6];
int id = 0;
for (int i = 0; i < ffts.length-1; i++) {
for (int j = i+1; j < ffts.length; j++) {
shifts[id][0] = i+1; shifts[id][1] = j+1;
double[] temp = DFTRegistration(ffts[i], ffts[j]);
shifts[id][2] = temp[2]; shifts[id][3] = temp[3];
shifts[id][4] = temp[0]; shifts[id][5] = temp[1];
id = id + 1;
IJ.showProgress(id + 1, ffts.length*(ffts.length-1)/2);
}
}
return shifts; // [ref,drifted,dr,dc,error, diffphase]
}
// compute 2D fft from an image
private ComplexMatrix fft2(double[][] data) {
int h = data.length;
int w = data[0].length;
DoubleFFT_2D fft = new DoubleFFT_2D(h, w);
fft.realForward(data);
ComplexMatrix m = FFTArray2D_to_ComplexMatrix(data, h, w);
return m;
}
// compute complex 2D fft from an image
private ComplexMatrix cfft2(double[][] data) {
int h = data.length;
int w = data[0].length;
DoubleFFT_2D fft = new DoubleFFT_2D(h, w/2);
fft.complexForward(data);
ComplexMatrix m = FFTComplexArray2D_to_ComplexMatrix(data, h, w/2);
return m;
}
// compute inverse 2D fft from a complex matrix
private double[][] ifft2(ComplexMatrix m) {
int w = m.getNcol();
int h = m.getNrow();
DoubleFFT_2D fft = new DoubleFFT_2D(h, w);
double[][] data = ComplexMatrix_to_FFTArray2D(m);
fft.realInverse(data, true);
return data;
}
// compute complex inverse 2D fft from a complex matrix
private ComplexMatrix cifft2(ComplexMatrix m) {
int w = m.getNcol();
int h = m.getNrow();
DoubleFFT_2D fft = new DoubleFFT_2D(h, w);
double[][] data = new double[h][2*w];
for (int j=0; j<h; j++) {
for (int i=0; i<w; i++) {
data[j][2*i] = m.getElementReference(j, i).getReal();
data[j][2*i+1] = m.getElementReference(j, i).getImag();
}
}
fft.complexInverse(data, true);
ComplexMatrix out = new ComplexMatrix(h, w);
for (int j=0; j<h; j++) {
for (int i=0; i<w; i++) {
out.setElement(j, i, data[j][2*i], data[j][2*i+1]);
}
}
return out;
}
private double[] DFTRegistration(ComplexMatrix ref, ComplexMatrix drifted) {
int m = ref.getNrow();
int n = ref.getNcol();
double[] output = new double[4];
// First upsample by a factor of 2 to obtain initial estimate
// Embed Fourier data in a 2x larger array
int mlarge = m*2;
int nlarge = n*2;
ComplexMatrix large = new ComplexMatrix(mlarge, nlarge);
ComplexMatrix c = fftshift(ElementProduct(ref, drifted.conjugate()));
for (int j = 0; j < m; j++) {
for (int i = 0; i < n; i++) {
large.setElement((int)(j + m - Math.floor(m/2.0)), (int)(i + n - Math.floor(n/2.0)), c.getElementReference(j, i));
}
}
// Compute crosscorrelation and locate the peak
ComplexMatrix CC = cifft2(ifftshift(large));
double[] peak = cFindPeak(CC); //max, r, c, max_r, max_c
// Obtain shift in original pixel grid from the position of the
// crosscorrelation peak
if (peak[1] > m) {
peak[1] = peak[1] - mlarge;
}
if (peak[2] > n) {
peak[2] = peak[2] - nlarge;
}
//% If upsampling > 2, then refine estimate with matrix multiply DFT
if (this.usfac > 2) {
// %%% DFT computation %%%
// % Initial shift estimate in upsampled grid
double row_shift = Math.round(peak[1]/2.0*this.usfac)/this.usfac;
double col_shift = Math.round(peak[2]/2.0*this.usfac)/this.usfac;
int dftshift = (int)Math.floor(Math.ceil(this.usfac*1.5)/2); // Center of output array at dftshift+1
// % Matrix multiply DFT around the current shift estimate
ComplexMatrix in = ElementProduct(drifted, ref.conjugate());
ComplexMatrix nCC = dftups(in, (int)Math.ceil(this.usfac*1.5), (int)Math.ceil(this.usfac*1.5),
dftshift-row_shift*this.usfac, dftshift-col_shift*this.usfac);
nCC = nCC.times(1.0/(m*n*this.usfac*this.usfac)).conjugate();
// % Locate maximum and map back to original pixel grid
double[] npeak = cFindPeak(nCC); //max_r, max_i, r, c
ComplexMatrix mrg00 = dftups(ElementProduct(ref, ref.conjugate()),1,1,0,0);
double rg00 = mrg00.getElementReference(0, 0).abs()/(m*n*this.usfac*this.usfac);
ComplexMatrix mrf00 = dftups(ElementProduct(drifted, drifted.conjugate()),1,1,0,0);
double rf00 = mrf00.getElementReference(0, 0).abs()/(m*n*this.usfac*this.usfac);
npeak[1] = npeak[1] - dftshift;
npeak[2] = npeak[2] - dftshift;
output[0] = Math.sqrt(Math.abs(1.0 - npeak[0]*npeak[0]/(rg00*rf00))); //error
output[1] = Math.atan2(npeak[4], npeak[3]); //diffphase
output[2] = row_shift + npeak[1]/this.usfac; //delta row
output[3] = col_shift + npeak[2]/this.usfac; //delta col
} else {
// % If upsampling = 2, no additional pixel shift refinement
double rg00 = SumSquareAbs(ref)/(mlarge*nlarge);
double rf00 = SumSquareAbs(drifted)/(mlarge*nlarge);
output[0] = Math.sqrt(Math.abs(1.0 - peak[0]*peak[0]/(rg00*rf00))); //error
output[1] = Math.atan2(peak[4], peak[3]); //diffphase
output[2] = peak[1]/2.0; //delta row
output[3] = peak[2]/2.0; //delta col
}
return output;
}
private double SumSquareAbs(ComplexMatrix m) {
double sum = 0.0;
for (int j = 0; j < m.getNrow(); j ++){
for (int i = 0; i < m.getNcol(); i++) {
sum += m.getElementReference(j, i).squareAbs();
}
}
return sum;
}
private double[] cFindPeak(ComplexMatrix m) {
double max = 0.0;
double realmax = 0.0;
double imagmax = 0.0;
int cmax = 0, rmax = 0;
for (int j = 0; j < m.getNrow(); j ++){
for (int i = 0; i < m.getNcol(); i++) {
if (m.getElementReference(j, i).abs() > max) {
max = m.getElementReference(j, i).abs();
realmax = m.getElementReference(j, i).getReal();
imagmax = m.getElementReference(j, i).getImag();
rmax = j;
cmax = i;
}
}
}
double[] res = new double[5];
res[0] = Math.sqrt(realmax*realmax+imagmax*imagmax); res[1] = rmax; res[2] = cmax;
res[3] = realmax; res[4] = imagmax;
return res;
}
private ComplexMatrix fftshift(ComplexMatrix in) {
int nc = in.getNcol();
int nr = in.getNrow();
ComplexMatrix out = new ComplexMatrix (nr, nc);
int midi = (int)Math.floor(nc/2.0);
int offi = (int)Math.ceil(nc/2.0);
int midj = (int)Math.floor(nr/2.0);
int offj = (int)Math.ceil(nr/2.0);
for (int j = 0; j < nr; j ++){
for (int i = 0; i < nc; i++) {
if (j < midj) {
if (i < midi) {
out.setElement(j, i, in.getElementReference(j+offj, i+offi));
} else {
out.setElement(j, i, in.getElementReference(j+offj, i-midi));
}
} else {
if (i < midi) {
out.setElement(j, i, in.getElementReference(j-midj, i+offi));
} else {
out.setElement(j, i, in.getElementReference(j-midj, i-midi));
}
}
}
}
return out;
}
private ComplexMatrix ifftshift(ComplexMatrix in) {
int nc = in.getNcol();
int nr = in.getNrow();
ComplexMatrix out = new ComplexMatrix (nr, nc);
int midi = (int)Math.ceil(nc/2.0);
int offi = (int)Math.floor(nc/2.0);
int midj = (int)Math.ceil(nr/2.0);
int offj = (int)Math.floor(nr/2.0);
for (int j = 0; j < nr; j ++){
for (int i = 0; i < nc; i++) {
if (j < midj) {
if (i < midi) {
out.setElement(j, i, in.getElementReference(j+offj, i+offi));
} else {
out.setElement(j, i, in.getElementReference(j+offj, i-midi));
}
} else {
if (i < midi) {
out.setElement(j, i, in.getElementReference(j-midj, i+offi));
} else {
out.setElement(j, i, in.getElementReference(j-midj, i-midi));
}
}
}
}
return out;
}
private Matrix ifftshift(Matrix in) {
int nc = in.getNcol();
int nr = in.getNrow();
Matrix out = new Matrix (nr, nc);
int midi = (int)Math.ceil(nc/2.0);
int offi = (int)Math.floor(nc/2.0);
int midj = (int)Math.ceil(nr/2.0);
int offj = (int)Math.floor(nr/2.0);
for (int j = 0; j < nr; j ++){
for (int i = 0; i < nc; i++) {
if (j < midj) {
if (i < midi) {
out.setElement(j, i, in.getElement(j+offj, i+offi));
} else {
out.setElement(j, i, in.getElement(j+offj, i-midi));
}
} else {
if (i < midi) {
out.setElement(j, i, in.getElement(j-midj, i+offi));
} else {
out.setElement(j, i, in.getElement(j-midj, i-midi));
}
}
}
}
return out;
}
public Matrix times(Matrix amat, Matrix bmat){
if(amat.getNumberOfColumns()!=bmat.getNumberOfRows())throw new IllegalArgumentException("Nonconformable matrices");
Matrix cmat = new Matrix(amat.getNumberOfRows(), bmat.getNumberOfColumns());
double [][] aarray = amat.getArrayReference();
double [][] barray = bmat.getArrayReference();
double [][] carray = cmat.getArrayReference();
double sum = 0.0D;
for(int i=0; i<amat.getNumberOfRows(); i++){
for(int j=0; j<bmat.getNumberOfColumns(); j++){
sum=0.0D;
for(int k=0; k<amat.getNumberOfColumns(); k++){
sum += aarray[i][k]*barray[k][j];
}
carray[i][j]=sum;
}
}
return cmat;
}
private ComplexMatrix dftups(ComplexMatrix in, int nor, int noc, double roff, double coff) {
// function out=dftups(in,nor,noc,usfac,roff,coff);
// Upsampled DFT by matrix multiplies, can compute an upsampled DFT in just
// a small region.
// usfac Upsampling factor (default usfac = 1)
// [nor,noc] Number of pixels in the output upsampled DFT, in
// units of upsampled pixels (default = size(in))
// roff, coff Row and column offsets, allow to shift the output array to
// a region of interest on the DFT (default = 0)
// Recieves DC in upper left corner, image center must be in (1,1)
// Loïc Le Guyader - Jun 11, 2011 Java version for ImageJ plugin
// Manuel Guizar - Dec 13, 2007
// Modified from dftus, by J.R. Fienup 7/31/06
// This code is intended to provide the same result as if the following
// operations were performed
// - Embed the array "in" in an array that is usfac times larger in each
// dimension. ifftshift to bring the center of the image to (1,1).
// - Take the FFT of the larger array
// - Extract an [nor, noc] region of the result. Starting with the
// [roff+1 coff+1] element.
// It achieves this result by computing the DFT in the output array without
// the need to zeropad. Much faster and memory efficient than the
// zero-padded FFT approach if [nor noc] are much smaller than [nr*usfac nc*usfac]
int nr = in.getNrow();
int nc = in.getNcol();
// Compute kernels and obtain DFT by matrix products
double amplitude = -2.0*Math.PI/(nc*usfac);
Matrix u = new Matrix(nc, 1);
for (int i = 0; i < nc; i++) {
u.setElement(i, 0, i - Math.floor(nc/2.0));
}
u = ifftshift(u);
Matrix v = new Matrix(1, noc);
for (int i = 0; i < noc; i++) {
v.setElement(0, i, i-coff);
}
Matrix phase = u.times(v);
//Matrix phase = times(u,v);
ComplexMatrix kernc = new ComplexMatrix(nc, noc);
for (int j = 0; j < nc; j++) {
for (int i = 0; i < noc; i++) {
Complex t = new Complex();
t.polar(1.0, amplitude*phase.getElement(j, i));
kernc.setElement(j, i, t);
}
}
//ComplexMatrixPrint(kernc);
amplitude = -2.0*Math.PI/(nr*usfac);
Matrix w = new Matrix(nor, 1);
for (int i = 0; i < nor; i++) {
w.setElement(i, 0, i - roff);
}
Matrix x = new Matrix(1, nr);
for (int i = 0; i < nr; i++) {
x.setElement(0, i, i - Math.floor(nr/2.0));
}
x = ifftshift(x);
Matrix nphase = w.times(x);
//Matrix nphase = times(w,x);
ComplexMatrix kernr = new ComplexMatrix(nor, nr);
for (int j = 0; j < nor; j++) {
for (int i = 0; i < nr; i++) {
Complex t = new Complex();
t.polar(1.0, amplitude*nphase.getElement(j, i));
kernr.setElement(j, i, t);
}
}
//ComplexMatrixPrint(kernr);
ComplexMatrix out = kernr.times(in.times(kernc));
return out;
}
private double[][] CrossCorrelation(ComplexMatrix ref, ComplexMatrix drifted) {
int h = ref.getNrow();
int w = ref.getNcol();
ComplexMatrix b = drifted.conjugate();
ComplexMatrix res = ElementProduct(ref, b);
double[][] data = ComplexMatrix_to_FFTArray2D(res);
DoubleFFT_2D fft = new DoubleFFT_2D(h, w);
fft.realInverse(data, true);
return data;
}
private ComplexMatrix ElementProduct(ComplexMatrix a, ComplexMatrix b) {
int nr = a.getNrow();
int nc = a.getNcol();
ComplexMatrix res = new ComplexMatrix(nr, nc);
for(int j = 0; j < nr; j++) {
for(int i = 0; i < nc; i++) {
res.setElement(j, i, a.getElementReference(j, i).times(b.getElementReference(j, i)));
}
}
return res;
}
private double[][] ImageProcessor_to_FFTArray2D(ImageProcessor ip) {
float[] pixels = (float[])ip.getPixels();
int w = ip.getWidth();
int h = ip.getHeight();
double[][] data = new double[h][w];
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
data[j][i] = (double)pixels[j*w + i];
}
}
return data;
}
private double[][] ImageProcessor_to_FFTComplexArray2D(ImageProcessor ip_r, ImageProcessor ip_i) {
float[] pixels_r = (float[])ip_r.getPixels();
float[] pixels_i = (float[])ip_i.getPixels();
int w = ip_r.getWidth();
int h = ip_r.getHeight();
double[][] data = new double[h][2*w];
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
data[j][2*i] = (double)pixels_r[j*w + i];
data[j][2*i+1] = (double)pixels_i[j*w + i];
}
}
return data;
}
private ComplexMatrix FFTArray2D_to_ComplexMatrix(double[][] data, int h, int w) {
ComplexMatrix m = new ComplexMatrix(h,w);
for (int j = 0; j < h; j++) {
for (int i = 0; i <= w/2; i++) {
if (j > 0 && i > 0 && i < w/2) {
m.setElement(j,i, new Complex(data[j][2*i], data[j][2*i+1]));
m.setElement(h-j, w-i, new Complex(data[j][2*i], -data[j][2*i+1]));
}
if (j == 0 && i > 0 && i < w/2) {
m.setElement(0, i, new Complex(data[0][2*i], data[0][2*i+1]));
m.setElement(0, w-i, new Complex(data[0][2*i], -data[0][2*i+1]));
}
if (i == 0 && j > 0 && j < h/2) {
m.setElement(j,0, new Complex(data[j][0], data[j][1]));
m.setElement(h-j, 0, new Complex(data[j][0], -data[j][1]));
m.setElement(j, w/2, new Complex(data[h-j][1], -data[h-j][0]));
m.setElement(h-j, w/2, new Complex(data[h-j][1], data[h-j][0]));
}
if (j == 0 && i == 0) {
m.setElement(0, 0, new Complex(data[0][0], 0));
}
if (j == 0 && i == w/2) {
m.setElement(0, w/2, new Complex(data[0][1], 0));
}
if (j == h/2 && i == 0) {
m.setElement(h/2, 0, new Complex(data[h/2][0], 0));
}
if (j == h/2 && i == w/2) {
m.setElement(h/2, w/2, new Complex(data[h/2][1], 0));
}
}
}
return m;
}
private ComplexMatrix FFTComplexArray2D_to_ComplexMatrix(double[][] data, int h, int w) {
ComplexMatrix m = new ComplexMatrix(h,w);
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
m.setElement(j,i, new Complex(data[j][2*i], data[j][2*i+1]));
}
}
return m;
}
private double[][] ComplexMatrix_to_FFTArray2D(ComplexMatrix m) {
int w = m.getNcol();
int h = m.getNrow();
double[][] data = new double[h][w];
for (int j = 0; j < h; j++) {
for (int i = 0; i <= w/2; i++) {
if (j > 0 && i > 0 && i < w/2) {
data[j][2*i] = m.getElementReference(j,i).getReal();
data[j][2*i+1] = m.getElementReference(j,i).getImag();
}
if (j == 0 && i > 0 && i < w/2) {
data[0][2*i] = m.getElementReference(0,i).getReal();
data[0][2*i+1] = m.getElementReference(0,i).getImag();
}
if (i == 0 && j > 0 && j < h/2) {
data[j][0] = m.getElementReference(j,0).getReal();
data[j][1] = m.getElementReference(j,0).getImag();
data[h-j][1] = m.getElementReference(j,w/2).getReal();
data[h-j][0] = m.getElementReference(h-j,w/2).getImag();
}
if (j == 0 && i == 0) {
data[0][0] = m.getElementReference(0,0).getReal();
}
if (j == 0 && i == w/2) {
data[0][1] = m.getElementReference(0,w/2).getReal();
}
if (j == h/2 && i == 0) {
data[h/2][0] = m.getElementReference(h/2,0).getReal();
}
if (j == h/2 && i == w/2) {
data[h/2][1] = m.getElementReference(h/2,w/2).getReal();
}
}
}
return data;
}
// convert a Complex Matrix into an 2d real part array data[0][][]
// and 2d imaginary part data[1][][]
private double[][][] ComplexMatrix_to_RealArray2D(ComplexMatrix m) {
int w = m.getNcol();
int h = m.getNrow();
double[][][] data = new double[2][h][w];
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
data[0][j][i] = m.getElementReference(j,i).getReal();
data[1][j][i] = m.getElementReference(j,i).getImag();
}
}
return data;
}
}
+115
View File
@@ -0,0 +1,115 @@
import ij.plugin.filter.ExtendedPlugInFilter;
import ij.plugin.filter.PlugInFilterRunner;
import ij.plugin.filter.GaussianBlur;
import ij.*;
import ij.process.*;
import ij.io.OpenDialog;
import ij.io.SaveDialog;
import java.util.ArrayList;
import java.io.IOException;
import java.io.File;
import jmatio.types.*;
import jmatio.io.*;
import ij.gui.GenericDialog;
import ij.IJ;
import ij.Prefs;
public class Align_TranslationFilter implements ExtendedPlugInFilter {
private double[][] shifts;
private final int flags = (DOES_ALL-DOES_RGB)|DOES_STACKS|NO_CHANGES|FINAL_PROCESSING;
private ImagePlus imp;
private ImagePlus registred;
private ImageStack translated;
private PlugInFilterRunner pifr;
private int nbslices = 0;
private int processed = 0;
public void setShifts(double[][] shifts){
this.shifts = shifts;
}
public double[][] getShifts(){
return shifts;
}
public ImagePlus getOutput(){
return registred;
}
public void setImp(ImagePlus imp){
this.imp = imp;
}
/**
* This method is called by ImageJ for initialization.
* @param arg Unused here. For plugins in a .jar file this argument string can
* be specified in the plugins.config file of the .jar archive.
* @param imp The ImagePlus containing the image (or stack) to process.
* @return The method returns flags (i.e., a bit mask) specifying the
* capabilities (supported formats, etc.) and needs of the filter.
* See PlugInFilter.java and ExtendedPlugInFilter in the ImageJ
* sources for details.
*/
public int setup(String arg, ImagePlus imp) {
System.out.println("Setup " + arg);
if ("final".equals(arg)) {
registred.setStack("REG_" + this.imp.getTitle(), translated);
return DONE;
} else {
if (imp==null ){
this.imp = imp;
}
return flags;
}
}
/** Called by ImageJ after setup. */
public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) {
pifr = pfr;
//ShiftsIO sio = new ShiftsIO();
//shifts = sio.load(null, "directshifts");
//if (shifts == null) return DONE;
//IJ.register(this.getClass()); // protect static class variables (filter parameters) from garbage collection
//return IJ.setupDialog(imp, flags); // ask whether to process all slices of stack (if a stack)
return flags;
}
/** Process a FloatProcessor (with the CONVERT_TO_FLOAT flag, ImageJ does the conversion to float).
* Called by ImageJ for each stack slice (when processing a full stack); for RGB also called once for each color. */
public void run(ImageProcessor ip) {
// translate from shifts
if (Thread.currentThread().isInterrupted()) return;
int thisone = pifr.getSliceNumber();
ImageProcessor nip = ip.duplicate().convertToFloat();
nip.setInterpolationMethod(ImageProcessor.BICUBIC);
if (shifts.length != nbslices) {
nip.translate(shifts[1][3], shifts[1][2]); // translate all the frame by the
// same shifts
} else {
nip.translate(shifts[thisone-1][3], shifts[thisone-1][2]);
}
String lbl = imp.getStack().getSliceLabel(thisone);
if (lbl != null) {
translated.addSlice(lbl, nip, thisone - 1);
} else {
translated.addSlice("" + thisone, nip, thisone - 1);
}
translated.deleteSlice(thisone + 1);
processed++;
IJ.showProgress(processed, nbslices);
}
/** Called by ImageJ to set the number of calls to run(ip) corresponding to 100% of the progress bar */
public void setNPasses(int nPasses) {
nbslices = nPasses;
registred = imp.createImagePlus();
translated = new ImageStack(imp.getWidth(), imp.getHeight(), nbslices);
}
}
+91
View File
@@ -0,0 +1,91 @@
import ij.plugin.filter.PlugInFilter;
import ij.plugin.filter.PlugInFilterRunner;
import ij.plugin.filter.GaussianBlur;
import ij.*;
import ij.process.*;
import com.jmatio.types.*;
import com.jmatio.io.*;
public class Align_TranslationFilter2 implements PlugInFilter {
private final int flags = (DOES_ALL-DOES_RGB)|DOES_STACKS|NO_CHANGES|FINAL_PROCESSING;
private ImagePlus imp;
private ImagePlus registred;
private ImageStack translated;
private int nbslices = 0;
private int processed = 0;
double[][] shifts;
public void setShifts(double[][] shifts){
this.shifts = shifts;
}
public double[][] getShifts(){
return this.shifts;
}
/**
* This method is called by ImageJ for initialization.
* @param arg Unused here. For plugins in a .jar file this argument string can
* be specified in the plugins.config file of the .jar archive.
* @param imp The ImagePlus containing the image (or stack) to process.
* @return The method returns flags (i.e., a bit mask) specifying the
* capabilities (supported formats, etc.) and needs of the filter.
* See PlugInFilter.java and ExtendedPlugInFilter in the ImageJ
* sources for details.
*/
public int setup(String arg, ImagePlus imp) {
nbslices = imp.getImageStackSize();
registred = imp.createImagePlus();
translated = new ImageStack(imp.getWidth(), imp.getHeight(), nbslices);
this.imp = imp;
if (shifts == null) return DONE;
//int ret = IJ.setupDialog(imp, flags); // ask whether to process all slices of stack (if a stack)
return flags;
}
public ImagePlus getRegistred(){
return registred;
}
public ImageStack getTranslated(){
return translated;
}
/** Process a FloatProcessor (with the CONVERT_TO_FLOAT flag, ImageJ does the conversion to float).
* Called by ImageJ for each stack slice (when processing a full stack); for RGB also called once for each color. */
public void run(ImageProcessor ip) {
for (int slice =1; slice<= nbslices; slice++){
if (Thread.currentThread().isInterrupted()) return;
ImageProcessor nip = ip.duplicate().convertToFloat();
nip.setInterpolationMethod(ImageProcessor.BICUBIC);
if (shifts.length != nbslices) {
nip.translate(shifts[1][3], shifts[1][2]); // translate all the frame by the
// same shifts
} else {
nip.translate(shifts[slice-1][3], shifts[slice-1][2]);
}
String lbl = imp.getStack().getSliceLabel(slice);
if (lbl != null) {
translated.addSlice(lbl, nip, slice - 1);
} else {
translated.addSlice("" + slice, nip, slice - 1);
}
translated.deleteSlice(slice + 1);
processed++;
IJ.showProgress(processed, nbslices);
}
registred.setStack("REG_" + imp.getTitle(), translated);
}
}
+588 -588
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.
+11
View File
@@ -510,6 +510,7 @@
<Group type="103" groupAlignment="0" attributes="0">
<Component id="buttonStart" max="32767" attributes="0"/>
<Component id="buttonAbort" pref="244" max="32767" attributes="0"/>
<Component id="buttonAddToQueue" pref="244" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@@ -528,6 +529,8 @@
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="buttonAbort" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonAddToQueue" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="36" max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="143" max="-2" attributes="0"/>
</Group>
@@ -556,6 +559,14 @@
<Property name="text" type="java.lang.String" value="jButton1"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonAddToQueue">
<Properties>
<Property name="text" type="java.lang.String" value="Add To Queue"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonAddToQueueActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
+43 -44
View File
@@ -1,15 +1,19 @@
/*
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
*/
*/
import ch.psi.pshell.device.Motor;
import ch.psi.pshell.ui.Panel;
import ch.psi.pshell.ui.ScriptProcessor;
import ch.psi.pshell.ui.Plugin;
import ch.psi.pshell.ui.QueueProcessor;
import ch.psi.utils.State;
import ch.psi.utils.swing.SwingUtils;
import java.awt.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -18,7 +22,7 @@ import javax.swing.SpinnerNumberModel;
/**
*
public class ManipulatorScan extends Panel {
*/
public class ManipulatorScan extends ScriptProcessor {
public ManipulatorScan() {
@@ -64,8 +68,14 @@ public class ManipulatorScan extends Panel {
void updateTable(){
void startScan() throws Exception {
}
@Override
public String getScript() {
return "ManipulatorScan";
}
@Override
public Map<String, Object> getArgs(){
HashMap<String, Object> args = new HashMap<>();
args.put("MOTOR", comboMotor.getSelectedItem().toString());
@@ -89,45 +99,10 @@ public class ManipulatorScan extends Panel {
args.put("STEPS", (Integer) spinnerSteps.getValue());
}
args.put("LATENCY", (Double) spinnerLatency.getValue());
runAsync("ManipulatorScan", args);
/*
getContext().setExecutingContext("manip_scan");
String scan ="lscan(" + comboMotor.getSelectedItem().toString() + ", ( " ;
for (Component c : panelSensors.getComponents()) {
if ((c instanceof JCheckBox) && ((JCheckBox)c).isSelected())
scan += c.getName() + ", ";
}
scan+="), ";
if (radioRelative.isSelected()){
double halfRange = (Double)spinnerRange.getValue()/2;
scan+= (-halfRange) + ", " + (halfRange)+ ", ";
} else {
Double from = (Double)spinnerFrom.getValue();
Double to = (Double)spinnerTo.getValue();
if (to <= from){
throw new Exception ("Invalid range");
}
scan+= from + ", " + to + ", ";
}
scan+= (radioStepSize.isSelected()) ? "(" +((Double)spinnerStepSize.getValue())+",)" :((Integer)spinnerSteps.getValue());
scan+=", " + (Double)spinnerLatency.getValue() + ", ";
if (radioRelative.isSelected()){
scan+="True, "; //Relative
}
scan+="before_read=trig_scienta)"; //Relative
if (checkImageIntegration.isSelected()){
scan = "set_preference(Preference.PLOT_TYPES,{'integration':1}); " + scan;
}
evalAsync(scan);
*/
args.put("RELATIVE", radioRelative.isSelected());
return args;
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
@@ -173,6 +148,7 @@ public class ManipulatorScan extends Panel {
jPanel3 = new javax.swing.JPanel();
buttonStart = new javax.swing.JButton();
buttonAbort = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
buttonAddToQueue = new javax.swing.JButton();
panelPositioner.setBorder(javax.swing.BorderFactory.createTitledBorder("Positioner"));
@@ -473,6 +449,13 @@ public class ManipulatorScan extends Panel {
});
jButton1.setText("jButton1");
buttonAddToQueue.setText("Add To Queue");
buttonAddToQueue.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonAddToQueueActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
@@ -481,7 +464,8 @@ public class ManipulatorScan extends Panel {
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(buttonAbort, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE))
.addComponent(buttonStart, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonAbort, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE)
.addComponent(buttonAddToQueue, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE))
.addContainerGap())
.addGroup(jPanel3Layout.createSequentialGroup()
@@ -496,6 +480,8 @@ public class ManipulatorScan extends Panel {
.addComponent(buttonStart)
.addGap(18, 18, 18)
.addComponent(buttonAbort)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonAddToQueue)
.addGap(36, 36, 36)
.addComponent(jButton1)
.addGap(143, 143, 143))
@@ -538,7 +524,7 @@ public class ManipulatorScan extends Panel {
}//GEN-LAST:event_buttonScientaSetupActionPerformed
private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed
startScan();
try {
execute();
} catch (Exception ex) {
SwingUtils.showException(this, ex);
@@ -566,7 +552,7 @@ public class ManipulatorScan extends Panel {
txtSize.setText("Size (" + motor.getUnit() +")");
//spinnerFrom.setModel(new javax.swing.SpinnerNumberModel(3.0, 0.001, 100.0, 1.0));
//spinnerTo.setModel(new javax.swing.SpinnerNumberModel(2.0, 0.001, 100.0, 1.0));
SwingUtils.showException(this, ex);
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_comboMotorActionPerformed
@@ -574,8 +560,20 @@ public class ManipulatorScan extends Panel {
private void radioAbsoluteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioAbsoluteActionPerformed
setEnabled(isEnabled());
}//GEN-LAST:event_radioAbsoluteActionPerformed
private void buttonAddToQueueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAddToQueueActionPerformed
try {
List<QueueProcessor> queues = getView().getQueues();
QueueProcessor tq = (queues.size() == 0) ? getView().openProcessor(QueueProcessor.class, null) : queues.get(0);
getView().getDocumentsTab().setSelectedComponent(tq);
tq.addNewFile(getScript(), getArgs());
} catch (Exception ex) {
showException( ex);
}
}//GEN-LAST:event_buttonAddToQueueActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonAbort;
private javax.swing.JButton buttonAddToQueue;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.ButtonGroup buttonGroup2;
@@ -617,4 +615,5 @@ public class ManipulatorScan extends Panel {
private javax.swing.JSpinner spinnerSteps;
private javax.swing.JSpinner spinnerTo;
private javax.swing.JLabel txtSize;
// End of variables declaration//GEN-END:variables
+76 -33
View File
@@ -22,39 +22,51 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="scriptButton2" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jSpinner1" min="-2" max="-2" attributes="0"/>
<Component id="motorPanel2" min="-2" max="-2" attributes="0"/>
<Component id="jSpinner2" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jSpinner3" alignment="1" min="-2" max="-2" attributes="0"/>
<Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
<Component id="jSpinner1" min="-2" max="-2" attributes="0"/>
<Component id="motorPanel2" min="-2" max="-2" attributes="0"/>
<Component id="jSpinner2" alignment="1" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="buttonExecShellCmd" min="-2" max="-2" attributes="0"/>
<Group type="103" alignment="1" groupAlignment="0" attributes="0">
<Component id="jRadioButton2" min="-2" max="-2" attributes="0"/>
<Component id="jRadioButton1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jSpinner3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="scriptButton1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="36" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="86" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jRadioButton2" min="-2" max="-2" attributes="0"/>
<Component id="jRadioButton1" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="panelSetp" min="-2" pref="95" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelRbck" min="-2" pref="82" max="-2" attributes="0"/>
</Group>
<Component id="scriptButton1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace pref="168" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
<Component id="buttonExecShellCmd" min="-2" max="-2" attributes="0"/>
<Component id="line" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<EmptySpace min="6" pref="6" max="-2" attributes="0"/>
<Component id="time" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="225" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -62,10 +74,7 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="scriptButton1" min="-2" max="-2" attributes="0"/>
<Component id="motorPanel2" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="motorPanel2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="scriptButton2" min="-2" max="-2" attributes="0"/>
@@ -73,17 +82,37 @@
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="jSpinner2" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jSpinner3" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="21" max="-2" attributes="0"/>
<Component id="jRadioButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jRadioButton2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonExecShellCmd" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="panelSetp" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="panelRbck" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="44" max="-2" attributes="0"/>
<Component id="scriptButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="line" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jSpinner3" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jRadioButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jRadioButton2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="buttonExecShellCmd" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="35" max="32767" attributes="0"/>
<Component id="time" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="12" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -166,5 +195,19 @@
<Property name="text" type="java.lang.String" value="Exec Sync"/>
</Properties>
</Component>
<Component class="ch.psi.pshell.plot.LinePlotJFree" name="line">
</Component>
<Component class="ch.psi.pshell.plot.TimePlotJFree" name="time">
</Component>
<Component class="ch.psi.pshell.swing.RegisterPanel" name="panelSetp">
<Properties>
<Property name="name" type="java.lang.String" value="TESTIOC:TESTCALCOUT:Input" noResource="true"/>
</Properties>
</Component>
<Component class="ch.psi.pshell.swing.DeviceValuePanel" name="panelRbck">
<Properties>
<Property name="name" type="java.lang.String" value="TESTIOC:TESTCALCOUT:Input" noResource="true"/>
</Properties>
</Component>
</SubComponents>
</Form>
+88 -31
View File
@@ -3,9 +3,14 @@
*/
import ch.psi.pshell.core.Context;
import ch.psi.pshell.epics.ChannelDouble;
import ch.psi.pshell.epics.GenericChannel;
import ch.psi.pshell.plot.Plot;
import ch.psi.pshell.swing.DevicePanel;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import java.awt.Component;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;
@@ -18,13 +23,29 @@ public class PanelPlugin extends Panel {
public PanelPlugin() {
initComponents();
this.setPersistedComponents(new Component[]{jRadioButton1, jRadioButton2});
line.getAxis(Plot.AxisId.Y).setLabel("LinePlot");
time.getAxis(Plot.AxisId.Y).setLabel("TimePlot");
time.setTitle("Test");
}
//Overridables
@Override
public void onInitialize(int runCount) {
DevicePanel[] panels = new DevicePanel[]{panelSetp, panelRbck};
for (DevicePanel p : panels){
GenericChannel channel = new GenericChannel(p.getName(), p.getName(), 3);
channel.setMonitored(true);
try {
channel.initialize();
p.setDevice(channel);
} catch (Exception ex) {
Logger.getLogger(PanelPlugin.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
@Override
public void onStateChange(State state, State former) {
@@ -56,6 +77,10 @@ public class PanelPlugin extends Panel {
jRadioButton2 = new javax.swing.JRadioButton();
buttonExecShellCmd = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
line = new ch.psi.pshell.plot.LinePlotJFree();
time = new ch.psi.pshell.plot.TimePlotJFree();
panelSetp = new ch.psi.pshell.swing.RegisterPanel();
panelRbck = new ch.psi.pshell.swing.DeviceValuePanel();
motorPanel2.setDeviceName("m1");
@@ -90,6 +115,10 @@ public class PanelPlugin extends Panel {
jButton2.setText("Exec Sync");
panelSetp.setName("TESTIOC:TESTCALCOUT:Input"); // NOI18N
panelRbck.setName("TESTIOC:TESTCALCOUT:Input"); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -100,52 +129,76 @@ public class PanelPlugin extends Panel {
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(scriptButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(motorPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jSpinner3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(scriptButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(motorPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(buttonExecShellCmd)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jRadioButton2)
.addComponent(jRadioButton1)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jSpinner3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGroup(layout.createSequentialGroup()
.addGap(36, 36, 36)
.addGap(86, 86, 86)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jRadioButton2)
.addComponent(jRadioButton1))))
.addContainerGap(168, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(panelSetp, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelRbck, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(scriptButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton2)
.addComponent(buttonExecShellCmd))
.addGap(225, 225, 225))
.addComponent(line, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(time, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(scriptButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(motorPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(motorPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(scriptButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSpinner3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(jRadioButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jRadioButton2)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonExecShellCmd)
.addComponent(jButton2))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(panelSetp, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(panelRbck, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(44, 44, 44)
.addComponent(scriptButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(25, 25, 25))
.addGroup(layout.createSequentialGroup()
.addComponent(line, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSpinner3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jRadioButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jRadioButton2)
.addGap(18, 18, 18)
.addComponent(buttonExecShellCmd)
.addGap(18, 18, 18)
.addComponent(jButton2)
.addContainerGap(35, Short.MAX_VALUE))
.addComponent(time, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 12, Short.MAX_VALUE))
);
layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {panelRbck, panelSetp});
}// </editor-fold>//GEN-END:initComponents
private void buttonExecShellCmdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExecShellCmdActionPerformed
@@ -178,8 +231,12 @@ public class PanelPlugin extends Panel {
private javax.swing.JSpinner jSpinner1;
private javax.swing.JSpinner jSpinner2;
private javax.swing.JSpinner jSpinner3;
private ch.psi.pshell.plot.LinePlotJFree line;
private ch.psi.pshell.swing.MotorPanel motorPanel2;
private ch.psi.pshell.swing.DeviceValuePanel panelRbck;
private ch.psi.pshell.swing.RegisterPanel panelSetp;
private ch.psi.pshell.swing.ScriptButton scriptButton1;
private ch.psi.pshell.swing.ScriptButton scriptButton2;
private ch.psi.pshell.plot.TimePlotJFree time;
// End of variables declaration//GEN-END:variables
}
+5
View File
@@ -0,0 +1,5 @@
This plugin for the analysis of PEEM images requires the following additional
libraries:
JTransform, http://sites.google.com/site/piotrwendykier/software/jtransforms
Michael Thomas Flanagan's Java Scientific Library, http://www.ee.ucl.ac.uk/~mflanaga/java/
JMatIO, http://www.mathworks.com/matlabcentral/fileexchange/10759
+3
View File
@@ -297,6 +297,9 @@
<Component class="javax.swing.JTextField" name="textExposures">
</Component>
<Component class="javax.swing.JCheckBox" name="checkZigZag">
<Properties>
<Property name="selected" type="boolean" value="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel12">
<Properties>
+2
View File
@@ -212,6 +212,8 @@ public class Regine extends ScriptProcessor {
jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel11.setText("Exposures(s):");
checkZigZag.setSelected(true);
jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel12.setText("ZigZag:");
+395
View File
@@ -0,0 +1,395 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.6" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel2" alignment="1" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="buttonAddToQueue" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="buttonStart" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="buttonAbort" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="137" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="buttonScienta" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="textFileId" min="-2" pref="67" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonResetId" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="jPanel2" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonScienta" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonResetId" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textFileId" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonStart" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonAbort" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonAddToQueue" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonScienta">
<Properties>
<Property name="text" type="java.lang.String" value="Scienta Panel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonScientaActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="File ID:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textFileId">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonResetId">
<Properties>
<Property name="text" type="java.lang.String" value="Reset"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonResetIdActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonStart">
<Properties>
<Property name="text" type="java.lang.String" value="Start"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonStartActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonAbort">
<Properties>
<Property name="text" type="java.lang.String" value="Abort"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonAbortActionPerformed"/>
</Events>
</Component>
<Container class="javax.swing.JPanel" name="jPanel2">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Parameters"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="17" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="0" pref="98" max="32767" attributes="0"/>
<Component id="checkZigzag" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerLatency" linkSize="3" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerPasses" linkSize="3" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="textFile" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="buttonOpen" linkSize="2" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="buttonSave" linkSize="2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonClear" linkSize="2" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonOpen" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonSave" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textFile" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonClear" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="0" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerLatency" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="checkZigzag" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerPasses" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="56" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonOpen">
<Properties>
<Property name="text" type="java.lang.String" value="Open"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonOpenActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonSave">
<Properties>
<Property name="text" type="java.lang.String" value="Save"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonSaveActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" value="File:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textFile">
<Properties>
<Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" id="TextField.foreground" palette="3" red="0" type="palette"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonClear">
<Properties>
<Property name="text" type="java.lang.String" value="Clear"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonClearActionPerformed"/>
</Events>
</Component>
<Container class="javax.swing.JPanel" name="jPanel1">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Positioners"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="0" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jScrollPane2" pref="0" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jScrollPane3" pref="0" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" pref="0" max="32767" attributes="0"/>
<Component id="jScrollPane2" pref="183" max="32767" attributes="0"/>
<Component id="jScrollPane3" pref="183" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Inactive"/>
</Border>
</Property>
</Properties>
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="tableInactive">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
<Table columnCount="1" rowCount="0">
<Column editable="false" title="Name" type="java.lang.String"/>
</Table>
</Property>
<Property name="selectionMode" type="int" value="0"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Fixed"/>
</Border>
</Property>
</Properties>
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="tableFixed">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
<Table columnCount="3" rowCount="0">
<Column editable="false" title="Name" type="java.lang.String"/>
<Column editable="true" title="Value" type="java.lang.Double"/>
<Column editable="false" title="Units" type="java.lang.String"/>
</Table>
</Property>
<Property name="selectionMode" type="int" value="0"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JScrollPane" name="jScrollPane3">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Scanned"/>
</Border>
</Property>
</Properties>
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="tableScanned">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
<Table columnCount="6" rowCount="0">
<Column editable="false" title="Name" type="java.lang.String"/>
<Column editable="true" title="Start" type="java.lang.Double"/>
<Column editable="true" title="Stop" type="java.lang.Double"/>
<Column editable="true" title="Points" type="java.lang.Integer"/>
<Column editable="false" title="Step" type="java.lang.Double"/>
<Column editable="false" title="Units" type="java.lang.String"/>
</Table>
</Property>
<Property name="selectionMode" type="int" value="0"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Passes:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerPasses">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="1" maximum="1000" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkZigzag">
<Properties>
<Property name="text" type="java.lang.String" value="Zigzag"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="text" type="java.lang.String" value="Settling Time:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerLatency">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" maximum="1000.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="buttonAddToQueue">
<Properties>
<Property name="text" type="java.lang.String" value="Add to Queue"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonAddToQueueActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>
+813
View File
@@ -0,0 +1,813 @@
import ch.psi.pshell.core.JsonSerializer;
import ch.psi.pshell.device.Positioner;
import ch.psi.pshell.ui.Panel;
import ch.psi.pshell.ui.PanelProcessor;
import ch.psi.pshell.ui.QueueProcessor;
import ch.psi.utils.Arr;
import ch.psi.utils.IO;
import ch.psi.utils.State;
import ch.psi.utils.swing.SwingUtils;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DropMode;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JTable;
import javax.swing.TransferHandler;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableModel;
/**
*
*/
public class SIStem extends PanelProcessor {
File currentFile;
final DefaultTableModel modelInactive;
final DefaultTableModel modelFixed;
final DefaultTableModel modelScanned;
public static final String FILE_EXTENSION = "json";
public SIStem() {
initComponents();
modelInactive = (DefaultTableModel) tableInactive.getModel();
modelFixed = (DefaultTableModel) tableFixed.getModel();
modelScanned = (DefaultTableModel) tableScanned.getModel();
clear();
Standard st = new Standard(); st.run();
abstract class PositinerTransferHandler extends TransferHandler{
@Override
public int getSourceActions(JComponent c) {
return DnDConstants.ACTION_COPY_OR_MOVE;
}
@Override
public Transferable createTransferable(JComponent comp) {
try{
JTable table = (JTable) comp;
return new StringSelection((String) table.getModel().getValueAt(table.getSelectedRow(),0));
} catch(Exception ex){
return null;
}
}
@Override
public boolean canImport(TransferHandler.TransferSupport support) {
return support.isDataFlavorSupported(DataFlavor.stringFlavor);
}
@Override
public boolean importData(TransferHandler.TransferSupport support) {
if (support.isDrop() && canImport(support)) {
try {
JTable.DropLocation dl = (JTable.DropLocation)support.getDropLocation();
String name = (String) support.getTransferable().getTransferData(DataFlavor.stringFlavor);
Positioner pos = getContext().getDevicePool().getByName(name, Positioner.class);
DefaultTableModel model = ((DefaultTableModel)((JTable)support.getComponent()).getModel());
addPositioner(pos, model, dl.getRow(), getRowData(pos));
} catch (Exception ex) {
return false;
}
}
return true;
}
abstract Object[] getRowData(Positioner pos);
};
tableInactive.setDragEnabled(true);
tableInactive.setDropMode(DropMode.INSERT_ROWS);
tableInactive.setFillsViewportHeight(true);
tableInactive.setTransferHandler(new PositinerTransferHandler() {
@Override
Object[] getRowData(Positioner pos) {
return new Object[]{pos.getName()};
}
});
tableFixed.setDragEnabled(true);
tableFixed.setDropMode(DropMode.INSERT_ROWS);
tableFixed.setFillsViewportHeight(true);
tableFixed.setTransferHandler(new PositinerTransferHandler() {
@Override
Object[] getRowData(Positioner pos) {
return new Object[]{pos.getName(), Double.NaN, pos.getUnit()};
}
});
tableScanned.setDragEnabled(true);
tableScanned.setDropMode(DropMode.INSERT_ROWS);
tableScanned.setFillsViewportHeight(true);
tableScanned.setTransferHandler(new PositinerTransferHandler() {
@Override
Object[] getRowData(Positioner pos) {
return new Object[]{pos.getName(), Double.NaN, Double.NaN, 0, Double.NaN, pos.getUnit()};
}
});
}
void addPositioner(Positioner pos, DefaultTableModel model, int row, Object[] data){
if (row<0){
row = model.getRowCount();
}
model.insertRow(row, data);
removePositioner(pos, modelInactive, (model==modelInactive) ? row : -1);
removePositioner(pos, modelFixed, (model==modelFixed) ? row : -1);
removePositioner(pos, modelScanned, (model==modelScanned) ?row : -1);
}
void removePositioner(Positioner pos, DefaultTableModel model, int except){
for (int i=0; i< model.getRowCount(); i++){
if ((except<0) || (i!=except)){
if (model.getValueAt(i, 0).equals(pos.getName())){
model.removeRow(i);
break;
}
}
}
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
}
@Override
public void onStateChange(State state, State former) {
updateControls();
}
@Override
public void onExecutedFile(String fileName, Object result) {
}
//Callback to perform update - in event thread
@Override
protected void doUpdate() {
}
@Override
public String getFileName(){
return (currentFile==null) ? null : currentFile.toString();
}
@Override
public boolean isTabNameUpdated() {
return false;
}
@Override
public String getType() {
return "SIStem";
}
@Override
public boolean createMenuNew() {
return true;
}
@Override
public boolean createFilePanel() {
return true;
}
@Override
public String getDescription() {
return "SIStem Scan definition file (*." + FILE_EXTENSION + ")";
}
@Override
public String[] getExtensions() {
return new String[]{FILE_EXTENSION};
}
@Override
public String getHomePath() {
return "{home}/scans";
}
@Override
public void saveAs(String fileName) throws IOException {
currentFile = new File(fileName);
Map preActions = new HashMap();
for (int i=0; i< modelFixed.getRowCount(); i++){
preActions.put(modelFixed.getValueAt(i, 0), modelFixed.getValueAt(i, 1));
}
String[] positioners = new String[modelScanned.getRowCount()];
Double[] start = new Double[modelScanned.getRowCount()];
Double[] stop = new Double[modelScanned.getRowCount()];
Integer[] steps = new Integer[modelScanned.getRowCount()];
for (int i=0; i< modelScanned.getRowCount(); i++){
positioners[i] = (String) modelScanned.getValueAt(i, 0);
start[i] = (Double) modelScanned.getValueAt(i, 1);
stop[i] = (Double) modelScanned.getValueAt(i, 2);
steps[i] = (Integer) modelScanned.getValueAt(i, 3) -1;
}
Map config = new HashMap();
config.put("PRE_ACTIONS", preActions);
config.put("POSITIONERS", positioners);
config.put("START", start);
config.put("STOP", stop);
config.put("STEPS", steps);
//TODO:
config.put("SENSORS", Arr.toList(new String[]{"scienta.dataMatrix", "sin"}));
config.put("SETTLING_TIME", spinnerLatency.getValue() );
config.put("PASSES", spinnerPasses.getValue());
config.put("ZIGZAG", checkZigzag.isSelected());
config.put("COMPRESSION", true);
String json = JsonSerializer.encode(config, true);
Files.write(currentFile.toPath(), json.getBytes());
updateControls();
}
@Override
public void open(String fileName) throws IOException {
clear();
if (fileName!=null){
Path path = Paths.get(fileName);
String json = new String(Files.readAllBytes(path));
currentFile = path.toFile();
Map config = (Map) JsonSerializer.decode(json, Map.class);
Map<String, Double> preActions = (Map) config.get("PRE_ACTIONS");
List<String> positioners = (List)config.get("POSITIONERS");
List<Double> start = (List)config.get("START");
List<Double> stop = (List)config.get("STOP");
List<Integer> steps = (List) config.get("STEPS");
for (String name:preActions.keySet()){
Positioner pos = getContext().getDevicePool().getByName(name, Positioner.class);
if (pos!=null){
addPositioner(pos, modelFixed, -1, new Object[]{name, preActions.get(name), pos.getUnit()});
}
}
for (int i=0; i< positioners.size(); i++){
String name = positioners.get(i);
Positioner pos = getContext().getDevicePool().getByName(name, Positioner.class);
if (pos!=null){
addPositioner(pos, modelScanned, -1, new Object[]{name, start.get(i), stop.get(i), steps.get(i), 0, pos.getUnit()});
}
}
spinnerLatency.setValue(config.get("SETTLING_TIME"));
spinnerPasses.setValue(config.get("PASSES"));
checkZigzag.setSelected((Boolean) config.get("ZIGZAG"));
}
updateControls();
}
public void clear(){
currentFile = null;
modelInactive.setRowCount(0);
modelFixed.setRowCount(0);
modelScanned.setRowCount(0);
Positioner[] positioners = getContext().getDevicePool().getAllDevicesOrderedByName(Positioner.class);
for (Positioner pos: positioners){
modelInactive.addRow(new Object[]{pos.getName()});
}
updateControls();
}
@Override
public void execute() throws Exception {
checkValues();
HashMap args = new HashMap();
if (currentFile == null) {
throw new Exception("TODO");
}
args.put("NAME", getScanName());
this.runAsync("SIStem", args).handle((ret, ex) -> {
if (ex != null) {
}
try {
} catch (Exception e) {
Logger.getLogger(SIStem.class.getName()).log(Level.SEVERE, null, e);
}
return ret;
});
}
String getScanName() {
if (currentFile != null) {
return IO.getPrefix(currentFile);
}
return null;
}
void updateControls() {
State state = getState();
try {
textFileId.setText(String.valueOf(getContext().getFileSequentialNumber()));
} catch (Exception ex) {
textFileId.setText("");
}
String fileName = getFileName();
if (fileName == null){
textFile.setText("");
} else {
String home = getContext().getSetup().expandPath(getHomePath());
if (IO.isSubPath(fileName, home)) {
fileName = IO.getRelativePath(fileName, home);
}
textFile.setText(fileName);
}
buttonStart.setEnabled((state == State.Ready) && (currentFile != null));
buttonAddToQueue.setEnabled((state == State.Ready) && (currentFile != null));
buttonAbort.setEnabled(state.isProcessing());
buttonScienta.setEnabled(state.isInitialized());
}
void checkValues(){
for (int i=0; i< modelFixed.getRowCount(); i++){
if (Double.isNaN((Double)modelFixed.getValueAt(i, 1))){
throw new IllegalArgumentException("Invalid value for " + modelFixed.getValueAt(i, 0));
}
}
for (int i=0; i< modelScanned.getRowCount(); i++){
if (Double.isNaN((Double)modelScanned.getValueAt(i, 1))){
throw new IllegalArgumentException("Invalid start for " + modelFixed.getValueAt(i, 0));
}
if (Double.isNaN((Double)modelScanned.getValueAt(i, 2))){
throw new IllegalArgumentException("Invalid stop for " + modelFixed.getValueAt(i, 0));
}
if (((Integer)modelScanned.getValueAt(i, 3)) < 1){
throw new IllegalArgumentException("Invalid points for " + modelFixed.getValueAt(i, 0));
}
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
buttonScienta = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
textFileId = new javax.swing.JTextField();
buttonResetId = new javax.swing.JButton();
buttonStart = new javax.swing.JButton();
buttonAbort = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
buttonOpen = new javax.swing.JButton();
buttonSave = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
textFile = new javax.swing.JTextField();
buttonClear = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
tableInactive = new javax.swing.JTable();
jScrollPane2 = new javax.swing.JScrollPane();
tableFixed = new javax.swing.JTable();
jScrollPane3 = new javax.swing.JScrollPane();
tableScanned = new javax.swing.JTable();
jLabel1 = new javax.swing.JLabel();
spinnerPasses = new javax.swing.JSpinner();
checkZigzag = new javax.swing.JCheckBox();
jLabel4 = new javax.swing.JLabel();
spinnerLatency = new javax.swing.JSpinner();
buttonAddToQueue = new javax.swing.JButton();
buttonScienta.setText("Scienta Panel");
buttonScienta.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonScientaActionPerformed(evt);
}
});
jLabel2.setText("File ID:");
textFileId.setEditable(false);
textFileId.setHorizontalAlignment(javax.swing.JTextField.CENTER);
buttonResetId.setText("Reset");
buttonResetId.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonResetIdActionPerformed(evt);
}
});
buttonStart.setText("Start");
buttonStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonStartActionPerformed(evt);
}
});
buttonAbort.setText("Abort");
buttonAbort.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonAbortActionPerformed(evt);
}
});
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Parameters"));
buttonOpen.setText("Open");
buttonOpen.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonOpenActionPerformed(evt);
}
});
buttonSave.setText("Save");
buttonSave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonSaveActionPerformed(evt);
}
});
jLabel3.setText("File:");
textFile.setDisabledTextColor(javax.swing.UIManager.getDefaults().getColor("TextField.foreground"));
textFile.setEnabled(false);
buttonClear.setText("Clear");
buttonClear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonClearActionPerformed(evt);
}
});
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Positioners"));
jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder("Inactive"));
tableInactive.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Name"
}
) {
Class[] types = new Class [] {
java.lang.String.class
};
boolean[] canEdit = new boolean [] {
false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
tableInactive.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jScrollPane1.setViewportView(tableInactive);
jScrollPane2.setBorder(javax.swing.BorderFactory.createTitledBorder("Fixed"));
tableFixed.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Name", "Value", "Units"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.Double.class, java.lang.String.class
};
boolean[] canEdit = new boolean [] {
false, true, false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
tableFixed.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jScrollPane2.setViewportView(tableFixed);
jScrollPane3.setBorder(javax.swing.BorderFactory.createTitledBorder("Scanned"));
tableScanned.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Name", "Start", "Stop", "Points", "Step", "Units"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.Integer.class, java.lang.Double.class, java.lang.String.class
};
boolean[] canEdit = new boolean [] {
false, true, true, true, false, false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
tableScanned.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jScrollPane3.setViewportView(tableScanned);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE)
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE))
.addGap(12, 12, 12))
);
jLabel1.setText("Passes:");
spinnerPasses.setModel(new javax.swing.SpinnerNumberModel(1, 1, 1000, 1));
checkZigzag.setText("Zigzag");
jLabel4.setText("Settling Time:");
spinnerLatency.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, 1000.0d, 1.0d));
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(17, 17, 17)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(0, 98, Short.MAX_VALUE)
.addComponent(checkZigzag)
.addGap(18, 18, 18)
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerLatency, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerPasses, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textFile)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonOpen)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonSave)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonClear)))))
.addContainerGap())
);
jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonClear, buttonOpen, buttonSave});
jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerLatency, spinnerPasses});
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonOpen)
.addComponent(buttonSave)
.addComponent(jLabel3)
.addComponent(textFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonClear))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(spinnerLatency, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(checkZigzag))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(spinnerPasses, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(2, 2, 2)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(56, Short.MAX_VALUE))
);
buttonAddToQueue.setText("Add to Queue");
buttonAddToQueue.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonAddToQueueActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(buttonAddToQueue)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(buttonStart)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(buttonAbort)
.addContainerGap(137, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(buttonScienta)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textFileId, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonResetId)
.addContainerGap())))
);
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonAbort, buttonAddToQueue, buttonStart});
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonScienta)
.addComponent(buttonResetId)
.addComponent(jLabel2)
.addComponent(textFileId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonStart)
.addComponent(buttonAbort)
.addComponent(buttonAddToQueue))
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
private void buttonScientaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonScientaActionPerformed
try {
this.showDevicePanel("scienta");
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonScientaActionPerformed
private void buttonResetIdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonResetIdActionPerformed
try {
this.getContext().setFileSequentialNumber(0);
updateControls();
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonResetIdActionPerformed
private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed
try {
execute();
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonStartActionPerformed
private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed
try {
abort();
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonAbortActionPerformed
private void buttonOpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonOpenActionPerformed
try {
open();
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonOpenActionPerformed
private void buttonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSaveActionPerformed
try {
JFileChooser chooser = new JFileChooser(getContext().getSetup().expandPath(getHomePath()));
FileNameExtensionFilter filter = new FileNameExtensionFilter(getDescription(), getExtensions());
chooser.setFileFilter(filter);
try {
if (currentFile != null) {
chooser.setSelectedFile(currentFile);
}
} catch (Exception ex) {
this.showException(ex);
}
int rVal = chooser.showSaveDialog(this);
if (rVal == JFileChooser.APPROVE_OPTION) {
String fileName = chooser.getSelectedFile().getAbsolutePath();
if (IO.getExtension(chooser.getSelectedFile().getAbsolutePath()).isEmpty()) {
fileName += "." + FILE_EXTENSION;
}
saveAs(fileName);
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonSaveActionPerformed
private void buttonAddToQueueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAddToQueueActionPerformed
try {
QueueProcessor tq = null;
List<QueueProcessor> queues = getView().getQueues();
if (queues.size()==0){
tq = getView().openProcessor(QueueProcessor.class, null);
} else {
tq = queues.get(0);
}
getView().getDocumentsTab().setSelectedComponent(tq);
tq.addNewFile(currentFile.getPath());
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonAddToQueueActionPerformed
private void buttonClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonClearActionPerformed
try {
clear();
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonClearActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonAbort;
private javax.swing.JButton buttonAddToQueue;
private javax.swing.JButton buttonClear;
private javax.swing.JButton buttonOpen;
private javax.swing.JButton buttonResetId;
private javax.swing.JButton buttonSave;
private javax.swing.JButton buttonScienta;
private javax.swing.JButton buttonStart;
private javax.swing.JCheckBox checkZigzag;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JSpinner spinnerLatency;
private javax.swing.JSpinner spinnerPasses;
private javax.swing.JTable tableFixed;
private javax.swing.JTable tableInactive;
private javax.swing.JTable tableScanned;
private javax.swing.JTextField textFile;
private javax.swing.JTextField textFileId;
// End of variables declaration//GEN-END:variables
}
+18 -6
View File
@@ -37,6 +37,7 @@ import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
/**
*
@@ -103,20 +104,30 @@ public class ScreenPanel extends Panel implements CamServerViewer.CamServerViewe
if (App.hasArgument("instance_format")) {
camServerViewer.setInstanceNameFormat(App.getArgumentValue("instance_format"));
}
camServerViewer.setShowFit(true);
camServerViewer.setShowProfile(true);
camServerViewer.setShowReticle(true);
}
@Override
public void onStart() {
super.onStart();
super.onStart();
try {
camServerViewer.setCameraServerUrl(App.getArgumentValue(ARG_CAMERA_SERVER));
camServerViewer.setPipelineServerUrl(App.getArgumentValue(ARG_PIPELINE_SERVER));
camServerViewer.setStartupStream(App.getArgumentValue(ARG_CAMERA));
camServerViewer.initialize(CamServerViewer.SourceSelecionMode.Cameras);
SwingUtilities.invokeLater(()->{
try {
camServerViewer.initialize(CamServerViewer.SourceSelecionMode.Cameras);
} catch (Exception ex) {
Logger.getLogger(ScreenPanel.class.getName()).log(Level.SEVERE, null, ex);
}
updateDialogTitle();
});
} catch (Exception ex) {
logger.log(Level.SEVERE, null, ex);
}
updateDialogTitle();
}
}
@Override
@@ -195,7 +206,7 @@ public class ScreenPanel extends Panel implements CamServerViewer.CamServerViewe
@Override
public void onOpeningStream(String name) throws Exception {
System.out.println("Initializing stream " + name);
System.out.println("Initializing stream " + name);
if ((devicesInitTask != null) && (devicesInitTask.isAlive())) {
devicesInitTask.interrupt();
}
@@ -207,6 +218,7 @@ public class ScreenPanel extends Panel implements CamServerViewer.CamServerViewe
filter.close();
filter = null;
}
updateDialogTitle();
}
@@ -272,7 +284,7 @@ public class ScreenPanel extends Panel implements CamServerViewer.CamServerViewe
devicesInitTask.start();
}
}
updateDialogTitle();
}
public void onSavedSnapshot(String name, String instancee, String snapshotFile) throws Exception {
+960
View File
@@ -0,0 +1,960 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<NonVisualComponents>
<Component class="javax.swing.ButtonGroup" name="buttonGroup1">
</Component>
<Component class="javax.swing.ButtonGroup" name="buttonGroup2">
</Component>
<Component class="javax.swing.ButtonGroup" name="buttonGroup3">
</Component>
<Component class="javax.swing.ButtonGroup" name="buttonGroup4">
</Component>
<Component class="javax.swing.JProgressBar" name="jProgressBar1">
</Component>
</NonVisualComponents>
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[873, 600]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="jPanel4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" max="32767" attributes="0"/>
<Component id="jPanel4" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel1">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="renderer" max="32767" attributes="0"/>
<Component id="jPanel7" alignment="1" max="32767" attributes="0"/>
<Component id="jPanel6" alignment="1" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel6" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="renderer" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel7" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel7">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="buttonPause" linkSize="5" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonMarker" linkSize="5" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonProfile" linkSize="5" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonFit" linkSize="5" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonReticle" linkSize="5" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="32767" attributes="0"/>
<Component id="buttonGrabBackground" linkSize="6" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonSave" linkSize="6" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonPause" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonFit" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonMarker" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonSave" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonReticle" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonGrabBackground" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonProfile" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JToggleButton" name="buttonMarker">
<Properties>
<Property name="text" type="java.lang.String" value="Marker"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonMarkerActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonGrabBackground">
<Properties>
<Property name="text" type="java.lang.String" value="Grab Background"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonGrabBackgroundActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JToggleButton" name="buttonSave">
<Properties>
<Property name="text" type="java.lang.String" value="Save Snapshot"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonSaveActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JToggleButton" name="buttonFit">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Fit"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonFitActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JToggleButton" name="buttonReticle">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Reticle"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonReticleActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JToggleButton" name="buttonPause">
<Properties>
<Property name="text" type="java.lang.String" value="Pause"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonPauseActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JToggleButton" name="buttonProfile">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Profile"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonProfileActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel6">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="comboCameras" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonArgs" linkSize="3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonConfig" linkSize="3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonStop" linkSize="3" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="textState" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="comboCameras" linkSize="2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textState" linkSize="2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonArgs" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonConfig" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonStop" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JTextField" name="textState">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="0" type="rgb"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="State:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboCameras">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="14" style="1"/>
</Property>
<Property name="maximumRowCount" type="int" value="30"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboCamerasActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonConfig">
<Properties>
<Property name="text" type="java.lang.String" value="Config"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonConfigActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Camera:"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonArgs">
<Properties>
<Property name="text" type="java.lang.String" value="Setup"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonArgsActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonStop">
<Properties>
<Property name="text" type="java.lang.String" value="Stop"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonStopActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Component class="ch.psi.pshell.imaging.Renderer" name="renderer">
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel4">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="jPanel5" max="32767" attributes="0"/>
<Component id="panelScreen" alignment="0" max="32767" attributes="0"/>
<Component id="panelScreen1" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel3" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel2" alignment="0" max="32767" attributes="0"/>
<Component id="pauseSelection" alignment="1" pref="0" max="32767" attributes="0"/>
<Component id="panelScreen2" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel5" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelScreen" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelScreen1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelScreen2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="32767" attributes="0"/>
<Component id="pauseSelection" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel3">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Zoom"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="buttonZoomFit" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="buttonZoomNormal" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="buttonZoomStretch" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="buttonZoom025" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="buttonZoom05" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="buttonZoom2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="buttonZoomNormal" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="buttonZoom025" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="buttonZoomFit" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="buttonZoom05" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="buttonZoomStretch" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="buttonZoom2" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JRadioButton" name="buttonZoomFit">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup1"/>
</Property>
<Property name="text" type="java.lang.String" value="Fit"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonZoomFitActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JRadioButton" name="buttonZoomStretch">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup1"/>
</Property>
<Property name="text" type="java.lang.String" value="Stretch"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonZoomStretchActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JRadioButton" name="buttonZoomNormal">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup1"/>
</Property>
<Property name="text" type="java.lang.String" value="Normal"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonZoomNormalActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JRadioButton" name="buttonZoom025">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup1"/>
</Property>
<Property name="text" type="java.lang.String" value="1/4"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonZoom025ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JRadioButton" name="buttonZoom05">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup1"/>
</Property>
<Property name="text" type="java.lang.String" value="1/2"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonZoom05ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JRadioButton" name="buttonZoom2">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup1"/>
</Property>
<Property name="text" type="java.lang.String" value="2"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonZoom2ActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel2">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Colormap"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel3" linkSize="9" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" linkSize="9" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="buttonAutomatic" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="buttonFullRange" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="buttonManual" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="comboColormap" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="12" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="labelMax" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Component id="spinnerMax" linkSize="7" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="checkHistogram" alignment="1" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Component id="labelMin" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="btFixColormapRange" linkSize="7" alignment="1" max="-2" attributes="0"/>
<Component id="spinnerMin" linkSize="7" alignment="1" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="comboColormap" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="checkHistogram" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonAutomatic" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btFixColormapRange" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="labelMin" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="spinnerMin" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="buttonFullRange" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="buttonManual" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="labelMax" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="spinnerMax" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JCheckBox" name="checkHistogram">
<Properties>
<Property name="text" type="java.lang.String" value="Histogram"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="checkHistogramActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JComboBox" name="comboColormap">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="onChangeColormap"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Type:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Range:"/>
</Properties>
</Component>
<Component class="javax.swing.JRadioButton" name="buttonFullRange">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup3"/>
</Property>
<Property name="text" type="java.lang.String" value="Full"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="onChangeColormap"/>
</Events>
</Component>
<Component class="javax.swing.JRadioButton" name="buttonManual">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup3"/>
</Property>
<Property name="text" type="java.lang.String" value="Manual"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="onChangeColormap"/>
</Events>
</Component>
<Component class="javax.swing.JRadioButton" name="buttonAutomatic">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup3"/>
</Property>
<Property name="text" type="java.lang.String" value="Automatic"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="onChangeColormap"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="labelMin">
<Properties>
<Property name="text" type="java.lang.String" value="Min:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerMin">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" maximum="65535" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[77, 20]"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="onChangeColormapRange"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerMax">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="255" maximum="65535" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[77, 20]"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="onChangeColormapRange"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="labelMax">
<Properties>
<Property name="text" type="java.lang.String" value="Max:"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="btFixColormapRange">
<Properties>
<Property name="text" type="java.lang.String" value="Fix"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btFixColormapRangeActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel5">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Source"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonServer" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonDirect" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonServer" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonDirect" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JRadioButton" name="buttonServer">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup4"/>
</Property>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Server"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonServerActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JRadioButton" name="buttonDirect">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup4"/>
</Property>
<Property name="text" type="java.lang.String" value="Direct"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonDirectActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelScreen">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Screen"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="valueScreen" max="32767" attributes="0"/>
<Component id="comboScreen" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Component id="comboScreen" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="valueScreen" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="ch.psi.pshell.swing.DeviceValuePanel" name="valueScreen">
</Component>
<Component class="javax.swing.JComboBox" name="comboScreen">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboScreenActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelScreen1">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Filter"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="valueFilter" alignment="0" max="32767" attributes="0"/>
<Component id="comboFilter" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Component id="comboFilter" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="valueFilter" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="ch.psi.pshell.swing.DeviceValuePanel" name="valueFilter">
</Component>
<Component class="javax.swing.JComboBox" name="comboFilter">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboFilterActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Component class="ch.psi.pshell.swing.ValueSelection" name="pauseSelection">
<Properties>
<Property name="decimals" type="int" value="0"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="panelScreen2">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Image"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="checkGoodRegion" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="labelGrScale" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Component id="spinnerGrScale" linkSize="8" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="labelGrThreshold" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Component id="spinnerGrThreshold" linkSize="8" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="checkBackground" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="checkThreshold" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="spinnerThreshold" linkSize="8" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Component id="checkBackground" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="checkThreshold" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerThreshold" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="checkGoodRegion" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerGrScale" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelGrScale" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="spinnerGrThreshold" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelGrThreshold" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JCheckBox" name="checkThreshold">
<Properties>
<Property name="text" type="java.lang.String" value="Threshold"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="checkThresholdActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerThreshold">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" maximum="99999.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[77, 20]"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spinnerThresholdonChange"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="checkBackground">
<Properties>
<Property name="text" type="java.lang.String" value="Subtract Background"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="checkBackgroundActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="checkGoodRegion">
<Properties>
<Property name="text" type="java.lang.String" value="Good Region"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="checkGoodRegionActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerGrScale">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="3.0" maximum="100.0" minimum="0.01" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[77, 20]"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spinnerGrThresholdonChange"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerGrThreshold">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.5" maximum="1.0" minimum="0.04" numberType="java.lang.Double" stepSize="0.1" type="number"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[77, 20]"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spinnerGrThresholdonChange"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="labelGrThreshold">
<Properties>
<Property name="text" type="java.lang.String" value="Threshold:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="labelGrScale">
<Properties>
<Property name="text" type="java.lang.String" value="Scale:"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>
+3223
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-1
View File
@@ -1177,7 +1177,6 @@
<SubComponents>
<Container class="javax.swing.JToolBar" name="toolBar">
<Properties>
<Property name="floatable" type="boolean" value="false"/>
<Property name="rollover" type="boolean" value="true"/>
</Properties>
+14 -9
View File
@@ -1320,7 +1320,7 @@ public class ScreenPanel9 extends Panel {
updatePipelineControls();
if (renderer.getDevice() == null) {
//renderer.setZoom(1.0);
//renderer.setMode(RendererMode.Zoom);
//renderer.setMode(RenderegetDisplayNamerMode.Zoom);
errorOverlay = new Text(renderer.getPenErrorText(), ex.toString(), new Font("Verdana", Font.PLAIN, 12), new Point(20, 20));
errorOverlay.setFixed(true);
errorOverlay.setAnchor(Overlay.ANCHOR_VIEWPORT_TOP_LEFT);
@@ -2832,13 +2832,18 @@ public class ScreenPanel9 extends Panel {
dm.setItem(pathTimestampStr, Chrono.getTimeStr(streamValue.getTimestamp(), "YYYY-MM-dd HH:mm:ss.SSS"), index);
for (String id : streamValue.getIdentifiers()) {
Object val = streamValue.getValue(id);
if (id.equals("image")) {
} else if (id.equals("processing_parameters")) {
} else if (val.getClass().isArray()) {
dm.setItem(pathRoot + id, val, index);
} else {
dm.setItem(pathRoot + id, val, index);
try{
Object val = streamValue.getValue(id);
if (id.equals("image")) {
} else if (id.equals("processing_parameters")) {
} else if (val.getClass().isArray()) {
dm.setItem(pathRoot + id, val, index);
} else {
dm.setItem(pathRoot + id, val, index);
}
} catch (Exception ex){
logger.log(Level.WARNING, null, ex);
System.out.println("Error saving " + id + " index " + index + ": " + ex.getMessage());
}
}
}
@@ -2998,7 +3003,7 @@ public class ScreenPanel9 extends Panel {
Frame frame = getCurrentFrame();
int[] sel_rows = (dataTable == null) ? null : dataTable.getSelectedRows();
int[] sel_cols = (dataTable == null) ? null : dataTable.getSelectedColumns();
List<String> ids = (value == null) ? new ArrayList<>() : new ArrayList(value.getIdentifiers());
List<String> ids = (value == null) ? new ArrayList<>() : value.getIdentifiers();//### TODO
if (ids.size() + 4 != dataTableModel.getRowCount()) {
dataTableModel.setNumRows(0);
try {
+109
View File
@@ -0,0 +1,109 @@
import ij.io.OpenDialog;
import ij.io.SaveDialog;
import java.util.ArrayList;
import java.io.IOException;
import java.io.File;
import jmatio.types.*;
import jmatio.io.*;
import ij.gui.GenericDialog;
import ij.IJ;
import ij.Prefs;
public class ShiftsIO {
public ShiftsIO () {}
public double[][] load(String filename, String varname) {
if (filename==null){
String analysis_dir = Prefs.get("peem.analysis_dir", "");
OpenDialog od = new OpenDialog("Open_shifts .mat file:", analysis_dir, "shifts.mat");
String dir = od.getDirectory();
if (null == dir) return null; // dialog was canceled
if (!dir.endsWith(File.separator)) dir += File.separator;
filename = dir + od.getFileName();
Prefs.set("peem.analysis_dir", dir);
}
return low_load(filename, varname);
}
private double[][] low_load(String filename, String varname) {
MatFileReader mfr = null;
try {
mfr = new MatFileReader(filename);
} catch (IOException e) {
System.err.println("Caught IOException: "
+ e.getMessage());
}
if (mfr != null) {
MLDouble array = (MLDouble)mfr.getMLArray(varname);
if (array != null){
return array.getArray();
} else {
return null;
}
} else {
return null;
}
}
public void save(String filename, double[][] shifts, String varname) {
boolean update = false;
if (filename==null){
String analysis_dir = Prefs.get("peem.analysis_dir", "");
SaveDialog sd = new SaveDialog("Save_shifts .mat file:", analysis_dir, "shifts.mat", ".mat");
String dir = sd.getDirectory();
String fname = sd.getFileName();
if (null == fname) return; // user canceled dialog
if (!dir.endsWith(File.separator)) dir += File.separator;
Prefs.set("peem.analysis_dir", dir);
if ((new File(dir + fname)).exists()) { // if file exist, overwrite or update shifts ?
GenericDialog gd = new GenericDialog("Update");
String[] options = {"overwrite","update"};
gd.addChoice("Mode of operation with existing file. You want to: ", options, options[0]);
gd.showDialog();
if (gd.wasCanceled()) return;
if (gd.getNextChoiceIndex() == 1) update = true;
}
filename = dir + fname;
}
double[][] final_shifts;
if (update) {
double[][] prev_shifts = low_load(filename, "directshifts");
if (prev_shifts == null) {
IJ.error("Can't read the direct shifts in this file");
return;
}
if (prev_shifts.length == shifts.length) {
for (int j = 0; j < prev_shifts.length; j++) {
prev_shifts[j][3] += shifts[j][3];
prev_shifts[j][4] += shifts[j][4];
}
} else if (shifts.length == 2) {// 2 shifts, like between two slices of different
// sequences
for (int j = 0; j < prev_shifts.length; j++) {
prev_shifts[j][3] += shifts[1][3];
prev_shifts[j][4] += shifts[1][4];
}
} else {
IJ.error("Old and new shifts have incompatible length !");
return;
}
final_shifts = prev_shifts;
} else {
final_shifts = shifts;
}
MLDouble mlDouble = new MLDouble(varname, final_shifts);
ArrayList<MLArray> list = new ArrayList<MLArray>();
list.add(mlDouble);
try {
new MatFileWriter(filename, list);
} catch (IOException e) {
System.err.println("Caught IOException: "
+ e.getMessage());
}
}
}
+1 -1
View File
@@ -19,7 +19,7 @@ public class SpinnerLayoutTest {
super.setLayout(new SpinnerLayout());
}
};
spinner.set
JPanel p = new JPanel(new BorderLayout(5,5));
p.add(new JSpinner(m), BorderLayout.NORTH);
p.add(spinner, BorderLayout.SOUTH);
+6
View File
@@ -0,0 +1,6 @@
public class Standard{
public void run() {
System.out.println("run");
}
}
+28
View File
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="449" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="137" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Form>
+195
View File
@@ -0,0 +1,195 @@
import ch.psi.pshell.core.JsonSerializer;
import ch.psi.pshell.ui.PanelProcessor;
import ch.psi.pshell.ui.Task;
import ch.psi.utils.State;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
/**
* Template for a processor plugin backed by json files.
*/
public class TstProc extends PanelProcessor {
public static final String TYPE = "TstProc";
public static final String FILE_EXTENSION = "json";
public static final String HOME_PATH = "{home}/" + TYPE;
File currentFile;
public TstProc() {
initComponents();
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
}
@Override
public void onStateChange(State state, State former) {
}
@Override
public void onExecutedFile(String fileName, Object result) {
}
@Override
public void onTaskFinished(Task task) {
}
@Override
protected void onTimer() {
}
@Override
protected void onLoaded() {
}
@Override
protected void onUnloaded() {
}
//Invoked by 'update()' to update components in the event thread
@Override
protected void doUpdate() {
}
//Processor Configuration
@Override
public String getType() {
return TYPE;
}
@Override
public String getDescription() {
return getType() + " definition file (*." + FILE_EXTENSION + ")";
}
@Override
public String getHomePath() {
return HOME_PATH;
}
@Override
public String[] getExtensions() {
return new String[]{FILE_EXTENSION};
}
@Override
public String getFileName() {
return (currentFile == null) ? null : currentFile.toString();
}
@Override
public boolean createFilePanel() {
return true;
}
@Override
public boolean createMenuNew() {
return true;
}
@Override
public boolean canStep() {
return false;
}
@Override
public boolean canPause() {
return false;
}
@Override
public boolean isTabNameUpdated() {
return false;
}
@Override
public void saveAs(String fileName) throws IOException {
currentFile = new File(fileName);
Map config = getConfig();
String json = JsonSerializer.encode(config, true);
Files.write(currentFile.toPath(), json.getBytes());
}
@Override
public void open(String fileName) throws IOException {
clear();
if (fileName != null) {
Path path = Paths.get(fileName);
String json = new String(Files.readAllBytes(path));
Map config = (Map) JsonSerializer.decode(json, Map.class);
currentFile = path.toFile();
setConfig(config);
}
}
//Component update
public void clear() throws IOException {
currentFile=null;
//TODO
}
Map getConfig() throws IOException {
//TODO
return new HashMap();
}
void setConfig(Map config) throws IOException {
//TODO
}
//Workbench actions
@Override
public void plotDataFile(File file) throws Exception {
throw new Exception("Not implemented");
}
@Override
public void step() {
}
@Override
public void pause() {
}
@Override
public void abort() throws InterruptedException {
super.abort();
}
@Override
public void execute() throws Exception {
this.evalAsync("tscan(sin,10,0.2)");
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 449, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 137, Short.MAX_VALUE)
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}
BIN
View File
Binary file not shown.
+41
View File
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="plotPanel" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="plotPanel" pref="232" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="170" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="plotPanel">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
</Container>
</SubComponents>
</Form>
+91
View File
@@ -0,0 +1,91 @@
import ch.psi.pshell.ui.App;
import ch.psi.pshell.ui.Panel;
import ch.psi.pshell.ui.StripChart;
import ch.psi.utils.State;
import ch.psi.utils.Sys;
import java.io.File;
/**
*
*/
public class sc extends Panel {
StripChart stripChart;
public sc() {
initComponents();
/*
stripChart = new StripChart(this.getTopLevel(),false, null);
this.add(stripChart.getPlotPanel());
try {
stripChart.open(new File("test.scd"));
stripChart.start();
} catch (Exception ex) { showException(ex);
}
*/
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
plotPanel.removeAll();
plotPanel.add(StripChart.getPlotPanel(new File("test.scd")));
}
@Override
public void onStateChange(State state, State former) {
}
@Override
public void onExecutedFile(String fileName, Object result) {
}
@Override
protected void onTimer() {
}
@Override
protected void onLoaded() {
}
@Override
protected void onUnloaded() {
}
//Invoked by 'update()' to update components in the event thread
@Override
protected void doUpdate() {
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
plotPanel = new javax.swing.JPanel();
plotPanel.setLayout(new java.awt.BorderLayout());
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(plotPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(plotPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE)
.addGap(170, 170, 170))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel plotPanel;
// End of variables declaration//GEN-END:variables
}