fix layout refresh after node expansion and collapse

remove redundant layout operations
This commit is contained in:
jmillman 2015-11-23 13:58:04 -05:00
parent 0d7fbc852e
commit e0f6479b6c
3 changed files with 11 additions and 37 deletions

View File

@ -31,6 +31,7 @@ import java.util.stream.Collectors;
import javafx.animation.KeyFrame; import javafx.animation.KeyFrame;
import javafx.animation.KeyValue; import javafx.animation.KeyValue;
import javafx.animation.Timeline; import javafx.animation.Timeline;
import javafx.application.Platform;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
import javafx.concurrent.Task; import javafx.concurrent.Task;
import javafx.event.EventHandler; import javafx.event.EventHandler;
@ -58,8 +59,6 @@ import javafx.scene.layout.BorderWidths;
import javafx.scene.layout.CornerRadii; import javafx.scene.layout.CornerRadii;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane; import javafx.scene.layout.Pane;
import static javafx.scene.layout.Region.USE_COMPUTED_SIZE;
import static javafx.scene.layout.Region.USE_PREF_SIZE;
import javafx.scene.layout.StackPane; import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.util.Duration; import javafx.util.Duration;
@ -154,33 +153,18 @@ public abstract class EventBundleNodeBase<BundleType extends EventBundle<ParentT
setBackground(defaultBackground); setBackground(defaultBackground);
setAlignment(Pos.TOP_LEFT); setAlignment(Pos.TOP_LEFT);
setPrefHeight(USE_COMPUTED_SIZE);
/* /*
* This triggers the layout when a mousover causes the action buttons to * This triggers the layout when a mousover causes the action buttons to
* interesect with another node, forcing it down. * interesect with another node, forcing it down.
*/ */
heightProperty().addListener(heightProp -> chart.requestChartLayout()); heightProperty().addListener(heightProp -> chart.requestChartLayout());
setMaxHeight(USE_PREF_SIZE);
setMinWidth(USE_PREF_SIZE);
setMaxWidth(USE_PREF_SIZE);
setLayoutX(chart.getXAxis().getDisplayPosition(new DateTime(eventBundle.getStartMillis())) - getLayoutXCompensation()); setLayoutX(chart.getXAxis().getDisplayPosition(new DateTime(eventBundle.getStartMillis())) - getLayoutXCompensation());
//initialize info hbox //initialize info hbox
infoHBox.setMinWidth(USE_PREF_SIZE);
infoHBox.setMaxWidth(USE_PREF_SIZE);
infoHBox.setPadding(new Insets(2, 3, 2, 3)); infoHBox.setPadding(new Insets(2, 3, 2, 3));
infoHBox.setAlignment(Pos.TOP_LEFT); infoHBox.setAlignment(Pos.TOP_LEFT);
//set up subnode pane sizing contraints
subNodePane.setPrefHeight(USE_COMPUTED_SIZE);
subNodePane.setPrefHeight(USE_COMPUTED_SIZE);
subNodePane.setMinHeight(24);
subNodePane.setPrefWidth(USE_COMPUTED_SIZE);
subNodePane.setMinWidth(USE_PREF_SIZE);
subNodePane.setMaxWidth(USE_PREF_SIZE);
Tooltip.install(this, this.tooltip); Tooltip.install(this, this.tooltip);
//set up mouse hover effect and tooltip //set up mouse hover effect and tooltip
@ -378,17 +362,20 @@ public abstract class EventBundleNodeBase<BundleType extends EventBundle<ParentT
void animateTo(double xLeft, double yTop) { void animateTo(double xLeft, double yTop) {
if (timeline != null) { if (timeline != null) {
timeline.stop(); timeline.stop();
chart.requestChartLayout(); Platform.runLater(chart::requestChartLayout);
} }
timeline = new Timeline(new KeyFrame(Duration.millis(100), timeline = new Timeline(new KeyFrame(Duration.millis(100),
new KeyValue(layoutXProperty(), xLeft), new KeyValue(layoutXProperty(), xLeft),
new KeyValue(layoutYProperty(), yTop)) new KeyValue(layoutYProperty(), yTop))
); );
timeline.setOnFinished(finished -> chart.requestChartLayout()); timeline.setOnFinished(finished -> Platform.runLater(chart::requestChartLayout));
timeline.play(); timeline.play();
} }
abstract EventHandler<MouseEvent> getDoubleClickHandler();
abstract Collection<? extends Action> getActions();
/** /**
* event handler used for mouse events on {@link EventStripeNode}s * event handler used for mouse events on {@link EventStripeNode}s
*/ */
@ -398,15 +385,11 @@ public abstract class EventBundleNodeBase<BundleType extends EventBundle<ParentT
@Override @Override
public void handle(MouseEvent t) { public void handle(MouseEvent t) {
if (t.getButton() == MouseButton.PRIMARY) { if (t.getButton() == MouseButton.PRIMARY) {
if (t.getClickCount() > 1) { if (t.getClickCount() > 1) {
getDoubleClickHandler().handle(t); getDoubleClickHandler().handle(t);
} else if (t.isShiftDown()) { } else if (t.isShiftDown()) {
if (chart.selectedNodes.contains(EventBundleNodeBase.this) == false) {
chart.selectedNodes.add(EventBundleNodeBase.this); chart.selectedNodes.add(EventBundleNodeBase.this);
}
} else if (t.isShortcutDown()) { } else if (t.isShortcutDown()) {
chart.selectedNodes.removeAll(EventBundleNodeBase.this); chart.selectedNodes.removeAll(EventBundleNodeBase.this);
} else { } else {
@ -428,10 +411,6 @@ public abstract class EventBundleNodeBase<BundleType extends EventBundle<ParentT
t.consume(); t.consume();
} }
} }
} }
abstract EventHandler<MouseEvent> getDoubleClickHandler();
abstract Collection<? extends Action> getActions();
} }

View File

@ -85,19 +85,15 @@ final public class EventClusterNode extends EventBundleNodeBase<EventCluster, Ev
public EventClusterNode(EventDetailsChart chart, EventCluster eventCluster, EventStripeNode parentNode) { public EventClusterNode(EventDetailsChart chart, EventCluster eventCluster, EventStripeNode parentNode) {
super(chart, eventCluster, parentNode); super(chart, eventCluster, parentNode);
setMinHeight(24);
subNodePane.setBorder(clusterBorder); subNodePane.setBorder(clusterBorder);
subNodePane.setBackground(defaultBackground); subNodePane.setBackground(defaultBackground);
subNodePane.setMaxHeight(USE_COMPUTED_SIZE);
subNodePane.setMaxWidth(USE_PREF_SIZE);
subNodePane.setMinWidth(1); subNodePane.setMinWidth(1);
setMinHeight(24);
setAlignment(Pos.CENTER_LEFT);
setCursor(Cursor.HAND); setCursor(Cursor.HAND);
setAlignment(Pos.CENTER_LEFT);
getChildren().addAll(subNodePane, infoHBox); getChildren().addAll(subNodePane, infoHBox);
} }

View File

@ -71,7 +71,6 @@ final public class EventStripeNode extends EventBundleNodeBase<EventStripe, Even
//setup description label //setup description label
eventTypeImageView.setImage(getEventType().getFXImage()); eventTypeImageView.setImage(getEventType().getFXImage());
descrLabel.setPrefWidth(USE_COMPUTED_SIZE);
descrLabel.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS); descrLabel.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS);
descrLabel.setGraphic(eventTypeImageView); descrLabel.setGraphic(eventTypeImageView);