From 156964322b61560edf9cdee5cb48a61018e8ca26 Mon Sep 17 00:00:00 2001 From: romankh3 Date: Thu, 10 Feb 2022 19:29:50 +0300 Subject: [PATCH] #212: updated metrics in GitHub #212: updated Javadocs --- .circleci/config.yml | 46 +++++++++++++++++++ .travis.yml | 13 ------ README.md | 8 +--- pom.xml | 12 +++-- .../image/comparison/ImageComparison.java | 5 +- .../image/comparison/ImageComparisonUtil.java | 2 +- .../image/comparison/model/ExcludedAreas.java | 5 ++ .../image/comparison/model/Rectangle.java | 6 +-- 8 files changed, 66 insertions(+), 31 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 .travis.yml diff --git a/ .circleci/config.yml b/ .circleci/config.yml new file mode 100644 index 0000000..f2320ae --- /dev/null +++ b/ .circleci/config.yml @@ -0,0 +1,46 @@ +# Java Gradle CircleCI 2.0 configuration file +# See: https://circleci.com/docs/2.0/language-java/ +version: 2 + +# Define a job to be invoked later in a workflow. +# See: https://circleci.com/docs/2.0/configuration-reference/#jobs +jobs: + build: + # Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub. + # See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor + docker: + # specify the version you desire here + - image: circleci/openjdk:8-jdk + + # Specify service dependencies here if necessary + # CircleCI maintains a library of pre-built images + # documented at https://circleci.com/docs/2.0/circleci-images/ + # - image: circleci/postgres:9.4 + + working_directory: ~/repo + + environment: + # Customize the JVM maximum heap limit + JVM_OPTS: -Xmx3200m + TERM: dumb + # Add steps to the job + # See: https://circleci.com/docs/2.0/configuration-reference/#steps + steps: + - checkout + + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "build.gradle" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + - run: gradle dependencies + + - save_cache: + paths: + - ~/.gradle + key: v1-dependencies-{{ checksum "build.gradle" }} + + # run tests! + - run: gradle test jacocoTestReport coveralls \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index effa563..0000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: java - -script: ./gradlew clean build jacocoTestReport - -before_install: - - "export DISPLAY=:99.0" -services: - - xvfb -jdk: - - openjdk8 - -after_success: - - ./gradlew jacocoTestReport coveralls \ No newline at end of file diff --git a/README.md b/README.md index e5f38f7..06c53d1 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![Maven Central](https://img.shields.io/maven-central/v/com.github.romankh3/image-comparison.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.github.romankh3%22%20AND%20a:%22image-comparison%22) [![Gitter](https://badges.gitter.im/image-comparison/community.svg)](https://gitter.im/image-comparison/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Javadocs](http://www.javadoc.io/badge/com.github.romankh3/image-comparison.svg?color=green)](http://www.javadoc.io/doc/com.github.romankh3/image-comparison) -[![Codacy Badge](https://api.codacy.com/project/badge/Grade/e4fd1c61d0f147358f8c5df212256491)](https://app.codacy.com/app/romankh3/image-comparison?utm_source=github.com&utm_medium=referral&utm_content=romankh3/image-comparison&utm_campaign=Badge_Grade_Dashboard) -[![Build Status](https://travis-ci.org/romankh3/image-comparison.svg?branch=master)](https://travis-ci.org/romankh3/image-comparison) [![Coverage Status](https://coveralls.io/repos/github/romankh3/image-comparison/badge.svg?branch=master)](https://coveralls.io/github/romankh3/image-comparison?branch=master) [![BCH compliance](https://bettercodehub.com/edge/badge/romankh3/image-comparison?branch=master)](https://bettercodehub.com/) +[![Coverage Status](https://coveralls.io/repos/github/romankh3/image-comparison/badge.svg?branch=master)](https://coveralls.io/github/romankh3/image-comparison?branch=master) +[![BCH compliance](https://bettercodehub.com/edge/badge/romankh3/image-comparison?branch=master)](https://bettercodehub.com/) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/romankh3/image-comparison/pulls) * [About](#about) @@ -119,19 +119,15 @@ To save result image, can be used two ways: ``` ## Demo - Demo shows how `image-comparison` works. ### Expected Image - ![expected](https://user-images.githubusercontent.com/16310793/28955567-52edeabe-78f0-11e7-8bb2-d435c8df23ff.png) ### Actual Image - ![actual](https://user-images.githubusercontent.com/16310793/28955566-52ead892-78f0-11e7-993c-847350da0bf8.png) ### Result - ![result](https://user-images.githubusercontent.com/16310793/28955568-52f23e02-78f0-11e7-92c5-07602b6a0887.png) ## Contributing diff --git a/pom.xml b/pom.xml index bd4bd06..77de9ef 100644 --- a/pom.xml +++ b/pom.xml @@ -17,19 +17,23 @@ 1.8 1.8 UTF-8 + 2.26.0 + 5.5.2 + 3.2.0 + 3.1.1 org.mockito mockito-core - 2.26.0 + ${mockito.version} test org.junit.jupiter junit-jupiter-api - 5.5.2 + ${junit.jupiter.api.version} test @@ -39,7 +43,7 @@ org.apache.maven.plugins maven-source-plugin - 3.2.0 + ${maven.source.plugin.version} attach-sources @@ -52,7 +56,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.1.1 + ${maven.javadoc.plugin.version} attach-javadocs diff --git a/src/main/java/com/github/romankh3/image/comparison/ImageComparison.java b/src/main/java/com/github/romankh3/image/comparison/ImageComparison.java index 728c6ef..8067c0b 100644 --- a/src/main/java/com/github/romankh3/image/comparison/ImageComparison.java +++ b/src/main/java/com/github/romankh3/image/comparison/ImageComparison.java @@ -309,7 +309,7 @@ private List populateRectangles() { * false - otherwise. */ private boolean isAllowedPercentOfDifferentPixels(long countOfDifferentPixels) { - long totalPixelCount = matrix.length * matrix[0].length; + long totalPixelCount = ((long) matrix.length) * ((long) matrix[0].length); double actualPercentOfDifferentPixels = ((double) countOfDifferentPixels / (double) totalPixelCount) * 100; return actualPercentOfDifferentPixels <= allowingPercentOfDifferentPixels; } @@ -681,10 +681,7 @@ public double getAllowingPercentOfDifferentPixels() { public ImageComparison setAllowingPercentOfDifferentPixels(double allowingPercentOfDifferentPixels) { if (0.0 <= allowingPercentOfDifferentPixels && allowingPercentOfDifferentPixels <= 100) { this.allowingPercentOfDifferentPixels = allowingPercentOfDifferentPixels; - } else { - //todo add warning here } - return this; } diff --git a/src/main/java/com/github/romankh3/image/comparison/ImageComparisonUtil.java b/src/main/java/com/github/romankh3/image/comparison/ImageComparisonUtil.java index 4d1f5f1..0231095 100644 --- a/src/main/java/com/github/romankh3/image/comparison/ImageComparisonUtil.java +++ b/src/main/java/com/github/romankh3/image/comparison/ImageComparisonUtil.java @@ -27,7 +27,7 @@ public final class ImageComparisonUtil { * @param image the provided image. * @return copy of the provided image. */ - static BufferedImage deepCopy(BufferedImage image) { + public static BufferedImage deepCopy(BufferedImage image) { ColorModel cm = image.getColorModel(); boolean isAlphaPremultiplied = cm.isAlphaPremultiplied(); WritableRaster raster = image.copyData(image.getRaster().createCompatibleWritableRaster()); diff --git a/src/main/java/com/github/romankh3/image/comparison/model/ExcludedAreas.java b/src/main/java/com/github/romankh3/image/comparison/model/ExcludedAreas.java index b71a95a..d896d37 100644 --- a/src/main/java/com/github/romankh3/image/comparison/model/ExcludedAreas.java +++ b/src/main/java/com/github/romankh3/image/comparison/model/ExcludedAreas.java @@ -42,6 +42,11 @@ public boolean contains(Point point) { return excluded.stream().anyMatch(rectangle -> rectangle.containsPoint(point)); } + /** + * Getter for excluded rectangles. + * + * @return the collection of the {@link Rectangle} objects. + */ public List getExcluded() { return excluded; } diff --git a/src/main/java/com/github/romankh3/image/comparison/model/Rectangle.java b/src/main/java/com/github/romankh3/image/comparison/model/Rectangle.java index d667362..db5d09b 100644 --- a/src/main/java/com/github/romankh3/image/comparison/model/Rectangle.java +++ b/src/main/java/com/github/romankh3/image/comparison/model/Rectangle.java @@ -90,7 +90,7 @@ public Rectangle merge(Rectangle that) { } /** - * Check is that rectangle overlapp this. + * Check is that rectangle overlap this. * * @param that {@link Rectangle} which checks with this. * @return true if this over lapp that, false otherwise. @@ -113,7 +113,7 @@ public void setDefaultValues() { } /** - * Make zero rectagle. + * Make zero rectangle. */ public void makeZeroRectangle() { this.minPoint = new Point(); @@ -150,7 +150,7 @@ public int getHeight() { } /** - * Check in the provided {@link Point} contains in the {@link Rectangle}. + * Check if the provided {@link Point} contains in the {@link Rectangle}. * * @param point provided {@link Point}. * @return {@code true} if provided {@link Point} contains, {@code false} - otherwise.