java.awt.geom.AffineTransform.getQuadrantRotateInstance()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(13.7k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中java.awt.geom.AffineTransform.getQuadrantRotateInstance()方法的一些代码示例,展示了AffineTransform.getQuadrantRotateInstance()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AffineTransform.getQuadrantRotateInstance()方法的具体详情如下:
包路径:java.awt.geom.AffineTransform
类名称:AffineTransform
方法名:getQuadrantRotateInstance

AffineTransform.getQuadrantRotateInstance介绍

暂无

代码示例

代码示例来源:origin: haraldk/TwelveMonkeys

  1. @Test
  2. public void testFilterRotateBIStandard() {
  3. BufferedImageOp jreOp = new java.awt.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);
  4. BufferedImageOp tmOp = new com.twelvemonkeys.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);
  5. for (Integer type : TYPES) {
  6. BufferedImage image = new BufferedImage(width, height, type);
  7. BufferedImage jreResult = jreOp.filter(image, null);
  8. BufferedImage tmResult = tmOp.filter(image, null);
  9. assertNotNull("No result!", tmResult);
  10. assertEquals("Bad type", jreResult.getType(), tmResult.getType());
  11. assertEquals("Incorrect color model", jreResult.getColorModel(), tmResult.getColorModel());
  12. assertEquals("Incorrect width", jreResult.getWidth(), tmResult.getWidth());
  13. assertEquals("Incorrect height", jreResult.getHeight(), tmResult.getHeight());
  14. }
  15. }

代码示例来源:origin: haraldk/TwelveMonkeys

  1. @Test
  2. public void testFilterRotateRasterStandard() {
  3. RasterOp jreOp = new java.awt.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);
  4. RasterOp tmOp = new com.twelvemonkeys.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);

代码示例来源:origin: haraldk/TwelveMonkeys

  1. @Test
  2. public void testFilterRotateRasterCustom() {
  3. RasterOp jreOp = new java.awt.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);
  4. RasterOp tmOp = new com.twelvemonkeys.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);

代码示例来源:origin: haraldk/TwelveMonkeys

  1. @Test
  2. public void testFilterRotateBICustom() {
  3. BufferedImageOp jreOp = new java.awt.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);
  4. BufferedImageOp tmOp = new com.twelvemonkeys.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);
  5. for (ImageTypeSpecifier spec : SPECS) {
  6. BufferedImage image = spec.createBufferedImage(width, height);
  7. BufferedImage tmResult = tmOp.filter(image, null);
  8. assertNotNull("No result!", tmResult);
  9. BufferedImage jreResult = null;
  10. try {
  11. jreResult = jreOp.filter(image, null);
  12. }
  13. catch (ImagingOpException ignore) {
  14. // We expect this to fail for certain cases, that's why we crated the class in the first place
  15. }
  16. if (jreResult != null) {
  17. assertEquals("Bad type", jreResult.getType(), tmResult.getType());
  18. assertEquals("Incorrect color model", jreResult.getColorModel(), tmResult.getColorModel());
  19. assertEquals("Incorrect width", jreResult.getWidth(), tmResult.getWidth());
  20. assertEquals("Incorrect height", jreResult.getHeight(), tmResult.getHeight());
  21. }
  22. else {
  23. assertEquals("Bad type", spec.getBufferedImageType(), tmResult.getType());
  24. assertEquals("Incorrect color model", spec.getColorModel(), tmResult.getColorModel());
  25. assertEquals("Incorrect width", height, tmResult.getWidth());
  26. assertEquals("Incorrect height", width, tmResult.getHeight());
  27. }
  28. }
  29. }

