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