Skip to content

Commit

Permalink
Merge pull request #60 from DEIS-Tools/fix/minor-rc-feedbacks
Browse files Browse the repository at this point in the history
Fix: v1.4.0-rc1 feedback issues & bugs
  • Loading branch information
sillydan1 authored Dec 9, 2022
2 parents fba26c3 + 085db9d commit e9a2989
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -847,24 +847,9 @@ else if (Math.abs(finalLocationX - (newLocationPresentation.getLayoutX())) < off
}
final ListChangeListener<Location> locationListChangeListener = c -> {
if (c.next()) {
// Locations are added to the component
c.getAddedSubList().forEach((loc) -> {
handleAddedLocation.accept(loc);

LocationPresentation locationPresentation = locationPresentationMap.get(loc);

//Ensure that the component is inside the bounds of the component
locationPresentation.setLayoutX(locationPresentation.getController().getDragBounds().trimX(locationPresentation.getLayoutX()));
locationPresentation.setLayoutY(locationPresentation.getController().getDragBounds().trimY(locationPresentation.getLayoutY()));

//Change the layoutXProperty slightly to invoke listener and ensure distance to existing locations
locationPresentation.setLayoutX(locationPresentation.getLayoutX() + 0.00001);
});

// Locations are removed from the component
c.getAddedSubList().forEach(handleAddedLocation);
c.getRemoved().forEach(location -> {
final LocationPresentation locationPresentation = locationPresentationMap.get(location);
modelContainerLocation.getChildren().remove(locationPresentation);
modelContainerLocation.getChildren().remove(locationPresentationMap.get(location));
locationPresentationMap.remove(location);
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/dk/cs/aau/huppaal/logging/LogRegex.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ private static Pattern getPattern() {
sb.append(sep).append(quantifier.name().toLowerCase());
}
// For humans:
// [<display>](<quantifier>:<ref1>/<ref2>?)
var x = "\\[(?<display>[^]]+)]\\((?<quantifier>"+sb+"):(?<link>(?<component>[^/]+)/?(?<identifier>\\S+)?)\\)";
return Pattern.compile(x);
// [<display>](<quantifier>:<component>/<identifier>?)
var z = "\\[(?<display>[^]]+)]\\((?<quantifier>"+sb+"):(?<link>((?<component>[^/]+?)/)?(?<identifier>(\\([^)]*\\))|[^(]+?)+?)\\)";
return Pattern.compile(z);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,10 @@ public CanvasPresentation() {

initializeGrid();

/*
// Center on the component
controller.component.heightProperty().addListener(observable -> {
setTranslateY(getHeight() / 2 - controller.component.getHeight() / 2);
setTranslateX(getWidth() / 2 - controller.component.getWidth() / 2);
});
// Move the component half a grid size to align it to the grid
controller.component.setLayoutX(GRID_SIZE / 2);
controller.component.setLayoutY(GRID_SIZE / 2);
*/
CanvasDragHelper.makeDraggable(this, mouseEvent -> mouseEvent.getButton().equals(MouseButton.SECONDARY));
setOnScroll(e -> {
var dx = getTranslateX() + e.getDeltaX();
var dy = getTranslateY() + e.getDeltaY();
if(e.isShiftDown()) { // shift enables you to scroll with one wheel to the side
dx = getTranslateX() + e.getDeltaY();
dy = getTranslateY() + e.getDeltaX();
}
setTranslateX(dx);
setTranslateY(dy);
setTranslateX(getTranslateX() + e.getDeltaX());
setTranslateY(getTranslateY() + e.getDeltaY());
});
// support trackpads
setOnZoom(e -> ZoomHelper.zoom(e.getZoomFactor()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private void onLinkClick(Hyperlink link) {
var component = SelectHelper.selectComponent(regexComponent);
regexIdentifier.ifPresent(s -> SelectHelper.selectLocation(component, s));
}
case COMPONENT -> SelectHelper.selectComponent(regexComponent);
case COMPONENT -> SelectHelper.selectComponent(regexLink);
case SUBCOMPONENT -> {
if(regexIdentifier.isEmpty())
Log.addWarning(notValidLink);
Expand Down
30 changes: 17 additions & 13 deletions src/main/java/dk/cs/aau/huppaal/presentations/TagPresentation.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.StackPane;
import javafx.scene.shape.LineTo;
Expand All @@ -42,6 +43,9 @@ public class TagPresentation extends StackPane {
private double dragOffsetX, dragOffsetY;
private boolean wasDragged;
private boolean hadInitialFocus = false;
private Path shape;
private JFXTextArea text;
private Label label;

private static double TAG_HEIGHT = 1.6 * GRID_SIZE;

Expand All @@ -54,6 +58,7 @@ public TagPresentation() {
fxmlLoader.setRoot(this);
fxmlLoader.load(location.openStream());

lookupJfxThings();
initializeShape();
initializeLabel();
initializeMouseTransparency();
Expand All @@ -63,6 +68,12 @@ public TagPresentation() {
}
}

private void lookupJfxThings() {
shape = (Path) lookup("#shape");
text = (JFXTextArea) lookup("#textArea");
label = (Label) lookup("#label");
}

private void initializeTextFocusHandler() {

// When a label is loaded do not request focus initially
Expand All @@ -79,20 +90,16 @@ private void initializeMouseTransparency() {
}

private void initializeTextAid() {
var textField = (JFXTextArea) lookup("#textArea");

textField.textProperty().addListener((obs, oldText, newText) -> {
text.textProperty().addListener((obs, oldText, newText) -> {
if (newText.contains(" ")) {
final String updatedString = newText.replace(" ", "_");
textField.setText(updatedString);
text.setText(updatedString);
}
});
}

private void initializeLabel() {
var label = (Label) lookup("#label");
var text = (JFXTextArea) lookup("#textArea");
var shape = (Path) lookup("#shape");
text.setWrapText(false);
var insets = new Insets(0,2,0,2);
text.setPadding(insets);
label.setPadding(insets);
Expand All @@ -101,13 +108,11 @@ private void initializeLabel() {
var newHeight = Math.max(newBounds.getHeight(), TAG_HEIGHT);
var resX = GRID_SIZE * 2 - (newWidth % (GRID_SIZE * 2));
var resY = GRID_SIZE * 2 - (newHeight % (GRID_SIZE * 2));
newWidth += resX;
newHeight += resY;
newWidth += resX + (GRID_SIZE * 0.1);
newHeight += resY + (GRID_SIZE * 0.1);

text.setMinWidth(newWidth);
text.setPrefWidth(newWidth);
text.setMinHeight(TAG_HEIGHT);
text.setPrefHeight(TAG_HEIGHT);
text.setPrefHeight(newHeight);

l2.setX(newWidth);
l3.setX(newWidth);
Expand Down Expand Up @@ -166,7 +171,6 @@ private void stayWithinParent(TextField textField) {
private void initializeShape() {
var width = 5000;
var height = 5000;
var shape = (Path) lookup("#shape");
var start = new MoveTo(0, 0);

l2 = new LineTo(width, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
type="StackPane">
<Path id="shape" StackPane.alignment="CENTER_LEFT" strokeType="INSIDE"/>
<Label id="label" styleClass="sub-caption" StackPane.alignment="CENTER_LEFT" visible="false"/>
<JFXTextArea id="textArea" styleClass="sub-caption" StackPane.alignment="CENTER_LEFT" mouseTransparent="true"/>
<JFXTextArea id="textArea" styleClass="sub-caption, tag-text-area" StackPane.alignment="CENTER_LEFT" mouseTransparent="true"/>
</fx:root>
8 changes: 8 additions & 0 deletions src/main/resources/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,11 @@
-fx-text-fill: #ffa86c;
-fx-fill: #ffa86c;
}
.tag-text-area .scroll-bar:vertical {
-fx-pref-width: 1;
-fx-opacity: 0;
}
.tag-text-area .scroll-bar:horizontal {
-fx-pref-height: 1;
-fx-opacity: 0;
}

0 comments on commit e9a2989

Please sign in to comment.