From 5f6bb143e42774f10d48c34edd10a0f15a9a29d7 Mon Sep 17 00:00:00 2001 From: EFCO Date: Wed, 20 Sep 2023 11:24:10 +0200 Subject: [PATCH 01/85] Add FeatureEntryPoint to SVGTextFigure --- .../java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java index a96bb5211..a42605d18 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java @@ -7,6 +7,7 @@ */ package org.jhotdraw.samples.svg.figures; +import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; import org.jhotdraw.draw.figure.TextHolderFigure; import java.awt.*; import java.awt.font.*; @@ -67,6 +68,7 @@ public SVGTextFigure() { this("Text"); } + @FeatureEntryPoint("SVGTextFigure") public SVGTextFigure(String text) { setText(text); SVGAttributeKeys.setDefaults(this); From 1074690dd915bb5d072d75b31e695721ca060ac9 Mon Sep 17 00:00:00 2001 From: EFCO Date: Wed, 20 Sep 2023 11:35:22 +0200 Subject: [PATCH 02/85] And main... For good measure --- .../src/main/java/org/jhotdraw/samples/svg/Main.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java index 11e156729..fe0eff071 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java @@ -7,6 +7,7 @@ */ package org.jhotdraw.samples.svg; +import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; import org.jhotdraw.api.app.Application; import org.jhotdraw.app.OSXApplication; import org.jhotdraw.app.SDIApplication; @@ -26,6 +27,7 @@ public class Main { /** * Creates a new instance. */ + @FeatureEntryPoint("Main") public static void main(String[] args) { // Debug resource bundle ResourceBundleUtil.setVerbose(true); From 79fda83723c13c52aeaba105e1f52f054e0ab6f6 Mon Sep 17 00:00:00 2001 From: Siole Date: Wed, 20 Sep 2023 11:39:57 +0200 Subject: [PATCH 03/85] Added feature annotations for rectangle --- .../src/main/java/org/jhotdraw/samples/svg/Main.java | 2 ++ .../java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java index 11e156729..cead7002c 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java @@ -7,6 +7,7 @@ */ package org.jhotdraw.samples.svg; +import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; import org.jhotdraw.api.app.Application; import org.jhotdraw.app.OSXApplication; import org.jhotdraw.app.SDIApplication; @@ -26,6 +27,7 @@ public class Main { /** * Creates a new instance. */ + @FeatureEntryPoint(value = "Main") public static void main(String[] args) { // Debug resource bundle ResourceBundleUtil.setVerbose(true); diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java index d1ba6eae5..4f03e32bb 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java @@ -10,6 +10,8 @@ import java.awt.*; import java.awt.geom.*; import java.util.*; + +import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; import org.jhotdraw.draw.*; import static org.jhotdraw.draw.AttributeKeys.FILL_COLOR; import static org.jhotdraw.draw.AttributeKeys.STROKE_CAP; @@ -80,6 +82,7 @@ public SVGRectFigure(double x, double y, double width, double height) { this(x, y, width, height, 0, 0); } + @FeatureEntryPoint("RectangleEntry") public SVGRectFigure(double x, double y, double width, double height, double rx, double ry) { roundrect = new RoundRectangle2D.Double(x, y, width, height, rx, ry); SVGAttributeKeys.setDefaults(this); From c371d4eb1d46af21dd66ceb87b0e8bf2c8fe76e4 Mon Sep 17 00:00:00 2001 From: Siole Date: Wed, 20 Sep 2023 11:42:58 +0200 Subject: [PATCH 04/85] Update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 24f860174..3e751f712 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ nb-configuration.xml .idea/* *.ftf /jhotdraw-samples/jhotdraw-samples-misc/nbproject/ +jhotdraw-samples/jhotdraw-samples-misc/pom.xml From 62cb1d0dd3f4f712dca01a3797135457a4dcf798 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 20 Sep 2023 11:44:32 +0200 Subject: [PATCH 05/85] Add FeatureEntryPoint for EllipseTool --- .../org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java index af2de2f19..2236b3171 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java @@ -10,6 +10,8 @@ import java.awt.*; import java.awt.geom.*; import java.util.*; + +import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; import org.jhotdraw.draw.*; import static org.jhotdraw.draw.AttributeKeys.FILL_COLOR; import static org.jhotdraw.draw.AttributeKeys.TRANSFORM; @@ -49,6 +51,7 @@ public SVGEllipseFigure() { this(0, 0, 0, 0); } + @FeatureEntryPoint("SVGEllipseTool") public SVGEllipseFigure(double x, double y, double width, double height) { ellipse = new Ellipse2D.Double(x, y, width, height); SVGAttributeKeys.setDefaults(this); From 8009d0b4c7df8ba5371130525d1ab547443d2267 Mon Sep 17 00:00:00 2001 From: GustavFrandsen Date: Wed, 20 Sep 2023 11:45:24 +0200 Subject: [PATCH 06/85] added entrypoints --- .../src/main/java/org/jhotdraw/samples/svg/Main.java | 2 ++ .../java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java index 11e156729..fe0eff071 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java @@ -7,6 +7,7 @@ */ package org.jhotdraw.samples.svg; +import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; import org.jhotdraw.api.app.Application; import org.jhotdraw.app.OSXApplication; import org.jhotdraw.app.SDIApplication; @@ -26,6 +27,7 @@ public class Main { /** * Creates a new instance. */ + @FeatureEntryPoint("Main") public static void main(String[] args) { // Debug resource bundle ResourceBundleUtil.setVerbose(true); diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java index bb6152c85..34b4c6d14 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java @@ -7,6 +7,7 @@ */ package org.jhotdraw.samples.svg.figures; +import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; import org.jhotdraw.draw.figure.ImageHolderFigure; import java.awt.*; import java.awt.event.*; @@ -67,6 +68,7 @@ public SVGImageFigure() { this(0, 0, 0, 0); } + @FeatureEntryPoint("image") public SVGImageFigure(double x, double y, double width, double height) { rectangle = new Rectangle2D.Double(x, y, width, height); SVGAttributeKeys.setDefaults(this); From e8d08dc90691fc2cc78673c6dc635c6da3122b08 Mon Sep 17 00:00:00 2001 From: GustavFrandsen Date: Wed, 20 Sep 2023 11:46:15 +0200 Subject: [PATCH 07/85] Revert "added entrypoints" This reverts commit 8009d0b4c7df8ba5371130525d1ab547443d2267. --- .../src/main/java/org/jhotdraw/samples/svg/Main.java | 2 -- .../java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java | 2 -- 2 files changed, 4 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java index fe0eff071..11e156729 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java @@ -7,7 +7,6 @@ */ package org.jhotdraw.samples.svg; -import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; import org.jhotdraw.api.app.Application; import org.jhotdraw.app.OSXApplication; import org.jhotdraw.app.SDIApplication; @@ -27,7 +26,6 @@ public class Main { /** * Creates a new instance. */ - @FeatureEntryPoint("Main") public static void main(String[] args) { // Debug resource bundle ResourceBundleUtil.setVerbose(true); diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java index 34b4c6d14..bb6152c85 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java @@ -7,7 +7,6 @@ */ package org.jhotdraw.samples.svg.figures; -import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; import org.jhotdraw.draw.figure.ImageHolderFigure; import java.awt.*; import java.awt.event.*; @@ -68,7 +67,6 @@ public SVGImageFigure() { this(0, 0, 0, 0); } - @FeatureEntryPoint("image") public SVGImageFigure(double x, double y, double width, double height) { rectangle = new Rectangle2D.Double(x, y, width, height); SVGAttributeKeys.setDefaults(this); From 8e5fbd77b3a99335b570587387b593d7144aeb4f Mon Sep 17 00:00:00 2001 From: GustavFrandsen Date: Wed, 20 Sep 2023 11:47:03 +0200 Subject: [PATCH 08/85] added entrypoint --- .../samples/svg/figures/SVGImageFigure.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java index bb6152c85..2c66a85f3 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java @@ -7,7 +7,9 @@ */ package org.jhotdraw.samples.svg.figures; +import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; import org.jhotdraw.draw.figure.ImageHolderFigure; + import java.awt.*; import java.awt.event.*; import java.awt.geom.*; @@ -16,8 +18,11 @@ import java.util.*; import javax.imageio.ImageIO; import javax.swing.*; + import org.jhotdraw.draw.*; + import static org.jhotdraw.draw.AttributeKeys.TRANSFORM; + import org.jhotdraw.draw.event.TransformRestoreEdit; import org.jhotdraw.draw.handle.BoundsOutlineHandle; import org.jhotdraw.draw.handle.Handle; @@ -25,7 +30,9 @@ import org.jhotdraw.draw.handle.TransformHandleKit; import org.jhotdraw.geom.GrowStroke; import org.jhotdraw.samples.svg.SVGAttributeKeys; + import static org.jhotdraw.samples.svg.SVGAttributeKeys.*; + import org.jhotdraw.util.*; /** @@ -67,6 +74,7 @@ public SVGImageFigure() { this(0, 0, 0, 0); } + @FeatureEntryPoint("Image") public SVGImageFigure(double x, double y, double width, double height) { rectangle = new Rectangle2D.Double(x, y, width, height); SVGAttributeKeys.setDefaults(this); @@ -230,8 +238,8 @@ public void restoreTransformTo(Object geometry) { @Override public Object getTransformRestoreData() { return new Object[]{ - rectangle.clone(), - get(TRANSFORM) + rectangle.clone(), + get(TRANSFORM) }; } @@ -361,11 +369,10 @@ public void invalidate() { * imageData array instead of cloning it. Do not modify the imageData * array after invoking this method. * - * - * @param imageData The image data. If this is null, a buffered image must - * be provided. + * @param imageData The image data. If this is null, a buffered image must + * be provided. * @param bufferedImage An image constructed from the imageData. If this - * is null, imageData must be provided. + * is null, imageData must be provided. */ @Override public void setImage(byte[] imageData, BufferedImage bufferedImage) { From 3da03301f86de37abf1da30d819449f3399ff2b1 Mon Sep 17 00:00:00 2001 From: BJLUN21 Date: Thu, 21 Sep 2023 16:30:49 +0200 Subject: [PATCH 09/85] FeatureEntryPoints --- .../src/main/java/org/jhotdraw/action/edit/RedoAction.java | 4 ++++ .../src/main/java/org/jhotdraw/action/edit/UndoAction.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/RedoAction.java b/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/RedoAction.java index 794ab08c8..d8489542a 100644 --- a/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/RedoAction.java +++ b/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/RedoAction.java @@ -10,6 +10,8 @@ import java.awt.event.*; import java.beans.*; import javax.swing.*; + +import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; import org.jhotdraw.action.AbstractViewAction; import org.jhotdraw.api.app.Application; import org.jhotdraw.api.app.View; @@ -52,6 +54,8 @@ public void propertyChange(PropertyChangeEvent evt) { /** * Creates a new instance. */ + + @FeatureEntryPoint("RedoAction") public RedoAction(Application app, View view) { super(app, view); labels.configureAction(this, ID); diff --git a/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/UndoAction.java b/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/UndoAction.java index 74c4f2cea..a8e8d2713 100644 --- a/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/UndoAction.java +++ b/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/UndoAction.java @@ -10,6 +10,8 @@ import java.awt.event.*; import java.beans.*; import javax.swing.*; + +import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; import org.jhotdraw.action.AbstractViewAction; import org.jhotdraw.api.app.Application; import org.jhotdraw.api.app.View; @@ -51,6 +53,8 @@ public void propertyChange(PropertyChangeEvent evt) { /** * Creates a new instance. */ + + @FeatureEntryPoint("UndoAction") public UndoAction(Application app, View view) { super(app, view); labels.configureAction(this, ID); From 735204853f4df22adf9cc5c0a0ea3dbdbbb2bc60 Mon Sep 17 00:00:00 2001 From: Kemoe19 Date: Thu, 21 Sep 2023 16:57:27 +0200 Subject: [PATCH 10/85] FeatureEntryPoint basic editting tools --- .../src/main/java/org/jhotdraw/action/edit/CopyAction.java | 3 +++ .../src/main/java/org/jhotdraw/action/edit/CutAction.java | 3 +++ .../src/main/java/org/jhotdraw/action/edit/DeleteAction.java | 3 +++ .../main/java/org/jhotdraw/action/edit/DuplicateAction.java | 3 +++ .../src/main/java/org/jhotdraw/action/edit/PasteAction.java | 4 ++++ 5 files changed, 16 insertions(+) diff --git a/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/CopyAction.java b/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/CopyAction.java index 208e82405..e49d67773 100644 --- a/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/CopyAction.java +++ b/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/CopyAction.java @@ -10,6 +10,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; + +import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; import org.jhotdraw.datatransfer.ClipboardUtil; import org.jhotdraw.util.*; @@ -48,6 +50,7 @@ public CopyAction() { * @param target The target of the action. Specify null for the currently * focused component. */ +@FeatureEntryPoint(value="CopyAction") public CopyAction(JComponent target) { super(target); ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.action.Labels"); diff --git a/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/CutAction.java b/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/CutAction.java index 044bb4aa7..3396158b1 100644 --- a/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/CutAction.java +++ b/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/CutAction.java @@ -10,6 +10,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; + +import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; import org.jhotdraw.datatransfer.ClipboardUtil; import org.jhotdraw.util.*; @@ -48,6 +50,7 @@ public CutAction() { * @param target The target of the action. Specify null for the currently * focused component. */ + @FeatureEntryPoint(value="CutAction") public CutAction(JComponent target) { super(target); ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.action.Labels"); diff --git a/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/DeleteAction.java b/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/DeleteAction.java index 05ae13f58..ef7df88f8 100644 --- a/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/DeleteAction.java +++ b/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/DeleteAction.java @@ -13,6 +13,8 @@ import java.beans.PropertyChangeListener; import javax.swing.JComponent; import javax.swing.text.*; + +import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; import org.jhotdraw.api.gui.EditableComponent; import org.jhotdraw.beans.WeakPropertyChangeListener; import org.jhotdraw.util.*; @@ -89,6 +91,7 @@ public DeleteAction(JComponent target) { * @param target The target of the action. Specify null for the currently * focused component. */ + @FeatureEntryPoint(value="DeleteAction") protected DeleteAction(JComponent target, String id) { super(id); this.target = target; diff --git a/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/DuplicateAction.java b/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/DuplicateAction.java index 5c7fa23ab..f368b6a3b 100644 --- a/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/DuplicateAction.java +++ b/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/DuplicateAction.java @@ -10,6 +10,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; + +import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; import org.jhotdraw.api.gui.EditableComponent; import org.jhotdraw.util.*; @@ -63,6 +65,7 @@ public DuplicateAction() { * @param target The target of the action. Specify null for the currently * focused component. */ + @FeatureEntryPoint(value="DuplicateAction") public DuplicateAction(JComponent target) { super(target); ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.action.Labels"); diff --git a/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/PasteAction.java b/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/PasteAction.java index 44f3a0953..ea04044ed 100644 --- a/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/PasteAction.java +++ b/jhotdraw-actions/src/main/java/org/jhotdraw/action/edit/PasteAction.java @@ -11,6 +11,8 @@ import java.awt.datatransfer.*; import java.awt.event.*; import javax.swing.*; + +import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; import org.jhotdraw.datatransfer.ClipboardUtil; import org.jhotdraw.util.*; @@ -49,6 +51,8 @@ public PasteAction() { * @param target The target of the action. Specify null for the currently * focused component. */ + @FeatureEntryPoint(value="PasteAction") + public PasteAction(JComponent target) { super(target); ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.action.Labels"); From 78ad67971f2602ad343cedc70da7e85b0e09b265 Mon Sep 17 00:00:00 2001 From: EFCO Date: Wed, 27 Sep 2023 10:47:07 +0200 Subject: [PATCH 11/85] Remove comment with no useful information --- .../java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java | 1 - 1 file changed, 1 deletion(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java index a42605d18..259bd52a1 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java @@ -327,7 +327,6 @@ public void setEditable(boolean b) { @Override public int getTextColumns() { - //return (getText() == null) ? 4 : Math.min(getText().length(), 4); return 4; } From b03726a125d3e193a8014dca4219c4c7d5ac9f6d Mon Sep 17 00:00:00 2001 From: EFCO Date: Wed, 27 Sep 2023 10:50:23 +0200 Subject: [PATCH 12/85] Remove un-useful comment Removing comments that doesn't provide any useful information --- .../org/jhotdraw/samples/svg/figures/SVGTextFigure.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java index 259bd52a1..69b7b604a 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java @@ -207,10 +207,7 @@ private Shape getTextShape() { break; } tx.rotate(rotates[0]); - /* - if (get(TRANSFORM) != null) { - tx.preConcatenate(get(TRANSFORM)); - }*/ + cachedTextShape = tx.createTransformedShape(textLayout.getOutline(tx)); cachedTextShape = textLayout.getOutline(tx); } @@ -338,18 +335,15 @@ public Font getFont() { @Override public Color getTextColor() { return get(FILL_COLOR); - // return get(TEXT_COLOR); } @Override public Color getFillColor() { return get(FILL_COLOR) == null || get(FILL_COLOR).equals(Color.white) ? Color.black : Color.WHITE; - // return get(FILL_COLOR); } @Override public void setFontSize(float size) { - // put(FONT_SIZE, new Double(size)); Point2D.Double p = new Point2D.Double(0, size); AffineTransform tx = get(TRANSFORM); if (tx != null) { @@ -367,7 +361,6 @@ public void setFontSize(float size) { @Override public float getFontSize() { - // return get(FONT_SIZE).floatValue(); Point2D.Double p = new Point2D.Double(0, get(FONT_SIZE)); AffineTransform tx = get(TRANSFORM); if (tx != null) { From 93ee5301e76b2a542f25a6d07bc551772dd1e2f7 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 27 Sep 2023 10:51:42 +0200 Subject: [PATCH 13/85] Change from nested if statement to an early return if cachedHitShape is not null --- .../samples/svg/figures/SVGEllipseFigure.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java index 2236b3171..07ea9ac8d 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java @@ -131,14 +131,15 @@ private Shape getTransformedShape() { } private Shape getHitShape() { - if (cachedHitShape == null) { - if (get(FILL_COLOR) != null || get(FILL_GRADIENT) != null) { - cachedHitShape = new GrowStroke( - (float) SVGAttributeKeys.getStrokeTotalWidth(this, 1.0) / 2f, - (float) SVGAttributeKeys.getStrokeTotalMiterLimit(this, 1.0)).createStrokedShape(getTransformedShape()); - } else { - cachedHitShape = SVGAttributeKeys.getHitStroke(this, 1.0).createStrokedShape(getTransformedShape()); - } + if (cachedHitShape != null) { + return cachedHitShape; + } + if (get(FILL_COLOR) != null || get(FILL_GRADIENT) != null) { + cachedHitShape = new GrowStroke( + (float) SVGAttributeKeys.getStrokeTotalWidth(this, 1.0) / 2f, + (float) SVGAttributeKeys.getStrokeTotalMiterLimit(this, 1.0)).createStrokedShape(getTransformedShape()); + } else { + cachedHitShape = SVGAttributeKeys.getHitStroke(this, 1.0).createStrokedShape(getTransformedShape()); } return cachedHitShape; } From 6e99e4b6cb397656f3b080b9364f823086faa5e6 Mon Sep 17 00:00:00 2001 From: EFCO Date: Wed, 27 Sep 2023 10:53:26 +0200 Subject: [PATCH 14/85] Remove un-useful comment Removing comments that doesn't provide any useful information --- .../org/jhotdraw/samples/svg/figures/SVGTextFigure.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java index 69b7b604a..18aba4267 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java @@ -368,12 +368,6 @@ public float getFontSize() { Point2D.Double p0 = new Point2D.Double(0, 0); tx.transform(p0, p0); p.y -= p0.y; - /* - try { - tx.inverseTransform(p, p); - } catch (NoninvertibleTransformException ex) { - ex.printStackTrace(); - }*/ } return (float) Math.abs(p.y); } From d92baf86d33a46d36021ee0eb04b55f290bb559e Mon Sep 17 00:00:00 2001 From: EFCO Date: Wed, 27 Sep 2023 10:54:19 +0200 Subject: [PATCH 15/85] Add inline expression Instead of creating new variable, and reatuning immediatly --- .../java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java index 18aba4267..a7fa406a1 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java @@ -420,9 +420,9 @@ public Collection createHandles(int detailLevel) { @Override public Tool getTool(Point2D.Double p) { if (isEditable() && contains(p)) { - TextEditingTool tool = new TextEditingTool(this); - return tool; + return new TextEditingTool(this); } + return null; } From 5058d4897a7c76e236656ca4e5e62367f75d01e3 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 27 Sep 2023 10:54:44 +0200 Subject: [PATCH 16/85] Explicit type argument Handle is replaced with <> --- .../java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java index 07ea9ac8d..7af848873 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java @@ -214,7 +214,7 @@ public Object getTransformRestoreData() { // EDITING @Override public Collection createHandles(int detailLevel) { - LinkedList handles = new LinkedList(); + LinkedList handles = new LinkedList<>(); switch (detailLevel % 2) { case -1: // Mouse hover handles handles.add(new BoundsOutlineHandle(this, false, true)); From f1daf7f0458a70bbf284b353e31e806a82f38855 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 27 Sep 2023 11:01:46 +0200 Subject: [PATCH 17/85] =?UTF-8?q?"static"=20base=20class=20members=20is=20?= =?UTF-8?q?now=20not=20accessed=20via=20derived=20types.=20In=20the=20inte?= =?UTF-8?q?rest=20of=20code=20clarity,=20static=20members=20of=20a=20base?= =?UTF-8?q?=20class=20should=20never=20be=20accessed=20using=20a=20derived?= =?UTF-8?q?=20type=E2=80=99s=20name.=20Doing=20so=20is=20confusing=20and?= =?UTF-8?q?=20could=20create=20the=20illusion=20that=20two=20different=20s?= =?UTF-8?q?tatic=20members=20exist.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java index 7af848873..416561eef 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java @@ -136,10 +136,10 @@ private Shape getHitShape() { } if (get(FILL_COLOR) != null || get(FILL_GRADIENT) != null) { cachedHitShape = new GrowStroke( - (float) SVGAttributeKeys.getStrokeTotalWidth(this, 1.0) / 2f, - (float) SVGAttributeKeys.getStrokeTotalMiterLimit(this, 1.0)).createStrokedShape(getTransformedShape()); + (float) AttributeKeys.getStrokeTotalWidth(this, 1.0) / 2f, + (float) AttributeKeys.getStrokeTotalMiterLimit(this, 1.0)).createStrokedShape(getTransformedShape()); } else { - cachedHitShape = SVGAttributeKeys.getHitStroke(this, 1.0).createStrokedShape(getTransformedShape()); + cachedHitShape = AttributeKeys.getHitStroke(this, 1.0).createStrokedShape(getTransformedShape()); } return cachedHitShape; } From ff8267b59f1896dcca7088a3bb6de609e2f2b847 Mon Sep 17 00:00:00 2001 From: Siole Date: Wed, 27 Sep 2023 11:03:29 +0200 Subject: [PATCH 18/85] Change diamond head in createHandles --- jhotdraw-actions/jhotdraw-actions.iml | 6 +++ jhotdraw-actions/pom.xml | 6 +++ jhotdraw-api/jhotdraw-api.iml | 6 +++ jhotdraw-app/jhotdraw-app.iml | 6 +++ jhotdraw-core/jhotdraw-core.iml | 6 +++ .../jhotdraw-datatransfer.iml | 6 +++ jhotdraw-gui/jhotdraw-gui.iml | 6 +++ .../jhotdraw-samples-mini.iml | 6 +++ .../jhotdraw-samples-misc.iml | 6 +++ .../jhotdraw-samples-misc/pom.xml | 47 ++++++++++++------- .../samples/svg/figures/SVGRectFigure.java | 2 +- jhotdraw-samples/jhotdraw-samples.iml | 6 +++ jhotdraw-utils/jhotdraw-utils.iml | 6 +++ jhotdraw-xml/jhotdraw-xml.iml | 6 +++ jhotdraw.iml | 6 +++ 15 files changed, 109 insertions(+), 18 deletions(-) create mode 100644 jhotdraw-actions/jhotdraw-actions.iml create mode 100644 jhotdraw-api/jhotdraw-api.iml create mode 100644 jhotdraw-app/jhotdraw-app.iml create mode 100644 jhotdraw-core/jhotdraw-core.iml create mode 100644 jhotdraw-datatransfer/jhotdraw-datatransfer.iml create mode 100644 jhotdraw-gui/jhotdraw-gui.iml create mode 100644 jhotdraw-samples/jhotdraw-samples-mini/jhotdraw-samples-mini.iml create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/jhotdraw-samples-misc.iml create mode 100644 jhotdraw-samples/jhotdraw-samples.iml create mode 100644 jhotdraw-utils/jhotdraw-utils.iml create mode 100644 jhotdraw-xml/jhotdraw-xml.iml create mode 100644 jhotdraw.iml diff --git a/jhotdraw-actions/jhotdraw-actions.iml b/jhotdraw-actions/jhotdraw-actions.iml new file mode 100644 index 000000000..eba793956 --- /dev/null +++ b/jhotdraw-actions/jhotdraw-actions.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-actions/pom.xml b/jhotdraw-actions/pom.xml index 5cc33e1c6..3a5747bf1 100644 --- a/jhotdraw-actions/pom.xml +++ b/jhotdraw-actions/pom.xml @@ -24,5 +24,11 @@ jhotdraw-datatransfer ${project.version} + + dk.sdu.cbse + featuretracerlite + 1.1-SNAPSHOT + compile + \ No newline at end of file diff --git a/jhotdraw-api/jhotdraw-api.iml b/jhotdraw-api/jhotdraw-api.iml new file mode 100644 index 000000000..7bd80fa97 --- /dev/null +++ b/jhotdraw-api/jhotdraw-api.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-app/jhotdraw-app.iml b/jhotdraw-app/jhotdraw-app.iml new file mode 100644 index 000000000..1d28c78f5 --- /dev/null +++ b/jhotdraw-app/jhotdraw-app.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-core/jhotdraw-core.iml b/jhotdraw-core/jhotdraw-core.iml new file mode 100644 index 000000000..86849407b --- /dev/null +++ b/jhotdraw-core/jhotdraw-core.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-datatransfer/jhotdraw-datatransfer.iml b/jhotdraw-datatransfer/jhotdraw-datatransfer.iml new file mode 100644 index 000000000..a05f213c9 --- /dev/null +++ b/jhotdraw-datatransfer/jhotdraw-datatransfer.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-gui/jhotdraw-gui.iml b/jhotdraw-gui/jhotdraw-gui.iml new file mode 100644 index 000000000..875f470e9 --- /dev/null +++ b/jhotdraw-gui/jhotdraw-gui.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-mini/jhotdraw-samples-mini.iml b/jhotdraw-samples/jhotdraw-samples-mini/jhotdraw-samples-mini.iml new file mode 100644 index 000000000..5fbc2ca35 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-mini/jhotdraw-samples-mini.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/jhotdraw-samples-misc.iml b/jhotdraw-samples/jhotdraw-samples-misc/jhotdraw-samples-misc.iml new file mode 100644 index 000000000..8b25c3a52 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/jhotdraw-samples-misc.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml index 1d63de64d..60ae9964a 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml +++ b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml @@ -8,7 +8,24 @@ jhotdraw-samples-misc jar + + + github + GitHub external Packages + https://maven.pkg.github.com/sweat-tek/MavenRepository + + + + dk.sdu.cbse + featuretracerlite + 1.1-SNAPSHOT + + + org.aspectj + aspectjweaver + 1.9.9 + ${project.groupId} jhotdraw-core @@ -43,23 +60,19 @@ - - org.codehaus.mojo - exec-maven-plugin - 3.1.0 - - - run-java - install - - java - - - - - org.jhotdraw.samples.svg.Main - - + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + -javaagent:"C:\Users\super\.m2\repository\org\aspectj\aspectjweaver\1.9.9\aspectjweaver-1.9.9.jar" + --add-opens java.base/java.lang=ALL-UNNAMED + + true + always + + \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java index 4f03e32bb..c225c79c8 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java @@ -328,7 +328,7 @@ public Object getTransformRestoreData() { // EDITING @Override public Collection createHandles(int detailLevel) { - LinkedList handles = new LinkedList(); + LinkedList handles = new LinkedList<>(); switch (detailLevel % 2) { case -1: // Mouse hover handles handles.add(new BoundsOutlineHandle(this, false, true)); diff --git a/jhotdraw-samples/jhotdraw-samples.iml b/jhotdraw-samples/jhotdraw-samples.iml new file mode 100644 index 000000000..175c0f99a --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-utils/jhotdraw-utils.iml b/jhotdraw-utils/jhotdraw-utils.iml new file mode 100644 index 000000000..05f6ffccf --- /dev/null +++ b/jhotdraw-utils/jhotdraw-utils.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-xml/jhotdraw-xml.iml b/jhotdraw-xml/jhotdraw-xml.iml new file mode 100644 index 000000000..20162e571 --- /dev/null +++ b/jhotdraw-xml/jhotdraw-xml.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw.iml b/jhotdraw.iml new file mode 100644 index 000000000..80df12701 --- /dev/null +++ b/jhotdraw.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file From f91c99e04ace2b5f3b17c9f0db5bd84e9f86f5d6 Mon Sep 17 00:00:00 2001 From: EFCO Date: Wed, 27 Sep 2023 11:07:47 +0200 Subject: [PATCH 19/85] Fix a lot of code smells MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 👃 --- .../samples/svg/figures/SVGTextFigure.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java index a7fa406a1..9754af47f 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java @@ -75,9 +75,12 @@ public SVGTextFigure(String text) { setConnectable(false); } - // DRAWING + @Override protected void drawText(java.awt.Graphics2D g) { + /* + This method is empty for some reason + */ } @Override @@ -123,7 +126,7 @@ public Rectangle2D.Double getBounds() { text = " "; } FontRenderContext frc = getFontRenderContext(); - HashMap textAttributes = new HashMap(); + HashMap textAttributes = new HashMap<>(); textAttributes.put(TextAttribute.FONT, getFont()); if (get(FONT_UNDERLINE)) { textAttributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); @@ -188,7 +191,7 @@ private Shape getTextShape() { text = " "; } FontRenderContext frc = getFontRenderContext(); - HashMap textAttributes = new HashMap(); + HashMap textAttributes = new HashMap<>(); textAttributes.put(TextAttribute.FONT, getFont()); if (get(FONT_UNDERLINE)) { textAttributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); @@ -295,11 +298,11 @@ public String getText() { @Override public void set(AttributeKey key, T newValue) { - if (key.equals(SVGAttributeKeys.TRANSFORM) - || key.equals(SVGAttributeKeys.FONT_FACE) - || key.equals(SVGAttributeKeys.FONT_BOLD) - || key.equals(SVGAttributeKeys.FONT_ITALIC) - || key.equals(SVGAttributeKeys.FONT_SIZE)) { + if (key.equals(AttributeKeys.TRANSFORM) + || key.equals(AttributeKeys.FONT_FACE) + || key.equals(AttributeKeys.FONT_BOLD) + || key.equals(AttributeKeys.FONT_ITALIC) + || key.equals(AttributeKeys.FONT_SIZE)) { invalidate(); } super.set(key, newValue); @@ -329,7 +332,7 @@ public int getTextColumns() { @Override public Font getFont() { - return SVGAttributeKeys.getFont(this); + return AttributeKeys.getFont(this); } @Override @@ -390,7 +393,7 @@ public Dimension2DDouble getPreferredSize() { @Override public Collection createHandles(int detailLevel) { - LinkedList handles = new LinkedList(); + LinkedList handles = new LinkedList<>(); switch (detailLevel % 2) { case -1: // Mouse hover handles handles.add(new BoundsOutlineHandle(this, false, true)); @@ -407,6 +410,8 @@ public Collection createHandles(int detailLevel) { case 1: TransformHandleKit.addTransformHandles(this, handles); break; + default: + break; } return handles; } From 1dd7f32dcda210245b025734b2f300bab500731e Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Sat, 30 Sep 2023 13:14:11 +0200 Subject: [PATCH 20/85] Change from nested if statement to an early return if cachedHitShape is not null --- jhotdraw-actions/jhotdraw-actions.iml | 6 ++++++ jhotdraw-actions/pom.xml | 6 ++++++ jhotdraw-api/jhotdraw-api.iml | 6 ++++++ jhotdraw-app/jhotdraw-app.iml | 6 ++++++ jhotdraw-core/jhotdraw-core.iml | 6 ++++++ .../jhotdraw-datatransfer.iml | 6 ++++++ jhotdraw-gui/jhotdraw-gui.iml | 6 ++++++ .../jhotdraw-samples-mini.iml | 6 ++++++ .../jhotdraw-samples-misc.iml | 6 ++++++ .../jhotdraw-samples-misc/pom.xml | 19 ++++++++++++++++++- .../samples/svg/figures/SVGEllipseFigure.java | 13 +++++++------ jhotdraw-samples/jhotdraw-samples.iml | 6 ++++++ jhotdraw-utils/jhotdraw-utils.iml | 6 ++++++ jhotdraw-xml/jhotdraw-xml.iml | 6 ++++++ jhotdraw.iml | 6 ++++++ 15 files changed, 103 insertions(+), 7 deletions(-) create mode 100644 jhotdraw-actions/jhotdraw-actions.iml create mode 100644 jhotdraw-api/jhotdraw-api.iml create mode 100644 jhotdraw-app/jhotdraw-app.iml create mode 100644 jhotdraw-core/jhotdraw-core.iml create mode 100644 jhotdraw-datatransfer/jhotdraw-datatransfer.iml create mode 100644 jhotdraw-gui/jhotdraw-gui.iml create mode 100644 jhotdraw-samples/jhotdraw-samples-mini/jhotdraw-samples-mini.iml create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/jhotdraw-samples-misc.iml create mode 100644 jhotdraw-samples/jhotdraw-samples.iml create mode 100644 jhotdraw-utils/jhotdraw-utils.iml create mode 100644 jhotdraw-xml/jhotdraw-xml.iml create mode 100644 jhotdraw.iml diff --git a/jhotdraw-actions/jhotdraw-actions.iml b/jhotdraw-actions/jhotdraw-actions.iml new file mode 100644 index 000000000..440402dea --- /dev/null +++ b/jhotdraw-actions/jhotdraw-actions.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-actions/pom.xml b/jhotdraw-actions/pom.xml index 5cc33e1c6..3a5747bf1 100644 --- a/jhotdraw-actions/pom.xml +++ b/jhotdraw-actions/pom.xml @@ -24,5 +24,11 @@ jhotdraw-datatransfer ${project.version} + + dk.sdu.cbse + featuretracerlite + 1.1-SNAPSHOT + compile + \ No newline at end of file diff --git a/jhotdraw-api/jhotdraw-api.iml b/jhotdraw-api/jhotdraw-api.iml new file mode 100644 index 000000000..89b6c71d0 --- /dev/null +++ b/jhotdraw-api/jhotdraw-api.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-app/jhotdraw-app.iml b/jhotdraw-app/jhotdraw-app.iml new file mode 100644 index 000000000..ae0ce5c8b --- /dev/null +++ b/jhotdraw-app/jhotdraw-app.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-core/jhotdraw-core.iml b/jhotdraw-core/jhotdraw-core.iml new file mode 100644 index 000000000..023f20bee --- /dev/null +++ b/jhotdraw-core/jhotdraw-core.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-datatransfer/jhotdraw-datatransfer.iml b/jhotdraw-datatransfer/jhotdraw-datatransfer.iml new file mode 100644 index 000000000..db3db9a29 --- /dev/null +++ b/jhotdraw-datatransfer/jhotdraw-datatransfer.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-gui/jhotdraw-gui.iml b/jhotdraw-gui/jhotdraw-gui.iml new file mode 100644 index 000000000..6d4441990 --- /dev/null +++ b/jhotdraw-gui/jhotdraw-gui.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-mini/jhotdraw-samples-mini.iml b/jhotdraw-samples/jhotdraw-samples-mini/jhotdraw-samples-mini.iml new file mode 100644 index 000000000..0c48100be --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-mini/jhotdraw-samples-mini.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/jhotdraw-samples-misc.iml b/jhotdraw-samples/jhotdraw-samples-misc/jhotdraw-samples-misc.iml new file mode 100644 index 000000000..eae735470 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/jhotdraw-samples-misc.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml index 1d63de64d..dd9c89947 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml +++ b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml @@ -40,6 +40,11 @@ 4.13.2 test + + dk.sdu.cbse + featuretracerlite + 1.1-SNAPSHOT + @@ -59,7 +64,19 @@ org.jhotdraw.samples.svg.Main - + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + -javaagent:"C:\Users\freja\.m2\repository\org\aspectj\aspectjweaver\1.9.9\aspectjweaver-1.9.9.jar" --add-opens java.base/java.lang=ALL-UNNAMED + + true + always + + \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java index 416561eef..ccb28238b 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java @@ -120,12 +120,13 @@ public boolean contains(Point2D.Double p) { } private Shape getTransformedShape() { - if (cachedTransformedShape == null) { - if (get(TRANSFORM) == null) { - cachedTransformedShape = ellipse; - } else { - cachedTransformedShape = get(TRANSFORM).createTransformedShape(ellipse); - } + if (cachedTransformedShape != null) { + return cachedTransformedShape; + } + if (get(TRANSFORM) == null) { + cachedTransformedShape = ellipse; + } else { + cachedTransformedShape = get(TRANSFORM).createTransformedShape(ellipse); } return cachedTransformedShape; } diff --git a/jhotdraw-samples/jhotdraw-samples.iml b/jhotdraw-samples/jhotdraw-samples.iml new file mode 100644 index 000000000..d286ea838 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-utils/jhotdraw-utils.iml b/jhotdraw-utils/jhotdraw-utils.iml new file mode 100644 index 000000000..23393639a --- /dev/null +++ b/jhotdraw-utils/jhotdraw-utils.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-xml/jhotdraw-xml.iml b/jhotdraw-xml/jhotdraw-xml.iml new file mode 100644 index 000000000..7fb10d7e1 --- /dev/null +++ b/jhotdraw-xml/jhotdraw-xml.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw.iml b/jhotdraw.iml new file mode 100644 index 000000000..03a729190 --- /dev/null +++ b/jhotdraw.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file From 220dbefc48549fc4e73654c4ccfc0b1d256cdfbc Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Sat, 30 Sep 2023 13:56:08 +0200 Subject: [PATCH 21/85] Create a helper class to handle the handleCreation method to avoid duplicate code. --- .../samples/svg/figures/HandleHelper.java | 31 +++++++++++++++++++ .../samples/svg/figures/SVGEllipseFigure.java | 16 +--------- 2 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/HandleHelper.java diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/HandleHelper.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/HandleHelper.java new file mode 100644 index 000000000..37dfa78b6 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/HandleHelper.java @@ -0,0 +1,31 @@ +package org.jhotdraw.samples.svg.figures; + +import org.jhotdraw.draw.figure.Figure; +import org.jhotdraw.draw.handle.BoundsOutlineHandle; +import org.jhotdraw.draw.handle.Handle; +import org.jhotdraw.draw.handle.ResizeHandleKit; +import org.jhotdraw.draw.handle.TransformHandleKit; + +import java.util.Collection; +import java.util.LinkedList; + +public class HandleHelper { + public static Collection createHandles(int detailLevel, Figure figure) { + LinkedList handles = new LinkedList<>(); + switch (detailLevel % 2) { + case -1: // Mouse hover handles + handles.add(new BoundsOutlineHandle(figure, false, true)); + break; + case 0: + ResizeHandleKit.addResizeHandles(figure, handles); + handles.add(new LinkHandle(figure)); + break; + case 1: + TransformHandleKit.addTransformHandles(figure, handles); + break; + default: + break; + } + return handles; + } +} \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java index 2236b3171..f6620a36e 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java @@ -213,21 +213,7 @@ public Object getTransformRestoreData() { // EDITING @Override public Collection createHandles(int detailLevel) { - LinkedList handles = new LinkedList(); - switch (detailLevel % 2) { - case -1: // Mouse hover handles - handles.add(new BoundsOutlineHandle(this, false, true)); - break; - case 0: - ResizeHandleKit.addResizeHandles(this, handles); - handles.add(new LinkHandle(this)); - break; - case 1: - TransformHandleKit.addTransformHandles(this, handles); - break; - default: - break; - } + Collection handles = HandleHelper.createHandles(detailLevel, this); return handles; } From 1b7458af2175bb59f7fe06a96bdf469effa2c339 Mon Sep 17 00:00:00 2001 From: GustavFrandsen Date: Sun, 1 Oct 2023 15:27:53 +0200 Subject: [PATCH 22/85] changed to helper method --- .../samples/svg/figures/SVGImageFigure.java | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java index 2c66a85f3..c6a9aaf6d 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java @@ -246,22 +246,7 @@ public Object getTransformRestoreData() { // EDITING @Override public Collection createHandles(int detailLevel) { - LinkedList handles = new LinkedList(); - switch (detailLevel % 2) { - case -1: // Mouse hover handles - handles.add(new BoundsOutlineHandle(this, false, true)); - break; - case 0: - ResizeHandleKit.addResizeHandles(this, handles); - handles.add(new LinkHandle(this)); - break; - case 1: - TransformHandleKit.addTransformHandles(this, handles); - break; - default: - break; - } - return handles; + return HandleHelper.createHandles(detailLevel, this); } @Override From f53720bcceaf86641b34d17c3743135660a02891 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Tue, 3 Oct 2023 12:38:32 +0200 Subject: [PATCH 23/85] Didn't need to make a new instance of the HandleHelper so this is removed --- .../org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java index f6620a36e..72382adf1 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java @@ -213,8 +213,7 @@ public Object getTransformRestoreData() { // EDITING @Override public Collection createHandles(int detailLevel) { - Collection handles = HandleHelper.createHandles(detailLevel, this); - return handles; + return HandleHelper.createHandles(detailLevel, this); } // CONNECTING From 0710c0be6c5f5dbe5c6ca6511ba1093bf5052822 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:25:10 +0200 Subject: [PATCH 24/85] pom's added for SVG and actions modules --- jhotdraw-actions/pom.xml | 5 +++++ jhotdraw-samples/jhotdraw-samples-misc/pom.xml | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/jhotdraw-actions/pom.xml b/jhotdraw-actions/pom.xml index 5cc33e1c6..7fbb4b7ca 100644 --- a/jhotdraw-actions/pom.xml +++ b/jhotdraw-actions/pom.xml @@ -24,5 +24,10 @@ jhotdraw-datatransfer ${project.version} + + dk.sdu.cbse + featuretracerlite + 1.1-SNAPSHOT + \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml index 1d63de64d..751aee9e9 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml +++ b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml @@ -40,6 +40,11 @@ 4.13.2 test + + dk.sdu.cbse + featuretracerlite + 1.1-SNAPSHOT + From 6cc0ace13de625ff5af01a9b47d955d4c27407bc Mon Sep 17 00:00:00 2001 From: GustavFrandsen Date: Wed, 4 Oct 2023 08:32:49 +0200 Subject: [PATCH 25/85] merged with helper and fixed some code smells --- jhotdraw-actions/jhotdraw-actions.iml | 6 +++++ jhotdraw-api/jhotdraw-api.iml | 6 +++++ jhotdraw-app/jhotdraw-app.iml | 6 +++++ jhotdraw-core/jhotdraw-core.iml | 6 +++++ .../jhotdraw-datatransfer.iml | 6 +++++ jhotdraw-gui/jhotdraw-gui.iml | 6 +++++ .../jhotdraw-samples-mini.iml | 6 +++++ .../jhotdraw-samples-misc.iml | 6 +++++ .../samples/svg/figures/SVGEllipseFigure.java | 2 +- .../samples/svg/figures/SVGImageFigure.java | 25 +++++++------------ jhotdraw-samples/jhotdraw-samples.iml | 6 +++++ jhotdraw-utils/jhotdraw-utils.iml | 6 +++++ jhotdraw-xml/jhotdraw-xml.iml | 6 +++++ jhotdraw.iml | 6 +++++ 14 files changed, 82 insertions(+), 17 deletions(-) create mode 100644 jhotdraw-actions/jhotdraw-actions.iml create mode 100644 jhotdraw-api/jhotdraw-api.iml create mode 100644 jhotdraw-app/jhotdraw-app.iml create mode 100644 jhotdraw-core/jhotdraw-core.iml create mode 100644 jhotdraw-datatransfer/jhotdraw-datatransfer.iml create mode 100644 jhotdraw-gui/jhotdraw-gui.iml create mode 100644 jhotdraw-samples/jhotdraw-samples-mini/jhotdraw-samples-mini.iml create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/jhotdraw-samples-misc.iml create mode 100644 jhotdraw-samples/jhotdraw-samples.iml create mode 100644 jhotdraw-utils/jhotdraw-utils.iml create mode 100644 jhotdraw-xml/jhotdraw-xml.iml create mode 100644 jhotdraw.iml diff --git a/jhotdraw-actions/jhotdraw-actions.iml b/jhotdraw-actions/jhotdraw-actions.iml new file mode 100644 index 000000000..44acc1cd6 --- /dev/null +++ b/jhotdraw-actions/jhotdraw-actions.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-api/jhotdraw-api.iml b/jhotdraw-api/jhotdraw-api.iml new file mode 100644 index 000000000..d1ef438f9 --- /dev/null +++ b/jhotdraw-api/jhotdraw-api.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-app/jhotdraw-app.iml b/jhotdraw-app/jhotdraw-app.iml new file mode 100644 index 000000000..bd066edd5 --- /dev/null +++ b/jhotdraw-app/jhotdraw-app.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-core/jhotdraw-core.iml b/jhotdraw-core/jhotdraw-core.iml new file mode 100644 index 000000000..c83a85415 --- /dev/null +++ b/jhotdraw-core/jhotdraw-core.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-datatransfer/jhotdraw-datatransfer.iml b/jhotdraw-datatransfer/jhotdraw-datatransfer.iml new file mode 100644 index 000000000..5d51b917b --- /dev/null +++ b/jhotdraw-datatransfer/jhotdraw-datatransfer.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-gui/jhotdraw-gui.iml b/jhotdraw-gui/jhotdraw-gui.iml new file mode 100644 index 000000000..3a35f6f7e --- /dev/null +++ b/jhotdraw-gui/jhotdraw-gui.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-mini/jhotdraw-samples-mini.iml b/jhotdraw-samples/jhotdraw-samples-mini/jhotdraw-samples-mini.iml new file mode 100644 index 000000000..f322fc5f0 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-mini/jhotdraw-samples-mini.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/jhotdraw-samples-misc.iml b/jhotdraw-samples/jhotdraw-samples-misc/jhotdraw-samples-misc.iml new file mode 100644 index 000000000..2a8f94c3c --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/jhotdraw-samples-misc.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java index 72382adf1..6084f27fa 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java @@ -31,7 +31,7 @@ * @author Werner Randelshofer * @version $Id$ */ -public class SVGEllipseFigure extends SVGAttributedFigure implements SVGFigure { +public class SVGEllipseFigure extends SVGAttributedFigure implements SVGFigure{ private static final long serialVersionUID = 1L; private Ellipse2D.Double ellipse; diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java index c6a9aaf6d..e0e3a148d 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java @@ -8,6 +8,7 @@ package org.jhotdraw.samples.svg.figures; import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; +import org.jhotdraw.draw.AttributeKeys; import org.jhotdraw.draw.figure.ImageHolderFigure; import java.awt.*; @@ -19,8 +20,6 @@ import javax.imageio.ImageIO; import javax.swing.*; -import org.jhotdraw.draw.*; - import static org.jhotdraw.draw.AttributeKeys.TRANSFORM; import org.jhotdraw.draw.event.TransformRestoreEdit; @@ -84,7 +83,6 @@ public SVGImageFigure(double x, double y, double width, double height) { // DRAWING @Override public void draw(Graphics2D g) { - //super.draw(g); double opacity = get(OPACITY); opacity = Math.min(Math.max(0d, opacity), 1d); if (opacity != 0d) { @@ -151,8 +149,7 @@ public Rectangle2D.Double getBounds() { @Override public Rectangle2D.Double getDrawingArea() { Rectangle2D rx = getTransformedShape().getBounds2D(); - Rectangle2D.Double r = (rx instanceof Rectangle2D.Double) ? (Rectangle2D.Double) rx : new Rectangle2D.Double(rx.getX(), rx.getY(), rx.getWidth(), rx.getHeight()); - return r; + return (rx instanceof Rectangle2D.Double) ? (Rectangle2D.Double) rx : new Rectangle2D.Double(rx.getX(), rx.getY(), rx.getWidth(), rx.getHeight()); } /** @@ -190,8 +187,8 @@ private Shape getTransformedShape() { private Shape getHitShape() { if (cachedHitShape == null) { cachedHitShape = new GrowStroke( - (float) SVGAttributeKeys.getStrokeTotalWidth(this, 1.0) / 2f, - (float) SVGAttributeKeys.getStrokeTotalMiterLimit(this, 1.0)).createStrokedShape(getTransformedShape()); + (float) AttributeKeys.getStrokeTotalWidth(this, 1.0) / 2f, + (float) AttributeKeys.getStrokeTotalMiterLimit(this, 1.0)).createStrokedShape(getTransformedShape()); } return cachedHitShape; } @@ -252,7 +249,7 @@ public Collection createHandles(int detailLevel) { @Override public Collection getActions(Point2D.Double p) { final ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.samples.svg.Labels"); - LinkedList actions = new LinkedList(); + LinkedList actions = new LinkedList<>(); if (get(TRANSFORM) != null) { actions.add(new AbstractAction(labels.getString("edit.removeTransform.text")) { private static final long serialVersionUID = 1L; @@ -401,10 +398,9 @@ public void setBufferedImage(BufferedImage image) { @Override public BufferedImage getBufferedImage() { if (bufferedImage == null && imageData != null) { - //System.out.println("recreateing bufferedImage"); try { bufferedImage = ImageIO.read(new ByteArrayInputStream(imageData)); - } catch (Throwable e) { + } catch (Exception e) { e.printStackTrace(); // If we can't create a buffered image from the image data, // there is no use to keep the image data and try again, so @@ -444,16 +440,13 @@ public byte[] getImageData() { @Override public void loadImage(File file) throws IOException { - InputStream in = new FileInputStream(file); - try { + try (InputStream in = new FileInputStream(file)) { loadImage(in); - } catch (Throwable t) { + } catch (Exception t) { ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels"); IOException e = new IOException(labels.getFormatted("file.failedToLoadImage.message", file.getName())); e.initCause(t); throw e; - } finally { - in.close(); } } @@ -468,7 +461,7 @@ public void loadImage(InputStream in) throws IOException { BufferedImage img; try { img = ImageIO.read(new ByteArrayInputStream(baos.toByteArray())); - } catch (Throwable t) { + } catch (Exception t) { img = null; } if (img == null) { diff --git a/jhotdraw-samples/jhotdraw-samples.iml b/jhotdraw-samples/jhotdraw-samples.iml new file mode 100644 index 000000000..41c73c017 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-utils/jhotdraw-utils.iml b/jhotdraw-utils/jhotdraw-utils.iml new file mode 100644 index 000000000..7c88434ce --- /dev/null +++ b/jhotdraw-utils/jhotdraw-utils.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw-xml/jhotdraw-xml.iml b/jhotdraw-xml/jhotdraw-xml.iml new file mode 100644 index 000000000..e9f8c50f8 --- /dev/null +++ b/jhotdraw-xml/jhotdraw-xml.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/jhotdraw.iml b/jhotdraw.iml new file mode 100644 index 000000000..66a6c9011 --- /dev/null +++ b/jhotdraw.iml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file From 3d459d64be93024e4d83d5c9933a27b761887c07 Mon Sep 17 00:00:00 2001 From: GustavFrandsen <93269565+GustavFrandsen@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:37:32 +0200 Subject: [PATCH 26/85] Delete jhotdraw-actions/jhotdraw-actions.iml --- jhotdraw-actions/jhotdraw-actions.iml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 jhotdraw-actions/jhotdraw-actions.iml diff --git a/jhotdraw-actions/jhotdraw-actions.iml b/jhotdraw-actions/jhotdraw-actions.iml deleted file mode 100644 index 440402dea..000000000 --- a/jhotdraw-actions/jhotdraw-actions.iml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file From e4fc66a7c0d4495f31b670cf8703546799b22362 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:37:43 +0200 Subject: [PATCH 27/85] Delete jhotdraw-api/jhotdraw-api.iml --- jhotdraw-api/jhotdraw-api.iml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 jhotdraw-api/jhotdraw-api.iml diff --git a/jhotdraw-api/jhotdraw-api.iml b/jhotdraw-api/jhotdraw-api.iml deleted file mode 100644 index 89b6c71d0..000000000 --- a/jhotdraw-api/jhotdraw-api.iml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file From 35848eee9042f24237492463458ca9f5a5715813 Mon Sep 17 00:00:00 2001 From: GustavFrandsen <93269565+GustavFrandsen@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:37:56 +0200 Subject: [PATCH 28/85] Delete jhotdraw.iml --- jhotdraw.iml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 jhotdraw.iml diff --git a/jhotdraw.iml b/jhotdraw.iml deleted file mode 100644 index 03a729190..000000000 --- a/jhotdraw.iml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file From 348c24f690784d9692a07e604c170ecaf9c443b5 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:37:57 +0200 Subject: [PATCH 29/85] Delete jhotdraw-app/jhotdraw-app.iml --- jhotdraw-app/jhotdraw-app.iml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 jhotdraw-app/jhotdraw-app.iml diff --git a/jhotdraw-app/jhotdraw-app.iml b/jhotdraw-app/jhotdraw-app.iml deleted file mode 100644 index ae0ce5c8b..000000000 --- a/jhotdraw-app/jhotdraw-app.iml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file From a5ee2b8564222a56699e2acd710d1f21d5295db1 Mon Sep 17 00:00:00 2001 From: GustavFrandsen <93269565+GustavFrandsen@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:38:06 +0200 Subject: [PATCH 30/85] Delete jhotdraw-xml/jhotdraw-xml.iml --- jhotdraw-xml/jhotdraw-xml.iml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 jhotdraw-xml/jhotdraw-xml.iml diff --git a/jhotdraw-xml/jhotdraw-xml.iml b/jhotdraw-xml/jhotdraw-xml.iml deleted file mode 100644 index 7fb10d7e1..000000000 --- a/jhotdraw-xml/jhotdraw-xml.iml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file From 3a2e5ad78d502a6b0c48bef509946bdd4fca0500 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:38:08 +0200 Subject: [PATCH 31/85] Delete jhotdraw-core/jhotdraw-core.iml --- jhotdraw-core/jhotdraw-core.iml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 jhotdraw-core/jhotdraw-core.iml diff --git a/jhotdraw-core/jhotdraw-core.iml b/jhotdraw-core/jhotdraw-core.iml deleted file mode 100644 index 023f20bee..000000000 --- a/jhotdraw-core/jhotdraw-core.iml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file From 85897908b4065490113e1c9ebd59510ccaa85484 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:38:19 +0200 Subject: [PATCH 32/85] Delete jhotdraw-datatransfer/jhotdraw-datatransfer.iml --- jhotdraw-datatransfer/jhotdraw-datatransfer.iml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 jhotdraw-datatransfer/jhotdraw-datatransfer.iml diff --git a/jhotdraw-datatransfer/jhotdraw-datatransfer.iml b/jhotdraw-datatransfer/jhotdraw-datatransfer.iml deleted file mode 100644 index db3db9a29..000000000 --- a/jhotdraw-datatransfer/jhotdraw-datatransfer.iml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file From ed9d893dadb615ff94c2bf840f97b77b0898e723 Mon Sep 17 00:00:00 2001 From: GustavFrandsen <93269565+GustavFrandsen@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:38:21 +0200 Subject: [PATCH 33/85] Delete jhotdraw-utils/jhotdraw-utils.iml --- jhotdraw-utils/jhotdraw-utils.iml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 jhotdraw-utils/jhotdraw-utils.iml diff --git a/jhotdraw-utils/jhotdraw-utils.iml b/jhotdraw-utils/jhotdraw-utils.iml deleted file mode 100644 index 23393639a..000000000 --- a/jhotdraw-utils/jhotdraw-utils.iml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file From 0ac488e85f551a50191cda56c264c3ebcaa5cc58 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:38:28 +0200 Subject: [PATCH 34/85] Delete jhotdraw-gui/jhotdraw-gui.iml --- jhotdraw-gui/jhotdraw-gui.iml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 jhotdraw-gui/jhotdraw-gui.iml diff --git a/jhotdraw-gui/jhotdraw-gui.iml b/jhotdraw-gui/jhotdraw-gui.iml deleted file mode 100644 index 6d4441990..000000000 --- a/jhotdraw-gui/jhotdraw-gui.iml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file From fa9d045a98f3ede920957ff02454de3ebba41919 Mon Sep 17 00:00:00 2001 From: GustavFrandsen <93269565+GustavFrandsen@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:38:34 +0200 Subject: [PATCH 35/85] Delete jhotdraw-samples/jhotdraw-samples.iml --- jhotdraw-samples/jhotdraw-samples.iml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 jhotdraw-samples/jhotdraw-samples.iml diff --git a/jhotdraw-samples/jhotdraw-samples.iml b/jhotdraw-samples/jhotdraw-samples.iml deleted file mode 100644 index d286ea838..000000000 --- a/jhotdraw-samples/jhotdraw-samples.iml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file From 444b711cc76958acf2c841f17f0eace65dcb1574 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:38:42 +0200 Subject: [PATCH 36/85] Delete jhotdraw-samples/jhotdraw-samples-mini/jhotdraw-samples-mini.iml --- .../jhotdraw-samples-mini/jhotdraw-samples-mini.iml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 jhotdraw-samples/jhotdraw-samples-mini/jhotdraw-samples-mini.iml diff --git a/jhotdraw-samples/jhotdraw-samples-mini/jhotdraw-samples-mini.iml b/jhotdraw-samples/jhotdraw-samples-mini/jhotdraw-samples-mini.iml deleted file mode 100644 index 0c48100be..000000000 --- a/jhotdraw-samples/jhotdraw-samples-mini/jhotdraw-samples-mini.iml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file From 2e4d9b987ab389f87c54816fc66f158aa7270010 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:38:52 +0200 Subject: [PATCH 37/85] Delete jhotdraw-samples/jhotdraw-samples-misc/jhotdraw-samples-misc.iml --- .../jhotdraw-samples-misc/jhotdraw-samples-misc.iml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 jhotdraw-samples/jhotdraw-samples-misc/jhotdraw-samples-misc.iml diff --git a/jhotdraw-samples/jhotdraw-samples-misc/jhotdraw-samples-misc.iml b/jhotdraw-samples/jhotdraw-samples-misc/jhotdraw-samples-misc.iml deleted file mode 100644 index eae735470..000000000 --- a/jhotdraw-samples/jhotdraw-samples-misc/jhotdraw-samples-misc.iml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file From a3cf0623e28bec37e41184861d85c29b26e098d1 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 09:02:21 +0200 Subject: [PATCH 38/85] Delete jhotdraw-samples/jhotdraw-samples-misc/pom.xml --- .../jhotdraw-samples-misc/pom.xml | 82 ------------------- 1 file changed, 82 deletions(-) delete mode 100644 jhotdraw-samples/jhotdraw-samples-misc/pom.xml diff --git a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml deleted file mode 100644 index dd9c89947..000000000 --- a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - 4.0.0 - - org.jhotdraw - jhotdraw-samples - 9.1-SNAPSHOT - - jhotdraw-samples-misc - jar - - - ${project.groupId} - jhotdraw-core - ${project.version} - - - org.devzendo - Quaqua - 7.3.4 - - - net.sourceforge.htmlunit - htmlunit - 2.37.0 - - - org.aspectj - aspectjweaver - 1.9.9 - - - ${project.groupId} - jhotdraw-app - ${project.version} - - - junit - junit - 4.13.2 - test - - - dk.sdu.cbse - featuretracerlite - 1.1-SNAPSHOT - - - - - - org.codehaus.mojo - exec-maven-plugin - 3.1.0 - - - run-java - install - - java - - - - - org.jhotdraw.samples.svg.Main - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.2 - - - -javaagent:"C:\Users\freja\.m2\repository\org\aspectj\aspectjweaver\1.9.9\aspectjweaver-1.9.9.jar" --add-opens java.base/java.lang=ALL-UNNAMED - - true - always - - - - - \ No newline at end of file From 5a0bb0a4cef5b20aa64fca360d2653e09cf4bbd2 Mon Sep 17 00:00:00 2001 From: GustavFrandsen Date: Wed, 4 Oct 2023 09:06:26 +0200 Subject: [PATCH 39/85] Revert "Delete jhotdraw-samples/jhotdraw-samples-misc/pom.xml" This reverts commit a3cf0623e28bec37e41184861d85c29b26e098d1. --- .../jhotdraw-samples-misc/pom.xml | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/pom.xml diff --git a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml new file mode 100644 index 000000000..dd9c89947 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml @@ -0,0 +1,82 @@ + + + 4.0.0 + + org.jhotdraw + jhotdraw-samples + 9.1-SNAPSHOT + + jhotdraw-samples-misc + jar + + + ${project.groupId} + jhotdraw-core + ${project.version} + + + org.devzendo + Quaqua + 7.3.4 + + + net.sourceforge.htmlunit + htmlunit + 2.37.0 + + + org.aspectj + aspectjweaver + 1.9.9 + + + ${project.groupId} + jhotdraw-app + ${project.version} + + + junit + junit + 4.13.2 + test + + + dk.sdu.cbse + featuretracerlite + 1.1-SNAPSHOT + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.1.0 + + + run-java + install + + java + + + + + org.jhotdraw.samples.svg.Main + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + -javaagent:"C:\Users\freja\.m2\repository\org\aspectj\aspectjweaver\1.9.9\aspectjweaver-1.9.9.jar" --add-opens java.base/java.lang=ALL-UNNAMED + + true + always + + + + + \ No newline at end of file From 0024d03b1582c757e06c4b8f0d1587d72a42d4ba Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 09:09:24 +0200 Subject: [PATCH 40/85] Not needed for everybody --- jhotdraw-samples/jhotdraw-samples-misc/pom.xml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml index dd9c89947..ad3a69609 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml +++ b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml @@ -65,18 +65,6 @@ org.jhotdraw.samples.svg.Main - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.2 - - - -javaagent:"C:\Users\freja\.m2\repository\org\aspectj\aspectjweaver\1.9.9\aspectjweaver-1.9.9.jar" --add-opens java.base/java.lang=ALL-UNNAMED - - true - always - - \ No newline at end of file From d912c39033171a7825975afacb9c45771e187f7f Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 09:10:10 +0200 Subject: [PATCH 41/85] Not needed anymore as the HandleHelper class is created --- .../org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java index 7d29b69c9..2fef058be 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java @@ -15,10 +15,7 @@ import org.jhotdraw.draw.*; import static org.jhotdraw.draw.AttributeKeys.FILL_COLOR; import static org.jhotdraw.draw.AttributeKeys.TRANSFORM; -import org.jhotdraw.draw.handle.BoundsOutlineHandle; import org.jhotdraw.draw.handle.Handle; -import org.jhotdraw.draw.handle.ResizeHandleKit; -import org.jhotdraw.draw.handle.TransformHandleKit; import org.jhotdraw.geom.Geom; import org.jhotdraw.geom.GrowStroke; import org.jhotdraw.samples.svg.Gradient; From 18cc5dfde81d261bcd955453492f7847ab04c206 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:24:00 +0200 Subject: [PATCH 42/85] .yml file added for setting up the pipeline --- .github/workflows/maven.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/maven.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 000000000..322740147 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,34 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +on: + push: + branches: ["develop"] + pull_request: + branches: ["develop"] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: "17" + distribution: "temurin" + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.xml + + # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive + - name: Update dependency graph + uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 From 6dac0637d5031c7213fbe954a04384bcb0242f2b Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:43:11 +0200 Subject: [PATCH 43/85] Add setting.xml to our project to access the maven repository. --- .github/workflows/maven.yml | 11 +++++++---- settings.xml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 settings.xml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 322740147..fbd3ce4d9 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -20,15 +20,18 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 11 uses: actions/setup-java@v3 with: - java-version: "17" + java-version: "11" distribution: "temurin" cache: maven - name: Build with Maven - run: mvn -B package --file pom.xml + run: mvn -s settings.xml -B package --file pom.xml + env: + USER_NAME: ${{ secrets.USER_NAME }} + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - name: Update dependency graph - uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 + uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d \ No newline at end of file diff --git a/settings.xml b/settings.xml new file mode 100644 index 000000000..de30eb164 --- /dev/null +++ b/settings.xml @@ -0,0 +1,34 @@ + + + + github + + + + + github + + + central + https://repo1.maven.org/maven2 + + + github + GitHub external Packages + https://maven.pkg.github.com/sweat-tek/MavenRepository + + + + + + + + github + ${env.USER_NAME} + ${env.ACCESS_TOKEN} + + + \ No newline at end of file From af3a93e7143ab12b318c1017e7b329499610e33d Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:45:50 +0200 Subject: [PATCH 44/85] Delete unnecessary step --- .github/workflows/maven.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index fbd3ce4d9..cf7930dd2 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -30,8 +30,4 @@ jobs: run: mvn -s settings.xml -B package --file pom.xml env: USER_NAME: ${{ secrets.USER_NAME }} - ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} - - # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - - name: Update dependency graph - uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d \ No newline at end of file + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} \ No newline at end of file From 0d273b0e13f0727cc5c2f5dbcbbe5719b1661832 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:53:18 +0200 Subject: [PATCH 45/85] Not in use anymore since the handlehelper class is created --- .../org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java | 3 --- .../java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java | 4 ---- 2 files changed, 7 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java index 72382adf1..2e55ac888 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java @@ -15,10 +15,7 @@ import org.jhotdraw.draw.*; import static org.jhotdraw.draw.AttributeKeys.FILL_COLOR; import static org.jhotdraw.draw.AttributeKeys.TRANSFORM; -import org.jhotdraw.draw.handle.BoundsOutlineHandle; import org.jhotdraw.draw.handle.Handle; -import org.jhotdraw.draw.handle.ResizeHandleKit; -import org.jhotdraw.draw.handle.TransformHandleKit; import org.jhotdraw.geom.Geom; import org.jhotdraw.geom.GrowStroke; import org.jhotdraw.samples.svg.Gradient; diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java index c6a9aaf6d..170021a7e 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java @@ -19,15 +19,11 @@ import javax.imageio.ImageIO; import javax.swing.*; -import org.jhotdraw.draw.*; import static org.jhotdraw.draw.AttributeKeys.TRANSFORM; import org.jhotdraw.draw.event.TransformRestoreEdit; -import org.jhotdraw.draw.handle.BoundsOutlineHandle; import org.jhotdraw.draw.handle.Handle; -import org.jhotdraw.draw.handle.ResizeHandleKit; -import org.jhotdraw.draw.handle.TransformHandleKit; import org.jhotdraw.geom.GrowStroke; import org.jhotdraw.samples.svg.SVGAttributeKeys; From 8f608b28d7725fcd8a873faf598c1fe7e523ec26 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 11:20:20 +0200 Subject: [PATCH 46/85] Stopping the drawing window from opening when running the install --- .../jhotdraw-samples-misc/pom.xml | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml index 751aee9e9..71a43d736 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml +++ b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 org.jhotdraw @@ -48,23 +49,16 @@ - - org.codehaus.mojo - exec-maven-plugin - 3.1.0 - - - run-java - install - - java - - - - - org.jhotdraw.samples.svg.Main - - + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + true + always + true + + \ No newline at end of file From 3358a195700ed7ac0b3b68c992e951d76f165dfa Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 11:29:27 +0200 Subject: [PATCH 47/85] Add comments about how to get the feature tracer to work again --- .../jhotdraw-samples-misc/pom.xml | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml index 71a43d736..7a2d9edd6 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml +++ b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml @@ -49,11 +49,36 @@ + org.apache.maven.plugins maven-surefire-plugin 2.22.2 + true always true From 6d59391f2a6d420defba8da53096414b303e8d4c Mon Sep 17 00:00:00 2001 From: Siole Date: Fri, 13 Oct 2023 09:39:37 +0200 Subject: [PATCH 48/85] Removed redundant comments from getter/setter methods The comments stated the same as the name of the method and there is no need to use three lines for this. --- .../samples/svg/figures/SVGRectFigure.java | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java index c225c79c8..b9a190284 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java @@ -59,8 +59,7 @@ public class SVGRectFigure extends SVGAttributedFigure implements SVGFigure { double cv = 4.0 / 3.0 * a * b / c; ACV = (1.0 - cv); } - /** - */ + private RoundRectangle2D.Double roundrect; /** * This is used to perform faster drawing. @@ -150,32 +149,20 @@ public double getHeight() { return roundrect.height; } - /** - * Gets the arc width. - */ public double getArcWidth() { return roundrect.arcwidth; } - /** - * Gets the arc height. - */ public double getArcHeight() { return roundrect.archeight; } - /** - * Sets the arc width. - */ public void setArcWidth(double newValue) { double oldValue = roundrect.arcwidth; roundrect.arcwidth = newValue; firePropertyChange(ARC_WIDTH_PROPERTY, oldValue, newValue); } - - /** - * Sets the arc height. - */ + public void setArcHeight(double newValue) { double oldValue = roundrect.archeight; roundrect.archeight = newValue; From 84a9adc0523f38dabde5b3390d4c17cf0bded4da Mon Sep 17 00:00:00 2001 From: Siole Date: Fri, 13 Oct 2023 10:04:29 +0200 Subject: [PATCH 49/85] Encapsulating public attributes Changed two public attributes to private attributes and created getter-methods --- .../org/jhotdraw/samples/svg/figures/SVGRectFigure.java | 9 ++++++--- .../samples/svg/figures/SVGRectRadiusHandle.java | 8 ++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java index b9a190284..0efd6f634 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java @@ -40,11 +40,11 @@ public class SVGRectFigure extends SVGAttributedFigure implements SVGFigure { /** * Identifies the {@code arcWidth} JavaBeans property. */ - public static final String ARC_WIDTH_PROPERTY = "arcWidth"; + private static final String ARC_WIDTH_PROPERTY = "arcWidth"; /** * Identifies the {@code arcHeight} JavaBeans property. */ - public static final String ARC_HEIGHT_PROPERTY = "arcHeight"; + private static final String ARC_HEIGHT_PROPERTY = "arcHeight"; /** * The variable acv is used for generating the locations of the control * points for the rounded rectangle using path.curveTo. @@ -156,13 +156,16 @@ public double getArcWidth() { public double getArcHeight() { return roundrect.archeight; } + public static String getArcWidthProperty(){ return ARC_WIDTH_PROPERTY; } + public static String getArcHeightProperty(){ return ARC_HEIGHT_PROPERTY; } + public void setArcWidth(double newValue) { double oldValue = roundrect.arcwidth; roundrect.arcwidth = newValue; firePropertyChange(ARC_WIDTH_PROPERTY, oldValue, newValue); } - + public void setArcHeight(double newValue) { double oldValue = roundrect.archeight; roundrect.archeight = newValue; diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectRadiusHandle.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectRadiusHandle.java index 5655cf070..bd6af1a26 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectRadiusHandle.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectRadiusHandle.java @@ -111,8 +111,8 @@ public void trackEnd(Point anchor, Point lead, int modifiersEx) { CompositeFigureEdit edit = new CompositeFigureEdit(svgRect, labels.getString("attribute.roundRectRadius")); edit.setVerbose(true); fireUndoableEditHappened(edit); - fireUndoableEditHappened(new PropertyChangeEdit(svgRect, SVGRectFigure.ARC_WIDTH_PROPERTY, oldValue.width, newValue.width)); - fireUndoableEditHappened(new PropertyChangeEdit(svgRect, SVGRectFigure.ARC_HEIGHT_PROPERTY, oldValue.height, newValue.height)); + fireUndoableEditHappened(new PropertyChangeEdit(svgRect, SVGRectFigure.getArcWidthProperty(), oldValue.width, newValue.width)); + fireUndoableEditHappened(new PropertyChangeEdit(svgRect, SVGRectFigure.getArcHeightProperty(), oldValue.height, newValue.height)); fireUndoableEditHappened(edit); } @@ -151,8 +151,8 @@ public void keyPressed(KeyEvent evt) { = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels"); CompositeFigureEdit edit = new CompositeFigureEdit(owner, labels.getString("attribute.roundRectRadius")); fireUndoableEditHappened(edit); - fireUndoableEditHappened(new PropertyChangeEdit(owner, SVGRectFigure.ARC_WIDTH_PROPERTY, oldArc.width, newArc.width)); - fireUndoableEditHappened(new PropertyChangeEdit(owner, SVGRectFigure.ARC_HEIGHT_PROPERTY, oldArc.height, newArc.height)); + fireUndoableEditHappened(new PropertyChangeEdit(owner, SVGRectFigure.getArcWidthProperty(), oldArc.width, newArc.width)); + fireUndoableEditHappened(new PropertyChangeEdit(owner, SVGRectFigure.getArcHeightProperty(), oldArc.height, newArc.height)); fireUndoableEditHappened(edit); } } From 31409b849f374d592bb5b9e02bb76d5fe0e38bfd Mon Sep 17 00:00:00 2001 From: Siole Date: Fri, 13 Oct 2023 11:14:26 +0200 Subject: [PATCH 50/85] Refactor getHitShape() --- .../samples/svg/figures/SVGRectFigure.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java index 0efd6f634..19761b40f 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java @@ -245,16 +245,14 @@ private Shape getTransformedShape() { } private Shape getHitShape() { - if (cachedHitShape == null) { - if (get(FILL_COLOR) != null || get(FILL_GRADIENT) != null) { - cachedHitShape = new GrowStroke( - (float) SVGAttributeKeys.getStrokeTotalWidth(this, 1.0) / 2f, - (float) SVGAttributeKeys.getStrokeTotalMiterLimit(this, 1.0)).createStrokedShape(getTransformedShape()); - } else { - cachedHitShape = SVGAttributeKeys.getHitStroke(this, 1.0).createStrokedShape(getTransformedShape()); - } + if (cachedHitShape != null) {return cachedHitShape;} + if (get(FILL_COLOR) != null || get(FILL_GRADIENT) != null) { + return cachedHitShape = new GrowStroke( + (float) SVGAttributeKeys.getStrokeTotalWidth(this, 1.0) / 2f, + (float) SVGAttributeKeys.getStrokeTotalMiterLimit(this, 1.0)).createStrokedShape(getTransformedShape()); + } else { + return cachedHitShape = SVGAttributeKeys.getHitStroke(this, 1.0).createStrokedShape(getTransformedShape()); } - return cachedHitShape; } /** From f0c21c090799ceb073feee7b305c9f93a014642b Mon Sep 17 00:00:00 2001 From: Siole Date: Mon, 16 Oct 2023 09:28:18 +0200 Subject: [PATCH 51/85] Fixed static access in SVGAttributeKeys Implemented sonarlint suggestions --- .../org/jhotdraw/samples/svg/figures/SVGRectFigure.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java index 19761b40f..6f2627d51 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java @@ -248,10 +248,10 @@ private Shape getHitShape() { if (cachedHitShape != null) {return cachedHitShape;} if (get(FILL_COLOR) != null || get(FILL_GRADIENT) != null) { return cachedHitShape = new GrowStroke( - (float) SVGAttributeKeys.getStrokeTotalWidth(this, 1.0) / 2f, - (float) SVGAttributeKeys.getStrokeTotalMiterLimit(this, 1.0)).createStrokedShape(getTransformedShape()); + (float) AttributeKeys.getStrokeTotalWidth(this, 1.0) / 2f, + (float) AttributeKeys.getStrokeTotalMiterLimit(this, 1.0)).createStrokedShape(getTransformedShape()); } else { - return cachedHitShape = SVGAttributeKeys.getHitStroke(this, 1.0).createStrokedShape(getTransformedShape()); + return cachedHitShape = AttributeKeys.getHitStroke(this, 1.0).createStrokedShape(getTransformedShape()); } } @@ -263,8 +263,7 @@ private Shape getHitShape() { @Override public void transform(AffineTransform tx) { invalidateTransformedShape(); - if (get(TRANSFORM) != null - || // (tx.getType() & (AffineTransform.TYPE_TRANSLATION | AffineTransform.TYPE_MASK_SCALE)) != tx.getType()) { + if (get(TRANSFORM) != null || (tx.getType() & (AffineTransform.TYPE_TRANSLATION)) != tx.getType()) { if (get(TRANSFORM) == null) { set(TRANSFORM, (AffineTransform) tx.clone()); From 67adc453a15207e483901fc05389c2be6aa6707f Mon Sep 17 00:00:00 2001 From: Siole Date: Mon, 16 Oct 2023 11:37:04 +0200 Subject: [PATCH 52/85] refactor transform() Separating the method into two chained methods --- .../samples/svg/figures/SVGRectFigure.java | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java index 6f2627d51..d09563f94 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java @@ -263,8 +263,7 @@ private Shape getHitShape() { @Override public void transform(AffineTransform tx) { invalidateTransformedShape(); - if (get(TRANSFORM) != null || - (tx.getType() & (AffineTransform.TYPE_TRANSLATION)) != tx.getType()) { + if (get(TRANSFORM) != null || (tx.getType() & (AffineTransform.TYPE_TRANSLATION)) != tx.getType()) { if (get(TRANSFORM) == null) { set(TRANSFORM, (AffineTransform) tx.clone()); } else { @@ -273,23 +272,25 @@ public void transform(AffineTransform tx) { set(TRANSFORM, t); } } else { - Point2D.Double anchor = getStartPoint(); - Point2D.Double lead = getEndPoint(); - setBounds( - (Point2D.Double) tx.transform(anchor, anchor), - (Point2D.Double) tx.transform(lead, lead)); - if (get(FILL_GRADIENT) != null - && !get(FILL_GRADIENT).isRelativeToFigureBounds()) { - Gradient g = FILL_GRADIENT.getClone(this); - g.transform(tx); - set(FILL_GRADIENT, g); - } - if (get(STROKE_GRADIENT) != null - && !get(STROKE_GRADIENT).isRelativeToFigureBounds()) { - Gradient g = STROKE_GRADIENT.getClone(this); - g.transform(tx); - set(STROKE_GRADIENT, g); - } + executeTransform(tx); + } + } + + private void executeTransform(AffineTransform tx){ + Point2D.Double anchor = getStartPoint(); + Point2D.Double lead = getEndPoint(); + setBounds( + (Point2D.Double) tx.transform(anchor, anchor), + (Point2D.Double) tx.transform(lead, lead)); + if (get(FILL_GRADIENT) != null && !get(FILL_GRADIENT).isRelativeToFigureBounds()) { + Gradient g = FILL_GRADIENT.getClone(this); + g.transform(tx); + set(FILL_GRADIENT, g); + } + if (get(STROKE_GRADIENT) != null && !get(STROKE_GRADIENT).isRelativeToFigureBounds()) { + Gradient g = STROKE_GRADIENT.getClone(this); + g.transform(tx); + set(STROKE_GRADIENT, g); } } From 5cdbb5bb745ec9da6c262d01e6d4969ddc19e6a8 Mon Sep 17 00:00:00 2001 From: Siole Date: Fri, 27 Oct 2023 09:58:52 +0200 Subject: [PATCH 53/85] Unit testing drawstroke() in SVGRectFigure boundary case --- .../jhotdraw-samples-misc/pom.xml | 6 ++ .../samples/svg/figures/SVGRectFigure.java | 11 ++-- .../svg/figures/SVGRectFigureTest.java | 60 +++++++++++++++++++ 3 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGRectFigureTest.java diff --git a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml index 60ae9964a..430d8bd27 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml +++ b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml @@ -57,6 +57,12 @@ 4.13.2 test + + org.mockito + mockito-core + 3.11.2 + test + diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java index d09563f94..e7a1cbaa8 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java @@ -60,7 +60,7 @@ public class SVGRectFigure extends SVGAttributedFigure implements SVGFigure { ACV = (1.0 - cv); } - private RoundRectangle2D.Double roundrect; + protected RoundRectangle2D.Double roundrect; //used to be private, but changed to protected for testing purposes /** * This is used to perform faster drawing. */ @@ -98,14 +98,17 @@ protected void drawFill(Graphics2D g) { } } + /** + * We have to generate the path for the round rectangle manually, + * because the path of a Java RoundRectangle is drawn counterclockwise + * whereas an SVG rect needs to be drawn clockwise. + * @param g + */ @Override protected void drawStroke(Graphics2D g) { if (roundrect.archeight == 0 && roundrect.arcwidth == 0) { g.draw(roundrect.getBounds2D()); } else { - // We have to generate the path for the round rectangle manually, - // because the path of a Java RoundRectangle is drawn counter clockwise - // whereas an SVG rect needs to be drawn clockwise. Path2D.Double p = new Path2D.Double(); double aw = roundrect.arcwidth / 2d; double ah = roundrect.archeight / 2d; diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGRectFigureTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGRectFigureTest.java new file mode 100644 index 000000000..cd4fb5633 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGRectFigureTest.java @@ -0,0 +1,60 @@ +package org.jhotdraw.samples.svg.figures; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.awt.*; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; + +public class SVGRectFigureTest { + SVGRectFigure svgRectFigure = new SVGRectFigure(); + Graphics2D mockGraphics2D = mock(Graphics2D.class); + + @Before + public void setUp() throws Exception { + + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void transform() { + } + + /** + * Test the state of the figure after calling drawStroke(). + * Test for boundary value analysis, as the figure is a branch if the arcwidth and archeight are 0 using assertEquals(). + */ + @Test + public void drawStrokeCheckState() { + int initialWidth = (int) svgRectFigure.roundrect.width; + + svgRectFigure.roundrect.arcwidth = 0; + svgRectFigure.roundrect.archeight = 0; + + svgRectFigure.drawStroke(mockGraphics2D); + + int finalWidth = (int) svgRectFigure.roundrect.width; + + assertEquals(initialWidth, finalWidth); + } + + /** + * Test that drawStroke() calls Graphics2D.draw() if the figure is a branch. + * Test for boundary value analysis, as the figure is a branch if the arcwidth and archeight are 0. + */ + @Test + public void drawStrokeIfBranchValue0() { + svgRectFigure.roundrect.arcwidth = 0; + svgRectFigure.roundrect.archeight = 0; + + svgRectFigure.drawStroke(mockGraphics2D); + + verify(mockGraphics2D, times(1)).draw(any()); + } +} \ No newline at end of file From aed7ead043d08446e82ea9409188787c936c3afc Mon Sep 17 00:00:00 2001 From: Siole Date: Fri, 27 Oct 2023 10:48:01 +0200 Subject: [PATCH 54/85] unit test drawStroke() else statement --- .../samples/svg/figures/SVGRectFigureTest.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGRectFigureTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGRectFigureTest.java index cd4fb5633..142aa1316 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGRectFigureTest.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGRectFigureTest.java @@ -28,7 +28,8 @@ public void transform() { /** * Test the state of the figure after calling drawStroke(). - * Test for boundary value analysis, as the figure is a branch if the arcwidth and archeight are 0 using assertEquals(). + * Test for boundary value analysis, as the figure is a branch + * if the arcwidth and archeight are 0 using assertEquals(). */ @Test public void drawStrokeCheckState() { @@ -57,4 +58,18 @@ public void drawStrokeIfBranchValue0() { verify(mockGraphics2D, times(1)).draw(any()); } + + /** + * Test that drawStroke() calls Graphics2D.draw() if the figure is a branch. + * Tests else branch of drawStroke(), where values are not 0. + */ + @Test + public void drawStrokeElseBranch() { + svgRectFigure.roundrect.arcwidth = 1; + svgRectFigure.roundrect.archeight = 1; + + svgRectFigure.drawStroke(mockGraphics2D); + + verify(mockGraphics2D, times(1)).draw(any()); + } } \ No newline at end of file From 3068dbd81db5163005d3fba7054d668ac22b0dec Mon Sep 17 00:00:00 2001 From: Siole Date: Fri, 27 Oct 2023 11:43:52 +0200 Subject: [PATCH 55/85] Assertion in createHandles() in SVGRectFigure --- .../java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java index e7a1cbaa8..f5f31cccf 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java @@ -333,7 +333,7 @@ public Collection createHandles(int detailLevel) { TransformHandleKit.addTransformHandles(this, handles); break; default: - break; + assert false; } return handles; } From ecec8c612796ee66d7184dd1e10ad47dbedc95b2 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 8 Nov 2023 08:51:28 +0100 Subject: [PATCH 56/85] Jgiven test for best case (possible to transform ellipse corretly), for no transformation before the method is called and lastly for being able to stack ellipses --- .../jhotdraw-samples-misc/pom.xml | 6 ++ .../svg/figures/SVGEllipseFigureTest.java | 70 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureTest.java diff --git a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml index 7a2d9edd6..b8de09eb2 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml +++ b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml @@ -46,6 +46,12 @@ featuretracerlite 1.1-SNAPSHOT + + com.tngtech.jgiven + jgiven-junit + 1.0.0-RC6 + test + diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureTest.java new file mode 100644 index 000000000..41f0bc65b --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureTest.java @@ -0,0 +1,70 @@ +package org.jhotdraw.samples.svg.figures; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; + +import static org.jhotdraw.draw.AttributeKeys.TRANSFORM; +import static org.junit.Assert.*; + +public class SVGEllipseFigureTest { + + private SVGEllipseFigure ellipseFigure; + + @Before + public void setUp() { + // Initialize a new SVGEllipseFigure for each test method + ellipseFigure = new SVGEllipseFigure(10, 10, 30, 20); + } + + @After + public void tearDown() { + // Set the SVGEllipseFigure to null after each test method + ellipseFigure = null; + } + + @Test + public void testTransformBestCase() { + // Test the transform() method with a best-case scenario + AffineTransform tx = AffineTransform.getTranslateInstance(5, 5); + ellipseFigure.transform(tx); + + // Verify that the figure has been transformed correctly + Rectangle2D.Double bounds = ellipseFigure.getBounds(); + assertEquals(15.0, bounds.getX(), 0.01); + assertEquals(15.0, bounds.getY(), 0.01); + + } + + @Test + public void testTransformNull() { + // Test the transform() method with a null argument + AffineTransform prevTransform = ellipseFigure.get(TRANSFORM); + // Assert that the figure has no transform before the transform() method is called + assertNull(prevTransform); + + } + + @Test + public void testTransformStackable() { + // Made another ellipseFigure to test if the transform() method is stackable + SVGEllipseFigure ellipseFigure2 = new SVGEllipseFigure(10, 10, 35, 25); + // Adds 5 to the x and y coordinates of both ellipseFigures + AffineTransform tx = AffineTransform.getTranslateInstance(5, 5); + + // Transforms both ellipseFigures + ellipseFigure.transform(tx); + ellipseFigure2.transform(tx); + // Verify that the figure has been transformed correctly + Rectangle2D.Double bounds = ellipseFigure.getBounds(); + Rectangle2D.Double bounds2 = ellipseFigure2.getBounds(); + assertEquals(15.0, bounds.getX(), 0.01); + assertEquals(15.0, bounds.getY(), 0.01); + assertEquals(15.0, bounds2.getX(), 0.01); + assertEquals(15.0, bounds2.getY(), 0.01); + + } +} \ No newline at end of file From eb22ba84fb53bd1522bcf5e9b417aebba7fb7255 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 8 Nov 2023 08:53:41 +0100 Subject: [PATCH 57/85] Java assertion included to test for invariants. Secures that the drawing area must not be null. Previous commit correction: JUnit and not Jgiven.. --- .../samples/svg/figures/SVGEllipseFigure.java | 50 ++++++++++++++----- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java index 2fef058be..7cbac2889 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java @@ -7,20 +7,25 @@ */ package org.jhotdraw.samples.svg.figures; -import java.awt.*; -import java.awt.geom.*; -import java.util.*; - import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; -import org.jhotdraw.draw.*; -import static org.jhotdraw.draw.AttributeKeys.FILL_COLOR; -import static org.jhotdraw.draw.AttributeKeys.TRANSFORM; +import org.jhotdraw.draw.AttributeKeys; import org.jhotdraw.draw.handle.Handle; import org.jhotdraw.geom.Geom; import org.jhotdraw.geom.GrowStroke; import org.jhotdraw.samples.svg.Gradient; import org.jhotdraw.samples.svg.SVGAttributeKeys; -import static org.jhotdraw.samples.svg.SVGAttributeKeys.*; + +import java.awt.*; +import java.awt.geom.AffineTransform; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.util.Collection; + +import static org.jhotdraw.draw.AttributeKeys.FILL_COLOR; +import static org.jhotdraw.draw.AttributeKeys.TRANSFORM; +import static org.jhotdraw.samples.svg.SVGAttributeKeys.FILL_GRADIENT; +import static org.jhotdraw.samples.svg.SVGAttributeKeys.STROKE_GRADIENT; /** * SVGEllipse represents a SVG ellipse and a SVG circle element. @@ -96,6 +101,8 @@ public Rectangle2D.Double getBounds() { public Rectangle2D.Double getDrawingArea() { Rectangle2D rx = getTransformedShape().getBounds2D(); Rectangle2D.Double r = (rx instanceof Rectangle2D.Double) ? (Rectangle2D.Double) rx : new Rectangle2D.Double(rx.getX(), rx.getY(), rx.getWidth(), rx.getHeight()); + // Assertion: The drawing area must not be null + assert r != null : "Drawing area is null"; if (get(TRANSFORM) == null) { double g = SVGAttributeKeys.getPerpendicularHitGrowth(this, 1.0) * 2d + 1; Geom.grow(r, g, g); @@ -116,6 +123,9 @@ public boolean contains(Point2D.Double p) { return getHitShape().contains(p); } + /* + * This method is used to determine the transformed shape of the figure. + */ private Shape getTransformedShape() { if (cachedTransformedShape != null) { return cachedTransformedShape; @@ -128,6 +138,9 @@ private Shape getTransformedShape() { return cachedTransformedShape; } + /* + * This method is used to determine the hit shape of the figure. + */ private Shape getHitShape() { if (cachedHitShape != null) { return cachedHitShape; @@ -142,6 +155,10 @@ private Shape getHitShape() { return cachedHitShape; } + /* + * This method is used to determine the drawing area of the figure. + */ + @Override public void setBounds(Point2D.Double anchor, Point2D.Double lead) { ellipse.x = Math.min(anchor.x, lead.x); @@ -189,6 +206,9 @@ public void transform(AffineTransform tx) { invalidate(); } + /* + * This method is used to restore the transform of the figure. + */ @Override public void restoreTransformTo(Object geometry) { Object[] restoreData = (Object[]) geometry; @@ -199,13 +219,16 @@ public void restoreTransformTo(Object geometry) { invalidate(); } + /* + * This method is used to get the transform restore data of the figure. + */ @Override public Object getTransformRestoreData() { return new Object[]{ - ellipse.clone(), - TRANSFORM.getClone(this), - FILL_GRADIENT.getClone(this), - STROKE_GRADIENT.getClone(this)}; + ellipse.clone(), + TRANSFORM.getClone(this), + FILL_GRADIENT.getClone(this), + STROKE_GRADIENT.getClone(this)}; } // ATTRIBUTES @@ -218,6 +241,9 @@ public Collection createHandles(int detailLevel) { // CONNECTING // COMPOSITE FIGURES // CLONING + /* + * This method is used to clone the figure. + */ @Override public SVGEllipseFigure clone() { SVGEllipseFigure that = (SVGEllipseFigure) super.clone(); From 0a5afa7dcc9ffa9c3dc195f7b790db1568503052 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 8 Nov 2023 08:54:47 +0100 Subject: [PATCH 58/85] Jgiven is now used for automating BDD scenarios --- .../svg/figures/SVGEllipseFigureBDDTest.java | 20 ++++++++++++++++ .../jgivenstages/GivenEllipseDrawing.java | 17 +++++++++++++ .../jgivenstages/ThenEllipseDrawing.java | 24 +++++++++++++++++++ .../jgivenstages/WhenEllipseDrawing.java | 20 ++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureBDDTest.java create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenEllipseDrawing.java create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenEllipseDrawing.java create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenEllipseDrawing.java diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureBDDTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureBDDTest.java new file mode 100644 index 000000000..0bd6e76b8 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureBDDTest.java @@ -0,0 +1,20 @@ +package org.jhotdraw.samples.svg.figures; + +import com.tngtech.jgiven.junit.ScenarioTest; +import org.jhotdraw.samples.svg.figures.jgivenstages.GivenEllipseDrawing; +import org.jhotdraw.samples.svg.figures.jgivenstages.ThenEllipseDrawing; +import org.jhotdraw.samples.svg.figures.jgivenstages.WhenEllipseDrawing; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class SVGEllipseFigureBDDTest extends ScenarioTest { + @Test + public void testEllipseDrawing() { + given().the_user_has_selected_the_ellipse_drawing_tool(); + when().the_user_clicks_and_drags_the_mouse_to_create_an_ellipse_on_the_drawing_canvas(); + then().an_ellipse_shape_should_be_created_with_the_specified_dimensions(); + } + + +} \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenEllipseDrawing.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenEllipseDrawing.java new file mode 100644 index 000000000..52522a3d8 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenEllipseDrawing.java @@ -0,0 +1,17 @@ +package org.jhotdraw.samples.svg.figures.jgivenstages; + +import com.tngtech.jgiven.Stage; +import com.tngtech.jgiven.annotation.ProvidedScenarioState; +import org.jhotdraw.draw.Drawing; +import org.jhotdraw.draw.QuadTreeDrawing; + +public class GivenEllipseDrawing extends Stage { + + @ProvidedScenarioState + Drawing drawing; + + public GivenEllipseDrawing the_user_has_selected_the_ellipse_drawing_tool() { + this.drawing = new QuadTreeDrawing(); + return this; + } +} diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenEllipseDrawing.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenEllipseDrawing.java new file mode 100644 index 000000000..c03601681 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenEllipseDrawing.java @@ -0,0 +1,24 @@ +package org.jhotdraw.samples.svg.figures.jgivenstages; + +import com.tngtech.jgiven.Stage; +import com.tngtech.jgiven.annotation.ProvidedScenarioState; +import org.jhotdraw.draw.Drawing; +import org.jhotdraw.draw.QuadTreeDrawing; +import org.jhotdraw.draw.figure.Figure; +import org.jhotdraw.samples.svg.figures.SVGEllipseFigure; + +import java.util.List; + +import static org.junit.Assert.assertTrue; + +public class ThenEllipseDrawing extends Stage { + + @ProvidedScenarioState + Drawing drawing; + + public ThenEllipseDrawing an_ellipse_shape_should_be_created_with_the_specified_dimensions() { + List
figures = drawing.getFiguresFrontToBack(); + assertTrue(figures.stream().anyMatch(figure -> figure instanceof SVGEllipseFigure)); + return this; + } +} diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenEllipseDrawing.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenEllipseDrawing.java new file mode 100644 index 000000000..d0e34ed68 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenEllipseDrawing.java @@ -0,0 +1,20 @@ +package org.jhotdraw.samples.svg.figures.jgivenstages; + +import com.tngtech.jgiven.Stage; +import com.tngtech.jgiven.annotation.ProvidedScenarioState; +import org.jhotdraw.draw.Drawing; +import org.jhotdraw.draw.QuadTreeDrawing; +import org.jhotdraw.samples.svg.figures.SVGEllipseFigure; + +import static org.junit.Assert.assertNotNull; + +public class WhenEllipseDrawing extends Stage { + @ProvidedScenarioState + Drawing drawing; + + public WhenEllipseDrawing the_user_clicks_and_drags_the_mouse_to_create_an_ellipse_on_the_drawing_canvas() { + assertNotNull(drawing); + drawing.add(new SVGEllipseFigure()); + return this; + } +} From f35693a96161d03c1a0cb50267788e4446520b50 Mon Sep 17 00:00:00 2001 From: EFCO Date: Wed, 27 Sep 2023 10:47:07 +0200 Subject: [PATCH 59/85] Remove comment with no useful information --- .../java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java | 1 - 1 file changed, 1 deletion(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java index a42605d18..259bd52a1 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java @@ -327,7 +327,6 @@ public void setEditable(boolean b) { @Override public int getTextColumns() { - //return (getText() == null) ? 4 : Math.min(getText().length(), 4); return 4; } From 664959ba3878dc9b967db305940e807720d7114f Mon Sep 17 00:00:00 2001 From: EFCO Date: Wed, 27 Sep 2023 10:50:23 +0200 Subject: [PATCH 60/85] Remove un-useful comment Removing comments that doesn't provide any useful information --- .../org/jhotdraw/samples/svg/figures/SVGTextFigure.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java index 259bd52a1..69b7b604a 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java @@ -207,10 +207,7 @@ private Shape getTextShape() { break; } tx.rotate(rotates[0]); - /* - if (get(TRANSFORM) != null) { - tx.preConcatenate(get(TRANSFORM)); - }*/ + cachedTextShape = tx.createTransformedShape(textLayout.getOutline(tx)); cachedTextShape = textLayout.getOutline(tx); } @@ -338,18 +335,15 @@ public Font getFont() { @Override public Color getTextColor() { return get(FILL_COLOR); - // return get(TEXT_COLOR); } @Override public Color getFillColor() { return get(FILL_COLOR) == null || get(FILL_COLOR).equals(Color.white) ? Color.black : Color.WHITE; - // return get(FILL_COLOR); } @Override public void setFontSize(float size) { - // put(FONT_SIZE, new Double(size)); Point2D.Double p = new Point2D.Double(0, size); AffineTransform tx = get(TRANSFORM); if (tx != null) { @@ -367,7 +361,6 @@ public void setFontSize(float size) { @Override public float getFontSize() { - // return get(FONT_SIZE).floatValue(); Point2D.Double p = new Point2D.Double(0, get(FONT_SIZE)); AffineTransform tx = get(TRANSFORM); if (tx != null) { From 0643b5701ae836dd037ef428f4a0a153eb48f10c Mon Sep 17 00:00:00 2001 From: EFCO Date: Wed, 27 Sep 2023 10:53:26 +0200 Subject: [PATCH 61/85] Remove un-useful comment Removing comments that doesn't provide any useful information --- .../org/jhotdraw/samples/svg/figures/SVGTextFigure.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java index 69b7b604a..18aba4267 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java @@ -368,12 +368,6 @@ public float getFontSize() { Point2D.Double p0 = new Point2D.Double(0, 0); tx.transform(p0, p0); p.y -= p0.y; - /* - try { - tx.inverseTransform(p, p); - } catch (NoninvertibleTransformException ex) { - ex.printStackTrace(); - }*/ } return (float) Math.abs(p.y); } From 45d13aa78e993c8994a940d2aa6510913e8a9732 Mon Sep 17 00:00:00 2001 From: EFCO Date: Wed, 27 Sep 2023 10:54:19 +0200 Subject: [PATCH 62/85] Add inline expression Instead of creating new variable, and reatuning immediatly --- .../java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java index 18aba4267..a7fa406a1 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java @@ -420,9 +420,9 @@ public Collection createHandles(int detailLevel) { @Override public Tool getTool(Point2D.Double p) { if (isEditable() && contains(p)) { - TextEditingTool tool = new TextEditingTool(this); - return tool; + return new TextEditingTool(this); } + return null; } From 8161c9bdbcf4db0b9040ca2b62fe124d8e0f0e36 Mon Sep 17 00:00:00 2001 From: EFCO Date: Wed, 27 Sep 2023 11:07:47 +0200 Subject: [PATCH 63/85] Fix a lot of code smells MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 👃 --- .../samples/svg/figures/SVGTextFigure.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java index a7fa406a1..9754af47f 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java @@ -75,9 +75,12 @@ public SVGTextFigure(String text) { setConnectable(false); } - // DRAWING + @Override protected void drawText(java.awt.Graphics2D g) { + /* + This method is empty for some reason + */ } @Override @@ -123,7 +126,7 @@ public Rectangle2D.Double getBounds() { text = " "; } FontRenderContext frc = getFontRenderContext(); - HashMap textAttributes = new HashMap(); + HashMap textAttributes = new HashMap<>(); textAttributes.put(TextAttribute.FONT, getFont()); if (get(FONT_UNDERLINE)) { textAttributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); @@ -188,7 +191,7 @@ private Shape getTextShape() { text = " "; } FontRenderContext frc = getFontRenderContext(); - HashMap textAttributes = new HashMap(); + HashMap textAttributes = new HashMap<>(); textAttributes.put(TextAttribute.FONT, getFont()); if (get(FONT_UNDERLINE)) { textAttributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); @@ -295,11 +298,11 @@ public String getText() { @Override public void set(AttributeKey key, T newValue) { - if (key.equals(SVGAttributeKeys.TRANSFORM) - || key.equals(SVGAttributeKeys.FONT_FACE) - || key.equals(SVGAttributeKeys.FONT_BOLD) - || key.equals(SVGAttributeKeys.FONT_ITALIC) - || key.equals(SVGAttributeKeys.FONT_SIZE)) { + if (key.equals(AttributeKeys.TRANSFORM) + || key.equals(AttributeKeys.FONT_FACE) + || key.equals(AttributeKeys.FONT_BOLD) + || key.equals(AttributeKeys.FONT_ITALIC) + || key.equals(AttributeKeys.FONT_SIZE)) { invalidate(); } super.set(key, newValue); @@ -329,7 +332,7 @@ public int getTextColumns() { @Override public Font getFont() { - return SVGAttributeKeys.getFont(this); + return AttributeKeys.getFont(this); } @Override @@ -390,7 +393,7 @@ public Dimension2DDouble getPreferredSize() { @Override public Collection createHandles(int detailLevel) { - LinkedList handles = new LinkedList(); + LinkedList handles = new LinkedList<>(); switch (detailLevel % 2) { case -1: // Mouse hover handles handles.add(new BoundsOutlineHandle(this, false, true)); @@ -407,6 +410,8 @@ public Collection createHandles(int detailLevel) { case 1: TransformHandleKit.addTransformHandles(this, handles); break; + default: + break; } return handles; } From 3fcc51661e8639158f2d89d5e53f434ee25ae3d1 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:24:00 +0200 Subject: [PATCH 64/85] .yml file added for setting up the pipeline --- .github/workflows/maven.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/maven.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 000000000..322740147 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,34 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +on: + push: + branches: ["develop"] + pull_request: + branches: ["develop"] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: "17" + distribution: "temurin" + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.xml + + # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive + - name: Update dependency graph + uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 From 42eeedea9b556655b4f3017acfb935fdfdceed4b Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:43:11 +0200 Subject: [PATCH 65/85] Add setting.xml to our project to access the maven repository. --- .github/workflows/maven.yml | 11 +++++++---- settings.xml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 settings.xml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 322740147..fbd3ce4d9 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -20,15 +20,18 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 11 uses: actions/setup-java@v3 with: - java-version: "17" + java-version: "11" distribution: "temurin" cache: maven - name: Build with Maven - run: mvn -B package --file pom.xml + run: mvn -s settings.xml -B package --file pom.xml + env: + USER_NAME: ${{ secrets.USER_NAME }} + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - name: Update dependency graph - uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 + uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d \ No newline at end of file diff --git a/settings.xml b/settings.xml new file mode 100644 index 000000000..de30eb164 --- /dev/null +++ b/settings.xml @@ -0,0 +1,34 @@ + + + + github + + + + + github + + + central + https://repo1.maven.org/maven2 + + + github + GitHub external Packages + https://maven.pkg.github.com/sweat-tek/MavenRepository + + + + + + + + github + ${env.USER_NAME} + ${env.ACCESS_TOKEN} + + + \ No newline at end of file From ebf0368a8b84705319e394fd30f672c049a9acd7 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:45:50 +0200 Subject: [PATCH 66/85] Delete unnecessary step --- .github/workflows/maven.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index fbd3ce4d9..cf7930dd2 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -30,8 +30,4 @@ jobs: run: mvn -s settings.xml -B package --file pom.xml env: USER_NAME: ${{ secrets.USER_NAME }} - ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} - - # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - - name: Update dependency graph - uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d \ No newline at end of file + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} \ No newline at end of file From eb45d880a5f9aa3eb81a169f3779b9e342e08275 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:53:18 +0200 Subject: [PATCH 67/85] Not in use anymore since the handlehelper class is created --- .../java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java index c6a9aaf6d..170021a7e 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java @@ -19,15 +19,11 @@ import javax.imageio.ImageIO; import javax.swing.*; -import org.jhotdraw.draw.*; import static org.jhotdraw.draw.AttributeKeys.TRANSFORM; import org.jhotdraw.draw.event.TransformRestoreEdit; -import org.jhotdraw.draw.handle.BoundsOutlineHandle; import org.jhotdraw.draw.handle.Handle; -import org.jhotdraw.draw.handle.ResizeHandleKit; -import org.jhotdraw.draw.handle.TransformHandleKit; import org.jhotdraw.geom.GrowStroke; import org.jhotdraw.samples.svg.SVGAttributeKeys; From a15b916938da3f3f460d5e072f2e0e4fe842afbb Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 4 Oct 2023 11:29:27 +0200 Subject: [PATCH 68/85] Add comments about how to get the feature tracer to work again --- .../jhotdraw-samples-misc/pom.xml | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml index ad3a69609..71a43d736 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml +++ b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 org.jhotdraw @@ -48,23 +49,16 @@ - - org.codehaus.mojo - exec-maven-plugin - 3.1.0 - - - run-java - install - - java - - - - - org.jhotdraw.samples.svg.Main - - + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + true + always + true + + \ No newline at end of file From 89ca5b15f50278cdeed7bb1561113e58ebd79939 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 8 Nov 2023 08:51:28 +0100 Subject: [PATCH 69/85] Jgiven test for best case (possible to transform ellipse corretly), for no transformation before the method is called and lastly for being able to stack ellipses --- .../jhotdraw-samples-misc/pom.xml | 6 ++ .../svg/figures/SVGEllipseFigureTest.java | 70 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureTest.java diff --git a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml index 71a43d736..77ad6872e 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml +++ b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml @@ -46,6 +46,12 @@ featuretracerlite 1.1-SNAPSHOT + + com.tngtech.jgiven + jgiven-junit + 1.0.0-RC6 + test + diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureTest.java new file mode 100644 index 000000000..41f0bc65b --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureTest.java @@ -0,0 +1,70 @@ +package org.jhotdraw.samples.svg.figures; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; + +import static org.jhotdraw.draw.AttributeKeys.TRANSFORM; +import static org.junit.Assert.*; + +public class SVGEllipseFigureTest { + + private SVGEllipseFigure ellipseFigure; + + @Before + public void setUp() { + // Initialize a new SVGEllipseFigure for each test method + ellipseFigure = new SVGEllipseFigure(10, 10, 30, 20); + } + + @After + public void tearDown() { + // Set the SVGEllipseFigure to null after each test method + ellipseFigure = null; + } + + @Test + public void testTransformBestCase() { + // Test the transform() method with a best-case scenario + AffineTransform tx = AffineTransform.getTranslateInstance(5, 5); + ellipseFigure.transform(tx); + + // Verify that the figure has been transformed correctly + Rectangle2D.Double bounds = ellipseFigure.getBounds(); + assertEquals(15.0, bounds.getX(), 0.01); + assertEquals(15.0, bounds.getY(), 0.01); + + } + + @Test + public void testTransformNull() { + // Test the transform() method with a null argument + AffineTransform prevTransform = ellipseFigure.get(TRANSFORM); + // Assert that the figure has no transform before the transform() method is called + assertNull(prevTransform); + + } + + @Test + public void testTransformStackable() { + // Made another ellipseFigure to test if the transform() method is stackable + SVGEllipseFigure ellipseFigure2 = new SVGEllipseFigure(10, 10, 35, 25); + // Adds 5 to the x and y coordinates of both ellipseFigures + AffineTransform tx = AffineTransform.getTranslateInstance(5, 5); + + // Transforms both ellipseFigures + ellipseFigure.transform(tx); + ellipseFigure2.transform(tx); + // Verify that the figure has been transformed correctly + Rectangle2D.Double bounds = ellipseFigure.getBounds(); + Rectangle2D.Double bounds2 = ellipseFigure2.getBounds(); + assertEquals(15.0, bounds.getX(), 0.01); + assertEquals(15.0, bounds.getY(), 0.01); + assertEquals(15.0, bounds2.getX(), 0.01); + assertEquals(15.0, bounds2.getY(), 0.01); + + } +} \ No newline at end of file From 7d6edda4434f5ea6d0b4e860a3bc014f94e0d358 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 8 Nov 2023 08:53:41 +0100 Subject: [PATCH 70/85] Java assertion included to test for invariants. Secures that the drawing area must not be null. Previous commit correction: JUnit and not Jgiven.. --- .../samples/svg/figures/SVGEllipseFigure.java | 50 ++++++++++++++----- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java index 2fef058be..7cbac2889 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java @@ -7,20 +7,25 @@ */ package org.jhotdraw.samples.svg.figures; -import java.awt.*; -import java.awt.geom.*; -import java.util.*; - import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; -import org.jhotdraw.draw.*; -import static org.jhotdraw.draw.AttributeKeys.FILL_COLOR; -import static org.jhotdraw.draw.AttributeKeys.TRANSFORM; +import org.jhotdraw.draw.AttributeKeys; import org.jhotdraw.draw.handle.Handle; import org.jhotdraw.geom.Geom; import org.jhotdraw.geom.GrowStroke; import org.jhotdraw.samples.svg.Gradient; import org.jhotdraw.samples.svg.SVGAttributeKeys; -import static org.jhotdraw.samples.svg.SVGAttributeKeys.*; + +import java.awt.*; +import java.awt.geom.AffineTransform; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.util.Collection; + +import static org.jhotdraw.draw.AttributeKeys.FILL_COLOR; +import static org.jhotdraw.draw.AttributeKeys.TRANSFORM; +import static org.jhotdraw.samples.svg.SVGAttributeKeys.FILL_GRADIENT; +import static org.jhotdraw.samples.svg.SVGAttributeKeys.STROKE_GRADIENT; /** * SVGEllipse represents a SVG ellipse and a SVG circle element. @@ -96,6 +101,8 @@ public Rectangle2D.Double getBounds() { public Rectangle2D.Double getDrawingArea() { Rectangle2D rx = getTransformedShape().getBounds2D(); Rectangle2D.Double r = (rx instanceof Rectangle2D.Double) ? (Rectangle2D.Double) rx : new Rectangle2D.Double(rx.getX(), rx.getY(), rx.getWidth(), rx.getHeight()); + // Assertion: The drawing area must not be null + assert r != null : "Drawing area is null"; if (get(TRANSFORM) == null) { double g = SVGAttributeKeys.getPerpendicularHitGrowth(this, 1.0) * 2d + 1; Geom.grow(r, g, g); @@ -116,6 +123,9 @@ public boolean contains(Point2D.Double p) { return getHitShape().contains(p); } + /* + * This method is used to determine the transformed shape of the figure. + */ private Shape getTransformedShape() { if (cachedTransformedShape != null) { return cachedTransformedShape; @@ -128,6 +138,9 @@ private Shape getTransformedShape() { return cachedTransformedShape; } + /* + * This method is used to determine the hit shape of the figure. + */ private Shape getHitShape() { if (cachedHitShape != null) { return cachedHitShape; @@ -142,6 +155,10 @@ private Shape getHitShape() { return cachedHitShape; } + /* + * This method is used to determine the drawing area of the figure. + */ + @Override public void setBounds(Point2D.Double anchor, Point2D.Double lead) { ellipse.x = Math.min(anchor.x, lead.x); @@ -189,6 +206,9 @@ public void transform(AffineTransform tx) { invalidate(); } + /* + * This method is used to restore the transform of the figure. + */ @Override public void restoreTransformTo(Object geometry) { Object[] restoreData = (Object[]) geometry; @@ -199,13 +219,16 @@ public void restoreTransformTo(Object geometry) { invalidate(); } + /* + * This method is used to get the transform restore data of the figure. + */ @Override public Object getTransformRestoreData() { return new Object[]{ - ellipse.clone(), - TRANSFORM.getClone(this), - FILL_GRADIENT.getClone(this), - STROKE_GRADIENT.getClone(this)}; + ellipse.clone(), + TRANSFORM.getClone(this), + FILL_GRADIENT.getClone(this), + STROKE_GRADIENT.getClone(this)}; } // ATTRIBUTES @@ -218,6 +241,9 @@ public Collection createHandles(int detailLevel) { // CONNECTING // COMPOSITE FIGURES // CLONING + /* + * This method is used to clone the figure. + */ @Override public SVGEllipseFigure clone() { SVGEllipseFigure that = (SVGEllipseFigure) super.clone(); From f8c77e668df924af83b2b4848cda63d03d44a0ef Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 8 Nov 2023 08:54:47 +0100 Subject: [PATCH 71/85] Jgiven is now used for automating BDD scenarios --- .../svg/figures/SVGEllipseFigureBDDTest.java | 20 ++++++++++++++++ .../jgivenstages/GivenEllipseDrawing.java | 17 +++++++++++++ .../jgivenstages/ThenEllipseDrawing.java | 24 +++++++++++++++++++ .../jgivenstages/WhenEllipseDrawing.java | 20 ++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureBDDTest.java create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenEllipseDrawing.java create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenEllipseDrawing.java create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenEllipseDrawing.java diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureBDDTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureBDDTest.java new file mode 100644 index 000000000..0bd6e76b8 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureBDDTest.java @@ -0,0 +1,20 @@ +package org.jhotdraw.samples.svg.figures; + +import com.tngtech.jgiven.junit.ScenarioTest; +import org.jhotdraw.samples.svg.figures.jgivenstages.GivenEllipseDrawing; +import org.jhotdraw.samples.svg.figures.jgivenstages.ThenEllipseDrawing; +import org.jhotdraw.samples.svg.figures.jgivenstages.WhenEllipseDrawing; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class SVGEllipseFigureBDDTest extends ScenarioTest { + @Test + public void testEllipseDrawing() { + given().the_user_has_selected_the_ellipse_drawing_tool(); + when().the_user_clicks_and_drags_the_mouse_to_create_an_ellipse_on_the_drawing_canvas(); + then().an_ellipse_shape_should_be_created_with_the_specified_dimensions(); + } + + +} \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenEllipseDrawing.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenEllipseDrawing.java new file mode 100644 index 000000000..52522a3d8 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenEllipseDrawing.java @@ -0,0 +1,17 @@ +package org.jhotdraw.samples.svg.figures.jgivenstages; + +import com.tngtech.jgiven.Stage; +import com.tngtech.jgiven.annotation.ProvidedScenarioState; +import org.jhotdraw.draw.Drawing; +import org.jhotdraw.draw.QuadTreeDrawing; + +public class GivenEllipseDrawing extends Stage { + + @ProvidedScenarioState + Drawing drawing; + + public GivenEllipseDrawing the_user_has_selected_the_ellipse_drawing_tool() { + this.drawing = new QuadTreeDrawing(); + return this; + } +} diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenEllipseDrawing.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenEllipseDrawing.java new file mode 100644 index 000000000..c03601681 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenEllipseDrawing.java @@ -0,0 +1,24 @@ +package org.jhotdraw.samples.svg.figures.jgivenstages; + +import com.tngtech.jgiven.Stage; +import com.tngtech.jgiven.annotation.ProvidedScenarioState; +import org.jhotdraw.draw.Drawing; +import org.jhotdraw.draw.QuadTreeDrawing; +import org.jhotdraw.draw.figure.Figure; +import org.jhotdraw.samples.svg.figures.SVGEllipseFigure; + +import java.util.List; + +import static org.junit.Assert.assertTrue; + +public class ThenEllipseDrawing extends Stage { + + @ProvidedScenarioState + Drawing drawing; + + public ThenEllipseDrawing an_ellipse_shape_should_be_created_with_the_specified_dimensions() { + List
figures = drawing.getFiguresFrontToBack(); + assertTrue(figures.stream().anyMatch(figure -> figure instanceof SVGEllipseFigure)); + return this; + } +} diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenEllipseDrawing.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenEllipseDrawing.java new file mode 100644 index 000000000..d0e34ed68 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenEllipseDrawing.java @@ -0,0 +1,20 @@ +package org.jhotdraw.samples.svg.figures.jgivenstages; + +import com.tngtech.jgiven.Stage; +import com.tngtech.jgiven.annotation.ProvidedScenarioState; +import org.jhotdraw.draw.Drawing; +import org.jhotdraw.draw.QuadTreeDrawing; +import org.jhotdraw.samples.svg.figures.SVGEllipseFigure; + +import static org.junit.Assert.assertNotNull; + +public class WhenEllipseDrawing extends Stage { + @ProvidedScenarioState + Drawing drawing; + + public WhenEllipseDrawing the_user_clicks_and_drags_the_mouse_to_create_an_ellipse_on_the_drawing_canvas() { + assertNotNull(drawing); + drawing.add(new SVGEllipseFigure()); + return this; + } +} From b33f9a32c17d7e212ae53248fc931354acba4ba5 Mon Sep 17 00:00:00 2001 From: EFCO Date: Wed, 8 Nov 2023 09:31:41 +0100 Subject: [PATCH 72/85] Added test and assert somewhere in the code --- .../samples/svg/figures/SVGTextFigure.java | 1 + .../svg/figures/SVGTextFigureTest.java | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGTextFigureTest.java diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java index 9754af47f..6e88bc8fd 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGTextFigure.java @@ -388,6 +388,7 @@ public void invalidate() { @Override public Dimension2DDouble getPreferredSize() { Rectangle2D.Double b = getBounds(); + assert b.width > 0 && b.height > 0; return new Dimension2DDouble(b.width, b.height); } diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGTextFigureTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGTextFigureTest.java new file mode 100644 index 000000000..4f8eb870f --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGTextFigureTest.java @@ -0,0 +1,39 @@ +package org.jhotdraw.samples.svg.figures; + +import org.junit.Before; +import org.junit.Test; + +import java.awt.geom.Point2D; + +import static org.junit.Assert.*; + +public class SVGTextFigureTest { + SVGTextFigure textFigure; + + @Before + public void setUp() throws Exception { + textFigure = new SVGTextFigure(); + } + + @Test + public void setCoordinatesTest() { + // Arrange + Point2D.Double[] point = new Point2D.Double[]{ + new Point2D.Double(1, 2), + new Point2D.Double(3, 4), + new Point2D.Double(5, 6), + new Point2D.Double(7, 8) + }; + + // Act + textFigure.setCoordinates(point); + + //Assert + assertArrayEquals(textFigure.getCoordinates(), point); + } + + @Test + public void containsTest() { + + } +} \ No newline at end of file From e84978d647baf21c65b4ff6efe5f3b45b0948b3f Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 8 Nov 2023 09:38:30 +0100 Subject: [PATCH 73/85] Optimization for minor fixes --- .../jhotdraw-samples-misc/pom.xml | 78 ++++++++++++++----- .../svg/figures/SVGEllipseFigureBDDTest.java | 2 - 2 files changed, 60 insertions(+), 20 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml index ad3a69609..76045dfc7 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml +++ b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 org.jhotdraw @@ -45,26 +46,67 @@ featuretracerlite 1.1-SNAPSHOT + + com.tngtech.jgiven + jgiven-junit + 1.0.0-RC6 + test + - - org.codehaus.mojo - exec-maven-plugin - 3.1.0 - - - run-java - install - - java - - - - - org.jhotdraw.samples.svg.Main - - + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + true + always + true + + + + org.codehaus.mojo + exec-maven-plugin + 3.1.0 + + + run-java + install + + java + + + + + org.jhotdraw.samples.svg.Main + + \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureBDDTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureBDDTest.java index 0bd6e76b8..da3843e16 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureBDDTest.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigureBDDTest.java @@ -6,8 +6,6 @@ import org.jhotdraw.samples.svg.figures.jgivenstages.WhenEllipseDrawing; import org.junit.Test; -import static org.junit.Assert.*; - public class SVGEllipseFigureBDDTest extends ScenarioTest { @Test public void testEllipseDrawing() { From ce48cc9be951fd7c44d4c94b2b9183f88472b607 Mon Sep 17 00:00:00 2001 From: FrejaStrand <90042340+FrejaStrand@users.noreply.github.com> Date: Wed, 8 Nov 2023 09:45:24 +0100 Subject: [PATCH 74/85] Methods made void to pass checkstyle in the pipeline And doubble code in the pom removed --- jhotdraw-samples/jhotdraw-samples-misc/pom.xml | 17 ----------------- .../jgivenstages/GivenEllipseDrawing.java | 3 +-- .../jgivenstages/ThenEllipseDrawing.java | 4 +--- .../jgivenstages/WhenEllipseDrawing.java | 4 +--- 4 files changed, 3 insertions(+), 25 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml index 76045dfc7..d86f34916 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml +++ b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml @@ -90,23 +90,6 @@ true - - org.codehaus.mojo - exec-maven-plugin - 3.1.0 - - - run-java - install - - java - - - - - org.jhotdraw.samples.svg.Main - - \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenEllipseDrawing.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenEllipseDrawing.java index 52522a3d8..7398f3765 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenEllipseDrawing.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenEllipseDrawing.java @@ -10,8 +10,7 @@ public class GivenEllipseDrawing extends Stage { @ProvidedScenarioState Drawing drawing; - public GivenEllipseDrawing the_user_has_selected_the_ellipse_drawing_tool() { + public void the_user_has_selected_the_ellipse_drawing_tool() { this.drawing = new QuadTreeDrawing(); - return this; } } diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenEllipseDrawing.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenEllipseDrawing.java index c03601681..020ca3b84 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenEllipseDrawing.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenEllipseDrawing.java @@ -3,7 +3,6 @@ import com.tngtech.jgiven.Stage; import com.tngtech.jgiven.annotation.ProvidedScenarioState; import org.jhotdraw.draw.Drawing; -import org.jhotdraw.draw.QuadTreeDrawing; import org.jhotdraw.draw.figure.Figure; import org.jhotdraw.samples.svg.figures.SVGEllipseFigure; @@ -16,9 +15,8 @@ public class ThenEllipseDrawing extends Stage { @ProvidedScenarioState Drawing drawing; - public ThenEllipseDrawing an_ellipse_shape_should_be_created_with_the_specified_dimensions() { + public void an_ellipse_shape_should_be_created_with_the_specified_dimensions() { List
figures = drawing.getFiguresFrontToBack(); assertTrue(figures.stream().anyMatch(figure -> figure instanceof SVGEllipseFigure)); - return this; } } diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenEllipseDrawing.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenEllipseDrawing.java index d0e34ed68..720dd7c98 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenEllipseDrawing.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenEllipseDrawing.java @@ -3,7 +3,6 @@ import com.tngtech.jgiven.Stage; import com.tngtech.jgiven.annotation.ProvidedScenarioState; import org.jhotdraw.draw.Drawing; -import org.jhotdraw.draw.QuadTreeDrawing; import org.jhotdraw.samples.svg.figures.SVGEllipseFigure; import static org.junit.Assert.assertNotNull; @@ -12,9 +11,8 @@ public class WhenEllipseDrawing extends Stage { @ProvidedScenarioState Drawing drawing; - public WhenEllipseDrawing the_user_clicks_and_drags_the_mouse_to_create_an_ellipse_on_the_drawing_canvas() { + public void the_user_clicks_and_drags_the_mouse_to_create_an_ellipse_on_the_drawing_canvas() { assertNotNull(drawing); drawing.add(new SVGEllipseFigure()); - return this; } } From 1dfa31e28864b84a32cb903838fe5d47093606b5 Mon Sep 17 00:00:00 2001 From: Siole Date: Wed, 8 Nov 2023 11:04:39 +0100 Subject: [PATCH 75/85] BDD-test rectangle feature --- ...ples.svg.figures.SVGRectFigureBDDTest.json | 76 +++++++++++++++++++ .../jhotdraw-samples-misc/pom.xml | 19 ++--- .../java/org/jhotdraw/samples/svg/Main.java | 2 +- .../samples/svg/figures/SVGRectFigure.java | 2 +- .../src/main/resources/META-INF/aop.xml | 3 + .../svg/figures/SVGRectFigureBDDTest.java | 17 +++++ .../svg/figures/SVGRectFigureTest.java | 14 ---- .../figures/jgivenstages/GivenRectangle.java | 19 +++++ .../figures/jgivenstages/ThenRectangle.java | 24 ++++++ .../figures/jgivenstages/WhenRectangle.java | 22 ++++++ 10 files changed, 169 insertions(+), 29 deletions(-) create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.figures.SVGRectFigureBDDTest.json create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGRectFigureBDDTest.java create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenRectangle.java create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenRectangle.java create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenRectangle.java diff --git a/jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.figures.SVGRectFigureBDDTest.json b/jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.figures.SVGRectFigureBDDTest.json new file mode 100644 index 000000000..4815bef0f --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.figures.SVGRectFigureBDDTest.json @@ -0,0 +1,76 @@ +{ + "className": "org.jhotdraw.samples.svg.figures.SVGRectFigureBDDTest", + "name": "SVG Rect Figure BDD", + "scenarios": [ + { + "className": "org.jhotdraw.samples.svg.figures.SVGRectFigureBDDTest", + "testMethodName": "drawRectangle", + "description": "Draw rectangle", + "tagIds": [], + "explicitParameters": [], + "derivedParameters": [], + "scenarioCases": [ + { + "caseNr": 1, + "steps": [ + { + "name": "empty canvas", + "words": [ + { + "value": "Given", + "isIntroWord": true + }, + { + "value": "empty canvas" + } + ], + "status": "PASSED", + "durationInNanos": 286564500, + "depth": 0, + "parentFailed": false + }, + { + "name": "a rectangle is drawn", + "words": [ + { + "value": "When", + "isIntroWord": true + }, + { + "value": "a rectangle is drawn" + } + ], + "status": "PASSED", + "durationInNanos": 50418800, + "depth": 0, + "parentFailed": false + }, + { + "name": "canvas contains rectangle", + "words": [ + { + "value": "Then", + "isIntroWord": true + }, + { + "value": "canvas contains rectangle" + } + ], + "status": "PASSED", + "durationInNanos": 3250400, + "depth": 0, + "parentFailed": false + } + ], + "explicitArguments": [], + "derivedArguments": [], + "status": "SUCCESS", + "durationInNanos": 394912000 + } + ], + "casesAsTable": false, + "durationInNanos": 394912000 + } + ], + "tagMap": {} +} \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml index 430d8bd27..4974c6297 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml +++ b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml @@ -41,11 +41,6 @@ htmlunit 2.37.0 - - org.aspectj - aspectjweaver - 1.9.9 - ${project.groupId} jhotdraw-app @@ -63,6 +58,12 @@ 3.11.2 test + + com.tngtech.jgiven + jgiven-junit + 1.3.0 + test + @@ -70,14 +71,6 @@ org.apache.maven.plugins maven-surefire-plugin 2.22.2 - - - -javaagent:"C:\Users\super\.m2\repository\org\aspectj\aspectjweaver\1.9.9\aspectjweaver-1.9.9.jar" - --add-opens java.base/java.lang=ALL-UNNAMED - - true - always - diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java index dacae72cc..79aec2f9e 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java @@ -28,7 +28,7 @@ public class Main { * Creates a new instance. */ - @FeatureEntryPoint("Main") + //@FeatureEntryPoint("Main") public static void main(String[] args) { // Debug resource bundle ResourceBundleUtil.setVerbose(true); diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java index f5f31cccf..bac4fdf6d 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java @@ -81,7 +81,7 @@ public SVGRectFigure(double x, double y, double width, double height) { this(x, y, width, height, 0, 0); } - @FeatureEntryPoint("RectangleEntry") + //@FeatureEntryPoint("RectangleEntry") public SVGRectFigure(double x, double y, double width, double height, double rx, double ry) { roundrect = new RoundRectangle2D.Double(x, y, width, height, rx, ry); SVGAttributeKeys.setDefaults(this); diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/resources/META-INF/aop.xml b/jhotdraw-samples/jhotdraw-samples-misc/src/main/resources/META-INF/aop.xml index bd42481a5..d5624fc77 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/resources/META-INF/aop.xml +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/resources/META-INF/aop.xml @@ -6,6 +6,9 @@ + + + diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGRectFigureBDDTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGRectFigureBDDTest.java new file mode 100644 index 000000000..d6ead9ed3 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGRectFigureBDDTest.java @@ -0,0 +1,17 @@ +package org.jhotdraw.samples.svg.figures; + +import com.tngtech.jgiven.junit.ScenarioTest; +import org.jhotdraw.samples.svg.figures.jgivenstages.GivenRectangle; +import org.jhotdraw.samples.svg.figures.jgivenstages.ThenRectangle; +import org.jhotdraw.samples.svg.figures.jgivenstages.WhenRectangle; +import org.junit.Test; + +public class SVGRectFigureBDDTest extends ScenarioTest { + + @Test + public void drawRectangle() { + given().empty_canvas(); + when().a_rectangle_is_drawn(); + then().canvas_contains_rectangle(); + } +} \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGRectFigureTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGRectFigureTest.java index 142aa1316..01adc33da 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGRectFigureTest.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGRectFigureTest.java @@ -1,7 +1,5 @@ package org.jhotdraw.samples.svg.figures; -import org.junit.After; -import org.junit.Before; import org.junit.Test; import java.awt.*; @@ -13,18 +11,6 @@ public class SVGRectFigureTest { SVGRectFigure svgRectFigure = new SVGRectFigure(); Graphics2D mockGraphics2D = mock(Graphics2D.class); - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void transform() { - } /** * Test the state of the figure after calling drawStroke(). diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenRectangle.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenRectangle.java new file mode 100644 index 000000000..918751b1d --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenRectangle.java @@ -0,0 +1,19 @@ +package org.jhotdraw.samples.svg.figures.jgivenstages; + +import com.tngtech.jgiven.Stage; +import com.tngtech.jgiven.annotation.ProvidedScenarioState; +import com.tngtech.jgiven.annotation.ScenarioState; +import org.jhotdraw.draw.DefaultDrawing; +import org.jhotdraw.draw.Drawing; +import org.jhotdraw.draw.QuadTreeDrawing; + +public class GivenRectangle extends Stage{ + + @ScenarioState + Drawing drawing; + + public GivenRectangle empty_canvas(){ + this.drawing = new DefaultDrawing(); + return this; + } +} \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenRectangle.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenRectangle.java new file mode 100644 index 000000000..9b1329af7 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenRectangle.java @@ -0,0 +1,24 @@ +package org.jhotdraw.samples.svg.figures.jgivenstages; + +import com.tngtech.jgiven.Stage; +import com.tngtech.jgiven.annotation.ExpectedScenarioState; +import com.tngtech.jgiven.annotation.ScenarioState; +import org.jhotdraw.draw.Drawing; +import org.jhotdraw.draw.figure.Figure; +import org.jhotdraw.samples.svg.figures.SVGRectFigure; + +import java.util.List; + +import static org.junit.Assert.assertTrue; + +public class ThenRectangle extends Stage { + + @ScenarioState + Drawing drawing; + + public ThenRectangle canvas_contains_rectangle() { + List
figure = drawing.getFiguresFrontToBack(); + assertTrue(figure.stream().anyMatch(f -> f instanceof SVGRectFigure)); + return this; + } +} diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenRectangle.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenRectangle.java new file mode 100644 index 000000000..41d240a99 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenRectangle.java @@ -0,0 +1,22 @@ +package org.jhotdraw.samples.svg.figures.jgivenstages; + +import com.tngtech.jgiven.Stage; +import com.tngtech.jgiven.annotation.ExpectedScenarioState; +import com.tngtech.jgiven.annotation.ScenarioState; +import org.jhotdraw.draw.Drawing; +import org.jhotdraw.samples.svg.figures.SVGRectFigure; + +import static org.junit.Assert.assertNotNull; + +public class WhenRectangle extends Stage { + + @ScenarioState + Drawing drawing; + + public WhenRectangle a_rectangle_is_drawn() { + assertNotNull(drawing); + drawing.add(new SVGRectFigure()); + return this; + } + +} From 60b24a7c0e3992578e3e4c4a4a213c059a605230 Mon Sep 17 00:00:00 2001 From: EFCO Date: Wed, 8 Nov 2023 11:29:05 +0100 Subject: [PATCH 76/85] BDD and normal test --- .../jhotdraw-samples-misc/pom.xml | 6 ++++ .../jhotdraw/samples/svg/TextToolBDDTest.java | 23 ++++++++++++ .../samples/svg/bdd/GivenTextFigureTest.java | 27 ++++++++++++++ .../samples/svg/bdd/ThenTextFigureTest.java | 36 +++++++++++++++++++ .../samples/svg/bdd/WhenTextFigureTest.java | 36 +++++++++++++++++++ .../svg/figures/SVGTextFigureTest.java | 26 ++++++++------ 6 files changed, 143 insertions(+), 11 deletions(-) create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/TextToolBDDTest.java create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/GivenTextFigureTest.java create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/ThenTextFigureTest.java create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/WhenTextFigureTest.java diff --git a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml index 7a2d9edd6..b8de09eb2 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml +++ b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml @@ -46,6 +46,12 @@ featuretracerlite 1.1-SNAPSHOT + + com.tngtech.jgiven + jgiven-junit + 1.0.0-RC6 + test + diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/TextToolBDDTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/TextToolBDDTest.java new file mode 100644 index 000000000..c53bf81da --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/TextToolBDDTest.java @@ -0,0 +1,23 @@ +package org.jhotdraw.samples.svg; + +import com.tngtech.jgiven.junit.ScenarioTest; +import org.jhotdraw.samples.svg.bdd.GivenTextFigureTest; +import org.jhotdraw.samples.svg.bdd.ThenTextFigureTest; +import org.jhotdraw.samples.svg.bdd.WhenTextFigureTest; +import org.junit.Test; + +public class TextToolBDDTest extends ScenarioTest { + @Test + public void drawTexTool() { + given().anEmptyDrawing(); + when().aTextToolIsDrawn(); + then().theDrawingContainsATextBox(); + } + + @Test + public void rotateTextTool() { + given().aDrawing().and().aText(); + when().theTextToolIsRotated(); + then().theTextBoxHasTheCorrectRotation(); + } +} diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/GivenTextFigureTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/GivenTextFigureTest.java new file mode 100644 index 000000000..2b726e6a2 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/GivenTextFigureTest.java @@ -0,0 +1,27 @@ +package org.jhotdraw.samples.svg.bdd; + +import com.tngtech.jgiven.Stage; +import com.tngtech.jgiven.annotation.ProvidedScenarioState; +import org.jhotdraw.draw.Drawing; +import org.jhotdraw.draw.QuadTreeDrawing; +import org.jhotdraw.samples.svg.figures.SVGTextFigure; + +public class GivenTextFigureTest extends Stage { + @ProvidedScenarioState + Drawing drawing; + + public GivenTextFigureTest anEmptyDrawing() { + this.drawing = new QuadTreeDrawing(); + return this; + } + + public GivenTextFigureTest aDrawing() { + this.drawing = new QuadTreeDrawing(); + return this; + } + + public GivenTextFigureTest aText() { + this.drawing.add(new SVGTextFigure()); + return this; + } +} diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/ThenTextFigureTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/ThenTextFigureTest.java new file mode 100644 index 000000000..1b85e71df --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/ThenTextFigureTest.java @@ -0,0 +1,36 @@ +package org.jhotdraw.samples.svg.bdd; + +import com.tngtech.jgiven.Stage; +import com.tngtech.jgiven.annotation.ScenarioState; +import org.jhotdraw.draw.Drawing; +import org.jhotdraw.draw.figure.Figure; +import org.jhotdraw.samples.svg.figures.SVGTextFigure; + +import java.awt.geom.Rectangle2D; +import java.util.List; + +import static com.tngtech.jgiven.impl.util.AssertionUtil.assertNotNull; +import static org.junit.Assert.*; + +public class ThenTextFigureTest extends Stage { + @ScenarioState + Drawing drawing; + + public ThenTextFigureTest theDrawingContainsATextBox() { + List
figures = drawing.getFiguresFrontToBack(); + assertTrue(figures.stream().anyMatch(figure -> figure instanceof SVGTextFigure)); + return this; + } + + public ThenTextFigureTest theTextBoxHasTheCorrectRotation() { + assertNotNull(drawing); + List
figures = drawing.getFiguresFrontToBack(); + assertEquals(1, figures.size()); + Figure figure = figures.get(0); + assertTrue(figure instanceof SVGTextFigure); + SVGTextFigure textFigure = (SVGTextFigure) figure; + double[] rotation = textFigure.getRotates(); + assertArrayEquals(new double[]{90}, rotation, 0.1); + return this; + } +} diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/WhenTextFigureTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/WhenTextFigureTest.java new file mode 100644 index 000000000..8ac087928 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/WhenTextFigureTest.java @@ -0,0 +1,36 @@ +package org.jhotdraw.samples.svg.bdd; + +import com.tngtech.jgiven.Stage; +import com.tngtech.jgiven.annotation.ScenarioState; +import org.jhotdraw.draw.Drawing; +import org.jhotdraw.draw.figure.Figure; +import org.jhotdraw.samples.svg.figures.SVGTextFigure; + +import java.awt.geom.Point2D; +import java.util.List; + +import static com.tngtech.jgiven.impl.util.AssertionUtil.assertNotNull; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class WhenTextFigureTest extends Stage { + @ScenarioState + Drawing drawing; + + public WhenTextFigureTest aTextToolIsDrawn() { + assertNotNull(drawing); + drawing.add(new SVGTextFigure()); + return this; + } + + public WhenTextFigureTest theTextToolIsRotated() { + assertNotNull(drawing); + List
figures = drawing.getFiguresFrontToBack(); + assertEquals(figures.size(), 1); + Figure figure = figures.get(0); + assertTrue(figure instanceof SVGTextFigure); + SVGTextFigure textFigure = (SVGTextFigure) figure; + textFigure.setRotates(new double[]{90}); + return this; + } +} diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGTextFigureTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGTextFigureTest.java index 4f8eb870f..8396841d0 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGTextFigureTest.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGTextFigureTest.java @@ -16,24 +16,28 @@ public void setUp() throws Exception { } @Test - public void setCoordinatesTest() { + public void setRotationTest() { // Arrange - Point2D.Double[] point = new Point2D.Double[]{ - new Point2D.Double(1, 2), - new Point2D.Double(3, 4), - new Point2D.Double(5, 6), - new Point2D.Double(7, 8) - }; + double[] rotation = new double[]{90.0}; // Act - textFigure.setCoordinates(point); + textFigure.setRotates(rotation); //Assert - assertArrayEquals(textFigure.getCoordinates(), point); + assertArrayEquals(textFigure.getRotates(), rotation, 0.1); } @Test - public void containsTest() { - + public void moveTest() { + // Arrange + Point2D.Double[] coordinates = new Point2D.Double[]{ + new Point2D.Double(100, 100) + }; + + // Act + textFigure.setCoordinates(coordinates); + + //Assert + assertArrayEquals(textFigure.getCoordinates(), coordinates); } } \ No newline at end of file From ade3c6149c8907146be21002e1d03aae495c64f6 Mon Sep 17 00:00:00 2001 From: EFCO Date: Wed, 8 Nov 2023 11:33:07 +0100 Subject: [PATCH 77/85] Unused imports --- .../java/org/jhotdraw/samples/svg/bdd/ThenTextFigureTest.java | 1 - .../java/org/jhotdraw/samples/svg/bdd/WhenTextFigureTest.java | 1 - 2 files changed, 2 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/ThenTextFigureTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/ThenTextFigureTest.java index 1b85e71df..a8c0f826b 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/ThenTextFigureTest.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/ThenTextFigureTest.java @@ -6,7 +6,6 @@ import org.jhotdraw.draw.figure.Figure; import org.jhotdraw.samples.svg.figures.SVGTextFigure; -import java.awt.geom.Rectangle2D; import java.util.List; import static com.tngtech.jgiven.impl.util.AssertionUtil.assertNotNull; diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/WhenTextFigureTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/WhenTextFigureTest.java index 8ac087928..e07ef6ae4 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/WhenTextFigureTest.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/bdd/WhenTextFigureTest.java @@ -6,7 +6,6 @@ import org.jhotdraw.draw.figure.Figure; import org.jhotdraw.samples.svg.figures.SVGTextFigure; -import java.awt.geom.Point2D; import java.util.List; import static com.tngtech.jgiven.impl.util.AssertionUtil.assertNotNull; From ad69125c404960926a782debf5aafb29cefce793 Mon Sep 17 00:00:00 2001 From: Siole Date: Wed, 22 Nov 2023 09:19:30 +0100 Subject: [PATCH 78/85] Refactor method name in setArc According to the comment the method was a convinience method to set both the height and width arc, so a more explanatory name would be setBothArchs --- ...ples.svg.figures.SVGRectFigureBDDTest.json | 10 +++--- .../samples/svg/figures/SVGRectFigure.java | 36 +++++-------------- .../svg/figures/SVGRectRadiusHandle.java | 6 ++-- .../svg/io/DefaultSVGFigureFactory.java | 2 +- 4 files changed, 17 insertions(+), 37 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.figures.SVGRectFigureBDDTest.json b/jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.figures.SVGRectFigureBDDTest.json index 4815bef0f..7c22d2408 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.figures.SVGRectFigureBDDTest.json +++ b/jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.figures.SVGRectFigureBDDTest.json @@ -25,7 +25,7 @@ } ], "status": "PASSED", - "durationInNanos": 286564500, + "durationInNanos": 380568400, "depth": 0, "parentFailed": false }, @@ -41,7 +41,7 @@ } ], "status": "PASSED", - "durationInNanos": 50418800, + "durationInNanos": 151817900, "depth": 0, "parentFailed": false }, @@ -57,7 +57,7 @@ } ], "status": "PASSED", - "durationInNanos": 3250400, + "durationInNanos": 16475300, "depth": 0, "parentFailed": false } @@ -65,11 +65,11 @@ "explicitArguments": [], "derivedArguments": [], "status": "SUCCESS", - "durationInNanos": 394912000 + "durationInNanos": 601272700 } ], "casesAsTable": false, - "durationInNanos": 394912000 + "durationInNanos": 601272700 } ], "tagMap": {} diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java index bac4fdf6d..61ebd5e3c 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java @@ -11,7 +11,6 @@ import java.awt.geom.*; import java.util.*; -import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; import org.jhotdraw.draw.*; import static org.jhotdraw.draw.AttributeKeys.FILL_COLOR; import static org.jhotdraw.draw.AttributeKeys.STROKE_CAP; @@ -26,6 +25,7 @@ import org.jhotdraw.geom.GrowStroke; import org.jhotdraw.samples.svg.Gradient; import org.jhotdraw.samples.svg.SVGAttributeKeys; + import static org.jhotdraw.samples.svg.SVGAttributeKeys.*; /** @@ -37,13 +37,9 @@ public class SVGRectFigure extends SVGAttributedFigure implements SVGFigure { private static final long serialVersionUID = 1L; - /** - * Identifies the {@code arcWidth} JavaBeans property. - */ + private static final String ARC_WIDTH_PROPERTY = "arcWidth"; - /** - * Identifies the {@code arcHeight} JavaBeans property. - */ + private static final String ARC_HEIGHT_PROPERTY = "arcHeight"; /** * The variable acv is used for generating the locations of the control @@ -60,7 +56,7 @@ public class SVGRectFigure extends SVGAttributedFigure implements SVGFigure { ACV = (1.0 - cv); } - protected RoundRectangle2D.Double roundrect; //used to be private, but changed to protected for testing purposes + protected RoundRectangle2D.Double roundrect; /** * This is used to perform faster drawing. */ @@ -70,9 +66,6 @@ public class SVGRectFigure extends SVGAttributedFigure implements SVGFigure { */ private transient Shape cachedHitShape; - /** - * Creates a new instance. - */ public SVGRectFigure() { this(0, 0, 0, 0); } @@ -81,9 +74,8 @@ public SVGRectFigure(double x, double y, double width, double height) { this(x, y, width, height, 0, 0); } - //@FeatureEntryPoint("RectangleEntry") - public SVGRectFigure(double x, double y, double width, double height, double rx, double ry) { - roundrect = new RoundRectangle2D.Double(x, y, width, height, rx, ry); + public SVGRectFigure(double x, double y, double width, double height, double arcWidth, double arcHeight) { + roundrect = new RoundRectangle2D.Double(x, y, width, height, arcWidth, arcHeight); SVGAttributeKeys.setDefaults(this); setConnectable(false); } @@ -99,7 +91,7 @@ protected void drawFill(Graphics2D g) { } /** - * We have to generate the path for the round rectangle manually, + * Path for the round rectangle must be generated manually, * because the path of a Java RoundRectangle is drawn counterclockwise * whereas an SVG rect needs to be drawn clockwise. * @param g @@ -175,10 +167,7 @@ public void setArcHeight(double newValue) { firePropertyChange(ARC_HEIGHT_PROPERTY, oldValue, newValue); } - /** - * Convenience method for setting both the arc width and the arc height. - */ - public void setArc(double width, double height) { + public void setBothArcs(double width, double height) { setArcWidth(width); setArcHeight(height); } @@ -210,9 +199,6 @@ public Rectangle2D.Double getDrawingArea() { return r; } - /** - * Checks if a Point2D.Double is inside the figure. - */ @Override public boolean contains(Point2D.Double p) { return getHitShape().contains(p); @@ -258,11 +244,6 @@ private Shape getHitShape() { } } - /** - * Transforms the figure. - * - * @param tx The transformation. - */ @Override public void transform(AffineTransform tx) { invalidateTransformedShape(); @@ -278,7 +259,6 @@ public void transform(AffineTransform tx) { executeTransform(tx); } } - private void executeTransform(AffineTransform tx){ Point2D.Double anchor = getStartPoint(); Point2D.Double lead = getEndPoint(); diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectRadiusHandle.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectRadiusHandle.java index bd6af1a26..8544e9a36 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectRadiusHandle.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectRadiusHandle.java @@ -11,7 +11,7 @@ import java.awt.*; import java.awt.event.KeyEvent; import java.awt.geom.*; -import org.jhotdraw.draw.*; + import static org.jhotdraw.draw.AttributeKeys.TRANSFORM; import org.jhotdraw.draw.event.CompositeFigureEdit; import org.jhotdraw.draw.handle.AbstractHandle; @@ -95,7 +95,7 @@ public void trackStep(Point anchor, Point lead, int modifiersEx) { } } Rectangle2D.Double r = owner.getBounds(); - owner.setArc( + owner.setBothArcs( Math.min(owner.getWidth(), Math.max(0, p.x - r.x)), Math.min(owner.getHeight(), Math.max(0, p.y - r.y))); owner.changed(); @@ -145,7 +145,7 @@ public void keyPressed(KeyEvent evt) { } if (!newArc.equals(oldArc)) { owner.willChange(); - owner.setArc(newArc.width, newArc.height); + owner.setBothArcs(newArc.width, newArc.height); owner.changed(); ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels"); diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/io/DefaultSVGFigureFactory.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/io/DefaultSVGFigureFactory.java index fe29d444b..53b02d372 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/io/DefaultSVGFigureFactory.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/io/DefaultSVGFigureFactory.java @@ -46,7 +46,7 @@ public DefaultSVGFigureFactory() { public Figure createRect(double x, double y, double w, double h, double rx, double ry, Map, Object> a) { SVGRectFigure figure = new SVGRectFigure(); figure.setBounds(new Point2D.Double(x, y), new Point2D.Double(x + w, y + h)); - figure.setArc(rx, ry); + figure.setBothArcs(rx, ry); figure.setAttributes(a); return figure; } From fe331c746e55f30479ebbfe28d8d7ac31d175b09 Mon Sep 17 00:00:00 2001 From: Siole Date: Wed, 22 Nov 2023 09:30:50 +0100 Subject: [PATCH 79/85] Extracted method drawStroke in SVGRectFigure Long method is divided into two methods for better readability in code. --- .../samples/svg/figures/SVGRectFigure.java | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java index 61ebd5e3c..1e799d3f6 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java @@ -101,32 +101,36 @@ protected void drawStroke(Graphics2D g) { if (roundrect.archeight == 0 && roundrect.arcwidth == 0) { g.draw(roundrect.getBounds2D()); } else { - Path2D.Double p = new Path2D.Double(); - double aw = roundrect.arcwidth / 2d; - double ah = roundrect.archeight / 2d; - p.moveTo((roundrect.x + aw), (float) roundrect.y); - p.lineTo((roundrect.x + roundrect.width - aw), (float) roundrect.y); - p.curveTo((roundrect.x + roundrect.width - aw * ACV), (float) roundrect.y, - (roundrect.x + roundrect.width), (float) (roundrect.y + ah * ACV), - (roundrect.x + roundrect.width), (roundrect.y + ah)); - p.lineTo((roundrect.x + roundrect.width), (roundrect.y + roundrect.height - ah)); - p.curveTo( - (roundrect.x + roundrect.width), (roundrect.y + roundrect.height - ah * ACV), - (roundrect.x + roundrect.width - aw * ACV), (roundrect.y + roundrect.height), - (roundrect.x + roundrect.width - aw), (roundrect.y + roundrect.height)); - p.lineTo((roundrect.x + aw), (roundrect.y + roundrect.height)); - p.curveTo((roundrect.x + aw * ACV), (roundrect.y + roundrect.height), - (roundrect.x), (roundrect.y + roundrect.height - ah * ACV), - (float) roundrect.x, (roundrect.y + roundrect.height - ah)); - p.lineTo((float) roundrect.x, (roundrect.y + ah)); - p.curveTo((roundrect.x), (roundrect.y + ah * ACV), - (roundrect.x + aw * ACV), (float) (roundrect.y), - (float) (roundrect.x + aw), (float) (roundrect.y)); - p.closePath(); - g.draw(p); + drawPath(g); } } + private void drawPath(Graphics2D g) { + Path2D.Double p = new Path2D.Double(); + double aw = roundrect.arcwidth / 2d; + double ah = roundrect.archeight / 2d; + p.moveTo((roundrect.x + aw), (float) roundrect.y); + p.lineTo((roundrect.x + roundrect.width - aw), (float) roundrect.y); + p.curveTo((roundrect.x + roundrect.width - aw * ACV), (float) roundrect.y, + (roundrect.x + roundrect.width), (float) (roundrect.y + ah * ACV), + (roundrect.x + roundrect.width), (roundrect.y + ah)); + p.lineTo((roundrect.x + roundrect.width), (roundrect.y + roundrect.height - ah)); + p.curveTo( + (roundrect.x + roundrect.width), (roundrect.y + roundrect.height - ah * ACV), + (roundrect.x + roundrect.width - aw * ACV), (roundrect.y + roundrect.height), + (roundrect.x + roundrect.width - aw), (roundrect.y + roundrect.height)); + p.lineTo((roundrect.x + aw), (roundrect.y + roundrect.height)); + p.curveTo((roundrect.x + aw * ACV), (roundrect.y + roundrect.height), + (roundrect.x), (roundrect.y + roundrect.height - ah * ACV), + (float) roundrect.x, (roundrect.y + roundrect.height - ah)); + p.lineTo((float) roundrect.x, (roundrect.y + ah)); + p.curveTo((roundrect.x), (roundrect.y + ah * ACV), + (roundrect.x + aw * ACV), (float) (roundrect.y), + (float) (roundrect.x + aw), (float) (roundrect.y)); + p.closePath(); + g.draw(p); + } + // SHAPE AND BOUNDS public double getX() { return roundrect.x; From d6db4fafbb8f2fff3ab331d97082cbaf7637c473 Mon Sep 17 00:00:00 2001 From: Siole Date: Wed, 22 Nov 2023 09:46:34 +0100 Subject: [PATCH 80/85] Update comments in SVGRectFigure --- .../samples/svg/figures/SVGRectFigure.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java index 1e799d3f6..95caabf63 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java @@ -80,7 +80,9 @@ public SVGRectFigure(double x, double y, double width, double height, double arc setConnectable(false); } - // DRAWING + /** + * Drawing + */ @Override protected void drawFill(Graphics2D g) { if (getArcHeight() == 0d && getArcWidth() == 0d) { @@ -90,12 +92,7 @@ protected void drawFill(Graphics2D g) { } } - /** - * Path for the round rectangle must be generated manually, - * because the path of a Java RoundRectangle is drawn counterclockwise - * whereas an SVG rect needs to be drawn clockwise. - * @param g - */ + @Override protected void drawStroke(Graphics2D g) { if (roundrect.archeight == 0 && roundrect.arcwidth == 0) { @@ -105,6 +102,12 @@ protected void drawStroke(Graphics2D g) { } } + /** + * Path for the round rectangle must be generated manually, + * because the path of a Java RoundRectangle is drawn counterclockwise + * whereas an SVG rect needs to be drawn clockwise. + * @param g + */ private void drawPath(Graphics2D g) { Path2D.Double p = new Path2D.Double(); double aw = roundrect.arcwidth / 2d; @@ -131,7 +134,9 @@ private void drawPath(Graphics2D g) { g.draw(p); } - // SHAPE AND BOUNDS + /** + * Shape and Bounds + */ public double getX() { return roundrect.x; } @@ -158,7 +163,6 @@ public double getArcHeight() { public static String getArcWidthProperty(){ return ARC_WIDTH_PROPERTY; } public static String getArcHeightProperty(){ return ARC_HEIGHT_PROPERTY; } - public void setArcWidth(double newValue) { double oldValue = roundrect.arcwidth; roundrect.arcwidth = newValue; @@ -300,7 +304,9 @@ public Object getTransformRestoreData() { STROKE_GRADIENT.getClone(this)}; } - // EDITING + /** + * Editing + */ @Override public Collection createHandles(int detailLevel) { LinkedList handles = new LinkedList<>(); @@ -322,7 +328,9 @@ public Collection createHandles(int detailLevel) { return handles; } - // CLONING + /** + * Cloning + */ @Override public SVGRectFigure clone() { SVGRectFigure that = (SVGRectFigure) super.clone(); From 6fa13f40fea770adac2d2dc902f2b694e4597cf6 Mon Sep 17 00:00:00 2001 From: Siole Date: Wed, 22 Nov 2023 10:08:05 +0100 Subject: [PATCH 81/85] update on BDD test --- ...tdraw.samples.svg.figures.SVGRectFigureBDDTest.json | 10 +++++----- .../svg/figures/jgivenstages/GivenRectangle.java | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.figures.SVGRectFigureBDDTest.json b/jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.figures.SVGRectFigureBDDTest.json index 7c22d2408..5f2566a74 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.figures.SVGRectFigureBDDTest.json +++ b/jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.figures.SVGRectFigureBDDTest.json @@ -25,7 +25,7 @@ } ], "status": "PASSED", - "durationInNanos": 380568400, + "durationInNanos": 232622500, "depth": 0, "parentFailed": false }, @@ -41,7 +41,7 @@ } ], "status": "PASSED", - "durationInNanos": 151817900, + "durationInNanos": 45962300, "depth": 0, "parentFailed": false }, @@ -57,7 +57,7 @@ } ], "status": "PASSED", - "durationInNanos": 16475300, + "durationInNanos": 16249500, "depth": 0, "parentFailed": false } @@ -65,11 +65,11 @@ "explicitArguments": [], "derivedArguments": [], "status": "SUCCESS", - "durationInNanos": 601272700 + "durationInNanos": 334821600 } ], "casesAsTable": false, - "durationInNanos": 601272700 + "durationInNanos": 334821600 } ], "tagMap": {} diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenRectangle.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenRectangle.java index 918751b1d..30aa6ea11 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenRectangle.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/GivenRectangle.java @@ -2,14 +2,13 @@ import com.tngtech.jgiven.Stage; import com.tngtech.jgiven.annotation.ProvidedScenarioState; -import com.tngtech.jgiven.annotation.ScenarioState; import org.jhotdraw.draw.DefaultDrawing; import org.jhotdraw.draw.Drawing; -import org.jhotdraw.draw.QuadTreeDrawing; + public class GivenRectangle extends Stage{ - @ScenarioState + @ProvidedScenarioState Drawing drawing; public GivenRectangle empty_canvas(){ From 1419fa779636141bdc9a0b6ccbf320f15686494f Mon Sep 17 00:00:00 2001 From: Siole Date: Tue, 28 Nov 2023 11:38:00 +0100 Subject: [PATCH 82/85] Semantic corrections --- .../main/java/org/jhotdraw/samples/svg/Main.java | 1 - .../jhotdraw/samples/svg/figures/SVGRectFigure.java | 13 ++++++++++--- .../svg/figures/jgivenstages/ThenRectangle.java | 1 - .../svg/figures/jgivenstages/WhenRectangle.java | 1 - 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java index 79aec2f9e..a690f09cd 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/Main.java @@ -7,7 +7,6 @@ */ package org.jhotdraw.samples.svg; -import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint; import org.jhotdraw.api.app.Application; import org.jhotdraw.app.OSXApplication; import org.jhotdraw.app.SDIApplication; diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java index 95caabf63..e3ebda659 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGRectFigure.java @@ -160,8 +160,13 @@ public double getArcWidth() { public double getArcHeight() { return roundrect.archeight; } - public static String getArcWidthProperty(){ return ARC_WIDTH_PROPERTY; } - public static String getArcHeightProperty(){ return ARC_HEIGHT_PROPERTY; } + public static String getArcWidthProperty() { + return ARC_WIDTH_PROPERTY; + } + + public static String getArcHeightProperty() { + return ARC_HEIGHT_PROPERTY; + } public void setArcWidth(double newValue) { double oldValue = roundrect.arcwidth; @@ -242,7 +247,9 @@ private Shape getTransformedShape() { } private Shape getHitShape() { - if (cachedHitShape != null) {return cachedHitShape;} + if (cachedHitShape != null) { + return cachedHitShape; + } if (get(FILL_COLOR) != null || get(FILL_GRADIENT) != null) { return cachedHitShape = new GrowStroke( (float) AttributeKeys.getStrokeTotalWidth(this, 1.0) / 2f, diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenRectangle.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenRectangle.java index 9b1329af7..c0a81a73c 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenRectangle.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/ThenRectangle.java @@ -1,7 +1,6 @@ package org.jhotdraw.samples.svg.figures.jgivenstages; import com.tngtech.jgiven.Stage; -import com.tngtech.jgiven.annotation.ExpectedScenarioState; import com.tngtech.jgiven.annotation.ScenarioState; import org.jhotdraw.draw.Drawing; import org.jhotdraw.draw.figure.Figure; diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenRectangle.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenRectangle.java index 41d240a99..2e3eab5f3 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenRectangle.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/jgivenstages/WhenRectangle.java @@ -1,7 +1,6 @@ package org.jhotdraw.samples.svg.figures.jgivenstages; import com.tngtech.jgiven.Stage; -import com.tngtech.jgiven.annotation.ExpectedScenarioState; import com.tngtech.jgiven.annotation.ScenarioState; import org.jhotdraw.draw.Drawing; import org.jhotdraw.samples.svg.figures.SVGRectFigure; From 092dc783df09eb42a5079f9f676c0715b4f19180 Mon Sep 17 00:00:00 2001 From: GustavFrandsen Date: Wed, 3 Jan 2024 13:39:04 +0100 Subject: [PATCH 83/85] final changes --- ...samples.svg.ImageFeatureBehaviourTest.json | 71 ++++++++++++++++ .../samples/svg/figures/SVGEllipseFigure.java | 3 - .../samples/svg/figures/SVGImageFigure.java | 84 +++++++++++-------- .../svg/ImageFeatureBehaviourTest.java | 25 ++++++ .../svg/figures/SVGImageFigureTest.java | 44 ++++++++++ .../samples/svg/jgivenstages/GivenImage.java | 22 +++++ .../samples/svg/jgivenstages/ThenImage.java | 39 +++++++++ .../samples/svg/jgivenstages/WhenImage.java | 44 ++++++++++ 8 files changed, 293 insertions(+), 39 deletions(-) create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.ImageFeatureBehaviourTest.json create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/ImageFeatureBehaviourTest.java create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGImageFigureTest.java create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/GivenImage.java create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/ThenImage.java create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/WhenImage.java diff --git a/jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.ImageFeatureBehaviourTest.json b/jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.ImageFeatureBehaviourTest.json new file mode 100644 index 000000000..cf7acede4 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.ImageFeatureBehaviourTest.json @@ -0,0 +1,71 @@ +{ + "className": "org.jhotdraw.samples.svg.ImageFeatureBehaviourTest", + "name": "Image Feature Behaviour", + "scenarios": [ + { + "className": "org.jhotdraw.samples.svg.ImageFeatureBehaviourTest", + "testMethodName": "drawImage", + "description": "Draw image", + "tagIds": [], + "explicitParameters": [], + "derivedParameters": [], + "casesAsTable": false, + "scenarioCases": [ + { + "caseNr": 1, + "steps": [ + { + "name": "an empty drawing", + "words": [ + { + "value": "Given", + "isIntroWord": true + }, + { + "value": "an empty drawing" + } + ], + "status": "PASSED", + "durationInNanos": 142936200 + }, + { + "name": "an image is drawn", + "words": [ + { + "value": "When", + "isIntroWord": true + }, + { + "value": "an image is drawn" + } + ], + "status": "PASSED", + "durationInNanos": 22861600 + }, + { + "name": "the drawing cointans the drawn image", + "words": [ + { + "value": "Then", + "isIntroWord": true + }, + { + "value": "the drawing cointans the drawn image" + } + ], + "status": "PASSED", + "durationInNanos": 2560300 + } + ], + "explicitArguments": [], + "derivedArguments": [], + "status": "SUCCESS", + "durationInNanos": 192670400 + } + ], + "durationInNanos": 192670400, + "executionStatus": "SUCCESS" + } + ], + "tagMap": {} +} \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java index 6084f27fa..b976c0007 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGEllipseFigure.java @@ -15,10 +15,7 @@ import org.jhotdraw.draw.*; import static org.jhotdraw.draw.AttributeKeys.FILL_COLOR; import static org.jhotdraw.draw.AttributeKeys.TRANSFORM; -import org.jhotdraw.draw.handle.BoundsOutlineHandle; import org.jhotdraw.draw.handle.Handle; -import org.jhotdraw.draw.handle.ResizeHandleKit; -import org.jhotdraw.draw.handle.TransformHandleKit; import org.jhotdraw.geom.Geom; import org.jhotdraw.geom.GrowStroke; import org.jhotdraw.samples.svg.Gradient; diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java index e0e3a148d..b15119e08 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/svg/figures/SVGImageFigure.java @@ -16,6 +16,7 @@ import java.awt.geom.*; import java.awt.image.*; import java.io.*; +import java.nio.file.Files; import java.util.*; import javax.imageio.ImageIO; import javax.swing.*; @@ -23,10 +24,7 @@ import static org.jhotdraw.draw.AttributeKeys.TRANSFORM; import org.jhotdraw.draw.event.TransformRestoreEdit; -import org.jhotdraw.draw.handle.BoundsOutlineHandle; import org.jhotdraw.draw.handle.Handle; -import org.jhotdraw.draw.handle.ResizeHandleKit; -import org.jhotdraw.draw.handle.TransformHandleKit; import org.jhotdraw.geom.GrowStroke; import org.jhotdraw.samples.svg.SVGAttributeKeys; @@ -263,6 +261,7 @@ public void actionPerformed(ActionEvent evt) { } }); } + if (bufferedImage != null) { if (rectangle.width != bufferedImage.getWidth() || rectangle.height != bufferedImage.getHeight()) { @@ -271,16 +270,7 @@ public void actionPerformed(ActionEvent evt) { @Override public void actionPerformed(ActionEvent evt) { - Object geometry = getTransformRestoreData(); - willChange(); - rectangle = new Rectangle2D.Double( - rectangle.x - (bufferedImage.getWidth() - rectangle.width) / 2d, - rectangle.y - (bufferedImage.getHeight() - rectangle.height) / 2d, - bufferedImage.getWidth(), - bufferedImage.getHeight()); - fireUndoableEditHappened( - new TransformRestoreEdit(SVGImageFigure.this, geometry, getTransformRestoreData())); - changed(); + actionsPerformed1(); } }); } @@ -292,13 +282,7 @@ public void actionPerformed(ActionEvent evt) { @Override public void actionPerformed(ActionEvent evt) { - Object geometry = getTransformRestoreData(); - willChange(); - double newHeight = bufferedImage.getHeight() * rectangle.width / bufferedImage.getWidth(); - rectangle = new Rectangle2D.Double(rectangle.x, rectangle.y - (newHeight - rectangle.height) / 2d, rectangle.width, newHeight); - fireUndoableEditHappened( - new TransformRestoreEdit(SVGImageFigure.this, geometry, getTransformRestoreData())); - changed(); + actionsPerformed2(); } }); actions.add(new AbstractAction(labels.getString("edit.adjustWidthToImageAspect.text")) { @@ -306,13 +290,7 @@ public void actionPerformed(ActionEvent evt) { @Override public void actionPerformed(ActionEvent evt) { - Object geometry = getTransformRestoreData(); - willChange(); - double newWidth = bufferedImage.getWidth() * rectangle.height / bufferedImage.getHeight(); - rectangle = new Rectangle2D.Double(rectangle.x - (newWidth - rectangle.width) / 2d, rectangle.y, newWidth, rectangle.height); - fireUndoableEditHappened( - new TransformRestoreEdit(SVGImageFigure.this, geometry, getTransformRestoreData())); - changed(); + actionsPerformed3(); } }); } @@ -320,16 +298,50 @@ public void actionPerformed(ActionEvent evt) { return actions; } + private void actionsPerformed1(){ + Object geometry = getTransformRestoreData(); + willChange(); + rectangle = new Rectangle2D.Double( + rectangle.x - (bufferedImage.getWidth() - rectangle.width) / 2d, + rectangle.y - (bufferedImage.getHeight() - rectangle.height) / 2d, + bufferedImage.getWidth(), + bufferedImage.getHeight()); + fireUndoableEditHappened( + new TransformRestoreEdit(SVGImageFigure.this, geometry, getTransformRestoreData())); + changed(); + } + + private void actionsPerformed2(){ + Object geometry = getTransformRestoreData(); + willChange(); + double newHeight = bufferedImage.getHeight() * rectangle.width / bufferedImage.getWidth(); + rectangle = new Rectangle2D.Double(rectangle.x, rectangle.y - (newHeight - rectangle.height) / 2d, rectangle.width, newHeight); + fireUndoableEditHappened( + new TransformRestoreEdit(SVGImageFigure.this, geometry, getTransformRestoreData())); + changed(); + } + private void actionsPerformed3(){ + Object geometry = getTransformRestoreData(); + willChange(); + double newWidth = bufferedImage.getWidth() * rectangle.height / bufferedImage.getHeight(); + rectangle = new Rectangle2D.Double(rectangle.x - (newWidth - rectangle.width) / 2d, rectangle.y, newWidth, rectangle.height); + fireUndoableEditHappened( + new TransformRestoreEdit(SVGImageFigure.this, geometry, getTransformRestoreData())); + changed(); + + } + + // CONNECTING // COMPOSITE FIGURES // CLONING @Override public SVGImageFigure clone() { - SVGImageFigure that = (SVGImageFigure) super.clone(); - that.rectangle = (Rectangle2D.Double) this.rectangle.clone(); - that.cachedTransformedShape = null; - that.cachedHitShape = null; - return that; + SVGImageFigure copy = (SVGImageFigure) super.clone(); + copy.rectangle = (Rectangle2D.Double) this.rectangle.clone(); + copy.cachedTransformedShape = null; + copy.cachedHitShape = null; + return copy; } @Override @@ -400,7 +412,7 @@ public BufferedImage getBufferedImage() { if (bufferedImage == null && imageData != null) { try { bufferedImage = ImageIO.read(new ByteArrayInputStream(imageData)); - } catch (Exception e) { + } catch (IOException e) { e.printStackTrace(); // If we can't create a buffered image from the image data, // there is no use to keep the image data and try again, so @@ -440,9 +452,9 @@ public byte[] getImageData() { @Override public void loadImage(File file) throws IOException { - try (InputStream in = new FileInputStream(file)) { + try (InputStream in = Files.newInputStream(file.toPath())) { loadImage(in); - } catch (Exception t) { + } catch (IOException t) { ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels"); IOException e = new IOException(labels.getFormatted("file.failedToLoadImage.message", file.getName())); e.initCause(t); @@ -461,7 +473,7 @@ public void loadImage(InputStream in) throws IOException { BufferedImage img; try { img = ImageIO.read(new ByteArrayInputStream(baos.toByteArray())); - } catch (Exception t) { + } catch (IOException t) { img = null; } if (img == null) { diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/ImageFeatureBehaviourTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/ImageFeatureBehaviourTest.java new file mode 100644 index 000000000..53a2b5610 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/ImageFeatureBehaviourTest.java @@ -0,0 +1,25 @@ +package org.jhotdraw.samples.svg; +import org.jhotdraw.samples.svg.jgivenstages.GivenImage; +import org.jhotdraw.samples.svg.jgivenstages.ThenImage; +import org.jhotdraw.samples.svg.jgivenstages.WhenImage; +import org.junit.Test; +import com.tngtech.jgiven.junit.ScenarioTest; + +public class ImageFeatureBehaviourTest extends ScenarioTest{ + + @Test + public void drawImage() { + given().anEmptyDrawing(); + when().anImageIsDrawn(); + then().theDrawingCointansTheDrawnImage(); + } + + @Test + public void resizeImage() { + given().anEmptyDrawing() + .and().anImageIsAdded(); + when().theImageIsResized(); + then().theImageHasTheNewSize(); + } + +} diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGImageFigureTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGImageFigureTest.java new file mode 100644 index 000000000..1c21c268f --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/figures/SVGImageFigureTest.java @@ -0,0 +1,44 @@ +package org.jhotdraw.samples.svg.figures; + +import org.junit.Test; +import java.awt.geom.AffineTransform; +import static org.jhotdraw.draw.AttributeKeys.TRANSFORM; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + + +public class SVGImageFigureTest{ + @Test + public void testTransformCanBeApplied() { + SVGImageFigure figure = new SVGImageFigure(); + + AffineTransform transform = new AffineTransform(5, 10, 5, 10, 5, 10); + figure.transform(transform); + + assertEquals(transform, figure.get(TRANSFORM)); + } + + @Test + public void transformShouldSetTransformWhenNoExistingTransform() { + // Arrange + SVGImageFigure imageFigure = new SVGImageFigure(); + AffineTransform nonExistingTransform = imageFigure.get(TRANSFORM); + + assertNull(nonExistingTransform); + } + + @Test + public void transformShouldSetBoundsWhenSpecialConditionIsMet() { + SVGImageFigure imageFigure1 = new SVGImageFigure(); + AffineTransform transform1 = new AffineTransform(2, 1, 2, 1, 2, 1); + AffineTransform transform2 = new AffineTransform(1, 2, 1, 2, 1, 2); + + imageFigure1.transform(transform2); + imageFigure1.transform(transform1); + + AffineTransform expectedTransform = new AffineTransform(6, 3, 6, 3, 8, 4); + assertEquals(expectedTransform, imageFigure1.get(TRANSFORM)); + + + } +} \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/GivenImage.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/GivenImage.java new file mode 100644 index 000000000..cdb3b1a8d --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/GivenImage.java @@ -0,0 +1,22 @@ +package org.jhotdraw.samples.svg.jgivenstages; + +import com.tngtech.jgiven.Stage; +import com.tngtech.jgiven.annotation.ProvidedScenarioState; +import org.jhotdraw.draw.Drawing; +import org.jhotdraw.draw.QuadTreeDrawing; +import org.jhotdraw.samples.svg.figures.SVGImageFigure; + +public class GivenImage extends Stage { + + @ProvidedScenarioState + Drawing drawing; + + public GivenImage anEmptyDrawing() { + this.drawing = new QuadTreeDrawing(); + return this; + } + public GivenImage anImageIsAdded() { + this.drawing.add(new SVGImageFigure()); + return this; + } +} diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/ThenImage.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/ThenImage.java new file mode 100644 index 000000000..886db7fda --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/ThenImage.java @@ -0,0 +1,39 @@ +package org.jhotdraw.samples.svg.jgivenstages; + +import com.tngtech.jgiven.Stage; +import com.tngtech.jgiven.annotation.ScenarioState; +import org.jhotdraw.draw.Drawing; +import org.jhotdraw.draw.figure.Figure; +import org.jhotdraw.samples.svg.figures.SVGEllipseFigure; +import org.jhotdraw.samples.svg.figures.SVGFigure; +import org.jhotdraw.samples.svg.figures.SVGImageFigure; +import org.jhotdraw.samples.svg.figures.SVGImageFigureTest; + +import java.awt.geom.Rectangle2D; +import java.util.List; + +import static org.junit.Assert.*; + +public class ThenImage extends Stage { + + @ScenarioState + Drawing drawing; + + public ThenImage theDrawingCointansTheDrawnImage() { + List
figures = drawing.getFiguresFrontToBack(); + assertTrue(figures.stream().anyMatch(figure -> figure instanceof SVGImageFigure)); + return this; + } + + public ThenImage theImageHasTheNewSize() { + assertNotNull(drawing); + List
figures = drawing.getFiguresFrontToBack(); + assertEquals(figures.size(), 1); + Figure figure = figures.get(0); + assertTrue(figure instanceof SVGImageFigure); + SVGImageFigure ellipse = (SVGImageFigure) figure; + Rectangle2D bounds = ellipse.getBounds(); + assertEquals(new Rectangle2D.Double(1, 2, 3, 4), bounds); + return this; + } +} diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/WhenImage.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/WhenImage.java new file mode 100644 index 000000000..159d6dd31 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/WhenImage.java @@ -0,0 +1,44 @@ +package org.jhotdraw.samples.svg.jgivenstages; + +import com.tngtech.jgiven.Stage; +import com.tngtech.jgiven.annotation.ScenarioState; +import org.jhotdraw.draw.Drawing; +import org.jhotdraw.draw.figure.Figure; +import org.jhotdraw.samples.svg.figures.SVGEllipseFigure; +import org.jhotdraw.samples.svg.figures.SVGFigure; +import org.jhotdraw.samples.svg.figures.SVGImageFigure; +import org.jhotdraw.samples.svg.figures.SVGImageFigureTest; + +import java.awt.geom.Point2D; +import java.util.List; + +import static org.junit.Assert.*; + +public class WhenImage extends Stage { + + @ScenarioState + Drawing drawing; + public WhenImage anImageIsDrawn(){ + assertNotNull(drawing); + drawing.add(new SVGImageFigure()); + return this; + } + + public WhenImage anEllipseIsDrawn() { + assertNotNull(drawing); + drawing.add(new SVGEllipseFigure()); + return this; + } + + public WhenImage theImageIsResized() { + assertNotNull(drawing); + List
figures = drawing.getFiguresFrontToBack(); + assertEquals(figures.size(), 1); + Figure figure = figures.get(0); + assertTrue(figure instanceof SVGImageFigure); + SVGImageFigure ellipse = (SVGImageFigure) figure; + ellipse.setBounds(new Point2D.Double(1, 2), new Point2D.Double(4, 6)); + return this; + } +} + From 5c3ecb43685747afbf3eb21b9b2ed8fa8e6cc7bb Mon Sep 17 00:00:00 2001 From: GustavFrandsen Date: Wed, 3 Jan 2024 13:50:43 +0100 Subject: [PATCH 84/85] removed unuses imports --- .../java/org/jhotdraw/samples/svg/jgivenstages/ThenImage.java | 3 --- .../java/org/jhotdraw/samples/svg/jgivenstages/WhenImage.java | 2 -- 2 files changed, 5 deletions(-) diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/ThenImage.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/ThenImage.java index 886db7fda..5b1c39e40 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/ThenImage.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/ThenImage.java @@ -4,10 +4,7 @@ import com.tngtech.jgiven.annotation.ScenarioState; import org.jhotdraw.draw.Drawing; import org.jhotdraw.draw.figure.Figure; -import org.jhotdraw.samples.svg.figures.SVGEllipseFigure; -import org.jhotdraw.samples.svg.figures.SVGFigure; import org.jhotdraw.samples.svg.figures.SVGImageFigure; -import org.jhotdraw.samples.svg.figures.SVGImageFigureTest; import java.awt.geom.Rectangle2D; import java.util.List; diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/WhenImage.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/WhenImage.java index 159d6dd31..34a5d3852 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/WhenImage.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/jgivenstages/WhenImage.java @@ -5,9 +5,7 @@ import org.jhotdraw.draw.Drawing; import org.jhotdraw.draw.figure.Figure; import org.jhotdraw.samples.svg.figures.SVGEllipseFigure; -import org.jhotdraw.samples.svg.figures.SVGFigure; import org.jhotdraw.samples.svg.figures.SVGImageFigure; -import org.jhotdraw.samples.svg.figures.SVGImageFigureTest; import java.awt.geom.Point2D; import java.util.List; From fea78fc4348e45ad9ca8ac36ad49d806bea7ff56 Mon Sep 17 00:00:00 2001 From: mShadow56 Date: Thu, 4 Jan 2024 10:07:53 +0100 Subject: [PATCH 85/85] KennethBasicEditing --- .../org/jhotdraw/draw/io/TextInputFormat.java | 12 ++-- ...draw.samples.svg.DeleteDrawingBDDTest.json | 71 +++++++++++++++++++ .../jhotdraw-samples-misc/pom.xml | 13 ++++ .../org/jhotdraw/samples/net/NetPanel.java | 8 +-- .../samples/svg/BasicEdit/GivenDelete.java | 25 +++++++ .../samples/svg/BasicEdit/ThenDelete.java | 25 +++++++ .../samples/svg/BasicEdit/WhenDelete.java | 20 ++++++ .../samples/svg/DeleteDrawingBDDTest.java | 20 ++++++ 8 files changed, 182 insertions(+), 12 deletions(-) create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.DeleteDrawingBDDTest.json create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/BasicEdit/GivenDelete.java create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/BasicEdit/ThenDelete.java create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/BasicEdit/WhenDelete.java create mode 100644 jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/DeleteDrawingBDDTest.java diff --git a/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/TextInputFormat.java b/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/TextInputFormat.java index ea6eac74e..9496dd36d 100644 --- a/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/TextInputFormat.java +++ b/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/TextInputFormat.java @@ -57,10 +57,6 @@ public class TextInputFormat implements InputFormat { * File name extension used for the file filter. */ private String fileExtension; - /** - * Image IO image format name. - */ - private String formatName; /** * This should be set to true for ImageHolderFigures that can hold multiple * lines of text. @@ -89,7 +85,9 @@ public TextInputFormat(TextHolderFigure prototype) { public TextInputFormat(TextHolderFigure prototype, String formatName, String description, String fileExtension, boolean isMultiline) { this.prototype = prototype; - this.formatName = formatName; + /** + * Image IO image format name. + */ this.description = description; this.fileExtension = fileExtension; this.isMultiline = isMultiline; @@ -137,7 +135,7 @@ public void read(InputStream in, Drawing drawing, boolean replace) throws IOExce drawing.basicAddAll(0, createTextHolderFigures(in)); } - public LinkedList
createTextHolderFigures(InputStream in) throws IOException { + public List
createTextHolderFigures(InputStream in) throws IOException { LinkedList
list = new LinkedList<>(); BufferedReader r = new BufferedReader(new InputStreamReader(in, "UTF8")); if (isMultiline) { @@ -169,7 +167,7 @@ public LinkedList
createTextHolderFigures(InputStream in) throws IOExcep y += s.height; } } - if (list.size() == 0) { + if (list.isEmpty()) { throw new IOException("No text found"); } return list; diff --git a/jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.DeleteDrawingBDDTest.json b/jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.DeleteDrawingBDDTest.json new file mode 100644 index 000000000..9cff954cb --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/jgiven-reports/org.jhotdraw.samples.svg.DeleteDrawingBDDTest.json @@ -0,0 +1,71 @@ +{ + "className": "org.jhotdraw.samples.svg.DeleteDrawingBDDTest", + "name": "Delete Drawing BDD", + "scenarios": [ + { + "className": "org.jhotdraw.samples.svg.DeleteDrawingBDDTest", + "testMethodName": "deleteDrawing", + "description": "Delete drawing", + "tagIds": [], + "explicitParameters": [], + "derivedParameters": [], + "casesAsTable": false, + "scenarioCases": [ + { + "caseNr": 1, + "steps": [ + { + "name": "empty drawing", + "words": [ + { + "value": "Given", + "isIntroWord": true + }, + { + "value": "empty drawing" + } + ], + "status": "PASSED", + "durationInNanos": 135710200 + }, + { + "name": "deleting the drawing", + "words": [ + { + "value": "When", + "isIntroWord": true + }, + { + "value": "deleting the drawing" + } + ], + "status": "PASSED", + "durationInNanos": 446600 + }, + { + "name": "the drawing is deleted", + "words": [ + { + "value": "Then", + "isIntroWord": true + }, + { + "value": "the drawing is deleted" + } + ], + "status": "PASSED", + "durationInNanos": 366700 + } + ], + "explicitArguments": [], + "derivedArguments": [], + "status": "SUCCESS", + "durationInNanos": 170965400 + } + ], + "durationInNanos": 170965400, + "executionStatus": "SUCCESS" + } + ], + "tagMap": {} +} \ No newline at end of file diff --git a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml index b69a502a7..b120f1536 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/pom.xml +++ b/jhotdraw-samples/jhotdraw-samples-misc/pom.xml @@ -70,6 +70,19 @@ 1.0.0-RC6 test + + org.slf4j + slf4j-api + 2.0.9 + compile + + + + org.slf4j + slf4j-simple + 2.0.10 + test + diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/net/NetPanel.java b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/net/NetPanel.java index 64d9a2e42..838cd58e4 100644 --- a/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/net/NetPanel.java +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/main/java/org/jhotdraw/samples/net/NetPanel.java @@ -10,11 +10,8 @@ import java.awt.*; import java.util.*; import javax.swing.*; -import org.jhotdraw.action.edit.CopyAction; -import org.jhotdraw.action.edit.CutAction; -import org.jhotdraw.action.edit.DuplicateAction; -import org.jhotdraw.action.edit.PasteAction; -import org.jhotdraw.action.edit.SelectAllAction; + +import org.jhotdraw.action.edit.*; import org.jhotdraw.draw.AttributeKey; import org.jhotdraw.draw.AttributeKeys; import org.jhotdraw.draw.DefaultDrawing; @@ -67,6 +64,7 @@ public NetPanel() { pb.add(new BringToFrontAction(editor)); pb.add(new SendToBackAction(editor)); pb.addSeparator(); + pb.add(new DeleteAction()); pb.add(new CutAction()); pb.add(new CopyAction()); pb.add(new PasteAction()); diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/BasicEdit/GivenDelete.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/BasicEdit/GivenDelete.java new file mode 100644 index 000000000..d096ba6cf --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/BasicEdit/GivenDelete.java @@ -0,0 +1,25 @@ +package org.jhotdraw.samples.svg.BasicEdit; + +import com.tngtech.jgiven.Stage; +import com.tngtech.jgiven.annotation.ProvidedScenarioState; +import org.jhotdraw.draw.Drawing; +import org.jhotdraw.draw.QuadTreeDrawing; +import org.jhotdraw.samples.svg.figures.SVGRectFigure; + +public class GivenDelete extends Stage { + + @ProvidedScenarioState + Drawing drawing; + + @ProvidedScenarioState + SVGRectFigure rect; + + + public GivenDelete EmptyDrawing() { + this.drawing = new QuadTreeDrawing(); + rect = new SVGRectFigure(10, 10, 50, 100); + drawing.add(rect); + return this; + } + +} diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/BasicEdit/ThenDelete.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/BasicEdit/ThenDelete.java new file mode 100644 index 000000000..7fa9b2481 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/BasicEdit/ThenDelete.java @@ -0,0 +1,25 @@ +package org.jhotdraw.samples.svg.BasicEdit; + +import com.tngtech.jgiven.Stage; +import com.tngtech.jgiven.annotation.ProvidedScenarioState; +import org.jhotdraw.samples.svg.figures.SVGRectFigure; + + + +import static org.junit.Assert.*; + +public class ThenDelete extends Stage { + + + @ProvidedScenarioState + SVGRectFigure rect; + + public ThenDelete theDrawingIsDeleted() { + assertNotNull(rect); + return this; + } + + + + +} diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/BasicEdit/WhenDelete.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/BasicEdit/WhenDelete.java new file mode 100644 index 000000000..8df918852 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/BasicEdit/WhenDelete.java @@ -0,0 +1,20 @@ +package org.jhotdraw.samples.svg.BasicEdit; + +import com.tngtech.jgiven.Stage; +import com.tngtech.jgiven.annotation.ProvidedScenarioState; +import org.jhotdraw.draw.Drawing; +import static org.junit.Assert.*; + +public class WhenDelete extends Stage { + + @ProvidedScenarioState + Drawing drawing; + + + public WhenDelete deletingTheDrawing() { + assertNotNull(this.drawing); + //rect.getActions().add(new DeleteAction()); + return this; + } +} + diff --git a/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/DeleteDrawingBDDTest.java b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/DeleteDrawingBDDTest.java new file mode 100644 index 000000000..cd2a79425 --- /dev/null +++ b/jhotdraw-samples/jhotdraw-samples-misc/src/test/java/org/jhotdraw/samples/svg/DeleteDrawingBDDTest.java @@ -0,0 +1,20 @@ +package org.jhotdraw.samples.svg; + +import com.tngtech.jgiven.junit.ScenarioTest; +import org.jhotdraw.samples.svg.BasicEdit.GivenDelete; +import org.jhotdraw.samples.svg.BasicEdit.WhenDelete; +import org.jhotdraw.samples.svg.BasicEdit.ThenDelete; +import org.junit.Test; + +public class DeleteDrawingBDDTest extends ScenarioTest { + @Test + public void deleteDrawing() { + given().EmptyDrawing(); + when().deletingTheDrawing(); + then().theDrawingIsDeleted(); + } + + + + +}