Skip to content

Commit

Permalink
Use autogenerated base interfaces
Browse files Browse the repository at this point in the history
This migrates all the ops to use the autogenerated base interfaces of
net.imagej.ops.Ops, where applicable.

Note that in some cases, there is still an interface with the same name
in its respective package which extends the base interface -- e.g.,
net.imagej.ops.chunker.Chunker extends net.imagej.ops.Ops.Chunker. The
reason is that the base interfaces exist _only_ to provide the NAME and
optional ALIASES, as well as to offer a type-safe anchor for concrete
ops. If you want anything fancier, like an interface that defines
additional methods, and/or uses generic parameters, then it is advised
to define that interface manually in the appropriate package as well.

In other cases, the previous base interface became wholly redundant and
was hence removed in favor of the one in net.imagej.ops.Ops.
  • Loading branch information
ctrueden committed Sep 18, 2014
1 parent 9583294 commit 1880558
Show file tree
Hide file tree
Showing 104 changed files with 248 additions and 1,018 deletions.
6 changes: 2 additions & 4 deletions src/main/java/net/imagej/ops/DefaultOpService.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
import java.util.HashSet;
import java.util.List;

import net.imagej.ops.create.CreateImg;

import org.scijava.command.CommandInfo;
import org.scijava.command.CommandService;
import org.scijava.log.LogService;
Expand Down Expand Up @@ -209,7 +207,7 @@ public Object convolve(Object... args) {

@Override
public Object createImg(Object... args) {
return run(CreateImg.class, args);
return run(Ops.CreateImg.class, args);
}

@Override
Expand Down Expand Up @@ -390,7 +388,7 @@ private Object result(final Module module) {
@Deprecated
@Override
public Object create(Object... args) {
return run(CreateImg.class, args);
return run(Ops.CreateImg.class, args);
}

}
51 changes: 0 additions & 51 deletions src/main/java/net/imagej/ops/arithmetic/add/Add.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
package net.imagej.ops.arithmetic.add;

import net.imagej.ops.Op;
import net.imagej.ops.Ops;
import net.imglib2.img.array.ArrayImg;
import net.imglib2.img.basictypeaccess.array.ByteArray;
import net.imglib2.type.numeric.integer.ByteType;
Expand All @@ -40,8 +41,8 @@
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

@Plugin(type = Op.class, name = Add.NAME, priority = Priority.HIGH_PRIORITY)
public class AddConstantToArrayByteImage implements Add {
@Plugin(type = Op.class, name = Ops.Add.NAME, priority = Priority.HIGH_PRIORITY)
public class AddConstantToArrayByteImage implements Ops.Add {

@Parameter(type = ItemIO.BOTH)
private ArrayImg<ByteType, ByteArray> image;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
package net.imagej.ops.arithmetic.add;

import net.imagej.ops.Op;
import net.imagej.ops.Ops;
import net.imglib2.img.array.ArrayImg;
import net.imglib2.img.basictypeaccess.array.DoubleArray;
import net.imglib2.type.numeric.real.DoubleType;
Expand All @@ -40,8 +41,9 @@
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

@Plugin(type = Op.class, name = Add.NAME, priority = Priority.HIGH_PRIORITY + 1)
public class AddConstantToArrayDoubleImage implements Add {
@Plugin(type = Op.class, name = Ops.Add.NAME,
priority = Priority.HIGH_PRIORITY + 1)
public class AddConstantToArrayDoubleImage implements Ops.Add {

@Parameter(type = ItemIO.BOTH)
private ArrayImg<DoubleType, DoubleArray> image;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import net.imagej.ops.AbstractStrictFunction;
import net.imagej.ops.Op;
import net.imagej.ops.Ops;
import net.imglib2.Cursor;
import net.imglib2.IterableInterval;
import net.imglib2.RandomAccess;
Expand All @@ -42,10 +43,11 @@
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

@Plugin(type = Op.class, name = Add.NAME, priority = Priority.VERY_LOW_PRIORITY)
@Plugin(type = Op.class, name = Ops.Add.NAME,
priority = Priority.VERY_LOW_PRIORITY)
public class AddConstantToImageFunctional<T extends NumericType<T>> extends
AbstractStrictFunction<IterableInterval<T>, RandomAccessibleInterval<T>>
implements Add
implements Ops.Add
{

@Parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@
package net.imagej.ops.arithmetic.add;

import net.imagej.ops.Op;
import net.imagej.ops.Ops;
import net.imglib2.IterableRealInterval;
import net.imglib2.type.numeric.NumericType;

import org.scijava.ItemIO;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

@Plugin(type = Op.class, name = Add.NAME)
public class AddConstantToImageInPlace<T extends NumericType<T>> implements Add
@Plugin(type = Op.class, name = Ops.Add.NAME)
public class AddConstantToImageInPlace<T extends NumericType<T>> implements
Ops.Add
{

@Parameter(type = ItemIO.BOTH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@

import net.imagej.ops.AbstractOutputFunction;
import net.imagej.ops.Op;
import net.imagej.ops.Ops;
import net.imglib2.type.numeric.NumericType;

import org.scijava.Priority;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

@Plugin(type = Op.class, name = Add.NAME, priority = Priority.LOW_PRIORITY)
@Plugin(type = Op.class, name = Ops.Add.NAME, priority = Priority.LOW_PRIORITY)
public class AddConstantToNumericType<T extends NumericType<T>> extends
AbstractOutputFunction<T, T> implements Add
AbstractOutputFunction<T, T> implements Ops.Add
{

@Parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
package net.imagej.ops.arithmetic.add;

import net.imagej.ops.Op;
import net.imagej.ops.Ops;
import net.imglib2.img.basictypeaccess.array.DoubleArray;
import net.imglib2.img.planar.PlanarImg;
import net.imglib2.type.numeric.real.DoubleType;
Expand All @@ -39,8 +40,8 @@
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

@Plugin(type = Op.class, name = Add.NAME)
public class AddConstantToPlanarDoubleImage implements Add {
@Plugin(type = Op.class, name = Ops.Add.NAME)
public class AddConstantToPlanarDoubleImage implements Ops.Add {

@Parameter(type = ItemIO.BOTH)
private PlanarImg<DoubleType, DoubleArray> image;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import net.imagej.ops.Contingent;
import net.imagej.ops.Op;
import net.imagej.ops.Ops;
import net.imglib2.Cursor;
import net.imglib2.IterableInterval;
import net.imglib2.RandomAccess;
Expand All @@ -42,8 +43,10 @@
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

@Plugin(type = Op.class, name = Add.NAME)
public class AddRandomAccessibleIntervalToIterableInterval<T extends NumericType<T>> implements Contingent, Add {
@Plugin(type = Op.class, name = Ops.Add.NAME)
public class AddRandomAccessibleIntervalToIterableInterval<T extends NumericType<T>>
implements Ops.Add, Contingent
{

@Parameter(type = ItemIO.BOTH)
private IterableInterval<T> a;
Expand Down
51 changes: 0 additions & 51 deletions src/main/java/net/imagej/ops/ascii/ASCII.java

This file was deleted.

5 changes: 3 additions & 2 deletions src/main/java/net/imagej/ops/ascii/DefaultASCII.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import net.imagej.ops.Op;
import net.imagej.ops.OpService;
import net.imagej.ops.Ops;
import net.imglib2.Cursor;
import net.imglib2.IterableInterval;
import net.imglib2.type.numeric.RealType;
Expand All @@ -48,8 +49,8 @@
*
* @author Curtis Rueden
*/
@Plugin(type = Op.class, name = ASCII.NAME)
public class DefaultASCII<T extends RealType<T>> implements ASCII {
@Plugin(type = Op.class, name = Ops.ASCII.NAME)
public class DefaultASCII<T extends RealType<T>> implements Ops.ASCII {

private static final String CHARS = " .,-+o*O#";

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/imagej/ops/chunker/AbstractChunker.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

package net.imagej.ops.chunker;

import net.imagej.ops.Ops;

import org.scijava.plugin.Parameter;
import org.scijava.thread.ThreadService;

Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/imagej/ops/chunker/Chunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

package net.imagej.ops.chunker;

import net.imagej.ops.Ops;
import net.imagej.ops.Parallel;

/**
Expand Down
14 changes: 3 additions & 11 deletions src/main/java/net/imagej/ops/chunker/Chunker.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,17 @@
package net.imagej.ops.chunker;

import net.imagej.ops.Op;
import net.imagej.ops.Ops;

import org.scijava.Cancelable;

/**
* Base interface for "chunker" operations. These operations execute code across
* A "chunker" operation which executes code across
* chunks of data using multiple threads.
* <p>
* Implementing classes should be annotated with:
* </p>
*
* <pre>
* @Plugin(type = Op.class, name = Chunker.NAME)
* </pre>
*
* @author Christian Dietz
*/
public interface Chunker extends Op, Cancelable {

String NAME = "chunker";
public interface Chunker extends Ops.Chunker, Cancelable {

/** Sets the {@link Chunk} for which will be multithreaded. */
void setChunk(final Chunk executor);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/imagej/ops/chunker/DefaultChunker.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.concurrent.Future;

import net.imagej.ops.Op;
import net.imagej.ops.Ops;

import org.scijava.log.LogService;
import org.scijava.plugin.Parameter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.concurrent.Future;

import net.imagej.ops.Op;
import net.imagej.ops.Ops;

import org.scijava.Priority;
import org.scijava.log.LogService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

import net.imagej.ops.AbstractStrictFunction;
import net.imagej.ops.OpService;
import net.imagej.ops.project.Project;
import net.imagej.ops.Ops.Project;
import net.imagej.ops.statistics.Mean;
import net.imglib2.img.Img;
import net.imglib2.meta.ImgPlus;
Expand Down
16 changes: 4 additions & 12 deletions src/main/java/net/imagej/ops/convert/Convert.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,13 @@
package net.imagej.ops.convert;

import net.imagej.ops.Function;
import net.imagej.ops.Ops;

/**
* Base interface for "convert" operations.
* <p>
* Implementing classes should be annotated with:
* </p>
*
* <pre>
* @Plugin(type = Op.class, name = Convert.NAME)
* </pre>
* A typed conversion operation.
*
* @author Martin Horn
*/
public interface Convert<I, O> extends Function<I, O> {

String NAME = "convert";

public interface Convert<I, O> extends Ops.Convert, Function<I, O> {
// NB: Marker interface.
}
1 change: 1 addition & 0 deletions src/main/java/net/imagej/ops/convert/ConvertII.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import net.imagej.ops.AbstractStrictFunction;
import net.imagej.ops.Op;
import net.imagej.ops.OpService;
import net.imagej.ops.Ops;
import net.imglib2.IterableInterval;
import net.imglib2.type.numeric.RealType;

Expand Down
Loading

0 comments on commit 1880558

Please sign in to comment.