本文整理汇总了Java中net.coobird.thumbnailator.geometry.Coordinate类的典型用法代码示例。如果您正苦于以下问题:Java Coordinate类的具体用法?Java Coordinate怎么用?Java Coordinate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Coordinate类属于net.coobird.thumbnailator.geometry包,在下文中一共展示了Coordinate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: appliesSourceRegionTooBig
import net.coobird.thumbnailator.geometry.Coordinate; //导入依赖的package包/类
@Test
public void appliesSourceRegionTooBig() throws IOException
{
// given
BufferedImage sourceImage = ImageIO.read(new File("src/test/resources/Thumbnailator/grid.png"));
BufferedImageSource source = new BufferedImageSource(sourceImage);
source.setThumbnailParameter(
new ThumbnailParameterBuilder()
.region(new Region(new Coordinate(20, 20), new AbsoluteSize(100, 100)))
.size(80, 80)
.build()
);
// when
BufferedImage img = source.read();
// then
BufferedImage expectedImg = sourceImage.getSubimage(20, 20, 80, 80);
assertTrue(BufferedImageComparer.isSame(expectedImg, img));
}
示例2: appliesSourceRegionBeyondOrigin
import net.coobird.thumbnailator.geometry.Coordinate; //导入依赖的package包/类
@Test
public void appliesSourceRegionBeyondOrigin() throws IOException
{
// given
BufferedImage sourceImage = ImageIO.read(new File("src/test/resources/Thumbnailator/grid.png"));
BufferedImageSource source = new BufferedImageSource(sourceImage);
source.setThumbnailParameter(
new ThumbnailParameterBuilder()
.region(new Region(new Coordinate(-20, -20), new AbsoluteSize(100, 100)))
.size(80, 80)
.build()
);
// when
BufferedImage img = source.read();
// then
BufferedImage expectedImg = sourceImage.getSubimage(0, 0, 80, 80);
assertTrue(BufferedImageComparer.isSame(expectedImg, img));
}
示例3: appliesSourceRegionTooBig
import net.coobird.thumbnailator.geometry.Coordinate; //导入依赖的package包/类
@Test
public void appliesSourceRegionTooBig() throws IOException
{
// given
File sourceFile = new File("src/test/resources/Thumbnailator/grid.png");
BufferedImage sourceImage = ImageIO.read(sourceFile);
URLImageSource source = new URLImageSource(new URL("file:src/test/resources/Thumbnailator/grid.png"));
source.setThumbnailParameter(
new ThumbnailParameterBuilder()
.region(new Region(new Coordinate(20, 20), new AbsoluteSize(100, 100)))
.size(80, 80)
.build()
);
// when
BufferedImage img = source.read();
// then
BufferedImage expectedImg = sourceImage.getSubimage(20, 20, 80, 80);
assertTrue(BufferedImageComparer.isRGBSimilar(expectedImg, img));
}
示例4: appliesSourceRegionBeyondOrigin
import net.coobird.thumbnailator.geometry.Coordinate; //导入依赖的package包/类
@Test
public void appliesSourceRegionBeyondOrigin() throws IOException
{
// given
File sourceFile = new File("src/test/resources/Thumbnailator/grid.png");
BufferedImage sourceImage = ImageIO.read(sourceFile);
URLImageSource source = new URLImageSource(new URL("file:src/test/resources/Thumbnailator/grid.png"));
source.setThumbnailParameter(
new ThumbnailParameterBuilder()
.region(new Region(new Coordinate(-20, -20), new AbsoluteSize(100, 100)))
.size(80, 80)
.build()
);
// when
BufferedImage img = source.read();
// then
BufferedImage expectedImg = sourceImage.getSubimage(0, 0, 80, 80);
assertTrue(BufferedImageComparer.isRGBSimilar(expectedImg, img));
}
示例5: appliesSourceRegionTooBig
import net.coobird.thumbnailator.geometry.Coordinate; //导入依赖的package包/类
@Test
public void appliesSourceRegionTooBig() throws IOException
{
// given
File sourceFile = new File("src/test/resources/Thumbnailator/grid.png");
BufferedImage sourceImage = ImageIO.read(sourceFile);
InputStreamImageSource source = new InputStreamImageSource(new FileInputStream(sourceFile));
source.setThumbnailParameter(
new ThumbnailParameterBuilder()
.region(new Region(new Coordinate(20, 20), new AbsoluteSize(100, 100)))
.size(80, 80)
.build()
);
// when
BufferedImage img = source.read();
// then
BufferedImage expectedImg = sourceImage.getSubimage(20, 20, 80, 80);
assertTrue(BufferedImageComparer.isRGBSimilar(expectedImg, img));
}
示例6: appliesSourceRegionBeyondOrigin
import net.coobird.thumbnailator.geometry.Coordinate; //导入依赖的package包/类
@Test
public void appliesSourceRegionBeyondOrigin() throws IOException
{
// given
File sourceFile = new File("src/test/resources/Thumbnailator/grid.png");
BufferedImage sourceImage = ImageIO.read(sourceFile);
InputStreamImageSource source = new InputStreamImageSource(new FileInputStream(sourceFile));
source.setThumbnailParameter(
new ThumbnailParameterBuilder()
.region(new Region(new Coordinate(-20, -20), new AbsoluteSize(100, 100)))
.size(80, 80)
.build()
);
// when
BufferedImage img = source.read();
// then
BufferedImage expectedImg = sourceImage.getSubimage(0, 0, 80, 80);
assertTrue(BufferedImageComparer.isRGBSimilar(expectedImg, img));
}
示例7: appliesSourceRegionTooBig
import net.coobird.thumbnailator.geometry.Coordinate; //导入依赖的package包/类
@Test
public void appliesSourceRegionTooBig() throws IOException
{
// given
File sourceFile = new File("src/test/resources/Thumbnailator/grid.png");
BufferedImage sourceImage = ImageIO.read(sourceFile);
FileImageSource source = new FileImageSource(sourceFile);
source.setThumbnailParameter(
new ThumbnailParameterBuilder()
.region(new Region(new Coordinate(20, 20), new AbsoluteSize(100, 100)))
.size(80, 80)
.build()
);
// when
BufferedImage img = source.read();
// then
BufferedImage expectedImg = sourceImage.getSubimage(20, 20, 80, 80);
assertTrue(BufferedImageComparer.isRGBSimilar(expectedImg, img));
}
示例8: appliesSourceRegionBeyondOrigin
import net.coobird.thumbnailator.geometry.Coordinate; //导入依赖的package包/类
@Test
public void appliesSourceRegionBeyondOrigin() throws IOException
{
// given
File sourceFile = new File("src/test/resources/Thumbnailator/grid.png");
BufferedImage sourceImage = ImageIO.read(sourceFile);
FileImageSource source = new FileImageSource(sourceFile);
source.setThumbnailParameter(
new ThumbnailParameterBuilder()
.region(new Region(new Coordinate(-20, -20), new AbsoluteSize(100, 100)))
.size(80, 80)
.build()
);
// when
BufferedImage img = source.read();
// then
BufferedImage expectedImg = sourceImage.getSubimage(0, 0, 80, 80);
assertTrue(BufferedImageComparer.isRGBSimilar(expectedImg, img));
}
示例9: sourceRegion_Region
import net.coobird.thumbnailator.geometry.Coordinate; //导入依赖的package包/类
/**
* Test for the {@link Thumbnails.Builder} class where,
* <ol>
* <li>sourceRegion(Region) is called with valid parameters</li>
* </ol>
* and the expected outcome is,
* <ol>
* <li>The thumbnail is successfully produced</li>
* <li>The specified range is used as the source</li>
* </ol>
* @throws IOException
*/
@Test
public void sourceRegion_Region() throws IOException
{
// given
BufferedImage img = ImageIO.read(new File("src/test/resources/Thumbnailator/grid.png"));
File outFile = new File("src/test/resources/Thumbnailator/grid.tmp.png");
outFile.deleteOnExit();
// when
Thumbnails.of(img)
.sourceRegion(new Region(new Coordinate(0, 0), new AbsoluteSize(50, 50)))
.size(50, 50)
.toFile(outFile);
// then
BufferedImage thumbnail = ImageIO.read(outFile);
assertEquals(50, thumbnail.getWidth());
assertEquals(50, thumbnail.getHeight());
assertTrue(BufferedImageComparer.isRGBSimilar(thumbnail, img.getSubimage(0, 0, 50, 50)));
}
示例10: sourceRegion_PositionSize
import net.coobird.thumbnailator.geometry.Coordinate; //导入依赖的package包/类
/**
* Test for the {@link Thumbnails.Builder} class where,
* <ol>
* <li>sourceRegion(Position, Size) is called with valid parameters</li>
* </ol>
* and the expected outcome is,
* <ol>
* <li>The thumbnail is successfully produced</li>
* <li>The specified range is used as the source</li>
* </ol>
* @throws IOException
*/
@Test
public void sourceRegion_PositionSize() throws IOException
{
// given
BufferedImage img = ImageIO.read(new File("src/test/resources/Thumbnailator/grid.png"));
File outFile = new File("src/test/resources/Thumbnailator/grid.tmp.png");
outFile.deleteOnExit();
// when
Thumbnails.of(img)
.sourceRegion(new Coordinate(0, 0), new AbsoluteSize(50, 50))
.size(50, 50)
.toFile(outFile);
// then
BufferedImage thumbnail = ImageIO.read(outFile);
assertEquals(50, thumbnail.getWidth());
assertEquals(50, thumbnail.getHeight());
assertTrue(BufferedImageComparer.isRGBSimilar(thumbnail, img.getSubimage(0, 0, 50, 50)));
}
示例11: sourceRegion_PositionSize_SizeNull
import net.coobird.thumbnailator.geometry.Coordinate; //导入依赖的package包/类
/**
* Test for the {@link Thumbnails.Builder} class where,
* <ol>
* <li>sourceRegion(Position, Size) is called with Size as null</li>
* </ol>
* and the expected outcome is,
* <ol>
* <li>An NullPointerException is thrown</li>
* </ol>
* @throws IOException
*/
@Test
public void sourceRegion_PositionSize_SizeNull() throws IOException
{
// given
BufferedImage img = ImageIO.read(new File("src/test/resources/Thumbnailator/grid.png"));
File outFile = new File("src/test/resources/Thumbnailator/grid.tmp.png");
outFile.deleteOnExit();
// when
try
{
Thumbnails.of(img)
.sourceRegion(new Coordinate(0, 0), null)
.size(50, 50)
.toFile(outFile);
fail();
}
catch (NullPointerException e)
{
// then
}
}
示例12: sourceRegion_PositionIntInt
import net.coobird.thumbnailator.geometry.Coordinate; //导入依赖的package包/类
/**
* Test for the {@link Thumbnails.Builder} class where,
* <ol>
* <li>sourceRegion(Position, int, int) is called with valid parameters</li>
* </ol>
* and the expected outcome is,
* <ol>
* <li>The thumbnail is successfully produced</li>
* <li>The specified range is used as the source</li>
* </ol>
* @throws IOException
*/
@Test
public void sourceRegion_PositionIntInt() throws IOException
{
// given
BufferedImage img = ImageIO.read(new File("src/test/resources/Thumbnailator/grid.png"));
File outFile = new File("src/test/resources/Thumbnailator/grid.tmp.png");
outFile.deleteOnExit();
// when
Thumbnails.of(img)
.sourceRegion(new Coordinate(0, 0), 50, 50)
.size(50, 50)
.toFile(outFile);
// then
BufferedImage thumbnail = ImageIO.read(outFile);
assertEquals(50, thumbnail.getWidth());
assertEquals(50, thumbnail.getHeight());
assertTrue(BufferedImageComparer.isRGBSimilar(thumbnail, img.getSubimage(0, 0, 50, 50)));
}
示例13: sourceRegion_PositionIntInt_WidthNonPositive
import net.coobird.thumbnailator.geometry.Coordinate; //导入依赖的package包/类
/**
* Test for the {@link Thumbnails.Builder} class where,
* <ol>
* <li>sourceRegion(Position, int, int) is called with width as non-positive</li>
* </ol>
* and the expected outcome is,
* <ol>
* <li>An IllegalArgumentException is thrown</li>
* </ol>
* @throws IOException
*/
@Test
public void sourceRegion_PositionIntInt_WidthNonPositive() throws IOException
{
// given
BufferedImage img = ImageIO.read(new File("src/test/resources/Thumbnailator/grid.png"));
File outFile = new File("src/test/resources/Thumbnailator/grid.tmp.png");
outFile.deleteOnExit();
// when
try
{
Thumbnails.of(img)
.sourceRegion(new Coordinate(0, 0), -1, 50)
.size(50, 50)
.toFile(outFile);
fail();
}
catch (IllegalArgumentException e)
{
// then
}
}
示例14: sourceRegion_PositionIntInt_HeightNonPositive
import net.coobird.thumbnailator.geometry.Coordinate; //导入依赖的package包/类
/**
* Test for the {@link Thumbnails.Builder} class where,
* <ol>
* <li>sourceRegion(Position, int, int) is called with height as non-positive</li>
* </ol>
* and the expected outcome is,
* <ol>
* <li>An IllegalArgumentException is thrown</li>
* </ol>
* @throws IOException
*/
@Test
public void sourceRegion_PositionIntInt_HeightNonPositive() throws IOException
{
// given
BufferedImage img = ImageIO.read(new File("src/test/resources/Thumbnailator/grid.png"));
File outFile = new File("src/test/resources/Thumbnailator/grid.tmp.png");
outFile.deleteOnExit();
// when
try
{
Thumbnails.of(img)
.sourceRegion(new Coordinate(0, 0), 50, -1)
.size(50, 50)
.toFile(outFile);
fail();
}
catch (IllegalArgumentException e)
{
// then
}
}
示例15: sourceRegion
import net.coobird.thumbnailator.geometry.Coordinate; //导入依赖的package包/类
/**
* Specifies the source region from which the thumbnail is to be
* created from.
* <p>
* Calling this method multiple times will result in an
* {@link IllegalStateException} to be thrown.
*
* @param region A rectangular region which specifies the source
* region to use when creating the thumbnail.
* @throws NullPointerException If the region is {@code null}.
* @since 0.3.4
*/
public Builder<T> sourceRegion(Rectangle region)
{
if (region == null)
{
throw new NullPointerException("Region cannot be null.");
}
return sourceRegion(
new Coordinate(region.x, region.y),
new AbsoluteSize(region.getSize())
);
}