Skip to content

Commit 271dd49

Browse files
authored
Merge pull request #12 from qupath/volatile-accesses
Make DataAccess implement VolatileAccess
2 parents e3cbdd2 + 5a18943 commit 271dd49

File tree

6 files changed

+54
-6
lines changed

6 files changed

+54
-6
lines changed

src/main/java/qupath/ext/imglib2/bufferedimageaccesses/ArgbBufferedImageAccess.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package qupath.ext.imglib2.bufferedimageaccesses;
22

33
import net.imglib2.img.basictypeaccess.IntAccess;
4+
import net.imglib2.img.basictypeaccess.volatiles.VolatileAccess;
45
import qupath.ext.imglib2.SizableDataAccess;
56

67
import java.awt.image.BufferedImage;
@@ -13,8 +14,10 @@
1314
* <p>
1415
* This {@link IntAccess} is immutable; any attempt to changes its values will result in a
1516
* {@link UnsupportedOperationException}.
17+
* <p>
18+
* This data access is marked as volatile but always contain valid data.
1619
*/
17-
public class ArgbBufferedImageAccess implements IntAccess, SizableDataAccess {
20+
public class ArgbBufferedImageAccess implements IntAccess, SizableDataAccess, VolatileAccess {
1821

1922
private final BufferedImage image;
2023
private final DataBuffer dataBuffer;
@@ -63,4 +66,9 @@ public void setValue(int index, int value) {
6366
public int getSizeBytes() {
6467
return size;
6568
}
69+
70+
@Override
71+
public boolean isValid() {
72+
return true;
73+
}
6674
}

src/main/java/qupath/ext/imglib2/bufferedimageaccesses/ByteRasterAccess.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package qupath.ext.imglib2.bufferedimageaccesses;
22

33
import net.imglib2.img.basictypeaccess.ByteAccess;
4+
import net.imglib2.img.basictypeaccess.volatiles.VolatileAccess;
45
import qupath.ext.imglib2.SizableDataAccess;
56

67
import java.awt.image.DataBuffer;
@@ -12,8 +13,10 @@
1213
* <p>
1314
* This {@link ByteAccess} is immutable; any attempt to changes its values will result in a
1415
* {@link UnsupportedOperationException}.
16+
* <p>
17+
* This data access is marked as volatile but always contain valid data.
1518
*/
16-
public class ByteRasterAccess implements ByteAccess, SizableDataAccess {
19+
public class ByteRasterAccess implements ByteAccess, SizableDataAccess, VolatileAccess {
1720

1821
private final Raster raster;
1922
private final DataBuffer dataBuffer;
@@ -62,4 +65,9 @@ public void setValue(int index, byte value) {
6265
public int getSizeBytes() {
6366
return size;
6467
}
68+
69+
@Override
70+
public boolean isValid() {
71+
return true;
72+
}
6573
}

src/main/java/qupath/ext/imglib2/bufferedimageaccesses/DoubleRasterAccess.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package qupath.ext.imglib2.bufferedimageaccesses;
22

33
import net.imglib2.img.basictypeaccess.DoubleAccess;
4+
import net.imglib2.img.basictypeaccess.volatiles.VolatileAccess;
45
import qupath.ext.imglib2.SizableDataAccess;
56

67
import java.awt.image.DataBuffer;
@@ -12,8 +13,10 @@
1213
* <p>
1314
* This {@link DoubleAccess} is immutable; any attempt to changes its values will result in a
1415
* {@link UnsupportedOperationException}.
16+
* <p>
17+
* This data access is marked as volatile but always contain valid data.
1518
*/
16-
public class DoubleRasterAccess implements DoubleAccess, SizableDataAccess {
19+
public class DoubleRasterAccess implements DoubleAccess, SizableDataAccess, VolatileAccess {
1720

1821
private final Raster raster;
1922
private final DataBuffer dataBuffer;
@@ -62,4 +65,9 @@ public void setValue(int index, double value) {
6265
public int getSizeBytes() {
6366
return size;
6467
}
68+
69+
@Override
70+
public boolean isValid() {
71+
return true;
72+
}
6573
}

src/main/java/qupath/ext/imglib2/bufferedimageaccesses/FloatRasterAccess.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package qupath.ext.imglib2.bufferedimageaccesses;
22

33
import net.imglib2.img.basictypeaccess.FloatAccess;
4+
import net.imglib2.img.basictypeaccess.volatiles.VolatileAccess;
45
import qupath.ext.imglib2.SizableDataAccess;
56

67
import java.awt.image.DataBuffer;
@@ -12,8 +13,10 @@
1213
* <p>
1314
* This {@link FloatAccess} is immutable; any attempt to changes its values will result in a
1415
* {@link UnsupportedOperationException}.
16+
* <p>
17+
* This data access is marked as volatile but always contain valid data.
1518
*/
16-
public class FloatRasterAccess implements FloatAccess, SizableDataAccess {
19+
public class FloatRasterAccess implements FloatAccess, SizableDataAccess, VolatileAccess {
1720

1821
private final Raster raster;
1922
private final DataBuffer dataBuffer;
@@ -62,4 +65,9 @@ public void setValue(int index, float value) {
6265
public int getSizeBytes() {
6366
return size;
6467
}
68+
69+
@Override
70+
public boolean isValid() {
71+
return true;
72+
}
6573
}

src/main/java/qupath/ext/imglib2/bufferedimageaccesses/IntRasterAccess.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package qupath.ext.imglib2.bufferedimageaccesses;
22

33
import net.imglib2.img.basictypeaccess.IntAccess;
4+
import net.imglib2.img.basictypeaccess.volatiles.VolatileAccess;
45
import qupath.ext.imglib2.SizableDataAccess;
56

67
import java.awt.image.DataBuffer;
@@ -12,8 +13,10 @@
1213
* <p>
1314
* This {@link IntAccess} is immutable; any attempt to changes its values will result in a
1415
* {@link UnsupportedOperationException}.
16+
* <p>
17+
* This data access is marked as volatile but always contain valid data.
1518
*/
16-
public class IntRasterAccess implements IntAccess, SizableDataAccess {
19+
public class IntRasterAccess implements IntAccess, SizableDataAccess, VolatileAccess {
1720

1821
private final Raster raster;
1922
private final DataBuffer dataBuffer;
@@ -62,4 +65,9 @@ public void setValue(int index, int value) {
6265
public int getSizeBytes() {
6366
return size;
6467
}
68+
69+
@Override
70+
public boolean isValid() {
71+
return true;
72+
}
6573
}

src/main/java/qupath/ext/imglib2/bufferedimageaccesses/ShortRasterAccess.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package qupath.ext.imglib2.bufferedimageaccesses;
22

33
import net.imglib2.img.basictypeaccess.ShortAccess;
4+
import net.imglib2.img.basictypeaccess.volatiles.VolatileAccess;
45
import qupath.ext.imglib2.SizableDataAccess;
56

67
import java.awt.image.DataBuffer;
@@ -13,8 +14,10 @@
1314
* <p>
1415
* This {@link ShortAccess} is immutable; any attempt to changes its values will result in a
1516
* {@link UnsupportedOperationException}.
17+
* <p>
18+
* This data access is marked as volatile but always contain valid data.
1619
*/
17-
public class ShortRasterAccess implements ShortAccess, SizableDataAccess {
20+
public class ShortRasterAccess implements ShortAccess, SizableDataAccess, VolatileAccess {
1821

1922
private final Raster raster;
2023
private final DataBuffer dataBuffer;
@@ -63,4 +66,9 @@ public void setValue(int index, short value) {
6366
public int getSizeBytes() {
6467
return size;
6568
}
69+
70+
@Override
71+
public boolean isValid() {
72+
return true;
73+
}
6674
}

0 commit comments

Comments
 (0)