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
13 changes: 8 additions & 5 deletions src/main/java/edu/jhuapl/trinity/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,21 @@ public void start(Stage stage) throws IOException {
mediaPlayer.play();
});

mediaPlayer.setOnEndOfMedia(() -> {
mediaPlayer.setVolume(0.0); // Ensure final volume is zero
mediaPlayer.currentTimeProperty().removeListener(fadeListener);
});

MediaView mediaView = new MediaView(mediaPlayer);
mediaView.setPreserveRatio(true);
centerStack.getChildren().add(mediaView);
mediaView.fitWidthProperty().bind(centerStack.widthProperty().subtract(10));
mediaPlayer.play();
mediaView.setOnMouseClicked(e-> {
mediaPlayer.setVolume(0.0); // Ensure final volume is zero
mediaPlayer.currentTimeProperty().removeListener(fadeListener);
mediaPlayer.stop();
centerStack.getChildren().remove(mediaView);
});

mediaPlayer.setOnEndOfMedia(() -> {
mediaPlayer.setVolume(0.0); // Ensure final volume is zero
mediaPlayer.currentTimeProperty().removeListener(fadeListener);
Timeline time = new Timeline(
new KeyFrame(Duration.seconds(0.5), new KeyValue(mediaView.opacityProperty(), 0.0)),
new KeyFrame(Duration.seconds(0.6), e -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ public static boolean isFeatureCollection(String messageBody) {
&& messageBody.contains("features");
}

public static FeatureCollection merge(List<FeatureCollection> collections) {
FeatureCollection fcf = new FeatureCollection();
List<FeatureVector> featureVectors = new ArrayList<>();
for(FeatureCollection fc : collections) {
featureVectors.addAll(fc.getFeatures());
}
fcf.setFeatures(featureVectors);
return fcf;
}

public float[][] convertFeaturesToFloatArray() {
int vectorCount = features.size();
int vectorWidth = features.get(0).getData().size();
Expand Down Expand Up @@ -166,7 +176,6 @@ public String getType() {
public void setType(String type) {
this.type = type;
}
//</editor-fold>

/**
* @return the dimensionLabels
Expand All @@ -181,4 +190,5 @@ public ArrayList<String> getDimensionLabels() {
public void setDimensionLabels(ArrayList<String> dimensionLabels) {
this.dimensionLabels = dimensionLabels;
}
}
//</editor-fold>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package edu.jhuapl.trinity.javafx.components;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.control.Label;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.Background;
import javafx.scene.layout.VBox;

/**
* @author Sean Phillips
*/
public class AnalysisVectorBox extends VBox {
public ObservableList<XYChart.Data<Double, Double>> analysisVector;
public XYChart.Series series;
private LineChart lineChart;
Label vectorLabel;

public AnalysisVectorBox(double width, double height) {
setPrefSize(width, height);
analysisVector = FXCollections.observableArrayList();
series = new XYChart.Series("Hyperdimensional Vector", analysisVector);
this.lineChart = new LineChart(new NumberAxis(), new NumberAxis(), FXCollections.observableArrayList(series));

lineChart.setAnimated(false);
lineChart.setLegendVisible(false);
setBackground(Background.EMPTY);
vectorLabel = new Label("Analys Vector");

setSpacing(10);
getChildren().addAll(vectorLabel, lineChart);
}

public void setAnalysisVector(String label, Double[] newData) {
if(null != label) {
vectorLabel.setText(label);
}
analysisVector.clear();
for (int i = 0; i < newData.length; i++) {
XYChart.Data data = new XYChart.Data(i, newData[i], newData[i]);
Tooltip.install(data.getNode(), new Tooltip("Analysis Vector "
+ data.getXValue().toString() + "\n"
+ data.getYValue()));

data.setNode(new HoverNode(i, newData[i]));
analysisVector.add(data);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.jhuapl.trinity.javafx.components.panes;
package edu.jhuapl.trinity.javafx.components;

import edu.jhuapl.trinity.javafx.events.FactorAnalysisEvent;
import javafx.collections.FXCollections;
Expand All @@ -14,7 +14,6 @@
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.CornerRadii;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;

Expand Down Expand Up @@ -48,6 +47,8 @@ public FactorControlBox(double width, double height) {

xFactorChart.setAnimated(false);
zFactorChart.setAnimated(false);
xFactorChart.setLegendVisible(false);
zFactorChart.setLegendVisible(false);

setBackground(Background.EMPTY);
Label xFactorLabel = new Label("X Axis (Feature Vector)");
Expand Down Expand Up @@ -95,31 +96,4 @@ public void setFactorVector(ObservableList<XYChart.Data<Double, Double>> vector,
vector.add(data);
}
}

/**
* a node which displays a value on hover, but is otherwise empty
*/
class HoverNode extends StackPane {

HoverNode(int index, Double value) {
setPrefSize(15, 15);
final Label label = new Label("Vector(" + index + ") = " + value);
label.getStyleClass().addAll("default-color0", "chart-line-symbol", "chart-series-line");
label.setStyle("-fx-font-size: 20; -fx-font-weight: bold;");
label.setMinSize(Label.USE_PREF_SIZE, Label.USE_PREF_SIZE);
label.setTranslateY(-30); //Move label 25 pixels up
Color ALICEBLUETRANS = new Color(0.9411765f, 0.972549f, 1.0f, 0.3);
label.setBackground(new Background(new BackgroundFill(ALICEBLUETRANS, CornerRadii.EMPTY, Insets.EMPTY)));

setOnMouseEntered(e -> {
label.getStyleClass().add("onHover");
getChildren().setAll(label);
toFront();
});
setOnMouseExited(e -> {
label.getStyleClass().remove("onHover");
getChildren().clear();
});
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package edu.jhuapl.trinity.javafx.components;

import javafx.geometry.Insets;
import javafx.scene.control.Label;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.CornerRadii;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;

/**
* a node which displays a value on hover, but is otherwise empty
* @author Sean Phillips
*/
public class HoverNode extends StackPane {

HoverNode(int index, Double value) {
// setPrefSize(15, 15);
Label label = new Label("Vector(" + index + ") = " + value);
label.getStyleClass().addAll("default-color0", "chart-line-symbol", "chart-series-line");
label.setStyle("-fx-font-size: 20; -fx-font-weight: bold;");
label.setPrefSize(Label.USE_PREF_SIZE, Label.USE_PREF_SIZE);
label.setTranslateY(-30); //Move label 25 pixels up
Color ALICEBLUETRANS = new Color(0.9411765f, 0.972549f, 1.0f, 0.3);
label.setBackground(new Background(new BackgroundFill(ALICEBLUETRANS, CornerRadii.EMPTY, Insets.EMPTY)));

setOnMouseEntered(e -> {
label.getStyleClass().add("onHover");
getChildren().setAll(label);
toFront();
});
setOnMouseExited(e -> {
label.getStyleClass().remove("onHover");
getChildren().clear();
});
}
}
Loading
Loading