-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,004 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,22 +5,22 @@ | |
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.flowingcode.vaadin.addons</groupId> | ||
<artifactId>template-addon</artifactId> | ||
<artifactId>image-crop-addon</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<name>Template Add-on</name> | ||
<description>Template Add-on for Vaadin Flow</description> | ||
<name>Image Crop Add-on</name> | ||
<description>Image Crop Add-on for Vaadin Flow</description> | ||
<url>https://www.flowingcode.com/en/open-source/</url> | ||
|
||
<properties> | ||
<vaadin.version>24.3.0</vaadin.version> | ||
<vaadin.version>24.4.6</vaadin.version> | ||
<selenium.version>4.10.0</selenium.version> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<drivers.dir>${project.basedir}/drivers</drivers.dir> | ||
<jetty.version>11.0.12</jetty.version> | ||
<flowingcode.commons.demo.version>3.9.0</flowingcode.commons.demo.version> | ||
<jetty.version>11.0.21</jetty.version> | ||
<flowingcode.commons.demo.version>4.1.0</flowingcode.commons.demo.version> | ||
<frontend.hotdeploy>true</frontend.hotdeploy> | ||
</properties> | ||
|
||
|
@@ -29,7 +29,7 @@ | |
<url>https://www.flowingcode.com</url> | ||
</organization> | ||
|
||
<inceptionYear>2023</inceptionYear> | ||
<inceptionYear>2024</inceptionYear> | ||
<licenses> | ||
<license> | ||
<name>Apache 2</name> | ||
|
@@ -39,9 +39,9 @@ | |
</licenses> | ||
|
||
<scm> | ||
<url>https://github.com/FlowingCode/AddonStarter24</url> | ||
<connection>scm:git:git://github.com/FlowingCode/AddonStarter24.git</connection> | ||
<developerConnection>scm:git:ssh://[email protected]:/FlowingCode/AddonStarter24.git</developerConnection> | ||
<url>https://github.com/FlowingCode/ImageCrop</url> | ||
<connection>scm:git:git://github.com/FlowingCode/ImageCrop.git</connection> | ||
<developerConnection>scm:git:ssh://[email protected]:/FlowingCode/ImageCrop.git</developerConnection> | ||
<tag>master</tag> | ||
</scm> | ||
|
||
|
@@ -156,6 +156,12 @@ | |
<version>5.1.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<version>3.12.4</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
|
@@ -254,7 +260,7 @@ | |
<artifactId>jetty-maven-plugin</artifactId> | ||
<version>${jetty.version}</version> | ||
<configuration> | ||
<scanIntervalSeconds>3</scanIntervalSeconds> | ||
<scan>3</scan> | ||
<!-- Use test scope because the UI/demo classes are in the test package. --> | ||
<useTestScope>true</useTestScope> | ||
<webApp> | ||
|
@@ -363,7 +369,7 @@ | |
<artifactId>jetty-maven-plugin</artifactId> | ||
<version>${jetty.version}</version> | ||
<configuration> | ||
<scanIntervalSeconds>0</scanIntervalSeconds> | ||
<scan>0</scan> | ||
<supportedPackagings> | ||
<supportedPackaging>jar</supportedPackaging> | ||
</supportedPackagings> | ||
|
50 changes: 50 additions & 0 deletions
50
src/main/java/com/flowingcode/vaadin/addons/imagecrop/Crop.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/*- | ||
* #%L | ||
* Image Crop Add-on | ||
* %% | ||
* Copyright (C) 2024 Flowing Code | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
|
||
package com.flowingcode.vaadin.addons.imagecrop; | ||
|
||
/** | ||
* Represents crop dimensions. | ||
* <p> | ||
* The crop dimensions are defined by the unit, x and y coordinates, width, and | ||
* height. | ||
* | ||
* @param unit the unit of the crop dimensions, can be 'px' (pixels) or '%' | ||
* (percentage). | ||
* @param x the x-coordinate of the cropped area. | ||
* @param y the y-coordinate of the cropped area. | ||
* @param width the width of the cropped area | ||
* @param height the height of the cropped area | ||
*/ | ||
public record Crop(String unit, int x, int y, int width, int height) { | ||
|
||
/** | ||
* Returns a string representation of the Crop object. | ||
* | ||
* @return A string representing the crop dimensions in the format: | ||
* "{ unit: %s, x: %s, y: %s, width: %s, height: %s }" | ||
* where %s is replaced by the corresponding value. | ||
*/ | ||
@Override | ||
public final String toString() { | ||
return "{ unit: %s, x: %s, y: %s, width: %s, height: %s }".formatted(unit, x, y, width, height); | ||
} | ||
|
||
} |
57 changes: 57 additions & 0 deletions
57
src/main/java/com/flowingcode/vaadin/addons/imagecrop/CroppedImageEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/*- | ||
* #%L | ||
* Image Crop Add-on | ||
* %% | ||
* Copyright (C) 2024 Flowing Code | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
|
||
package com.flowingcode.vaadin.addons.imagecrop; | ||
|
||
import com.vaadin.flow.component.ComponentEvent; | ||
import com.vaadin.flow.component.DomEvent; | ||
import com.vaadin.flow.component.EventData; | ||
|
||
/** | ||
* Represents an event triggered when an image is cropped and encoded. | ||
*/ | ||
@DomEvent("cropped-image") | ||
public class CroppedImageEvent extends ComponentEvent<ImageCrop> { | ||
|
||
private String croppedImageDataUri; | ||
|
||
/** | ||
* Constructs a new CroppedImageEvent. | ||
* | ||
* @param source the source of the event | ||
* @param fromClient <code>true</code> if the event originated from the client-side, | ||
* <code>false</code> otherwise | ||
* @param croppedImageDataUri the data URL of the cropped image | ||
*/ | ||
public CroppedImageEvent(ImageCrop source, boolean fromClient, | ||
@EventData("event.detail.croppedImageDataUri") String croppedImageDataUri) { | ||
super(source, fromClient); | ||
this.croppedImageDataUri = croppedImageDataUri; | ||
} | ||
|
||
/** | ||
* Returns the cropped image data URL. | ||
* | ||
* @return the cropped image data URL | ||
*/ | ||
public String getCroppedImageDataUri() { | ||
return this.croppedImageDataUri; | ||
} | ||
} |
Oops, something went wrong.