Skip to content

Commit 81adb1f

Browse files
Birdasaursamypr100
andauthored
123 shap values input process (#124)
Co-authored-by: samypr100 <3933065+samypr100@users.noreply.github.com>
1 parent 6069071 commit 81adb1f

115 files changed

Lines changed: 24790 additions & 1528 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/edu/jhuapl/trinity/App.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ public void start(Stage stage) throws IOException {
119119
centerStack.getChildren().add(mediaView);
120120
mediaView.fitWidthProperty().bind(centerStack.widthProperty().subtract(10));
121121
mediaPlayer.play();
122-
mediaView.setOnMouseClicked(e-> {
122+
mediaView.setOnMouseClicked(e -> {
123123
mediaPlayer.setVolume(0.0); // Ensure final volume is zero
124-
mediaPlayer.currentTimeProperty().removeListener(fadeListener);
124+
mediaPlayer.currentTimeProperty().removeListener(fadeListener);
125125
mediaPlayer.stop();
126126
centerStack.getChildren().remove(mediaView);
127127
});
@@ -155,6 +155,8 @@ public void start(Stage stage) throws IOException {
155155
scene.getStylesheets().add(CSS);
156156
CSS = StyleResourceProvider.getResource("covalent.css").toExternalForm();
157157
scene.getStylesheets().add(CSS);
158+
CSS = StyleResourceProvider.getResource("dialogstyles.css").toExternalForm();
159+
scene.getStylesheets().add(CSS);
158160

159161
//add just the dark necessities...
160162
JukeBox jukeBox = new JukeBox(scene);
@@ -336,6 +338,23 @@ private void keyReleased(Stage stage, KeyEvent e) {
336338
if (e.isAltDown() && e.isControlDown() && e.getCode().equals(KeyCode.Q)) {
337339
shutdown(false);
338340
}
341+
//J cuz i'm running out of letters
342+
if (e.isAltDown() && e.isControlDown() && e.getCode().equals(KeyCode.J)) {
343+
stage.getScene().getRoot().fireEvent(new ApplicationEvent(e.isShiftDown()
344+
? ApplicationEvent.POPOUT_STATISTICS_PANE : ApplicationEvent.SHOW_STATISTICS_PANE));
345+
}
346+
if (e.isAltDown() && e.isControlDown() && e.getCode().equals(KeyCode.F)) {
347+
stage.getScene().getRoot().fireEvent(
348+
new ApplicationEvent(ApplicationEvent.SHOW_FEATUREVECTOR_MANAGER));
349+
}
350+
if (e.isAltDown() && e.isControlDown() && e.getCode().equals(KeyCode.Y)) {
351+
stage.getScene().getRoot().fireEvent(
352+
new ApplicationEvent(ApplicationEvent.SHOW_PAIRWISEJPDF_PANE));
353+
}
354+
if (e.isAltDown() && e.isControlDown() && e.getCode().equals(KeyCode.U)) {
355+
stage.getScene().getRoot().fireEvent(
356+
new ApplicationEvent(ApplicationEvent.SHOW_PAIRWISEMATRIX_PANE));
357+
}
339358
if (e.isAltDown() && e.isControlDown() && e.getCode().equals(KeyCode.S)) {
340359
stage.getScene().getRoot().fireEvent(
341360
new ApplicationEvent(ApplicationEvent.SHOW_SPECIALEFFECTS_PANE));

src/main/java/edu/jhuapl/trinity/AppAsyncManager.java

Lines changed: 180 additions & 39 deletions
Large diffs are not rendered by default.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package edu.jhuapl.trinity.data.files;
2+
3+
import com.fasterxml.jackson.databind.DeserializationFeature;
4+
import com.fasterxml.jackson.databind.ObjectMapper;
5+
import edu.jhuapl.trinity.data.messages.xai.CyberReport;
6+
import edu.jhuapl.trinity.data.messages.xai.CyberReportIO;
7+
8+
import java.awt.datatransfer.DataFlavor;
9+
import java.io.File;
10+
import java.io.IOException;
11+
import java.nio.file.Files;
12+
import java.util.List;
13+
14+
/**
15+
* @author Sean Phillips
16+
*/
17+
public class CyberReporterFile extends DroppableFile {
18+
public List<CyberReport> cyberReports = null;
19+
20+
public CyberReporterFile(String pathname) {
21+
super(pathname);
22+
}
23+
24+
public CyberReporterFile(String pathname, Boolean parseExisting) throws IOException {
25+
super(pathname);
26+
if (parseExisting)
27+
parseContent();
28+
}
29+
30+
/**
31+
* Tests whether a given File is this type of file or not
32+
*
33+
* @param file The File to be tested
34+
* @return True if the file being tested is this type of file
35+
* @throws java.io.IOException
36+
*/
37+
public static boolean isFileType(File file) throws IOException {
38+
String extension = file.getName().substring(file.getName().lastIndexOf("."));
39+
if (extension.equalsIgnoreCase(".json")) {
40+
String body = Files.readString(file.toPath());
41+
return CyberReport.isCyberReport(body);
42+
}
43+
return false;
44+
}
45+
46+
@Override
47+
public DataFlavor getDataFlavor() {
48+
return new DataFlavor(CyberReporterFile.class, "CYBERREPORT");
49+
}
50+
51+
@Override
52+
public void parseContent() throws IOException {
53+
/** Provides deserialization support for JSON messages */
54+
ObjectMapper mapper = new ObjectMapper();
55+
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
56+
String message = Files.readString(this.toPath());
57+
// From a string:
58+
cyberReports = CyberReportIO.readReports(message);
59+
}
60+
61+
@Override
62+
public void writeContent() throws IOException {
63+
if (null != cyberReports) {
64+
ObjectMapper mapper = new ObjectMapper();
65+
//mapper.configure(SerializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
66+
mapper.writeValue(this, cyberReports);
67+
LOG.info("CyberReports serialized to file.");
68+
}
69+
}
70+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package edu.jhuapl.trinity.data.files;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
6+
import java.awt.datatransfer.DataFlavor;
7+
import java.awt.datatransfer.Transferable;
8+
import java.awt.datatransfer.UnsupportedFlavorException;
9+
import java.io.File;
10+
import java.io.IOException;
11+
12+
/**
13+
*
14+
* @author Sean Phillips
15+
*/
16+
public abstract class DroppableFile extends File implements Transferable {
17+
public static final Logger LOG = LoggerFactory.getLogger(DroppableFile.class);
18+
19+
/**
20+
* Constructor that extends File super constructor
21+
*
22+
* @param pathname Full path string to the file
23+
*/
24+
public DroppableFile(String pathname) {
25+
super(pathname);
26+
}
27+
28+
/**
29+
* Constructor that allows for automatically parsing the content of the file
30+
*
31+
* @param pathname Full path string to the file
32+
* @param parseExisting True to automatically parse the content of the file
33+
* specified by pathname
34+
* @throws java.io.IOException
35+
*/
36+
public DroppableFile(String pathname, Boolean parseExisting) throws IOException {
37+
super(pathname);
38+
if (parseExisting)
39+
parseContent();
40+
}
41+
42+
/**
43+
* Parses the file specified via this object's constructor
44+
* Assumes the file exists and is readable and conforms to expected format.
45+
*
46+
* @throws java.io.IOException
47+
*/
48+
public void parse() throws IOException {
49+
parseContent();
50+
}
51+
52+
public abstract DataFlavor getDataFlavor();
53+
54+
public abstract void parseContent() throws IOException;
55+
56+
/**
57+
* Writes out the content of this File at the location
58+
* specified via this object's constructor.
59+
* Assumes the file exists.
60+
*
61+
* @throws java.io.IOException
62+
*/
63+
public abstract void writeContent() throws IOException;
64+
65+
@Override
66+
public DataFlavor[] getTransferDataFlavors() {
67+
return new DataFlavor[]{getDataFlavor()};
68+
}
69+
70+
@Override
71+
public boolean isDataFlavorSupported(DataFlavor df) {
72+
return df == getDataFlavor();
73+
}
74+
75+
@Override
76+
public Object getTransferData(DataFlavor df) throws UnsupportedFlavorException, IOException {
77+
if (df == getDataFlavor()) {
78+
return this;
79+
} else {
80+
throw new UnsupportedFlavorException(df);
81+
}
82+
}
83+
}

0 commit comments

Comments
 (0)