mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 09:17:42 +00:00
improve default chart tooltip. fixe guideline tooltip. fix guideline drag mouse event handler
This commit is contained in:
parent
00f4f4309f
commit
20debd55e7
@ -72,13 +72,12 @@ import org.sleuthkit.autopsy.timeline.events.RefreshRequestedEvent;
|
||||
* common history context menu items out of derived classes? -jm
|
||||
*/
|
||||
public abstract class AbstractVisualizationPane<X, Y, N, C extends XYChart<X, Y> & TimeLineChart<X>> extends BorderPane {
|
||||
|
||||
@NbBundle.Messages("AbstractVisualization.Drag_Tooltip.text=Drag the mouse to select a time interval to zoom into.")
|
||||
private static final Tooltip DRAG_TOOLTIP = new Tooltip(Bundle.AbstractVisualization_Drag_Tooltip_text());
|
||||
@NbBundle.Messages("AbstractVisualization.Default_Tooltip.text=Drag the mouse to select a time interval to zoom into.\nRight-click for more actions.")
|
||||
private static final Tooltip DEFAULT_TOOLTIP = new Tooltip(Bundle.AbstractVisualization_Default_Tooltip_text());
|
||||
private static final Logger LOGGER = Logger.getLogger(AbstractVisualizationPane.class.getName());
|
||||
|
||||
public static Tooltip getDragTooltip() {
|
||||
return DRAG_TOOLTIP;
|
||||
public static Tooltip getDefaultTooltip() {
|
||||
return DEFAULT_TOOLTIP;
|
||||
}
|
||||
protected final SimpleBooleanProperty hasEvents = new SimpleBooleanProperty(true);
|
||||
|
||||
@ -242,16 +241,16 @@ public abstract class AbstractVisualizationPane<X, Y, N, C extends XYChart<X, Y>
|
||||
});
|
||||
|
||||
TimeLineController.getTimeZone().addListener(invalidationListener);
|
||||
|
||||
|
||||
//show tooltip text in status bar
|
||||
hoverProperty().addListener((observable, oldActivated, newActivated) -> {
|
||||
if (newActivated) {
|
||||
controller.setStatus(DRAG_TOOLTIP.getText());
|
||||
controller.setStatus(DEFAULT_TOOLTIP.getText());
|
||||
} else {
|
||||
controller.setStatus("");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ public class CountsViewPane extends AbstractVisualizationPane<String, Number, No
|
||||
chart.setData(dataSets);
|
||||
setCenter(chart);
|
||||
|
||||
Tooltip.install(chart, getDragTooltip());
|
||||
Tooltip.install(chart, getDefaultTooltip());
|
||||
|
||||
settingsNodes = new ArrayList<>(new CountsViewSettingsPane().getChildrenUnmodifiable());
|
||||
|
||||
|
@ -175,7 +175,7 @@ public abstract class EventBundleNodeBase<BundleType extends EventBundle<ParentT
|
||||
* surprisingly large impact on speed of loading the chart
|
||||
*/
|
||||
installTooltip();
|
||||
Tooltip.uninstall(chart, AbstractVisualizationPane.getDragTooltip());
|
||||
Tooltip.uninstall(chart, AbstractVisualizationPane.getDefaultTooltip());
|
||||
showHoverControls(true);
|
||||
toFront();
|
||||
});
|
||||
@ -184,7 +184,7 @@ public abstract class EventBundleNodeBase<BundleType extends EventBundle<ParentT
|
||||
if (parentNode != null) {
|
||||
parentNode.showHoverControls(true);
|
||||
} else {
|
||||
Tooltip.install(chart, AbstractVisualizationPane.getDragTooltip());
|
||||
Tooltip.install(chart, AbstractVisualizationPane.getDefaultTooltip());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -57,7 +57,6 @@ import javafx.scene.control.ContextMenu;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.MouseButton;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.shape.Line;
|
||||
import javafx.scene.shape.StrokeLineCap;
|
||||
@ -200,7 +199,7 @@ public final class EventDetailsChart extends XYChart<DateTime, EventCluster> imp
|
||||
projectionMap.clear();
|
||||
controller.selectEventIDs(Collections.emptyList());
|
||||
});
|
||||
Tooltip.install(this, AbstractVisualizationPane.getDragTooltip());
|
||||
Tooltip.install(this, AbstractVisualizationPane.getDefaultTooltip());
|
||||
|
||||
dateAxis.setAutoRanging(false);
|
||||
|
||||
@ -430,7 +429,7 @@ public final class EventDetailsChart extends XYChart<DateTime, EventCluster> imp
|
||||
nodeGroup.setTranslateY(-d * h);
|
||||
}
|
||||
|
||||
private void clearGuideLine() {
|
||||
void clearGuideLine() {
|
||||
getChartChildren().remove(guideLine);
|
||||
guideLine = null;
|
||||
}
|
||||
@ -612,16 +611,11 @@ public final class EventDetailsChart extends XYChart<DateTime, EventCluster> imp
|
||||
setGraphic(new ImageView(MARKER)); // NON-NLS
|
||||
setEventHandler(actionEvent -> {
|
||||
if (guideLine == null) {
|
||||
guideLine = new GuideLine(0, 0, 0, getHeight(), getXAxis());
|
||||
guideLine = new GuideLine(0, 0, 0, getHeight(), EventDetailsChart.this);
|
||||
guideLine.relocate(sceneToLocal(clickEvent.getSceneX(), 0).getX(), 0);
|
||||
guideLine.endYProperty().bind(heightProperty().subtract(getXAxis().heightProperty().subtract(getXAxis().tickLengthProperty())));
|
||||
getChartChildren().add(guideLine);
|
||||
guideLine.setOnMouseClicked(mouseEvent -> {
|
||||
if (mouseEvent.getButton() == MouseButton.SECONDARY) {
|
||||
clearGuideLine();
|
||||
mouseEvent.consume();
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
guideLine.relocate(sceneToLocal(clickEvent.getSceneX(), 0).getX(), 0);
|
||||
}
|
||||
|
@ -18,31 +18,40 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.timeline.ui.detailview;
|
||||
|
||||
import javafx.beans.binding.StringBinding;
|
||||
import javafx.scene.Cursor;
|
||||
import javafx.scene.chart.Axis;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.input.MouseButton;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Line;
|
||||
import org.joda.time.DateTime;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.timeline.TimeLineController;
|
||||
import org.sleuthkit.autopsy.timeline.ui.AbstractVisualizationPane;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@NbBundle.Messages({"GuideLine.tooltip.text={0}\nRight-click to remove.\nRight-drag to reposition."})
|
||||
@NbBundle.Messages({"GuideLine.tooltip.text={0}\nRight-click to remove.\nDrag to reposition."})
|
||||
class GuideLine extends Line {
|
||||
|
||||
private final Axis<DateTime> dateAxis;
|
||||
private static final Tooltip CHART_DEFAULT_TOOLTIP = AbstractVisualizationPane.getDefaultTooltip();
|
||||
|
||||
private Tooltip tooltip = new Tooltip();
|
||||
|
||||
private double startLayoutX;
|
||||
private double dragStartX = 0;
|
||||
private final EventDetailsChart chart;
|
||||
|
||||
GuideLine(double startX, double startY, double endX, double endY, Axis<DateTime> axis) {
|
||||
/**
|
||||
*
|
||||
* @param startX
|
||||
* @param startY
|
||||
* @param endX
|
||||
* @param endY
|
||||
* @param chart
|
||||
*/
|
||||
GuideLine(double startX, double startY, double endX, double endY, EventDetailsChart chart) {
|
||||
super(startX, startY, endX, endY);
|
||||
dateAxis = axis;
|
||||
this.chart = chart;
|
||||
//TODO: assign via css
|
||||
setCursor(Cursor.E_RESIZE);
|
||||
getStrokeDashArray().setAll(5.0, 5.0);
|
||||
@ -51,17 +60,16 @@ class GuideLine extends Line {
|
||||
setStrokeWidth(3);
|
||||
|
||||
Tooltip.install(this, tooltip);
|
||||
tooltip.textProperty().bind(new StringBinding() {
|
||||
{
|
||||
bind(layoutXProperty());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String computeValue() {
|
||||
return Bundle.GuideLine_tooltip_text(formatSpan(getDateTime()));
|
||||
tooltip.setOnShowing(windowEvent -> tooltip.setText(Bundle.GuideLine_tooltip_text(getDateTimeAsString())));
|
||||
setOnMouseEntered(entered -> Tooltip.uninstall(chart, CHART_DEFAULT_TOOLTIP));
|
||||
setOnMouseExited(exited -> Tooltip.install(chart, CHART_DEFAULT_TOOLTIP));
|
||||
setOnMouseClicked(mouseEvent -> {
|
||||
if (mouseEvent.getButton() == MouseButton.SECONDARY
|
||||
&& mouseEvent.isStillSincePress() == false) {
|
||||
chart.clearGuideLine();
|
||||
mouseEvent.consume();
|
||||
}
|
||||
});
|
||||
// setOnMouseEntered(enteredEvent -> updateToolTipText());
|
||||
setOnMousePressed(pressedEvent -> {
|
||||
startLayoutX = getLayoutX();
|
||||
dragStartX = pressedEvent.getScreenX();
|
||||
@ -69,24 +77,12 @@ class GuideLine extends Line {
|
||||
setOnMouseDragged(dragEvent -> {
|
||||
double dX = dragEvent.getScreenX() - dragStartX;
|
||||
relocate(startLayoutX + dX, 0);
|
||||
// updateToolTipText();
|
||||
dragEvent.consume();
|
||||
});
|
||||
}
|
||||
|
||||
private void updateToolTipText() {
|
||||
Tooltip.uninstall(this, tooltip);
|
||||
|
||||
tooltip = new Tooltip(Bundle.GuideLine_tooltip_text(formatSpan(getDateTime())));
|
||||
Tooltip.install(this, tooltip);
|
||||
}
|
||||
|
||||
private String formatSpan(DateTime date) {
|
||||
return date.toString(TimeLineController.getZonedFormatter());
|
||||
}
|
||||
|
||||
private DateTime getDateTime() {
|
||||
return dateAxis.getValueForDisplay(dateAxis.parentToLocal(getLayoutX(), 0).getX());
|
||||
private String getDateTimeAsString() {
|
||||
return chart.getDateTimeForPosition(getLayoutX()).toString(TimeLineController.getZonedFormatter());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user