Skip to content

Commit

Permalink
[ci] Incorporate spelling fixes from upstream PR #16
Browse files Browse the repository at this point in the history
  • Loading branch information
hazendaz committed Nov 15, 2021
1 parent e7dc9c9 commit f0bda88
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public SmartSpritesParameters(String rootDir, List<String> cssFiles,
}

/**
* Validates the provided parameters. All resource paths are resolved agains the local
* Validates the provided parameters. All resource paths are resolved against the local
* file system.
*
* @return <code>true</code> if the parameters are valid
Expand All @@ -196,7 +196,7 @@ public boolean validate(MessageLog log)
// Either root dir or css files are required
if (!hasRootDir() && !hasCssFiles())
{
log.error(MessageType.EITHER_ROOT_DIR_OR_CSS_FILES_IS_REQIRED);
log.error(MessageType.EITHER_ROOT_DIR_OR_CSS_FILES_IS_REQUIRED);
return false;
}

Expand Down Expand Up @@ -225,7 +225,7 @@ public boolean validate(MessageLog log)
// For output dir, we need root dir
if (!hasRootDir())
{
log.error(MessageType.ROOT_DIR_IS_REQIRED_FOR_OUTPUT_DIR);
log.error(MessageType.ROOT_DIR_IS_REQUIRED_FOR_OUTPUT_DIR);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private void writeSprite(SpriteImage spriteImage, final BufferedImage mergedImag
final SpriteImageDirective spriteImageDirective = spriteImageOccurrence.spriteImageDirective;

// Write the image to a byte array first. We need the data to compute an sha512 hash.
final ByteArrayOutputStream spriteImageByteArrayOuputStream = new ByteArrayOutputStream();
final ByteArrayOutputStream spriteImageByteArrayOutputStream = new ByteArrayOutputStream();

// If writing to a JPEG, we need to make a 3-byte-encoded image
final BufferedImage imageToWrite;
Expand All @@ -205,7 +205,7 @@ private void writeSprite(SpriteImage spriteImage, final BufferedImage mergedImag
try
{
ImageIO.write(imageToWrite, spriteImageDirective.format.toString(),
spriteImageByteArrayOuputStream);
spriteImageByteArrayOutputStream);
}
catch (IOException e)
{
Expand All @@ -215,7 +215,7 @@ private void writeSprite(SpriteImage spriteImage, final BufferedImage mergedImag
}

// Build file name
byte [] spriteImageBytes = spriteImageByteArrayOuputStream.toByteArray();
byte [] spriteImageBytes = spriteImageByteArrayOutputStream.toByteArray();
String resolvedImagePath = spriteImage.resolveImagePath(spriteImageBytes,
timestamp, ie6Reduced);
if (resolvedImagePath.indexOf('?') >= 0)
Expand Down Expand Up @@ -290,12 +290,12 @@ static SpriteImage buildSpriteImage(SpriteImageOccurrence spriteImageOccurrence,
.entrySet())
{
final BufferedImage image = entry.getValue();
final SpriteReferenceOccurrence spriteReferenceOcurrence = entry.getKey();
final SpriteReferenceOccurrence spriteReferenceOccurrence = entry.getKey();

// Compute dimensions
dimension = Math.max(dimension,
vertical ? spriteReferenceOcurrence.getRequiredWidth(image, layout)
: spriteReferenceOcurrence.getRequiredHeight(image, layout));
vertical ? spriteReferenceOccurrence.getRequiredWidth(image, layout)
: spriteReferenceOccurrence.getRequiredHeight(image, layout));
}

// Correct for least common multiple
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private BufferedImage quantize(BufferedImage sprite, SpriteImage spriteImage,
{
messageLog.log(logLevel, MessageType.TOO_MANY_COLORS_FOR_INDEXED_COLOR,
spriteImageDirective.spriteId,
colorReductionInfo.distictColors, ColorQuantizer.MAX_INDEXED_COLORS);
colorReductionInfo.distinctColors, ColorQuantizer.MAX_INDEXED_COLORS);
}

final Color matte;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public enum MessageLevel
WARN(4),

/**
* Error messages, SmartSpricess cannot perform processing.
* Error messages, SmartSprites cannot perform processing.
*/
ERROR(5),

Expand Down Expand Up @@ -112,13 +112,13 @@ public enum MessageType
NO_BACKGROUND_IMAGE_RULE_NEXT_TO_SPRITE_REFERENCE_DIRECTIVE(
"No 'background-image' CSS rule next to sprite reference comment: %s"),

