Skip to content

Commit

Permalink
fixing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanCheshire committed Jul 3, 2024
1 parent 2291884 commit dd678a2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
import java.awt.image.BufferedImage;
import java.util.concurrent.Future;

/**
* A class for generating audio waveforms PNGs from audio files.
*/
/** A class for generating audio waveforms PNGs from audio files. */
public final class WaveformImage {
/**
* The number denoting a value should be interpolated.
Expand Down Expand Up @@ -138,9 +136,7 @@ private static BufferedImage generate(WaveformImageBuilder builder) {
return waveformImage;
}

/**
* A builder for constructing the parameters of waveform png generation from a {@link CyderAudioFile}.
*/
/** A builder for constructing the parameters of waveform png generation from a {@link CyderAudioFile}. */
public static final class WaveformImageBuilder {
private static final int DEFAULT_WIDTH = 800;
private static final int DEFAULT_HEIGHT = 100;
Expand All @@ -149,39 +145,25 @@ public static final class WaveformImageBuilder {
private static final Color DEFAULT_TOP_WAVEFORM_COLOR = CyderColors.navy;
private static final Color DEFAULT_CENTER_LINE_COLOR = CyderColors.navy;

/**
* The audio file this builder is returning a representation of.
*/
/** The audio file this builder is returning a representation of. */
private final CyderAudioFile audioFile;

/**
* the width of this waveform builder.
*/
/** the width of this waveform builder. */
private int width = DEFAULT_WIDTH;

/**
* the height of this waveform builder.
*/
/** the height of this waveform builder. */
private int height = DEFAULT_HEIGHT;

/**
* The background color of the waveform png.
*/
/** The background color of the waveform png. */
private Color backgroundColor = DEFAULT_BACKGROUND_COLOR;

/**
* The color of the bottom of the waveform png.
*/
/** The color of the bottom of the waveform png. */
private Color bottomWaveformColor = DEFAULT_BOTTOM_WAVEFORM_COLOR;

/**
* The color of the top of the waveform png.
*/
/** The color of the top of the waveform png. */
private Color topWaveformColor = DEFAULT_TOP_WAVEFORM_COLOR;

/**
* The center line color for the waveform png.
*/
/** The center line color for the waveform png. */
private Color centerLineColor = DEFAULT_CENTER_LINE_COLOR;

/**
Expand Down Expand Up @@ -347,9 +329,7 @@ public CyderImage generate() {
return CyderImage.fromBufferedImage(image);
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public boolean equals(Object o) {
if (this == o) {
Expand All @@ -368,9 +348,7 @@ public boolean equals(Object o) {
&& centerLineColor.equals(other.centerLineColor);
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public int hashCode() {
int ret = audioFile.hashCode();
Expand All @@ -383,9 +361,7 @@ public int hashCode() {
return ret;
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public String toString() {
return "WaveformGenerationBuilder{"
Expand Down
40 changes: 10 additions & 30 deletions src/main/java/com/github/natche/cyderutils/image/CyderImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,27 @@
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;

/**
* An image abstraction for usage throughout Cyder.
*/
/** An image abstraction for usage throughout Cyder. */
public final class CyderImage {
/**
* A bitmask for a bit.
*/
/** A bitmask for a bit. */
private static final int EIGHT_BIT_MASK = 0xff;

/**
* The amount to shift a number by to obtain the alpha.
*/
/** The amount to shift a number by to obtain the alpha. */
private static final int ALPHA_SHIFT = 24;

/**
* The amount to shift a number by to obtain the red.
*/
/** The amount to shift a number by to obtain the red. */
private static final int RED_SHIFT = 16;

/**
* The amount to shift a number by to obtain the green.
*/
/** The amount to shift a number by to obtain the green. */
private static final int GREEN_SHIFT = 8;

/**
* The default color counter the dominant color contained in this image hashmap max length.
*/
/** The default color counter the dominant color contained in this image hashmap max length. */
private static final int DEFAULT_COLOR_COUNTER_MAX_LENGTH = 100;

/**
* The encapsulated image.
*/
/** The encapsulated image. */
private BufferedImage image;

/**
* The color counter hashmap's max length.
*/
/** The color counter hashmap's max length. */
private int colorCounterMaxLength = DEFAULT_COLOR_COUNTER_MAX_LENGTH;

/**
Expand Down Expand Up @@ -355,9 +339,7 @@ public void rotate(double degrees) {
image = rotated;
}

/**
* Crops this image to the maximum square size.
*/
/** Crops this image to the maximum square size. */
@SuppressWarnings("SuspiciousNameCombination") /* Cropping logic */
public void cropToMaximumSquare() {
int width = image.getWidth();
Expand Down Expand Up @@ -571,9 +553,7 @@ public boolean ensureFitsInBounds(Dimension dimension) {
return resized;
}

/**
* Converts this image converted to grayscale.
*/
/** Converts this image converted to grayscale. */
public void grayscaleImage() {
BufferedImage bi = getBufferedImage();
int width = bi.getWidth();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,15 @@
import java.io.File;
import java.util.Arrays;

/**
* The image file types supported by Cyder.
*/
/** The image file types supported by Cyder. */
public enum SupportedImageFileType {
/**
* The PNG image extension.
*/
/** The PNG image extension. */
PNG(".png", ImmutableList.of(0x89, 0x50, 0x4E, 0x47)),

/**
* The JPG image extension.
*/
/** The JPG image extension. */
JPG(".jpg", ImmutableList.of(0xFF, 0xD8, 0xFF)),

/**
* The JPEG image extension. {@link #JPG} is equivalent and should be preferred over this.
*/
/** The JPEG image extension. {@link #JPG} is equivalent and should be preferred over this. */
JPEG(".jpeg", ImmutableList.of(0xFF, 0xD8, 0xFF));

private final String extension;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ import com.github.natche.cyderutils.utils.OsUtil
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test

/**
* Tests for waveform image generation.
*/
/** Tests for waveform image generation. */
class WaveformImageTest {
/**
* Tests the default waveform generation properties.
*/
/** Tests the default waveform generation properties. */
@Test
fun testWaveformGenerationDefault() {
val audioFile = CyderAudioFile.from(
Expand Down Expand Up @@ -55,9 +51,7 @@ class WaveformImageTest {
assertTrue(image.equals(builder.generate()))
}

/**
* Test for generating an image using gray colors, white background and a resolution of 200x50
*/
/** Test for generating an image using gray colors, white background and a resolution of 200x50 */
@Test
fun testWaveformGenerationGray() {
val audioFile = CyderAudioFile.from(
Expand Down Expand Up @@ -104,9 +98,7 @@ class WaveformImageTest {
assertTrue(image.equals(builder.generate()))
}

/**
* Tests for generating an image with pink top and bottom, a navy center line, with a resolution of 6000x800.
*/
/** Tests for generating an image with pink top and bottom, a navy center line, with a resolution of 6000x800. */
@Test
fun testWaveformGenerationPinkNavyLine() {
val audioFile = CyderAudioFile.from(
Expand Down

0 comments on commit dd678a2

Please sign in to comment.