代码示例来源:origin: ribomation/DroidAtScreen1

  1. BufferedImage rotate(int quadrants, BufferedImage img) {
  2. int w = img.getWidth();
  3. int h = img.getHeight();
  4. int x = (quadrants == 2 || quadrants == 3) ? w : 0;
  5. int y = (quadrants == 1 || quadrants == 2) ? h : 0;
  6. Point2D origo = AffineTransform.getQuadrantRotateInstance(quadrants, 0, 0).transform(new Point(x, y), null);
  7. BufferedImage result = new BufferedImage(h, w, img.getType());
  8. Graphics2D g = result.createGraphics();
  9. g.translate(0 - origo.getX(), 0 - origo.getY());
  10. g.transform(AffineTransform.getQuadrantRotateInstance(quadrants, 0, 0));
  11. g.drawRenderedImage(img, null);
  12. return result;
  13. }

代码示例来源:origin: com.github.lafa.pdfbox/pdfbox

  1. private BufferedImage getRotatedImage(BufferedImage gray) throws IOException
  2. {
  3. BufferedImage gray2;
  4. AffineTransform at;
  5. switch (pageRotation % 360)
  6. {
  7. case 90:
  8. gray2 = new BufferedImage(gray.getHeight(), gray.getWidth(), BufferedImage.TYPE_BYTE_GRAY);
  9. at = AffineTransform.getQuadrantRotateInstance(1, gray.getHeight() / 2d, gray.getHeight() / 2d);
  10. break;
  11. case 180:
  12. gray2 = new BufferedImage(gray.getWidth(), gray.getHeight(), BufferedImage.TYPE_BYTE_GRAY);
  13. at = AffineTransform.getQuadrantRotateInstance(2, gray.getWidth()/ 2d, gray.getHeight() / 2d);
  14. break;
  15. case 270:
  16. gray2 = new BufferedImage(gray.getHeight(), gray.getWidth(), BufferedImage.TYPE_BYTE_GRAY);
  17. at = AffineTransform.getQuadrantRotateInstance(3, gray.getWidth()/ 2d, gray.getWidth() / 2d);
  18. break;
  19. default:
  20. return gray;
  21. }
  22. Graphics2D g2 = (Graphics2D) gray2.getGraphics();
  23. g2.drawImage(gray, at, null);
  24. g2.dispose();
  25. return gray2;
  26. }

代码示例来源:origin: stackoverflow.com

  1. import java.io.File;
  2. import javax.imageio.ImageIO;
  3. import java.awt.image.BufferedImage;
  4. import java.awt.image.AffineTransformOp;
  5. import java.awt.geom.AffineTransform;
  6. class RT {
  7. public static void main(String[] args) throws java.io.IOException {
  8. BufferedImage img = ImageIO.read(new File("input-image.png"));
  9. BufferedImage rotated = new AffineTransformOp(
  10. AffineTransform.getQuadrantRotateInstance(
  11. 3, img.getWidth() / 2, img.getHeight() / 2),
  12. AffineTransformOp.TYPE_BILINEAR).filter(img, null);
  13. ImageIO.write(rotated, "PNG", new File("output-image.png"));
  14. }
  15. }

代码示例来源:origin: apache/pdfbox

  1. form.setMatrix(AffineTransform.getQuadrantRotateInstance(1));
  2. initialScale = Matrix.getScaleInstance(bbox.getWidth() / bbox.getHeight(), bbox.getHeight() / bbox.getWidth());
  3. height = bbox.getWidth();
  4. break;
  5. case 180:
  6. form.setMatrix(AffineTransform.getQuadrantRotateInstance(2));
  7. break;
  8. case 270:
  9. form.setMatrix(AffineTransform.getQuadrantRotateInstance(3));
  10. initialScale = Matrix.getScaleInstance(bbox.getWidth() / bbox.getHeight(), bbox.getHeight() / bbox.getWidth());
  11. height = bbox.getWidth();

代码示例来源:origin: com.synaptix/SynaptixWidget

  1. @Override
  2. protected void paintComponent(Graphics g) {
  3. Graphics2D gr = (Graphics2D) g.create();
  4. if (direction == SwingConstants.LEFT || direction == SwingConstants.RIGHT) {
  5. gr.translate(0, getSize().getHeight());
  6. gr.transform(AffineTransform.getQuadrantRotateInstance(-1));
  7. needsRotate = true;
  8. }
  9. super.paintComponent(gr);
  10. needsRotate = false;
  11. gr.dispose();
  12. }
  13. }

