adjust EventClusterNode subbundle loading

This commit is contained in:
jmillman 2015-10-13 16:41:50 -04:00
parent 09270a524a
commit bd9c9109e4
4 changed files with 75 additions and 81 deletions

View File

@ -98,7 +98,7 @@ public abstract class EventBundleNodeBase<BundleType extends EventBundle<ParentT
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;

View File

@ -42,6 +42,7 @@ import javafx.scene.layout.Border;
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 @@ final public class EventClusterNode extends EventBundleNodeBase<EventCluster, Ev
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,17 +140,13 @@ final public class EventClusterNode extends EventBundleNodeBase<EventCluster, Ev
*/ */
@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 * make new ZoomParams to query with
* *
@ -179,7 +177,7 @@ final public class EventClusterNode extends EventBundleNodeBase<EventCluster, Ev
return Collections.emptySet(); return Collections.emptySet();
} }
bundles = eventsModel.getEventClusters(zoomParams.withDescrLOD(loadedDescriptionLoD)).stream() bundles = eventsModel.getEventClusters(zoomParams.withDescrLOD(loadedDescriptionLoD)).stream()
.collect(Collectors.toMap((eventCluster) -> eventCluster.getDescription(), //key .collect(Collectors.toMap(EventCluster::getDescription, //key
(eventCluster) -> new EventStripe(eventCluster, getEventCluster()), //value (eventCluster) -> new EventStripe(eventCluster, getEventCluster()), //value
EventStripe::merge) //merge method EventStripe::merge) //merge method
).values(); ).values();
@ -193,24 +191,24 @@ final public class EventClusterNode extends EventBundleNodeBase<EventCluster, Ev
@Override @Override
protected void succeeded() { protected void succeeded() {
chart.setCursor(Cursor.WAIT);
try { try {
Collection<EventStripe> bundles = get(); Collection<EventStripe> bundles = get();
if (bundles.isEmpty()) { if (bundles.isEmpty()) {
countLabel.setVisible(true); subNodePane.getChildren().clear();
getChildren().setAll(subNodePane, infoHBox);
descLOD.set(getEventBundle().getDescriptionLoD());
} else { } else {
countLabel.setVisible(false);
chart.getEventBundles().addAll(bundles); chart.getEventBundles().addAll(bundles);
subNodes.addAll(bundles.stream() subNodes.addAll(bundles.stream()
.map(EventClusterNode.this::createStripeNode) .map(EventClusterNode.this::createStripeNode)
.sorted(Comparator.comparing(EventStripeNode::getStartMillis)) .sorted(Comparator.comparing(EventStripeNode::getStartMillis))
.collect(Collectors.toList())); .collect(Collectors.toList()));
subNodePane.getChildren().addAll(subNodes); subNodePane.getChildren().setAll(subNodes);
} getChildren().setAll(new VBox(infoHBox, subNodePane));
descLOD.set(loadedDescriptionLoD); descLOD.set(loadedDescriptionLoD);
//assign subNodes and request chart layout }
} catch (InterruptedException | ExecutionException ex) { } catch (InterruptedException | ExecutionException ex) {
LOGGER.log(Level.SEVERE, "Error loading subnodes", ex); LOGGER.log(Level.SEVERE, "Error loading subnodes", ex);
} }
@ -222,7 +220,6 @@ final public class EventClusterNode extends EventBundleNodeBase<EventCluster, Ev
//start task //start task
chart.getController().monitorTask(loggedTask); chart.getController().monitorTask(loggedTask);
} }
}
private EventStripeNode createStripeNode(EventStripe stripe) { private EventStripeNode createStripeNode(EventStripe stripe) {
return new EventStripeNode(chart, stripe, this); return new EventStripeNode(chart, stripe, this);
@ -249,7 +246,7 @@ final public class EventClusterNode extends EventBundleNodeBase<EventCluster, Ev
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 @@ final public class EventClusterNode extends EventBundleNodeBase<EventCluster, Ev
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));

View File

@ -57,7 +57,6 @@ final public class EventStripeNode extends EventBundleNodeBase<EventStripe, Even
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 @@ final public class EventStripeNode extends EventBundleNodeBase<EventStripe, Even
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);

View File

@ -43,7 +43,7 @@ public enum DescriptionLoD {
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 enum DescriptionLoD {
try { try {
return values()[ordinal() - 1]; return values()[ordinal() - 1];
} catch (ArrayIndexOutOfBoundsException e) { } catch (ArrayIndexOutOfBoundsException e) {
return null; return SHORT;
} }
} }