Skip to content
Snippets Groups Projects
Commit bd9c9109 authored by jmillman's avatar jmillman
Browse files

adjust EventClusterNode subbundle loading

parent 09270a52
Branches CI_oscer447
No related tags found
No related merge requests found
...@@ -98,7 +98,7 @@ static void show(Node b, boolean show) { ...@@ -98,7 +98,7 @@ static void show(Node b, boolean show) {
protected final EventDetailChart chart; protected final EventDetailChart chart;
final SimpleObjectProperty<DescriptionLoD> descLOD = new SimpleObjectProperty<>(); final SimpleObjectProperty<DescriptionLoD> descLOD = new SimpleObjectProperty<>();
final SimpleObjectProperty<DescriptionVisibility> descVisibility= new SimpleObjectProperty<>(DescriptionVisibility.SHOWN); final SimpleObjectProperty<DescriptionVisibility> descVisibility = new SimpleObjectProperty<>(DescriptionVisibility.SHOWN);
protected final BundleType eventBundle; protected final BundleType eventBundle;
protected final ParentNodeType parentNode; protected final ParentNodeType parentNode;
...@@ -181,7 +181,7 @@ public EventBundleNodeBase(EventDetailChart chart, BundleType eventBundle, Paren ...@@ -181,7 +181,7 @@ public EventBundleNodeBase(EventDetailChart chart, BundleType eventBundle, Paren
parentNode.showHoverControls(true); parentNode.showHoverControls(true);
} }
}); });
setDescriptionVisibility(DescriptionVisibility.SHOWN); setDescriptionVisibility(DescriptionVisibility.SHOWN);
descVisibility.addListener((ObservableValue<? extends DescriptionVisibility> observable, DescriptionVisibility oldValue, DescriptionVisibility newValue) -> { descVisibility.addListener((ObservableValue<? extends DescriptionVisibility> observable, DescriptionVisibility oldValue, DescriptionVisibility newValue) -> {
setDescriptionVisibility(newValue); setDescriptionVisibility(newValue);
...@@ -331,7 +331,7 @@ protected void layoutChildren() { ...@@ -331,7 +331,7 @@ protected void layoutChildren() {
abstract void setDescriptionWidth(double w); abstract void setDescriptionWidth(double w);
void setDescriptionVisibilityLevel(DescriptionVisibility get) { void setDescriptionVisibilityLevel(DescriptionVisibility get) {
descVisibility.set(get); descVisibility.set(get);
} }
} }
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
import javafx.scene.layout.BorderStroke; import javafx.scene.layout.BorderStroke;
import javafx.scene.layout.BorderStrokeStyle; import javafx.scene.layout.BorderStrokeStyle;
import javafx.scene.layout.BorderWidths; import javafx.scene.layout.BorderWidths;
import javafx.scene.layout.VBox;
import org.controlsfx.control.action.Action; import org.controlsfx.control.action.Action;
import org.controlsfx.control.action.ActionUtils; import org.controlsfx.control.action.ActionUtils;
import org.joda.time.DateTime; import org.joda.time.DateTime;
...@@ -92,6 +93,7 @@ public EventClusterNode(EventDetailChart chart, EventCluster eventCluster, Event ...@@ -92,6 +93,7 @@ public EventClusterNode(EventDetailChart chart, EventCluster eventCluster, Event
setAlignment(Pos.CENTER_LEFT); setAlignment(Pos.CENTER_LEFT);
infoHBox.getChildren().addAll(minusButton, plusButton); infoHBox.getChildren().addAll(minusButton, plusButton);
getChildren().addAll(subNodePane, infoHBox); getChildren().addAll(subNodePane, infoHBox);
} }
@Override @Override
...@@ -138,90 +140,85 @@ public void setDescriptionVisibility(DescriptionVisibility descrVis) { ...@@ -138,90 +140,85 @@ public void setDescriptionVisibility(DescriptionVisibility descrVis) {
*/ */
@NbBundle.Messages(value = "EventStripeNode.loggedTask.name=Load sub clusters") @NbBundle.Messages(value = "EventStripeNode.loggedTask.name=Load sub clusters")
private synchronized void loadSubBundles(DescriptionLoD.RelativeDetail relativeDetail) { private synchronized void loadSubBundles(DescriptionLoD.RelativeDetail relativeDetail) {
chart.setCursor(Cursor.WAIT);
chart.getEventBundles().removeIf(bundle -> chart.getEventBundles().removeIf(bundle ->
subNodes.stream().anyMatch(subNode -> subNodes.stream().anyMatch(subNode ->
bundle.equals(subNode.getEventStripe())) bundle.equals(subNode.getEventStripe()))
); );
subNodePane.getChildren().clear();
subNodes.clear(); subNodes.clear();
if (descLOD.get().withRelativeDetail(relativeDetail) == getEventBundle().getDescriptionLoD()) {
countLabel.setVisible(true);
descLOD.set(getEventBundle().getDescriptionLoD());
chart.layoutPlotChildren();
} else {
/*
* make new ZoomParams to query with
*
* We need to extend end time because for the query by one second,
* because it is treated as an open interval but we want to include
* events at exactly the time of the last event in this cluster
*/
final RootFilter subClusterFilter = getSubClusterFilter();
final Interval subClusterSpan = new Interval(getStartMillis(), getEndMillis() + 1000);
final EventTypeZoomLevel eventTypeZoomLevel = eventsModel.eventTypeZoomProperty().get();
final ZoomParams zoomParams = new ZoomParams(subClusterSpan, eventTypeZoomLevel, subClusterFilter, getDescriptionLoD());
Task<Collection<EventStripe>> loggedTask = new Task<Collection<EventStripe>>() {
private volatile DescriptionLoD loadedDescriptionLoD = getDescriptionLoD().withRelativeDetail(relativeDetail);
{
updateTitle(Bundle.EventStripeNode_loggedTask_name());
}
@Override /*
protected Collection<EventStripe> call() throws Exception { * make new ZoomParams to query with
Collection<EventStripe> bundles; *
DescriptionLoD next = loadedDescriptionLoD; * We need to extend end time because for the query by one second,
do { * because it is treated as an open interval but we want to include
loadedDescriptionLoD = next; * events at exactly the time of the last event in this cluster
if (loadedDescriptionLoD == getEventBundle().getDescriptionLoD()) { */
return Collections.emptySet(); final RootFilter subClusterFilter = getSubClusterFilter();
} final Interval subClusterSpan = new Interval(getStartMillis(), getEndMillis() + 1000);
bundles = eventsModel.getEventClusters(zoomParams.withDescrLOD(loadedDescriptionLoD)).stream() final EventTypeZoomLevel eventTypeZoomLevel = eventsModel.eventTypeZoomProperty().get();
.collect(Collectors.toMap((eventCluster) -> eventCluster.getDescription(), //key final ZoomParams zoomParams = new ZoomParams(subClusterSpan, eventTypeZoomLevel, subClusterFilter, getDescriptionLoD());
(eventCluster) -> new EventStripe(eventCluster, getEventCluster()), //value
EventStripe::merge) //merge method
).values();
next = loadedDescriptionLoD.withRelativeDetail(relativeDetail);
} while (bundles.size() == 1 && nonNull(next));
// return list of AbstractEventStripeNodes representing sub-bundles
return bundles;
} Task<Collection<EventStripe>> loggedTask = new Task<Collection<EventStripe>>() {
@Override private volatile DescriptionLoD loadedDescriptionLoD = getDescriptionLoD().withRelativeDetail(relativeDetail);
protected void succeeded() {
chart.setCursor(Cursor.WAIT);
try {
Collection<EventStripe> bundles = get();
if (bundles.isEmpty()) {
countLabel.setVisible(true);
} else {
countLabel.setVisible(false);
chart.getEventBundles().addAll(bundles);
subNodes.addAll(bundles.stream()
.map(EventClusterNode.this::createStripeNode)
.sorted(Comparator.comparing(EventStripeNode::getStartMillis))
.collect(Collectors.toList()));
subNodePane.getChildren().addAll(subNodes);
}
descLOD.set(loadedDescriptionLoD);
//assign subNodes and request chart layout
} catch (InterruptedException | ExecutionException ex) { {
LOGGER.log(Level.SEVERE, "Error loading subnodes", ex); updateTitle(Bundle.EventStripeNode_loggedTask_name());
}
@Override
protected Collection<EventStripe> call() throws Exception {
Collection<EventStripe> bundles;
DescriptionLoD next = loadedDescriptionLoD;
do {
loadedDescriptionLoD = next;
if (loadedDescriptionLoD == getEventBundle().getDescriptionLoD()) {
return Collections.emptySet();
} }
chart.layoutPlotChildren(); bundles = eventsModel.getEventClusters(zoomParams.withDescrLOD(loadedDescriptionLoD)).stream()
chart.setCursor(null); .collect(Collectors.toMap(EventCluster::getDescription, //key
(eventCluster) -> new EventStripe(eventCluster, getEventCluster()), //value
EventStripe::merge) //merge method
).values();
next = loadedDescriptionLoD.withRelativeDetail(relativeDetail);
} while (bundles.size() == 1 && nonNull(next));
// return list of AbstractEventStripeNodes representing sub-bundles
return bundles;
}
@Override
protected void succeeded() {
try {
Collection<EventStripe> bundles = get();
if (bundles.isEmpty()) {
subNodePane.getChildren().clear();
getChildren().setAll(subNodePane, infoHBox);
descLOD.set(getEventBundle().getDescriptionLoD());
} else {
chart.getEventBundles().addAll(bundles);
subNodes.addAll(bundles.stream()
.map(EventClusterNode.this::createStripeNode)
.sorted(Comparator.comparing(EventStripeNode::getStartMillis))
.collect(Collectors.toList()));
subNodePane.getChildren().setAll(subNodes);
getChildren().setAll(new VBox(infoHBox, subNodePane));
descLOD.set(loadedDescriptionLoD);
}
} catch (InterruptedException | ExecutionException ex) {
LOGGER.log(Level.SEVERE, "Error loading subnodes", ex);
} }
}; chart.layoutPlotChildren();
chart.setCursor(null);
}
};
//start task //start task
chart.getController().monitorTask(loggedTask); chart.getController().monitorTask(loggedTask);
}
} }
private EventStripeNode createStripeNode(EventStripe stripe) { private EventStripeNode createStripeNode(EventStripe stripe) {
...@@ -249,7 +246,7 @@ protected void layoutChildren() { ...@@ -249,7 +246,7 @@ protected void layoutChildren() {
RootFilter getSubClusterFilter() { RootFilter getSubClusterFilter() {
RootFilter subClusterFilter = eventsModel.filterProperty().get().copyOf(); RootFilter subClusterFilter = eventsModel.filterProperty().get().copyOf();
subClusterFilter.getSubFilters().addAll( subClusterFilter.getSubFilters().addAll(
new DescriptionFilter(getDescriptionLoD(), getDescription(), DescriptionFilter.FilterMode.INCLUDE), new DescriptionFilter(getEventBundle().getDescriptionLoD(), getDescription(), DescriptionFilter.FilterMode.INCLUDE),
new TypeFilter(getEventType())); new TypeFilter(getEventType()));
return subClusterFilter; return subClusterFilter;
} }
...@@ -310,7 +307,6 @@ private class ExpandClusterAction extends Action { ...@@ -310,7 +307,6 @@ private class ExpandClusterAction extends Action {
final DescriptionLoD next = descLOD.get().moreDetailed(); final DescriptionLoD next = descLOD.get().moreDetailed();
if (next != null) { if (next != null) {
loadSubBundles(DescriptionLoD.RelativeDetail.MORE); loadSubBundles(DescriptionLoD.RelativeDetail.MORE);
} }
}); });
disabledProperty().bind(descLOD.isEqualTo(DescriptionLoD.FULL)); disabledProperty().bind(descLOD.isEqualTo(DescriptionLoD.FULL));
......
...@@ -57,7 +57,6 @@ public EventStripeNode(EventDetailChart chart, EventStripe eventStripe, EventClu ...@@ -57,7 +57,6 @@ public EventStripeNode(EventDetailChart chart, EventStripe eventStripe, EventClu
super(chart, eventStripe, parentNode); super(chart, eventStripe, parentNode);
setMinHeight(48); setMinHeight(48);
// minWidthProperty().bind(subNodePane.widthProperty());
EventDetailChart.HideDescriptionAction hideClusterAction = chart.new HideDescriptionAction(getDescription(), eventBundle.getDescriptionLoD()); EventDetailChart.HideDescriptionAction hideClusterAction = chart.new HideDescriptionAction(getDescription(), eventBundle.getDescriptionLoD());
hideButton = ActionUtils.createButton(hideClusterAction, ActionUtils.ActionTextBehavior.HIDE); hideButton = ActionUtils.createButton(hideClusterAction, ActionUtils.ActionTextBehavior.HIDE);
...@@ -70,7 +69,6 @@ public EventStripeNode(EventDetailChart chart, EventStripe eventStripe, EventClu ...@@ -70,7 +69,6 @@ public EventStripeNode(EventDetailChart chart, EventStripe eventStripe, EventClu
descrLabel.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS); descrLabel.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS);
descrLabel.setGraphic(eventTypeImageView); descrLabel.setGraphic(eventTypeImageView);
// subNodePane.setPickOnBounds(false);
setAlignment(subNodePane, Pos.BOTTOM_LEFT); setAlignment(subNodePane, Pos.BOTTOM_LEFT);
for (EventCluster cluster : eventStripe.getClusters()) { for (EventCluster cluster : eventStripe.getClusters()) {
EventClusterNode clusterNode = new EventClusterNode(chart, cluster, this); EventClusterNode clusterNode = new EventClusterNode(chart, cluster, this);
......
...@@ -43,7 +43,7 @@ public DescriptionLoD moreDetailed() { ...@@ -43,7 +43,7 @@ public DescriptionLoD moreDetailed() {
try { try {
return values()[ordinal() + 1]; return values()[ordinal() + 1];
} catch (ArrayIndexOutOfBoundsException e) { } catch (ArrayIndexOutOfBoundsException e) {
return null; return FULL;
} }
} }
...@@ -51,7 +51,7 @@ public DescriptionLoD lessDetailed() { ...@@ -51,7 +51,7 @@ public DescriptionLoD lessDetailed() {
try { try {
return values()[ordinal() - 1]; return values()[ordinal() - 1];
} catch (ArrayIndexOutOfBoundsException e) { } catch (ArrayIndexOutOfBoundsException e) {
return null; return SHORT;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment