Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
259 changes: 259 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "CIELABColorSpace",
"request": "launch",
"mainClass": "org.jhotdraw.color.CIELABColorSpace",
"projectName": "jhotdraw-gui"
},
{
"type": "java",
"name": "CIELCHabColorSpace",
"request": "launch",
"mainClass": "org.jhotdraw.color.CIELCHabColorSpace",
"projectName": "jhotdraw-gui"
},
{
"type": "java",
"name": "EditCanvasPanel",
"request": "launch",
"mainClass": "org.jhotdraw.gui.action.EditCanvasPanel",
"projectName": "jhotdraw-gui"
},
{
"type": "java",
"name": "CIEXYChromaticityDiagram",
"request": "launch",
"mainClass": "org.jhotdraw.samples.color.CIEXYChromaticityDiagram",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "JMixer",
"request": "launch",
"mainClass": "org.jhotdraw.samples.color.JMixer",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "WheelsAndSlidersMain",
"request": "launch",
"mainClass": "org.jhotdraw.samples.color.WheelsAndSlidersMain",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "FontChooserMain",
"request": "launch",
"mainClass": "org.jhotdraw.samples.font.FontChooserMain",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "ActivityMonitorSample",
"request": "launch",
"mainClass": "org.jhotdraw.samples.mini.ActivityMonitorSample",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "AnimationSample",
"request": "launch",
"mainClass": "org.jhotdraw.samples.mini.AnimationSample",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "BezierDemo",
"request": "launch",
"mainClass": "org.jhotdraw.samples.mini.BezierDemo",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "ConnectingFiguresSample",
"request": "launch",
"mainClass": "org.jhotdraw.samples.mini.ConnectingFiguresSample",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "CreationToolSample",
"request": "launch",
"mainClass": "org.jhotdraw.samples.mini.CreationToolSample",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "DefaultDOMStorableSample",
"request": "launch",
"mainClass": "org.jhotdraw.samples.mini.DefaultDOMStorableSample",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "DnDMultiEditorSample",
"request": "launch",
"mainClass": "org.jhotdraw.samples.mini.DnDMultiEditorSample",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "EditorSample",
"request": "launch",
"mainClass": "org.jhotdraw.samples.mini.EditorSample",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "FileIconsSample",
"request": "launch",
"mainClass": "org.jhotdraw.samples.mini.FileIconsSample",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "LabeledLineConnectionFigureSample",
"request": "launch",
"mainClass": "org.jhotdraw.samples.mini.LabeledLineConnectionFigureSample",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "LayouterSample",
"request": "launch",
"mainClass": "org.jhotdraw.samples.mini.LayouterSample",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "MovableChildFiguresSample",
"request": "launch",
"mainClass": "org.jhotdraw.samples.mini.MovableChildFiguresSample",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "MovableChildFiguresSampleWithAbstractDrawingView",
"request": "launch",
"mainClass": "org.jhotdraw.samples.mini.MovableChildFiguresSampleWithAbstractDrawingView",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "MovableChildFiguresSampleWithDelegatorDrawingView",
"request": "launch",
"mainClass": "org.jhotdraw.samples.mini.MovableChildFiguresSampleWithDelegatorDrawingView",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "MultiEditorSample",
"request": "launch",
"mainClass": "org.jhotdraw.samples.mini.MultiEditorSample",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "SVGDrawingPanelSample",
"request": "launch",
"mainClass": "org.jhotdraw.samples.mini.SVGDrawingPanelSample",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "SelectionToolSample",
"request": "launch",
"mainClass": "org.jhotdraw.samples.mini.SelectionToolSample",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "SmartConnectionFigureSample",
"request": "launch",
"mainClass": "org.jhotdraw.samples.mini.SmartConnectionFigureSample",
"projectName": "jhotdraw-samples-mini"
},
{
"type": "java",
"name": "Main",
"request": "launch",
"mainClass": "org.jhotdraw.samples.draw.Main",
"projectName": "jhotdraw-samples-misc"
},
{
"type": "java",
"name": "Main(1)",
"request": "launch",
"mainClass": "org.jhotdraw.samples.net.Main",
"projectName": "jhotdraw-samples-misc"
},
{
"type": "java",
"name": "NetApplet",
"request": "launch",
"mainClass": "org.jhotdraw.samples.net.NetApplet",
"projectName": "jhotdraw-samples-misc"
},
{
"type": "java",
"name": "Main(2)",
"request": "launch",
"mainClass": "org.jhotdraw.samples.odg.Main",
"projectName": "jhotdraw-samples-misc"
},
{
"type": "java",
"name": "Main(3)",
"request": "launch",
"mainClass": "org.jhotdraw.samples.pert.Main",
"projectName": "jhotdraw-samples-misc"
},
{
"type": "java",
"name": "PertApplet",
"request": "launch",
"mainClass": "org.jhotdraw.samples.pert.PertApplet",
"projectName": "jhotdraw-samples-misc"
},
{
"type": "java",
"name": "Main(4)",
"request": "launch",
"mainClass": "org.jhotdraw.samples.svg.Main",
"projectName": "jhotdraw-samples-misc"
},
{
"type": "java",
"name": "SVGApplet",
"request": "launch",
"mainClass": "org.jhotdraw.samples.svg.SVGApplet",
"projectName": "jhotdraw-samples-misc"
},
{
"type": "java",
"name": "Main(5)",
"request": "launch",
"mainClass": "org.jhotdraw.samples.teddy.Main",
"projectName": "jhotdraw-samples-misc"
},
{
"type": "java",
"name": "Bezier",
"request": "launch",
"mainClass": "org.jhotdraw.geom.Bezier",
"projectName": "jhotdraw-utils"
}
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sonarlint.connectedMode.project": {
"connectionId": "jakubpotocky",
"projectKey": "JakubPotocky_JHotDraw"
}
}
30 changes: 30 additions & 0 deletions jhotdraw-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,36 @@
<version>6.8.21</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-swing</artifactId>
<version>3.17.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.tngtech.jgiven</groupId>
<artifactId>jgiven-junit</artifactId>
<version>2.0.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jhotdraw-actions</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class ImageFigure extends AbstractAttributedDecoratedFigure
implements ImageHolderFigure {

private static final long serialVersionUID = 1L;
private static final String IMAGE_DATA_STRING = "imageData";
/**
* This rectangle describes the bounds into which we draw the image.
*/
Expand Down Expand Up @@ -117,8 +118,7 @@ protected void drawStroke(Graphics2D g) {
// SHAPE AND BOUNDS
@Override
public Rectangle2D.Double getBounds() {
Rectangle2D.Double bounds = (Rectangle2D.Double) rectangle.clone();
return bounds;
return (Rectangle2D.Double) rectangle.clone();
}

@Override
Expand Down Expand Up @@ -170,14 +170,13 @@ public void restoreTransformTo(Object geometry) {

@Override
public Object getTransformRestoreData() {
return (Rectangle2D.Double) rectangle.clone();
return rectangle.clone();
}

// EDITING
@Override
public Collection<Action> getActions(Point2D.Double p) {
LinkedList<Action> actions = new LinkedList<>();
return actions;
return new LinkedList<>();
}

// CONNECTING
Expand All @@ -193,20 +192,11 @@ public Connector findCompatibleConnector(Connector c, boolean isStartConnector)
return new ChopRectangleConnector(this);
}

// COMPOSITE FIGURES
// CLONING
@Override
public ImageFigure clone() {
ImageFigure that = (ImageFigure) super.clone();
that.rectangle = (Rectangle2D.Double) this.rectangle.clone();
return that;
}

@Override
public void read(DOMInput in) throws IOException {
super.read(in);
if (in.getElementCount("imageData") > 0) {
in.openElement("imageData");
if (in.getElementCount(IMAGE_DATA_STRING) > 0) {
in.openElement(IMAGE_DATA_STRING);
String base64Data = in.getText();
if (base64Data != null) {
setImageData(Base64.decode(base64Data));
Expand All @@ -219,7 +209,7 @@ public void read(DOMInput in) throws IOException {
public void write(DOMOutput out) throws IOException {
super.write(out);
if (getImageData() != null) {
out.openElement("imageData");
out.openElement(IMAGE_DATA_STRING);
out.addText(Base64.encodeBytes(getImageData()));
out.closeElement();
}
Expand Down Expand Up @@ -274,7 +264,6 @@ public BufferedImage getBufferedImage() {
try {
bufferedImage = ImageIO.read(new ByteArrayInputStream(imageData));
} 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
// we drop the image data.
Expand All @@ -300,7 +289,6 @@ public byte[] getImageData() {
bout.close();
imageData = bout.toByteArray();
} catch (IOException e) {
e.printStackTrace();
// If we can't create image data from the buffered image,
// there is no use to keep the buffered image and try again, so
// we drop the buffered image.
Expand All @@ -314,7 +302,7 @@ public byte[] getImageData() {
public void loadImage(File file) throws IOException {
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);
Expand Down
Loading