代码示例来源:origin: com.synaptix/SynaptixSwing

  1. @Override
  2. protected void paintComponent(Graphics g) {
  3. Graphics2D gr = (Graphics2D) g.create();
  4. switch (direction) {
  5. case VERTICAL_UP:
  6. gr.translate(0, getSize().getHeight());
  7. gr.transform(AffineTransform.getQuadrantRotateInstance(-1));
  8. break;
  9. case VERTICAL_DOWN:
  10. gr.transform(AffineTransform.getQuadrantRotateInstance(1));
  11. gr.translate(0, -getSize().getWidth());
  12. break;
  13. default:
  14. }
  15. needsRotate = true;
  16. super.paintComponent(gr);
  17. needsRotate = false;
  18. }
  19. }

代码示例来源:origin: ribomation/DroidAtScreen1

  1. double x = (landscapeMode ? h : w) / 2;
  2. double y = (landscapeMode ? w : h) / 2;
  3. TX.concatenate(AffineTransform.getQuadrantRotateInstance(2, x, y));

代码示例来源:origin: opengeospatial/geoapi

  1. /**
  2. * Tests using a 180° rotation in a two-dimensional space.
  3. *
  4. * @throws FactoryException should never happen.
  5. * @throws TransformException should never happen.
  6. */
  7. @Test
  8. public void testSouthOrientated2D() throws FactoryException, TransformException {
  9. runTest(AffineTransform.getQuadrantRotateInstance(2));
  10. assertFalse("MathTransform.isIdentity().", transform.isIdentity());
  11. }

代码示例来源:origin: igvteam/igv

  1. transform = AffineTransform.getQuadrantRotateInstance(-1);
  2. graphics2.transform(transform);
  3. graphics2.setFont(font);

代码示例来源:origin: com.twelvemonkeys.common/common-image

  1. @Test
  2. public void testFilterRotateBIStandard() {
  3. BufferedImageOp jreOp = new java.awt.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);
  4. BufferedImageOp tmOp = new com.twelvemonkeys.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);
  5. for (Integer type : TYPES) {
  6. BufferedImage image = new BufferedImage(width, height, type);
  7. BufferedImage jreResult = jreOp.filter(image, null);
  8. BufferedImage tmResult = tmOp.filter(image, null);
  9. assertNotNull("No result!", tmResult);
  10. assertEquals("Bad type", jreResult.getType(), tmResult.getType());
  11. assertEquals("Incorrect color model", jreResult.getColorModel(), tmResult.getColorModel());
  12. assertEquals("Incorrect width", jreResult.getWidth(), tmResult.getWidth());
  13. assertEquals("Incorrect height", jreResult.getHeight(), tmResult.getHeight());
  14. }
  15. }

代码示例来源:origin: com.github.lafa.twelvemonkeyspurejava.common/common-image

  1. @Test
  2. public void testFilterRotateBIStandard() {
  3. BufferedImageOp jreOp = new java.awt.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);
  4. BufferedImageOp tmOp = new com.twelvemonkeys.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);
  5. for (Integer type : TYPES) {
  6. BufferedImage image = new BufferedImage(width, height, type);
  7. BufferedImage jreResult = jreOp.filter(image, null);
  8. BufferedImage tmResult = tmOp.filter(image, null);
  9. assertNotNull("No result!", tmResult);
  10. assertEquals("Bad type", jreResult.getType(), tmResult.getType());
  11. assertEquals("Incorrect color model", jreResult.getColorModel(), tmResult.getColorModel());
  12. assertEquals("Incorrect width", jreResult.getWidth(), tmResult.getWidth());
  13. assertEquals("Incorrect height", jreResult.getHeight(), tmResult.getHeight());
  14. }
  15. }

代码示例来源:origin: com.twelvemonkeys.common/common-image

  1. @Test
  2. public void testFilterRotateRasterStandard() {
  3. RasterOp jreOp = new java.awt.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);
  4. RasterOp tmOp = new com.twelvemonkeys.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);

