Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write SamplerConverter javadoc #359

Merged
merged 3 commits into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Expand All @@ -35,10 +35,37 @@
package net.imglib2.converter.readwrite;

import net.imglib2.Sampler;
import net.imglib2.converter.Converters;
import net.imglib2.type.Type;

/**
* TODO
*
* This interface converts a {@link Sampler Sampler<A>} into an instance
* of {@code B}, where {@code A} and {@code B} are typically {@link Type}s.
* <p>
* Its intended use is to create objects that <b>wrap</b> the provided
* {@code Sampler} itself instead of wrapping values obtained through the
* {@code Sampler}. In other words, <em>if the {@code Sampler} is pointed at a
* different object, <b>existing</b> objects returned by this
* {@code SamplerConverter} should point at it as well</em>.
* <p>
* {@code SamplerConverter}s are used in {@link Converters} to create on-the-fly
* converted images that are both readable and writable. For example, consider
* accessing a channel of an {@code ARGBType} image as {@code UnsignedByteType}.
* The converted image needs to provide converted samplers (e.g., {@code
* RandomAccess<UnsignedByteType>}) that "translate" to the samplers of the
* original image (e.g., {@code RandomAccess<ARGBType>}).
* <p>
* The converted {@code Sampler} returns an {@code UnsignedByteType} instance on
* {@code get()}. If {@code .setByte(10)} is called on that {@code
* UnsignedByteType} instance, that must be translated back to the underlying
* {@code ARGBType}. To achieve this, {@code SamplerConverter.convert(...)}
* creates a special {@code UnsignedByteType} instance which knows about a
* specific source sampler (e.g., {@code RandomAccess<ARGBType>}). When the
* {@code UnsignedByteType} instance is written to (or read from), it gets the
* current {@code ARGBType} from the source sampler and performs the conversion.
*
* @param <A> The type of values accessed by the {@link Sampler}.
* @param <B> The type of the value returned by this {@link SamplerConverter}.
*/
public interface SamplerConverter< A, B >
{
Expand Down
Loading