diff --git a/src/java/org/apache/poi/sl/usermodel/TextPainter.java b/src/java/org/apache/poi/sl/usermodel/TextPainter.java new file mode 100644 index 000000000..e2490dece --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/TextPainter.java @@ -0,0 +1,62 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +package org.apache.poi.sl.usermodel; + +import java.awt.RenderingHints; +import java.text.AttributedString; + +/** + * Common parent for painting Text into a Graphics2D object + * for rendering + */ +public interface TextPainter { + public static final Key KEY_FONTFALLBACK = new Key(50, "Font fallback map"); + public static final Key KEY_FONTMAP = new Key(51, "Font map"); + + public static class TextElement { + public AttributedString _text; + public int _textOffset; + public AttributedString _bullet; + public int _bulletOffset; + public int _align; + public float ascent, descent; + public float advance; + public int textStartIndex, textEndIndex; + } + + public static class Key extends RenderingHints.Key { + String description; + + public Key(int paramInt, String paramString) { + super(paramInt); + this.description = paramString; + } + + public final int getIndex() { + return intKey(); + } + + public final String toString() { + return this.description; + } + + public boolean isCompatibleValue(Object paramObject) { + return true; + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java index e0b383a76..32d9faef4 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java @@ -29,7 +29,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import org.apache.poi.hslf.model.TextPainter; +import org.apache.poi.sl.model.TextPainter; import org.apache.poi.util.Beta; import org.apache.poi.util.Internal; import org.apache.poi.util.Units; diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java index 5c616cd43..1a79292f4 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java @@ -25,7 +25,7 @@ import java.awt.image.BufferedImage; import java.util.HashMap; import java.util.Map; -import org.apache.poi.hslf.model.TextPainter; +import org.apache.poi.sl.model.TextPainter; import org.apache.poi.util.JvmBugs; import org.apache.poi.xslf.XSLFTestDataSamples; import org.junit.Test; diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java b/src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java index 6d0dbc82d..79864d678 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java @@ -20,7 +20,6 @@ package org.apache.poi.hslf.model; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; -import java.awt.RenderingHints; import java.awt.font.FontRenderContext; import java.awt.font.LineBreakMeasurer; import java.awt.font.TextAttribute; @@ -41,13 +40,8 @@ import org.apache.poi.util.POILogger; /** * Paint text into java.awt.Graphics2D - * - * @author Yegor Kozlov */ -public final class TextPainter { - public static final Key KEY_FONTFALLBACK = new Key(50, "Font fallback map"); - public static final Key KEY_FONTMAP = new Key(51, "Font map"); - +public final class TextPainter implements org.apache.poi.sl.usermodel.TextPainter { protected POILogger logger = POILogFactory.getLogger(this.getClass()); /** @@ -383,36 +377,4 @@ public final class TextPainter { TextElement[] elems = new TextElement[lines.size()]; return lines.toArray(elems); } - - public static class TextElement { - public AttributedString _text; - public int _textOffset; - public AttributedString _bullet; - public int _bulletOffset; - public int _align; - public float ascent, descent; - public float advance; - public int textStartIndex, textEndIndex; - } - - public static class Key extends RenderingHints.Key { - String description; - - public Key(int paramInt, String paramString) { - super(paramInt); - this.description = paramString; - } - - public final int getIndex() { - return intKey(); - } - - public final String toString() { - return this.description; - } - - public boolean isCompatibleValue(Object paramObject) { - return true; - } - } }