代码示例来源:origin: com.github.lafa.twelvemonkeyspurejava.common/common-image

  1. @Test
  2. public void testFilterRotateRasterStandard() {
  3. RasterOp jreOp = new java.awt.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);
  4. RasterOp tmOp = new com.twelvemonkeys.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);

代码示例来源:origin: com.twelvemonkeys.common/common-image

  1. @Test
  2. public void testFilterRotateRasterCustom() {
  3. RasterOp jreOp = new java.awt.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);
  4. RasterOp tmOp = new com.twelvemonkeys.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);

代码示例来源:origin: com.github.lafa.twelvemonkeyspurejava.common/common-image

  1. @Test
  2. public void testFilterRotateBICustom() {
  3. BufferedImageOp jreOp = new java.awt.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);
  4. BufferedImageOp tmOp = new com.twelvemonkeys.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);
  5. for (ImageTypeSpecifier spec : SPECS) {
  6. BufferedImage image = spec.createBufferedImage(width, height);
  7. BufferedImage tmResult = tmOp.filter(image, null);
  8. assertNotNull("No result!", tmResult);
  9. BufferedImage jreResult = null;
  10. try {
  11. jreResult = jreOp.filter(image, null);
  12. }
  13. catch (ImagingOpException ignore) {
  14. // We expect this to fail for certain cases, that's why we crated the class in the first place
  15. }
  16. if (jreResult != null) {
  17. assertEquals("Bad type", jreResult.getType(), tmResult.getType());
  18. assertEquals("Incorrect color model", jreResult.getColorModel(), tmResult.getColorModel());
  19. assertEquals("Incorrect width", jreResult.getWidth(), tmResult.getWidth());
  20. assertEquals("Incorrect height", jreResult.getHeight(), tmResult.getHeight());
  21. }
  22. else {
  23. assertEquals("Bad type", spec.getBufferedImageType(), tmResult.getType());
  24. assertEquals("Incorrect color model", spec.getColorModel(), tmResult.getColorModel());
  25. assertEquals("Incorrect width", height, tmResult.getWidth());
  26. assertEquals("Incorrect height", width, tmResult.getHeight());
  27. }
  28. }
  29. }

代码示例来源:origin: com.twelvemonkeys.common/common-image

  1. @Test
  2. public void testFilterRotateBICustom() {
  3. BufferedImageOp jreOp = new java.awt.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);
  4. BufferedImageOp tmOp = new com.twelvemonkeys.image.AffineTransformOp(AffineTransform.getQuadrantRotateInstance(1, Math.min(width, height) / 2, Math.min(width, height) / 2), null);
  5. for (ImageTypeSpecifier spec : SPECS) {
  6. BufferedImage image = spec.createBufferedImage(width, height);
  7. BufferedImage tmResult = tmOp.filter(image, null);
  8. assertNotNull("No result!", tmResult);
  9. BufferedImage jreResult = null;
  10. try {
  11. jreResult = jreOp.filter(image, null);
  12. }
  13. catch (ImagingOpException ignore) {
  14. // We expect this to fail for certain cases, that's why we crated the class in the first place
  15. }
  16. if (jreResult != null) {
  17. assertEquals("Bad type", jreResult.getType(), tmResult.getType());
  18. assertEquals("Incorrect color model", jreResult.getColorModel(), tmResult.getColorModel());
  19. assertEquals("Incorrect width", jreResult.getWidth(), tmResult.getWidth());
  20. assertEquals("Incorrect height", jreResult.getHeight(), tmResult.getHeight());
  21. }
  22. else {
  23. assertEquals("Bad type", spec.getBufferedImageType(), tmResult.getType());
  24. assertEquals("Incorrect color model", spec.getColorModel(), tmResult.getColorModel());
  25. assertEquals("Incorrect width", height, tmResult.getWidth());
  26. assertEquals("Incorrect height", width, tmResult.getHeight());
  27. }
  28. }
  29. }

相关文章