Browse Source

port image type bug fixes from Java8 refactoring in master

master
Stefan Bodewig 7 years ago
parent
commit
2a5857c384
4 changed files with 15 additions and 4 deletions
  1. +1
    -1
      src/main/org/apache/tools/ant/types/optional/image/Arc.java
  2. +1
    -1
      src/main/org/apache/tools/ant/types/optional/image/Ellipse.java
  3. +1
    -1
      src/main/org/apache/tools/ant/types/optional/image/Rectangle.java
  4. +12
    -1
      src/main/org/apache/tools/ant/types/optional/image/Text.java

+ 1
- 1
src/main/org/apache/tools/ant/types/optional/image/Arc.java View File

@@ -112,10 +112,10 @@ public class Arc extends BasicShape implements DrawOperation {
PlanarImage img = ((DrawOperation) instr).executeDrawOperation();
graphics.drawImage(img.getAsBufferedImage(), null, 0, 0);
} else if (instr instanceof TransformOperation) {
graphics = (Graphics2D) bi.getGraphics();
PlanarImage image = ((TransformOperation) instr)
.executeTransformOperation(PlanarImage.wrapRenderedImage(bi));
bi = image.getAsBufferedImage();
graphics = (Graphics2D) bi.getGraphics();
}
}
return PlanarImage.wrapRenderedImage(bi);


+ 1
- 1
src/main/org/apache/tools/ant/types/optional/image/Ellipse.java View File

@@ -76,10 +76,10 @@ public class Ellipse extends BasicShape implements DrawOperation {
PlanarImage img = ((DrawOperation) instr).executeDrawOperation();
graphics.drawImage(img.getAsBufferedImage(), null, 0, 0);
} else if (instr instanceof TransformOperation) {
graphics = (Graphics2D) bi.getGraphics();
PlanarImage image = ((TransformOperation) instr)
.executeTransformOperation(PlanarImage.wrapRenderedImage(bi));
bi = image.getAsBufferedImage();
graphics = (Graphics2D) bi.getGraphics();
}
}
return PlanarImage.wrapRenderedImage(bi);


+ 1
- 1
src/main/org/apache/tools/ant/types/optional/image/Rectangle.java View File

@@ -107,11 +107,11 @@ public class Rectangle extends BasicShape implements DrawOperation {
PlanarImage img = ((DrawOperation) instr).executeDrawOperation();
graphics.drawImage(img.getAsBufferedImage(), null, 0, 0);
} else if (instr instanceof TransformOperation) {
graphics = (Graphics2D) bi.getGraphics();
PlanarImage image
= ((TransformOperation) instr)
.executeTransformOperation(PlanarImage.wrapRenderedImage(bi));
bi = image.getAsBufferedImage();
graphics = (Graphics2D) bi.getGraphics();
}
}
return PlanarImage.wrapRenderedImage(bi);


+ 12
- 1
src/main/org/apache/tools/ant/types/optional/image/Text.java View File

@@ -103,7 +103,7 @@ public class Text extends ImageOperation implements DrawOperation {
RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
graphics.setRenderingHint(
RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
Font f = new Font(font, Font.PLAIN, point);
Font f = createFont();
FontMetrics fmetrics = graphics.getFontMetrics(f);
height = fmetrics.getMaxAscent() + fmetrics.getMaxDescent();
width = fmetrics.stringWidth(strText);
@@ -123,4 +123,15 @@ public class Text extends ImageOperation implements DrawOperation {
PlanarImage image = PlanarImage.wrapRenderedImage(bi);
return image;
}

private Font createFont() {
int style = Font.PLAIN;
if (bold) {
style |= Font.BOLD;
}
if (italic) {
style |= Font.ITALIC;
}
return new Font(font, style, point);
}
}

Loading…
Cancel
Save