Skip to content

Commit

Permalink
Merge pull request #9 from imagingbook/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
imagingbook authored Jan 11, 2023
2 parents bb1df7c + f9e89d7 commit fa75e2b
Show file tree
Hide file tree
Showing 1,998 changed files with 16,275 additions and 16,335 deletions.
8 changes: 4 additions & 4 deletions imagingbook-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.imagingbook</groupId>
<artifactId>imagingbook-public</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>7.1.0</version>
</parent>

<name>${project.groupId}:${project.artifactId}</name>
Expand All @@ -33,7 +33,7 @@
<dependency>
<groupId>com.imagingbook</groupId>
<artifactId>imagingbook-core</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>7.1.0</version>
</dependency>

<dependency>
Expand All @@ -44,14 +44,14 @@
<dependency>
<groupId>com.imagingbook</groupId>
<artifactId>imagingbook-testing</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>7.1.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.imagingbook</groupId>
<artifactId>imagingbook-sample-images</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>7.1.0</version>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ else if (clazz.equals(String.class)) {
dialog.addStringField(name, str, stringColumns);
}
else if (clazz.isEnum()) {
dialog.addEnumChoice(name, (Enum<?>) field.get(params));
// dialog.addEnumChoice(name, (Enum<?>) field.get(params));
dialog.addEnumChoice(name, (Enum) field.get(params));
}
else {
// ignore this field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1028,4 +1028,14 @@ public static int countColors(ColorProcessor cp) {
}
return k;
}

