Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.control.*;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import javafx.stage.FileChooser;
Expand Down Expand Up @@ -100,6 +102,9 @@
public record ParItem(String columnName, int group, String parName, double value, double error) {
}

public void setBottom(Node node) {
borderPane.setBottom(node);
}
/**
* Creates and populates a new stage for the TablePlotGUI, if not already
* created. The stage is displayed and raised to front.
Expand Down Expand Up @@ -177,6 +182,7 @@
borderPane.setCenter(chartPane);
borderPane.setRight(null);
stage.setScene(stageScene);
activeChart.getCanvas().setOnMouseClicked(this::mouseClicked);
}
updateAxisChoices();
if (extraMode == ExtraMode.DIFFUSION) {
Expand All @@ -188,6 +194,8 @@
updatePlot();
}

public void mouseClicked(MouseEvent e) {

Check failure on line 197 in nmrfx-analyst-gui/src/main/java/org/nmrfx/analyst/gui/TablePlotGUI.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.

See more on https://sonarcloud.io/project/issues?id=nanalysis_nmrfx&issues=AZ35-RQMn1POGIojjt9M&open=AZ35-RQMn1POGIojjt9M&pullRequest=707
}

private void toggleFitPane(CheckBox showFitBox) {
if (showFitBox.isSelected()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package org.nmrfx.analyst.gui.molecule;

import javafx.scene.control.Label;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;

Check warning on line 5 in nmrfx-analyst-gui/src/main/java/org/nmrfx/analyst/gui/molecule/PPMPlotGUI.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused import 'javafx.scene.control.TextField'.

See more on https://sonarcloud.io/project/issues?id=nanalysis_nmrfx&issues=AZ35-RPen1POGIojjt9L&open=AZ35-RPen1POGIojjt9L&pullRequest=707
import javafx.scene.input.MouseEvent;
import org.nmrfx.analyst.gui.TablePlotGUI;
import org.nmrfx.chart.*;
import org.nmrfx.chemistry.Atom;
Expand All @@ -10,19 +13,23 @@

public class PPMPlotGUI extends TablePlotGUI {

Label statusField = new Label();
public PPMPlotGUI(TableView<Atom> atomTableView) {
super(atomTableView, null, false);
setChartTypeChoice(Arrays.asList("ScatterPlot", "BarChart", "BarChart-Euclidean"));
skipColumns = Arrays.asList("Index", "Entity", "Res", "Atom");
statusField.setPrefWidth(300);
setBottom(statusField);
xZeroIncluded(false);
yZeroIncluded(false);
}

@Override
@Override
protected DataSeries getBarChartData(List<TableItem> items, String yElem) {
Map<String, String> nameMap = getNameMap();
DataSeries series = new DataSeries();
series.clear();
series.setName(yElem);
String xElem = getXElem();
String firstAtomType = ((Atom) items.getFirst()).getName();
if (!items.stream().allMatch(item ->
Expand All @@ -34,9 +41,11 @@
Double yValue = item.getDouble(nameMap.get(yElem));
if (xValue != null && yValue != null) {
if (item.getGroup() != 1) {
yValue /= 10.0;
yValue /= 5.0;
}
series.add(new XYValue(xValue, yValue));
XYValue xyValue = new XYValue(xValue, yValue);
xyValue.setExtraValue(item);
series.add(xyValue);
}
});
return series;
Expand All @@ -48,19 +57,26 @@
String yElem = getYElem().getFirst();
DataSeries series = new DataSeries();
series.clear();
series.setName(yElem);
HashMap<Integer, Double> values = new HashMap<>();
HashMap<Integer, TableItem> plotItems = new HashMap<>();

items.forEach(item -> {
int xValue = item.getDouble(nameMap.get(xElem)).intValue();
Double yValue = item.getDouble(nameMap.get(yElem));
if (yValue != null) {
if (item.getGroup() != 1) {
yValue /= 10.0;}
yValue /= 10.0;
}
values.put(xValue, values.getOrDefault(xValue, 0.0) + Math.pow(yValue, 2.0));
plotItems.put(xValue, item);
}
});
values.forEach((key, value) ->
series.add(new XYValue(key, Math.sqrt(value))));
values.forEach((key, value) -> {
XYValue xyValue = new XYValue(key, Math.sqrt(value));
xyValue.setExtraValue(plotItems.get(key));
series.add(xyValue);
});
return series;
}

Expand All @@ -70,16 +86,30 @@
String xElem = getXElem();
DataSeries series = new DataSeries();
series.clear();
series.setName(yElem);
items.forEach(item -> {
Double ppm1 = item.getDouble(nameMap.get(xElem));
Double ppm2 = item.getDouble(nameMap.get(yElem));
if (ppm1 != null && ppm2 != null) {
series.add(new XYValue(ppm1, ppm2));
XYValue xyValue = new XYValue(ppm1, ppm2);
xyValue.setExtraValue(item);
series.add(xyValue);
}
});
setYAxisLabel(yElem);
return series;
}

@Override
public void mouseClicked(MouseEvent e) {
Optional<XYCanvasChart.Hit> hitOpt = activeChart.pickChart(e.getX(), e.getY(), 5);
if (hitOpt.isPresent()) {
XYCanvasChart.Hit hit = hitOpt.get();
Atom atom = (Atom) hit.getValue().getExtraValue();
statusField.setText("HIT: " + hit + " " + atom);
} else {
statusField.setText("");
}
}

}
Loading