EITHER_ROOT_DIR_OR_CSS_FILES_IS_REQIRED(
EITHER_ROOT_DIR_OR_CSS_FILES_IS_REQUIRED(
"Either root directory or non-empty list of individual CSS files is required"),

ROOT_DIR_AND_CSS_FILES_CANNOT_BE_BOTH_SPECIFIED_UNLESS_WITH_OUTPUT_DIR(
"Root directory and individual CSS files cannot be both specified, unless output dir is also specified"),

ROOT_DIR_IS_REQIRED_FOR_OUTPUT_DIR(
ROOT_DIR_IS_REQUIRED_FOR_OUTPUT_DIR(
"If output directory is specified, root directory must also be provided"),

ROOT_DIR_DOES_NOT_EXIST_OR_IS_NOT_DIRECTORY(
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/carrot2/util/BufferedImageUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,26 @@ public static boolean hasTransparency(BufferedImage image)
* Returns the number of distinct colors (excluding transparency) in the
* <code>image</code>.
*/
public static int countDistictColors(BufferedImage image)
public static int countDistinctColors(BufferedImage image)
{
return getDistictColors(image).length;
return getDistinctColors(image).length;
}

/**
* Returns the <code>image</code>'s distinct colors in an RGB format, discarding
* transparency information.
*/
public static int [] getDistictColors(BufferedImage image)
public static int [] getDistinctColors(BufferedImage image)
{
return getDistictColors(image, 0);
return getDistinctColors(image, 0);
}

/**
* Returns the <code>image</code>'s distinct colors in an RGB format, discarding
* transparency information. Adds <code>padding</code> empty slots at the beginning of
* the returned array.
*/
public static int [] getDistictColors(BufferedImage image, int padding)
public static int [] getDistinctColors(BufferedImage image, int padding)
{
final int width = image.getWidth();
final int height = image.getHeight();
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/carrot2/util/ColorQuantizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static BufferedImage reduce(BufferedImage source)
"The source image cannot contain translucent areas");
}

final int [] colorsWithAlpha = BufferedImageUtils.getDistictColors(source, 1);
final int [] colorsWithAlpha = BufferedImageUtils.getDistinctColors(source, 1);
if (colorsWithAlpha.length - 1 > MAX_INDEXED_COLORS)
{
throw new IllegalArgumentException(
Expand Down Expand Up @@ -150,25 +150,25 @@ public static BufferedImage reduce(BufferedImage source)
public static ColorReductionInfo getColorReductionInfo(BufferedImage source)
{
return new ColorReductionInfo(BufferedImageUtils.hasPartialTransparency(source),
BufferedImageUtils.countDistictColors(source));
BufferedImageUtils.countDistinctColors(source));
}

/**
* Indicates how many distinct colors an image has, whether it has partial trasparency
* Indicates how many distinct colors an image has, whether it has partial transparency
* (alpha channel).
*/
public static class ColorReductionInfo
{
/** Number of distint colors in the image */
public int distictColors;
/** Number of distinct colors in the image */
public int distinctColors;

/** True if the image has partially transparent areas (alpha channel) */
public boolean hasPartialTransparency;

public ColorReductionInfo(boolean hasPartialTransparency, int distictColors)
public ColorReductionInfo(boolean hasPartialTransparency, int distinctColors)
{
this.hasPartialTransparency = hasPartialTransparency;
this.distictColors = distictColors;
this.distinctColors = distinctColors;
}

/**
Expand All @@ -177,7 +177,7 @@ public ColorReductionInfo(boolean hasPartialTransparency, int distictColors)
*/
public boolean canReduceWithoutQualityLoss()
{
return !hasPartialTransparency && distictColors <= MAX_INDEXED_COLORS;
return !hasPartialTransparency && distinctColors <= MAX_INDEXED_COLORS;
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/carrot2/util/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static String canonicalize(String path, String separator)
}

/**
* Attempts to delete the provided filesand throws an {@link IOException} in case
* Attempts to delete the provided files and throws an {@link IOException} in case
* {@link File#delete()} returns <code>false</code> for any of them.
*/
public static void deleteThrowingExceptions(File... files) throws IOException
Expand Down
36 changes: 18 additions & 18 deletions src/main/java/org/carrot2/util/PathUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,25 @@ public static final String getRelativeFilePath( final String oldPath, final Stri

private static final String buildRelativePath( String toPath, String fromPath, final char separatorChar )
{
// use tokeniser to traverse paths and for lazy checking
StringTokenizer toTokeniser = new StringTokenizer( toPath, String.valueOf( separatorChar ) );
StringTokenizer fromTokeniser = new StringTokenizer( fromPath, String.valueOf( separatorChar ) );
// use tokenizer to traverse paths and for lazy checking
StringTokenizer toTokenizer = new StringTokenizer( toPath, String.valueOf( separatorChar ) );
StringTokenizer fromTokenizer = new StringTokenizer( fromPath, String.valueOf( separatorChar ) );

int count = 0;

// walk along the to path looking for divergence from the from path
while ( toTokeniser.hasMoreTokens() && fromTokeniser.hasMoreTokens() )
while ( toTokenizer.hasMoreTokens() && fromTokenizer.hasMoreTokens() )
{
if ( separatorChar == '\\' )
{
if ( !fromTokeniser.nextToken().equalsIgnoreCase( toTokeniser.nextToken() ) )
if ( !fromTokenizer.nextToken().equalsIgnoreCase( toTokenizer.nextToken() ) )
{
break;
}
}
else
{
if ( !fromTokeniser.nextToken().equals( toTokeniser.nextToken() ) )
if ( !fromTokenizer.nextToken().equals( toTokenizer.nextToken() ) )
{
break;
}
Expand All @@ -139,44 +139,44 @@ private static final String buildRelativePath( String toPath, String fromPath,
count++;
}

// reinitialise the tokenisers to count positions to retrieve the
// reinitialise the tokenizers to count positions to retrieve the
// gobbled token

toTokeniser = new StringTokenizer( toPath, String.valueOf( separatorChar ) );
fromTokeniser = new StringTokenizer( fromPath, String.valueOf( separatorChar ) );
toTokenizer = new StringTokenizer( toPath, String.valueOf( separatorChar ) );
fromTokenizer = new StringTokenizer( fromPath, String.valueOf( separatorChar ) );

while ( count-- > 0 )
{
fromTokeniser.nextToken();
toTokeniser.nextToken();
fromTokenizer.nextToken();
toTokenizer.nextToken();
}

StringBuilder relativePath = new StringBuilder();

// add back refs for the rest of from location.
while ( fromTokeniser.hasMoreTokens() )
while ( fromTokenizer.hasMoreTokens() )
{
fromTokeniser.nextToken();
fromTokenizer.nextToken();

relativePath.append("..");

if ( fromTokeniser.hasMoreTokens() )
if ( fromTokenizer.hasMoreTokens() )
{
relativePath.append(separatorChar);
}
}

if ( relativePath.length() != 0 && toTokeniser.hasMoreTokens() )
if ( relativePath.length() != 0 && toTokenizer.hasMoreTokens() )
{
relativePath.append(separatorChar);
}

// add fwd fills for whatevers left of newPath.
while ( toTokeniser.hasMoreTokens() )
while ( toTokenizer.hasMoreTokens() )
{
relativePath.append(toTokeniser.nextToken());
relativePath.append(toTokenizer.nextToken());

if ( toTokeniser.hasMoreTokens() )
if ( toTokenizer.hasMoreTokens() )
{
relativePath.append(separatorChar);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void cleanUpFiles() throws IOException
void testValidateNoRootDirNoCssFiles()
{
checkInvalid(parameters(null, null),
Message.error(MessageType.EITHER_ROOT_DIR_OR_CSS_FILES_IS_REQIRED));
Message.error(MessageType.EITHER_ROOT_DIR_OR_CSS_FILES_IS_REQUIRED));
}

@Test
Expand All @@ -68,7 +68,7 @@ void testValidateOutputDirNoRootDir()
checkInvalid(
parameters(null, Lists.newArrayList("css/file.css"), existingOutputDirPath),
Message.error(
MessageType.ROOT_DIR_IS_REQIRED_FOR_OUTPUT_DIR));
MessageType.ROOT_DIR_IS_REQUIRED_FOR_OUTPUT_DIR));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public BufferedImageAssertion doesNotHaveAlpha()
*/
public BufferedImageAssertion hasNumberOfColorsEqualTo(int colors)
{
assertThat(BufferedImageUtils.countDistictColors(actual)).as(
assertThat(BufferedImageUtils.countDistinctColors(actual)).as(
description + ".colors").isEqualTo(colors);
return this;
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/org/carrot2/util/BufferedImageUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,22 @@ void testCountDistinctColorsTransparency() throws IOException
{
assertEquals(1,
BufferedImageUtils
.countDistictColors(image("full-alpha.png")));
.countDistinctColors(image("full-alpha.png")));
}

@Test
void testCountDistinctColorsTransparencyMatted() throws IOException
{
assertEquals(4,
BufferedImageUtils.countDistictColors(BufferedImageUtils.matte(
BufferedImageUtils.countDistinctColors(BufferedImageUtils.matte(
image("full-alpha.png"), Color.WHITE)));
}

@Test
void testCountDistinctColorsNoTransparency() throws IOException
{
assertEquals(4,
BufferedImageUtils.countDistictColors(image("no-alpha.png")));
BufferedImageUtils.countDistinctColors(image("no-alpha.png")));
}

@Test
Expand All @@ -88,6 +88,6 @@ void testCountDistinctColorsGradient() throws IOException
// black is the same in all bands
assertEquals(1021,
BufferedImageUtils
.countDistictColors(image("many-colors.png")));
.countDistinctColors(image("many-colors.png")));
}
}

0 comments on commit f0bda88

Please sign in to comment.