/**
* Checks if the specified class implements one of ImageJ's plugin interfaces.
*
* @param clazz any class
* @return true iff class implements one of ImageJ's plugin interfaces
*/
public static boolean isIjPlugin(Class<?> clazz) {
return PlugIn.class.isAssignableFrom(clazz) || PlugInFilter.class.isAssignableFrom(clazz);
}
}
2 changes: 1 addition & 1 deletion imagingbook-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.imagingbook</groupId>
<artifactId>imagingbook-public</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>7.1.0</version>
<!--<relativePath />-->
<!--<relativePath>../imagingbook-parent-pom/pom.xml</relativePath>-->
</parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,42 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.MODULE;
import static java.lang.annotation.ElementType.PACKAGE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* This module or package-level annotation is used to specify a base URL for automatic retrieval of JavaDoc
* information. The URL is given WITH the module's name, e.g., for module {@code imagingbook_plugins_book} this is<br>
* {@literal https://imagingbook.github.io/imagingbook-public/javadoc/imagingbook_plugins_book}<br>
* This information is used by {@link JavaDocUtils#getJavaDocUrl(Class)}.
* <p>
* This package-level annotation is used to specify a URL for automatic retrieval of JavaDoc information. The the
* supplied URL-string must include all address parts including the module part and must end with '/'.
* </p>
* <p>
* For example, for class '{@literal Compute_Histogram}' in package '{@literal Ch02_Histograms_Statistics}' and module
* '{@literal imagingbook_plugins_book}' the associated JavaDoc page is
* </p>
* <pre>
* https://imagingbook.github.io/imagingbook-public/javadoc/imagingbook_plugins_book/Ch02_Histograms_Statistics/Compute_Histogram.html</pre>
* i.e., in the format
* <pre>
* https://BASEURL/MODULENAME/PACKAGENAME/CLASSNAME.htlm</pre>
* In this case, the URL-string to be supplied is
* <pre>
* https://BASEURL/MODULENAME/</pre>
* that is,
* <pre>
* https://imagingbook.github.io/imagingbook-public/javadoc/imagingbook_plugins_book/</pre>
* <p>
* The remaining parts (PACKAGENAME, CLASSNAME) are filled in automatically.
* </p>
* <p>
* This information is used by {@link JavaDocHelp#getJavaDocUrl(Class)}. Future version may include annotations at the
* MODULE and TYPE (class) level. Note that currently ImageJ does not fully support modules and cannot read the names
* and annotations of external modules.
* </p>
*
* @see JavaDocUtils#JAVADOC_BASE_URL
* @see JavaDocHelp
*/
@Retention(RUNTIME)
@Target({MODULE, PACKAGE})
@Target({PACKAGE})
public @interface JavaDocBaseUrl {
public String value();
}
113 changes: 113 additions & 0 deletions imagingbook-core/src/main/java/imagingbook/core/jdoc/JavaDocHelp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*******************************************************************************
* This software is provided as a supplement to the authors' textbooks on digital
* image processing published by Springer-Verlag in various languages and editions.
* Permission to use and distribute this software is granted under the BSD 2-Clause
* "Simplified" License (see http://opensource.org/licenses/BSD-2-Clause).
* Copyright (c) 2006-2023 Wilhelm Burger, Mark J. Burge. All rights reserved.
* Visit https://imagingbook.com for additional details.
******************************************************************************/
package imagingbook.core.jdoc;

import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Objects;

/**
* Classes implementing this interface provide a URL that links to the associated JavaDoc page (returned by method
* {@link #getJavaDocUrl()}). This is mainly intended as help information in user dialogs of ImageJ plugins.
*/
public interface JavaDocHelp {

/**
* Returns a JavaDoc URL for this object's class.
* @return a JavaDoc URL
*/
public default String getJavaDocUrl() {
String url = getJavaDocUrl(this.getClass());
if (Objects.isNull(url)) {
throw new RuntimeException("no JavaDoc URL available");
}
return url;
}

/**
* Returns the JavaDoc URL for the specified class, which is obtained from the value of {@link JavaDocBaseUrl}
* annotations present at the PACKAGE level (in file {@code package-info.java}). Note that there is no guarantee
* that the associated JavaDoc exists at the resulting address (this is not checked by unit tests).
*
* @param clazz a class reference
* @return a string with the web URL for the JavaDoc information of the specified class
*/
public static String getJavaDocUrl(Class<?> clazz) {
// Module mod = clazz.getModule();
Package pkg = clazz.getPackage();
String baseUrl = null;

if (pkg != null && pkg.isAnnotationPresent(JavaDocBaseUrl.class)) {
baseUrl = pkg.getAnnotation(JavaDocBaseUrl.class).value();
// baseUrl is assumed to end with '/'
if (!baseUrl.endsWith("/")) {
throw new RuntimeException("JavaDocBaseUrl value must end with '/': " + baseUrl);
}
}

if (baseUrl == null) {
return null;
}
else {
String classCName = clazz.getCanonicalName();
String url = baseUrl + classCName.replace('.', '/') + ".html";
// valid URL is checked during testing!
return url;
}
}

/**
* Checks if the specified string is a valid URL. Does the standard (non-perfect) URL/URI check followed by some
* additional checks that could indicate likely definition errors.
*
* @param url the string to be checked
* @return true iff a valid URL
*/
public static boolean isValidURL(String url) {
try {
new URL(url).toURI();
} catch (URISyntaxException | MalformedURLException e) {
return false;
}
// do additional checks on url:
{ // check for multiple "//"s
int k1 = url.indexOf("//"); // there must be at least one "//"
if (k1 < 0)
return false;
int k2 = url.indexOf("//", k1 + 2);
if (k2 > 0) // there must not be another "//"
return false;
if (url.contains(".."))
return false;
}
return true;
}

// public static void main(String[] args) {
// String[] urls = {
// "https://www.geeksforgeeks.org/",
// "https://www.geeksforgeeks..org/foo/3",
// "http://www.geeksforgeeks.org//check-if-url-is-valid-or-not-in-java/",
// "http//foo",
// "imagingbook.com"
// };
// for (String url : urls) {
// boolean passed = isValidURL(url);
// System.out.println(passed + " | " + url);
// }
// }

// true | https://www.geeksforgeeks.org/
// false | https://www.geeksforgeeks..org/foo/3
// false | http://www.geeksforgeeks.org//check-if-url-is-valid-or-not-in-java/
// false | http//foo
// false | imagingbook.com

}

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions imagingbook-parent-pom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.imagingbook</groupId>
<artifactId>imagingbook-parent-pom</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>7.1.0</version>
<packaging>pom</packaging>

<name>${project.groupId}:${project.artifactId}</name>
Expand Down Expand Up @@ -51,7 +51,7 @@
<imagingbook.buildprofile>DefaultProfile</imagingbook.buildprofile>

<java.version>11</java.version> <!-- need to step to 11 to make Javadoc API linking work! -->
<imagej.version>1.53v</imagej.version> <!-- see https://mvnrepository.com/artifact/net.imagej/ij -->
<imagej.version>1.54b</imagej.version> <!-- see https://mvnrepository.com/artifact/net.imagej/ij -->
<imagej.apilink>https://javadoc.io/doc/net.imagej/ij/1.53v</imagej.apilink>

<commons-math3.version>3.6.1</commons-math3.version>
Expand Down
6 changes: 3 additions & 3 deletions imagingbook-pdf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>com.imagingbook</groupId>
<artifactId>imagingbook-public</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>7.1.0</version>
</parent>

<name>${project.groupId}:${project.artifactId}</name>
Expand All @@ -25,13 +25,13 @@
<dependency>
<groupId>com.imagingbook</groupId>
<artifactId>imagingbook-core</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>7.1.0</version>
</dependency>

<dependency>
<groupId>com.imagingbook</groupId>
<artifactId>imagingbook-common</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>7.1.0</version>
</dependency>

<dependency>
Expand Down
6 changes: 3 additions & 3 deletions imagingbook-sample-images/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.imagingbook</groupId>
<artifactId>imagingbook-public</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>7.1.0</version>
</parent>

<name>${project.groupId}:${project.artifactId}</name>
Expand All @@ -31,13 +31,13 @@
<dependency>
<groupId>com.imagingbook</groupId>
<artifactId>imagingbook-core</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>7.1.0</version>
</dependency>

<dependency>
<groupId>com.imagingbook</groupId>
<artifactId>imagingbook-testing</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>7.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
6 changes: 3 additions & 3 deletions imagingbook-spectral/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>com.imagingbook</groupId>
<artifactId>imagingbook-public</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>7.1.0</version>
</parent>

<name>${project.groupId}:${project.artifactId}</name>
Expand All @@ -29,13 +29,13 @@
<dependency>
<groupId>com.imagingbook</groupId>
<artifactId>imagingbook-common</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>7.1.0</version>
</dependency>

<dependency>
<groupId>com.imagingbook</groupId>
<artifactId>imagingbook-testing</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>7.1.0</version>
<scope>test</scope>
</dependency>

Expand Down
Loading

0 comments on commit fa75e2b

Please sign in to comment.