This commit is contained in:
+171
-149
@@ -62,6 +62,7 @@ import ch.psi.utils.swing.SwingUtils.OptionType;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
|
import java.awt.FontMetrics;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
@@ -147,7 +148,7 @@ public class ScreenPanel3 extends Panel {
|
|||||||
String instanceName;
|
String instanceName;
|
||||||
Overlay titleOv = null;
|
Overlay titleOv = null;
|
||||||
int integration = 0;
|
int integration = 0;
|
||||||
|
|
||||||
String pipelineSuffix = "_sp";
|
String pipelineSuffix = "_sp";
|
||||||
|
|
||||||
Double getServerDouble(String name) {
|
Double getServerDouble(String name) {
|
||||||
@@ -183,7 +184,7 @@ public class ScreenPanel3 extends Panel {
|
|||||||
x_center_of_mass = getServerDouble("x_center_of_mass", cache);
|
x_center_of_mass = getServerDouble("x_center_of_mass", cache);
|
||||||
y_center_of_mass = getServerDouble("y_center_of_mass", cache);
|
y_center_of_mass = getServerDouble("y_center_of_mass", cache);
|
||||||
x_rms = getServerDouble("x_rms", cache);
|
x_rms = getServerDouble("x_rms", cache);
|
||||||
y_rms = getServerDouble("y_rms", cache);
|
y_rms = getServerDouble("y_rms", cache);
|
||||||
if (goodRegion) {
|
if (goodRegion) {
|
||||||
double[] gX2 = new double[x_profile.length];
|
double[] gX2 = new double[x_profile.length];
|
||||||
Arrays.fill(gX2, Double.NaN);
|
Arrays.fill(gX2, Double.NaN);
|
||||||
@@ -191,7 +192,7 @@ public class ScreenPanel3 extends Panel {
|
|||||||
double x = getServerDoubleArray("gr_x_axis", cache)[0];
|
double x = getServerDoubleArray("gr_x_axis", cache)[0];
|
||||||
gr_size_x = x_fit_gauss_function.length;
|
gr_size_x = x_fit_gauss_function.length;
|
||||||
gr_pos_x = (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageX(x) : x);
|
gr_pos_x = (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageX(x) : x);
|
||||||
System.arraycopy(x_fit_gauss_function, 0, gX2, gr_pos_x , gr_size_x);
|
System.arraycopy(x_fit_gauss_function, 0, gX2, gr_pos_x, gr_size_x);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
x_fit_gauss_function = gX2;
|
x_fit_gauss_function = gX2;
|
||||||
@@ -200,7 +201,7 @@ public class ScreenPanel3 extends Panel {
|
|||||||
try {
|
try {
|
||||||
double y = getServerDoubleArray("gr_y_axis", cache)[0];
|
double y = getServerDoubleArray("gr_y_axis", cache)[0];
|
||||||
gr_size_y = y_fit_gauss_function.length;
|
gr_size_y = y_fit_gauss_function.length;
|
||||||
gr_pos_y = (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageY(y) : y);
|
gr_pos_y = (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageY(y) : y);
|
||||||
System.arraycopy(y_fit_gauss_function, 0, gY2, gr_pos_y, y_fit_gauss_function.length);
|
System.arraycopy(y_fit_gauss_function, 0, gY2, gr_pos_y, y_fit_gauss_function.length);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
@@ -251,7 +252,7 @@ public class ScreenPanel3 extends Panel {
|
|||||||
final ArrayList<Frame> imageBuffer = new ArrayList();
|
final ArrayList<Frame> imageBuffer = new ArrayList();
|
||||||
Frame currentFrame;
|
Frame currentFrame;
|
||||||
int imageBufferLenght = 1;
|
int imageBufferLenght = 1;
|
||||||
Text imageBufferOverlay;
|
Text imagePauseOverlay;
|
||||||
|
|
||||||
public ScreenPanel3() {
|
public ScreenPanel3() {
|
||||||
try {
|
try {
|
||||||
@@ -314,19 +315,19 @@ public class ScreenPanel3 extends Panel {
|
|||||||
}
|
}
|
||||||
if (App.hasArgument("suffix")) {
|
if (App.hasArgument("suffix")) {
|
||||||
pipelineSuffix = App.getArgumentValue("suffix");
|
pipelineSuffix = App.getArgumentValue("suffix");
|
||||||
}
|
}
|
||||||
if (App.hasArgument("integration")) {
|
if (App.hasArgument("integration")) {
|
||||||
try {
|
try {
|
||||||
integration = Integer.valueOf(App.getArgumentValue("integration"));
|
integration = Integer.valueOf(App.getArgumentValue("integration"));
|
||||||
if (integration !=0){
|
if (integration != 0) {
|
||||||
buttonFit.setSelected(false);
|
buttonFit.setSelected(false);
|
||||||
buttonProfile.setSelected(false);
|
buttonProfile.setSelected(false);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.setProfileNormalized(true);
|
renderer.setProfileNormalized(true);
|
||||||
renderer.setShowProfileLimits(false);
|
renderer.setShowProfileLimits(false);
|
||||||
|
|
||||||
@@ -382,20 +383,18 @@ public class ScreenPanel3 extends Panel {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
JMenuItem menuSetImageBufferSize = new JMenuItem("Set Stack Size...");
|
||||||
|
|
||||||
JMenuItem menuSetImageBufferSize = new JMenuItem("Set Stack Size...");
|
|
||||||
menuSetImageBufferSize.addActionListener((ActionEvent e) -> {
|
menuSetImageBufferSize.addActionListener((ActionEvent e) -> {
|
||||||
try {
|
try {
|
||||||
String ret = SwingUtils.getString(getTopLevel(), "Enter size of image buffer: ", String.valueOf(imageBufferLenght));
|
String ret = SwingUtils.getString(getTopLevel(), "Enter size of image buffer: ", String.valueOf(imageBufferLenght));
|
||||||
if (ret!=null){
|
if (ret != null) {
|
||||||
this.setImageBufferSize(Integer.valueOf(ret));
|
this.setImageBufferSize(Integer.valueOf(ret));
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
showException(ex);
|
showException(ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
JMenuItem menuSaveStack = new JMenuItem("Save Stack");
|
JMenuItem menuSaveStack = new JMenuItem("Save Stack");
|
||||||
menuSaveStack.addActionListener((ActionEvent e) -> {
|
menuSaveStack.addActionListener((ActionEvent e) -> {
|
||||||
try {
|
try {
|
||||||
@@ -403,8 +402,7 @@ public class ScreenPanel3 extends Panel {
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
showException(ex);
|
showException(ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
JMenuItem menuSetROI = new JMenuItem("Set ROI...");
|
JMenuItem menuSetROI = new JMenuItem("Set ROI...");
|
||||||
menuSetROI.addActionListener((ActionEvent e) -> {
|
menuSetROI.addActionListener((ActionEvent e) -> {
|
||||||
@@ -496,9 +494,6 @@ public class ScreenPanel3 extends Panel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
imageBufferOverlay = new Text(renderer.getPenErrorText(), "", new Font("Verdana", Font.PLAIN, 12), new Point(-100, 42));
|
|
||||||
imageBufferOverlay.setFixed(true);
|
|
||||||
imageBufferOverlay.setAnchor(Overlay.ANCHOR_VIEWPORT_OR_IMAGE_TOP_RIGHT);
|
|
||||||
if (MainFrame.isDark()) {
|
if (MainFrame.isDark()) {
|
||||||
textState.setDisabledTextColor(textState.getForeground());
|
textState.setDisabledTextColor(textState.getForeground());
|
||||||
}
|
}
|
||||||
@@ -786,7 +781,7 @@ public class ScreenPanel3 extends Panel {
|
|||||||
}
|
}
|
||||||
if (renderer.isPaused()) {
|
if (renderer.isPaused()) {
|
||||||
renderer.resume();
|
renderer.resume();
|
||||||
renderer.removeOverlay(imageBufferOverlay);
|
removePauseOverlay();
|
||||||
pauseSelection.setVisible(false);
|
pauseSelection.setVisible(false);
|
||||||
panelCameraSelection.setVisible(true);
|
panelCameraSelection.setVisible(true);
|
||||||
}
|
}
|
||||||
@@ -820,7 +815,7 @@ public class ScreenPanel3 extends Panel {
|
|||||||
if (server != null) {
|
if (server != null) {
|
||||||
//server.start(cameraName, false);
|
//server.start(cameraName, false);
|
||||||
String pipelineName = cameraName + pipelineSuffix;
|
String pipelineName = cameraName + pipelineSuffix;
|
||||||
instanceName = cameraName + pipelineSuffix +"1";
|
instanceName = cameraName + pipelineSuffix + "1";
|
||||||
if (!server.getPipelines().contains(pipelineName)) {
|
if (!server.getPipelines().contains(pipelineName)) {
|
||||||
System.out.println("Creating pipeline: " + pipelineName);
|
System.out.println("Creating pipeline: " + pipelineName);
|
||||||
HashMap<String, Object> config = new HashMap<>();
|
HashMap<String, Object> config = new HashMap<>();
|
||||||
@@ -845,7 +840,7 @@ public class ScreenPanel3 extends Panel {
|
|||||||
}
|
}
|
||||||
updateButtons();
|
updateButtons();
|
||||||
camera.getConfig().save();
|
camera.getConfig().save();
|
||||||
if (Math.abs(integration)>1) {
|
if (Math.abs(integration) > 1) {
|
||||||
renderer.setDevice(new ImageIntegrator(integration));
|
renderer.setDevice(new ImageIntegrator(integration));
|
||||||
} else {
|
} else {
|
||||||
renderer.setDevice(camera);
|
renderer.setDevice(camera);
|
||||||
@@ -883,6 +878,10 @@ public class ScreenPanel3 extends Panel {
|
|||||||
imageBuffer.remove(0);
|
imageBuffer.remove(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Update data
|
||||||
|
if (!renderer.isPaused()) {
|
||||||
|
updateStreamData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
manageFit(bi, data);
|
manageFit(bi, data);
|
||||||
@@ -970,58 +969,60 @@ public class ScreenPanel3 extends Panel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ImageIntegrator extends ColormapSource {
|
class ImageIntegrator extends ColormapSource {
|
||||||
|
|
||||||
ImageIntegrator(int num) {
|
ImageIntegrator(int num) {
|
||||||
super("Image Averager", camera.getConfig());
|
super("Image Averager", camera.getConfig());
|
||||||
boolean continuous = (num<0);
|
boolean continuous = (num < 0);
|
||||||
final int numImages = Math.abs(num);
|
final int numImages = Math.abs(num);
|
||||||
|
|
||||||
camera.addListener(new ImageListener() {
|
camera.addListener(new ImageListener() {
|
||||||
final ArrayList<Data> buffer = new ArrayList();
|
final ArrayList<Data> buffer = new ArrayList();
|
||||||
Data integration = null;
|
Data integration = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onImage(Object o, BufferedImage bi, Data data) {
|
public void onImage(Object o, BufferedImage bi, Data data) {
|
||||||
if (continuous){
|
if (continuous) {
|
||||||
buffer.add(data);
|
buffer.add(data);
|
||||||
if (buffer.size()>=numImages){
|
if (buffer.size() >= numImages) {
|
||||||
for (Data d: buffer){
|
for (Data d : buffer) {
|
||||||
process(d);
|
process(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
buffer.add(null); //Just to count
|
buffer.add(null); //Just to count
|
||||||
process(data);
|
process(data);
|
||||||
}
|
}
|
||||||
if (buffer.size()>=numImages){
|
if (buffer.size() >= numImages) {
|
||||||
if (continuous){
|
if (continuous) {
|
||||||
buffer.remove(0);
|
buffer.remove(0);
|
||||||
} else {
|
} else {
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
}
|
}
|
||||||
if (integration!=null){
|
if (integration != null) {
|
||||||
//integration.div(numImages);
|
//integration.div(numImages);
|
||||||
ImageIntegrator.this.pushData(integration);
|
ImageIntegrator.this.pushData(integration);
|
||||||
}
|
}
|
||||||
integration = null;
|
integration = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void process(Data data){
|
|
||||||
if (integration == null){
|
void process(Data data) {
|
||||||
|
if (integration == null) {
|
||||||
integration = new Data(data);
|
integration = new Data(data);
|
||||||
} else {
|
} else {
|
||||||
integration.sum(data);
|
integration.sum(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Object origin, Exception ex) {
|
public void onError(Object origin, Exception ex) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
volatile Dimension imageSize;
|
volatile Dimension imageSize;
|
||||||
|
|
||||||
@@ -1226,9 +1227,6 @@ public class ScreenPanel3 extends Panel {
|
|||||||
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!renderer.isPaused() && (dataTableDialog != null) && (dataTableDialog.isShowing())) {
|
|
||||||
updateStreamData();
|
|
||||||
}
|
|
||||||
updateZoom();
|
updateZoom();
|
||||||
updateColormap();
|
updateColormap();
|
||||||
updateButtons();
|
updateButtons();
|
||||||
@@ -1283,7 +1281,7 @@ public class ScreenPanel3 extends Panel {
|
|||||||
//Double xCom=null, yCom=null;
|
//Double xCom=null, yCom=null;
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
int height = data.getHeight();
|
int height = data.getHeight();
|
||||||
int width = data.getWidth();
|
int width = data.getWidth();
|
||||||
int profileSize = renderer.getProfileSize();
|
int profileSize = renderer.getProfileSize();
|
||||||
if ((useServerStats) && (server != null)) {
|
if ((useServerStats) && (server != null)) {
|
||||||
try {
|
try {
|
||||||
@@ -1318,33 +1316,33 @@ public class ScreenPanel3 extends Panel {
|
|||||||
double maxProfile = Collections.max(l);
|
double maxProfile = Collections.max(l);
|
||||||
double rangeProfile = maxProfile - minProfile;
|
double rangeProfile = maxProfile - minProfile;
|
||||||
double minGauss = minProfile;
|
double minGauss = minProfile;
|
||||||
double rangeGauss = rangeProfile;
|
double rangeGauss = rangeProfile;
|
||||||
//If not good region, range of profile and fit are similar so save this calcultion
|
//If not good region, range of profile and fit are similar so save this calcultion
|
||||||
if (goodRegion && id.gr_size_x>0){
|
if (goodRegion && id.gr_size_x > 0) {
|
||||||
l = Arrays.asList( (Double[]) Convert.toWrapperArray(Arrays.copyOfRange(gX, id.gr_pos_x, id.gr_pos_x + id.gr_size_x)));
|
l = Arrays.asList((Double[]) Convert.toWrapperArray(Arrays.copyOfRange(gX, id.gr_pos_x, id.gr_pos_x + id.gr_size_x)));
|
||||||
minGauss = Collections.min(l);
|
minGauss = Collections.min(l);
|
||||||
rangeGauss = Collections.max(l) - minGauss;
|
rangeGauss = Collections.max(l) - minGauss;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < xp.length; i++) {
|
for (int i = 0; i < xp.length; i++) {
|
||||||
if (gX != null) {
|
if (gX != null) {
|
||||||
yg[i] = (int) (height - 1 - (((gX[i] - minGauss) / rangeGauss) * profileSize));
|
yg[i] = (int) (height - 1 - (((gX[i] - minGauss) / rangeGauss) * profileSize));
|
||||||
}
|
}
|
||||||
yp[i] = (int) (height - 1 - (((pX[i] - minProfile) / rangeProfile) * profileSize));
|
yp[i] = (int) (height - 1 - (((pX[i] - minProfile) / rangeProfile) * profileSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (goodRegion && id.gr_size_x>0){
|
if (goodRegion && id.gr_size_x > 0) {
|
||||||
xg = Arrays.copyOfRange(xg, id.gr_pos_x, id.gr_pos_x + id.gr_size_x);
|
xg = Arrays.copyOfRange(xg, id.gr_pos_x, id.gr_pos_x + id.gr_size_x);
|
||||||
yg = Arrays.copyOfRange(yg, id.gr_pos_x, id.gr_pos_x + id.gr_size_x);
|
yg = Arrays.copyOfRange(yg, id.gr_pos_x, id.gr_pos_x + id.gr_size_x);
|
||||||
}
|
}
|
||||||
|
|
||||||
vgaussian = new Overlays.Polyline(penFit, xg, yg);
|
vgaussian = new Overlays.Polyline(penFit, xg, yg);
|
||||||
vprofile = new Overlays.Polyline(renderer.getPenProfile(), xp, yp);
|
vprofile = new Overlays.Polyline(renderer.getPenProfile(), xp, yp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pY != null) {
|
if (pY != null) {
|
||||||
int[] xp = new int[pY.length];
|
int[] xp = new int[pY.length];
|
||||||
int[] xg = new int[pY.length];
|
int[] xg = new int[pY.length];
|
||||||
int[] yp = Arr.indexesInt(pY.length);
|
int[] yp = Arr.indexesInt(pY.length);
|
||||||
int[] yg = yp;
|
int[] yg = yp;
|
||||||
|
|
||||||
@@ -1353,12 +1351,12 @@ public class ScreenPanel3 extends Panel {
|
|||||||
double maxProfile = Collections.max(l);
|
double maxProfile = Collections.max(l);
|
||||||
double rangeProfile = maxProfile - minProfile;
|
double rangeProfile = maxProfile - minProfile;
|
||||||
double minGauss = minProfile;
|
double minGauss = minProfile;
|
||||||
double rangeGauss = rangeProfile;
|
double rangeGauss = rangeProfile;
|
||||||
//If not good region, range of profile and fit are similar so save this calcultion
|
//If not good region, range of profile and fit are similar so save this calcultion
|
||||||
if (goodRegion && id.gr_size_y>0){
|
if (goodRegion && id.gr_size_y > 0) {
|
||||||
l = Arrays.asList( (Double[]) Convert.toWrapperArray(Arrays.copyOfRange(gY, id.gr_pos_y, id.gr_pos_y + id.gr_size_y)));
|
l = Arrays.asList((Double[]) Convert.toWrapperArray(Arrays.copyOfRange(gY, id.gr_pos_y, id.gr_pos_y + id.gr_size_y)));
|
||||||
minGauss = Collections.min(l);
|
minGauss = Collections.min(l);
|
||||||
rangeGauss = Collections.max(l) - minGauss;
|
rangeGauss = Collections.max(l) - minGauss;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < xp.length; i++) {
|
for (int i = 0; i < xp.length; i++) {
|
||||||
@@ -1368,7 +1366,7 @@ public class ScreenPanel3 extends Panel {
|
|||||||
xp[i] = (int) (((pY[i] - minProfile) / rangeProfile) * profileSize);
|
xp[i] = (int) (((pY[i] - minProfile) / rangeProfile) * profileSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (goodRegion && id.gr_size_x>0){
|
if (goodRegion && id.gr_size_x > 0) {
|
||||||
xg = Arrays.copyOfRange(xg, id.gr_pos_y, id.gr_pos_y + id.gr_size_y);
|
xg = Arrays.copyOfRange(xg, id.gr_pos_y, id.gr_pos_y + id.gr_size_y);
|
||||||
yg = Arrays.copyOfRange(yg, id.gr_pos_y, id.gr_pos_y + id.gr_size_y);
|
yg = Arrays.copyOfRange(yg, id.gr_pos_y, id.gr_pos_y + id.gr_size_y);
|
||||||
}
|
}
|
||||||
@@ -1876,16 +1874,31 @@ public class ScreenPanel3 extends Panel {
|
|||||||
synchronized (imageBuffer) {
|
synchronized (imageBuffer) {
|
||||||
if (index < imageBuffer.size()) {
|
if (index < imageBuffer.size()) {
|
||||||
Data data = imageBuffer.get(index).data;
|
Data data = imageBuffer.get(index).data;
|
||||||
|
long pid = imageBuffer.get(index).cache.getPulseId();
|
||||||
BufferedImage image = camera.generateImage(data);
|
BufferedImage image = camera.generateImage(data);
|
||||||
renderer.setImage(renderer.getOrigin(), image, data);
|
renderer.setImage(renderer.getOrigin(), image, data);
|
||||||
imageBufferOverlay.update(Chrono.getTimeStr(data.getTimestamp(), "HH:mm:ss.SSS"));
|
|
||||||
|
String text = "PID: " + pid;
|
||||||
|
if (imagePauseOverlay == null) {
|
||||||
|
Font font = new Font("Verdana", Font.PLAIN, 12);
|
||||||
|
Dimension d = SwingUtils.getTextSize(text, renderer.getFontMetrics(font));
|
||||||
|
imagePauseOverlay = new Text(renderer.getPenErrorText(), "", font, new Point(-20 - d.width, 42));
|
||||||
|
imagePauseOverlay.setFixed(true);
|
||||||
|
imagePauseOverlay.setAnchor(Overlay.ANCHOR_VIEWPORT_OR_IMAGE_TOP_RIGHT);
|
||||||
|
renderer.addOverlay(imagePauseOverlay);
|
||||||
|
}
|
||||||
|
//imagePauseOverlay.update(Chrono.getTimeStr(data.getTimestamp(), "HH:mm:ss.SSS"));
|
||||||
|
imagePauseOverlay.update(text);
|
||||||
manageFit(image, data);
|
manageFit(image, data);
|
||||||
manageUserOverlays(image, data);
|
manageUserOverlays(image, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((dataTableDialog != null) && (dataTableDialog.isShowing())) {
|
updateStreamData();
|
||||||
updateStreamData();
|
}
|
||||||
}
|
|
||||||
|
void removePauseOverlay() {
|
||||||
|
renderer.removeOverlay(imagePauseOverlay);
|
||||||
|
imagePauseOverlay = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveSnapshot() throws Exception {
|
void saveSnapshot() throws Exception {
|
||||||
@@ -2145,16 +2158,17 @@ public class ScreenPanel3 extends Panel {
|
|||||||
int row = dataTable.getSelectedRow();
|
int row = dataTable.getSelectedRow();
|
||||||
int col = dataTable.getSelectedColumn();
|
int col = dataTable.getSelectedColumn();
|
||||||
dataTable.setToolTipText(null);
|
dataTable.setToolTipText(null);
|
||||||
if (row>1){
|
if (row > 1) {
|
||||||
String id = String.valueOf(dataTable.getModel().getValueAt(row, 0));
|
String id = String.valueOf(dataTable.getModel().getValueAt(row, 0));
|
||||||
String locator = String.valueOf(dataTable.getModel().getValueAt(0, 1));
|
String locator = String.valueOf(dataTable.getModel().getValueAt(0, 1));
|
||||||
String channelId = locator + " " + id;
|
String channelId = locator + " " + id;
|
||||||
dataTable.setToolTipText(channelId);
|
dataTable.setToolTipText(channelId);
|
||||||
if ((e.getClickCount() == 2) && (!e.isPopupTrigger())) {
|
if ((e.getClickCount() == 2) && (!e.isPopupTrigger())) {
|
||||||
if (col == 0){
|
if (col == 0) {
|
||||||
SwingUtils.showMessage(dataTableDialog, "Channel Identifier", "Copied to clipboard: " + channelId);
|
SwingUtils.showMessage(dataTableDialog, "Channel Identifier", "Copied to clipboard: " + channelId);
|
||||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||||
clipboard.setContents(new StringSelection(channelId), (Clipboard clipboard1, Transferable contents) -> {});
|
clipboard.setContents(new StringSelection(channelId), (Clipboard clipboard1, Transferable contents) -> {
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
Object obj = getCurrentFrame().cache.getValue(id);
|
Object obj = getCurrentFrame().cache.getValue(id);
|
||||||
if (id.equals("image")) {
|
if (id.equals("image")) {
|
||||||
@@ -2163,107 +2177,112 @@ public class ScreenPanel3 extends Panel {
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (String key : pars.keySet()) {
|
for (String key : pars.keySet()) {
|
||||||
sb.append(key).append(" = ").append(Str.toString(pars.get(key), 10)).append("\n");
|
sb.append(key).append(" = ").append(Str.toString(pars.get(key), 10)).append("\n");
|
||||||
}
|
}
|
||||||
SwingUtils.showMessage(dataTableDialog, "Processing Parameters", sb.toString());
|
SwingUtils.showMessage(dataTableDialog, "Processing Parameters", sb.toString());
|
||||||
} else if ((obj!=null) && (obj.getClass().isArray() || (obj instanceof Number))) {
|
} else if ((obj != null) && (obj.getClass().isArray() || (obj instanceof Number))) {
|
||||||
DeviceValueChart chart = new DeviceValueChart();
|
DeviceValueChart chart = new DeviceValueChart();
|
||||||
Device dev = null;
|
Device dev = null;
|
||||||
if (obj.getClass().isArray()){
|
if (obj.getClass().isArray()) {
|
||||||
dev = new ReadableRegisterArray(new ReadableArray() {
|
dev = new ReadableRegisterArray(new ReadableArray() {
|
||||||
@Override
|
@Override
|
||||||
public Object read() throws IOException, InterruptedException {
|
public Object read() throws IOException, InterruptedException {
|
||||||
return Convert.toDouble(getCurrentFrame().cache.getValue(id));
|
return Convert.toDouble(getCurrentFrame().cache.getValue(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return Array.getLength(getCurrentFrame().cache.getValue(id));
|
return Array.getLength(getCurrentFrame().cache.getValue(id));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
dev = new ReadableRegisterNumber(new ReadableNumber() {
|
dev = new ReadableRegisterNumber(new ReadableNumber() {
|
||||||
@Override
|
@Override
|
||||||
public Object read() throws IOException, InterruptedException {
|
public Object read() throws IOException, InterruptedException {
|
||||||
return Convert.toDouble(getCurrentFrame().cache.getValue(id));
|
return Convert.toDouble(getCurrentFrame().cache.getValue(id));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
dev.setPolling(1000);
|
dev.setPolling(1000);
|
||||||
chart.setDevice(dev);
|
chart.setDevice(dev);
|
||||||
JDialog dlg = SwingUtils.showDialog(dataTableDialog, cameraName +" " + id, null, chart);
|
JDialog dlg = SwingUtils.showDialog(dataTableDialog, cameraName + " " + id, null, chart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
showException(ex);
|
showException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
SwingUtils.centerComponent(getTopLevel(), dataTableDialog);
|
SwingUtils.centerComponent(getTopLevel(), dataTableDialog);
|
||||||
|
updateStreamData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
volatile boolean updatingStreamData = false;
|
||||||
|
|
||||||
void updateStreamData() {
|
void updateStreamData() {
|
||||||
if ((dataTableModel != null) && (server != null)) {
|
if ((dataTableDialog == null) || !dataTableDialog.isShowing() || updatingStreamData) {
|
||||||
StreamValue value = server.getValue();
|
return;
|
||||||
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());
|
|
||||||
if (ids.size() + 2 != dataTableModel.getRowCount()) {
|
|
||||||
dataTableModel.setNumRows(0);
|
|
||||||
try {
|
|
||||||
dataTableModel.addRow(new Object[]{"Locator", server.getUrl() + "/" + ((value == null) ? instanceName : server.getCurrentInstance())});
|
|
||||||
} catch (Exception ex) {
|
|
||||||
dataTableModel.addRow(new Object[]{"Locator", ex.getMessage()});
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
dataTableModel.addRow(new Object[]{"Stream", server.getStreamAddress()});
|
|
||||||
} catch (Exception ex) {
|
|
||||||
dataTableModel.addRow(new Object[]{"Stream", ex.getMessage()});
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
dataTableModel.addRow(new Object[]{"PID", value.getPulseId()});
|
|
||||||
} catch (Exception ex) {
|
|
||||||
dataTableModel.addRow(new Object[]{"PID", ex.getMessage()});
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
dataTableModel.addRow(new Object[]{"Timestamp", value.getTimestamp()});
|
|
||||||
} catch (Exception ex) {
|
|
||||||
dataTableModel.addRow(new Object[]{"Timestamp", ex.getMessage()});
|
|
||||||
}
|
|
||||||
Collections.sort(ids);
|
|
||||||
for (String id : ids) {
|
|
||||||
dataTableModel.addRow(new Object[]{id, ""});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Frame frame = getCurrentFrame();
|
|
||||||
if ((frame != null) && (frame.cache!=null)){
|
|
||||||
for (int i = 4; i < dataTableModel.getRowCount(); i++) {
|
|
||||||
String id = String.valueOf(dataTableModel.getValueAt(i, 0));
|
|
||||||
//Object obj = server.getValue(id);
|
|
||||||
Object obj = frame.cache.getValue(id);
|
|
||||||
if (obj != null) {
|
|
||||||
if (obj.getClass().isArray()) {
|
|
||||||
obj = obj.getClass().getComponentType().getSimpleName() + "[" + Array.getLength(obj) + "]";
|
|
||||||
} else if (obj instanceof Double) {
|
|
||||||
obj = Convert.roundDouble((Double) obj, 1);
|
|
||||||
} else if (obj instanceof Float) {
|
|
||||||
obj = Convert.roundDouble((Float) obj, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dataTableModel.setValueAt(String.valueOf(obj), i, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((sel_rows!=null) && (sel_rows.length>0)){
|
|
||||||
//dataTable.setRowSelectionInterval((Integer)Arr.getMin(sel_rows), (Integer)Arr.getMax(sel_rows));
|
|
||||||
dataTable.setRowSelectionInterval(sel_rows[0], sel_rows[sel_rows.length-1]);
|
|
||||||
}
|
|
||||||
if ((sel_cols!=null) && (sel_cols.length>0)){
|
|
||||||
//dataTable.setColumnSelectionInterval((Integer)Arr.getMin(sel_cols), (Integer)Arr.getMax(sel_cols));
|
|
||||||
dataTable.setColumnSelectionInterval(sel_cols[0], sel_cols[sel_cols.length-1]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
updatingStreamData = true;
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
updatingStreamData = false;
|
||||||
|
if ((dataTableModel != null) && (server != null)) {
|
||||||
|
StreamValue value = server.getValue();
|
||||||
|
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());
|
||||||
|
if (ids.size() + 4 != dataTableModel.getRowCount()) {
|
||||||
|
dataTableModel.setNumRows(0);
|
||||||
|
try {
|
||||||
|
dataTableModel.addRow(new Object[]{"Locator", server.getUrl() + "/" + ((value == null) ? instanceName : server.getCurrentInstance())});
|
||||||
|
} catch (Exception ex) {
|
||||||
|
dataTableModel.addRow(new Object[]{"Locator", ex.getMessage()});
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
dataTableModel.addRow(new Object[]{"Stream", server.getStreamAddress()});
|
||||||
|
} catch (Exception ex) {
|
||||||
|
dataTableModel.addRow(new Object[]{"Stream", ex.getMessage()});
|
||||||
|
}
|
||||||
|
dataTableModel.addRow(new Object[]{"PID", ""});
|
||||||
|
dataTableModel.addRow(new Object[]{"Timestamp", ""});
|
||||||
|
Collections.sort(ids);
|
||||||
|
for (String id : ids) {
|
||||||
|
dataTableModel.addRow(new Object[]{id, ""});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((frame != null) && (frame.cache != null)) {
|
||||||
|
dataTableModel.setValueAt(frame.cache.getPulseId(), 2, 1); //PID
|
||||||
|
dataTableModel.setValueAt(frame.cache.getTimestamp(), 3, 1); //Timestamp
|
||||||
|
for (int i = 4; i < dataTableModel.getRowCount(); i++) {
|
||||||
|
String id = String.valueOf(dataTableModel.getValueAt(i, 0));
|
||||||
|
//Object obj = server.getValue(id);
|
||||||
|
Object obj = frame.cache.getValue(id);
|
||||||
|
if (obj != null) {
|
||||||
|
if (obj.getClass().isArray()) {
|
||||||
|
obj = obj.getClass().getComponentType().getSimpleName() + "[" + Array.getLength(obj) + "]";
|
||||||
|
} else if (obj instanceof Double) {
|
||||||
|
obj = Convert.roundDouble((Double) obj, 1);
|
||||||
|
} else if (obj instanceof Float) {
|
||||||
|
obj = Convert.roundDouble((Float) obj, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dataTableModel.setValueAt(String.valueOf(obj), i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((sel_rows != null) && (sel_rows.length > 0)) {
|
||||||
|
//dataTable.setRowSelectionInterval((Integer)Arr.getMin(sel_rows), (Integer)Arr.getMax(sel_rows));
|
||||||
|
dataTable.setRowSelectionInterval(sel_rows[0], sel_rows[sel_rows.length - 1]);
|
||||||
|
}
|
||||||
|
if ((sel_cols != null) && (sel_cols.length > 0)) {
|
||||||
|
//dataTable.setColumnSelectionInterval((Integer)Arr.getMin(sel_cols), (Integer)Arr.getMax(sel_cols));
|
||||||
|
dataTable.setColumnSelectionInterval(sel_cols[0], sel_cols[sel_cols.length - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageIcon getIcon(String name) {
|
ImageIcon getIcon(String name) {
|
||||||
@@ -3193,7 +3212,7 @@ public class ScreenPanel3 extends Panel {
|
|||||||
Color colorReticule = new Color(16, 16, 16);
|
Color colorReticule = new Color(16, 16, 16);
|
||||||
Color colorMarker = new Color(128, 128, 128);
|
Color colorMarker = new Color(128, 128, 128);
|
||||||
Colormap colormap = (Colormap) comboColormap.getSelectedItem();
|
Colormap colormap = (Colormap) comboColormap.getSelectedItem();
|
||||||
source.getConfig().colormap = (colormap==null) ? Colormap.Flame: colormap;
|
source.getConfig().colormap = (colormap == null) ? Colormap.Flame : colormap;
|
||||||
switch (source.getConfig().colormap) {
|
switch (source.getConfig().colormap) {
|
||||||
case Grayscale:
|
case Grayscale:
|
||||||
case Inverted:
|
case Inverted:
|
||||||
@@ -3508,26 +3527,29 @@ public class ScreenPanel3 extends Panel {
|
|||||||
|
|
||||||
private void buttonPauseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPauseActionPerformed
|
private void buttonPauseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPauseActionPerformed
|
||||||
try {
|
try {
|
||||||
if (!updatingButtons){
|
if (!updatingButtons) {
|
||||||
renderer.removeOverlay(imageBufferOverlay);
|
removePauseOverlay();
|
||||||
if (camera != null) {
|
if (camera != null) {
|
||||||
boolean pause = !renderer.isPaused();
|
boolean pause = !renderer.isPaused();
|
||||||
synchronized (imageBuffer) {
|
synchronized (imageBuffer) {
|
||||||
if (pause) {
|
if (pause) {
|
||||||
renderer.pause();
|
renderer.pause();
|
||||||
|
panelCameraSelection.setVisible(false);
|
||||||
|
pauseSelection.setVisible(true);
|
||||||
|
if (imageBuffer.size() > 0) {
|
||||||
|
pauseSelection.setEnabled(true);
|
||||||
|
pauseSelection.setMaxValue(imageBuffer.size());
|
||||||
|
pauseSelection.setValue(imageBuffer.size());
|
||||||
|
updatePause();
|
||||||
|
} else {
|
||||||
|
pauseSelection.setEnabled(false);
|
||||||
|
pauseSelection.setMaxValue(1);
|
||||||
|
pauseSelection.setValue(1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
imageBuffer.clear();
|
imageBuffer.clear();
|
||||||
renderer.resume();
|
renderer.resume();
|
||||||
}
|
//renderer.clear();
|
||||||
|
|
||||||
if (pause && (imageBuffer.size() > 1)) {
|
|
||||||
panelCameraSelection.setVisible(false);
|
|
||||||
pauseSelection.setVisible(true);
|
|
||||||
renderer.addOverlay(imageBufferOverlay);
|
|
||||||
pauseSelection.setMaxValue(imageBuffer.size());
|
|
||||||
pauseSelection.setValue(imageBuffer.size());;
|
|
||||||
updatePause();
|
|
||||||
} else {
|
|
||||||
pauseSelection.setVisible(false);
|
pauseSelection.setVisible(false);
|
||||||
panelCameraSelection.setVisible(true);
|
panelCameraSelection.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user