diff --git a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFEmitter.java b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFEmitter.java index df9895c33a9..59e0fc428d0 100644 --- a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFEmitter.java +++ b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFEmitter.java @@ -19,6 +19,12 @@ import org.eclipse.birt.report.engine.layout.emitter.PageDeviceRender; import org.eclipse.birt.report.engine.layout.emitter.PageEmitter; +/** + * Class of PDFEmitter + * + * @since 3.3 + * + */ public class PDFEmitter extends PageEmitter { @Override diff --git a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPage.java b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPage.java index 1fd16e32b0c..e258dbd9ffd 100644 --- a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPage.java +++ b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPage.java @@ -233,7 +233,7 @@ protected void drawImage(String imageId, byte[] imageData, String extension, flo // Not cached yet if (SvgFile.isSvg(null, null, extension)) { - template = generateTemplateFromSVG(null, imageData, imageX, imageY, height, width, helpText); + template = generateTemplateFromSVG(imageData, height, width); } else { // PNG/JPG/BMP... images: Image image = Image.getInstance(imageData); @@ -663,13 +663,13 @@ protected void embedFlash(String flashPath, byte[] flashData, float x, float y, contentByte.restoreState(); } - protected PdfTemplate generateTemplateFromSVG(String svgPath, byte[] svgData, float x, float y, float height, - float width, String helpText) throws Exception { - return transSVG(null, svgData, x, y, height, width, helpText); + protected PdfTemplate generateTemplateFromSVG(byte[] svgData, float height, float width) + throws Exception { + return transSVG(null, svgData, height, width); } - protected PdfTemplate transSVG(String svgPath, byte[] svgData, float x, float y, float height, float width, - String helpText) throws IOException, DocumentException { + protected PdfTemplate transSVG(String svgPath, byte[] svgData, float height, float width) + throws DocumentException { PdfTemplate template = contentByte.createTemplate(width, height); Graphics2D g2D = template.createGraphics(width, height); diff --git a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFRender.java b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFRender.java index ab3d18b5281..61be5adad25 100644 --- a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFRender.java +++ b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFRender.java @@ -23,7 +23,7 @@ import org.eclipse.birt.report.engine.api.EngineException; import org.eclipse.birt.report.engine.api.IHTMLActionHandler; -import org.eclipse.birt.report.engine.api.RenderOption; +import org.eclipse.birt.report.engine.api.IRenderOption; import org.eclipse.birt.report.engine.api.impl.Action; import org.eclipse.birt.report.engine.api.script.IReportContext; import org.eclipse.birt.report.engine.content.IHyperlinkAction; @@ -42,6 +42,12 @@ import com.lowagie.text.pdf.PdfTemplate; +/** + * Class to create the PDF renderer + * + * @since 3.3 + * + */ public class PDFRender extends PageDeviceRender { /** @@ -57,6 +63,12 @@ public class PDFRender extends PageDeviceRender { protected HashSet bookmarks = new HashSet<>(); + /** + * Constructor + * + * @param services emitter service + * @throws EngineException engine exception + */ public PDFRender(IEmitterServices services) throws EngineException { initialize(services); } @@ -187,7 +199,7 @@ private void createHyperlink(IArea area, int x, int y) { Action act = new Action(systemId, hlAction); String link = null; IHTMLActionHandler actionHandler = null; - Object ac = services.getOption(RenderOption.ACTION_HANDLER); + Object ac = services.getOption(IRenderOption.ACTION_HANDLER); if (ac instanceof IHTMLActionHandler) { actionHandler = (IHTMLActionHandler) ac; } diff --git a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/TOCHandler.java b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/TOCHandler.java index 0c12af92fb7..4fea1450f66 100644 --- a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/TOCHandler.java +++ b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/TOCHandler.java @@ -25,6 +25,12 @@ import com.lowagie.text.pdf.PdfAction; import com.lowagie.text.pdf.PdfOutline; +/** + * Class of PDF TOC handler + * + * @since 3.3 + * + */ public class TOCHandler { /** @@ -51,7 +57,9 @@ public class TOCHandler { /** * The constructor. * - * @param root The TOC node in which need to build PDF outline + * @param root The TOC node in which need to build PDF outline + * @param outline pdf outline + * @param bookmarks bookmarks of the pdf */ public TOCHandler(TOCNode root, PdfOutline outline, Set bookmarks) { this.root = root; @@ -68,6 +76,9 @@ public TOCNode getTOCRoot() { return this.root; } + /** + * Create the TOC of the PDF + */ public void createTOC() { createTOC(root, outline, bookmarks); } @@ -83,7 +94,7 @@ protected void createTOC(TOCNode tocNode, PdfOutline pol, Set bookmarks) if (isOutlineSizeOverflow() || null == tocNode || null == tocNode.getChildren()) { return; } - for (Iterator i = tocNode.getChildren().iterator(); i.hasNext();) { + for (Iterator i = tocNode.getChildren().iterator(); i.hasNext();) { TOCNode node = (TOCNode) i.next(); if (!bookmarks.contains(node.getBookmark())) { createTOC(node, outline, bookmarks); @@ -91,7 +102,7 @@ protected void createTOC(TOCNode tocNode, PdfOutline pol, Set bookmarks) } PdfOutline outline = new PdfOutline(pol, PdfAction.gotoLocalPage(node.getBookmark(), false), node.getDisplayString()); - countOutlineSize(node.getBookmark().length()); + countOutlineSize(); IScriptStyle style = node.getTOCStyle(); String color = style.getColor(); if (color != null) { @@ -113,7 +124,7 @@ protected boolean isOutlineSizeOverflow() { return counter > MAX_COUNT; } - protected void countOutlineSize(long size) { + protected void countOutlineSize() { counter++; } } diff --git a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/plugin/PDFEmitterPlugin.java b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/plugin/PDFEmitterPlugin.java index 36b3d4b8cf5..bb37adf492e 100644 --- a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/plugin/PDFEmitterPlugin.java +++ b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/plugin/PDFEmitterPlugin.java @@ -17,6 +17,12 @@ import org.eclipse.birt.core.plugin.BIRTPlugin; import org.osgi.framework.BundleContext; +/** + * Class of PDFEmitter plugin + * + * @since 3.3 + * + */ public class PDFEmitterPlugin extends BIRTPlugin { @Override diff --git a/engine/org.eclipse.birt.report.engine.emitter.pptx/src/org/eclipse/birt/report/engine/emitter/pptx/PPTXPage.java b/engine/org.eclipse.birt.report.engine.emitter.pptx/src/org/eclipse/birt/report/engine/emitter/pptx/PPTXPage.java index 02c1787023a..c67f49027e2 100644 --- a/engine/org.eclipse.birt.report.engine.emitter.pptx/src/org/eclipse/birt/report/engine/emitter/pptx/PPTXPage.java +++ b/engine/org.eclipse.birt.report.engine.emitter.pptx/src/org/eclipse/birt/report/engine/emitter/pptx/PPTXPage.java @@ -85,7 +85,8 @@ public void drawImage(String imageId, byte[] imageData, String extension, int im @Override public void drawImage(String uri, String extension, int imageX, int imageY, int height, int width, String helpText, - Map parameters) throws Exception { + Map parameters) + throws Exception { imageX = PPTXUtil.convertToEnums(imageX); imageY = PPTXUtil.convertToEnums(imageY); width = PPTXUtil.convertToEnums(width); diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/emitter/AbstractPage.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/emitter/AbstractPage.java index 0a3802bfddc..1e6d087d25c 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/emitter/AbstractPage.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/emitter/AbstractPage.java @@ -19,12 +19,24 @@ import org.eclipse.birt.report.engine.layout.PDFConstants; import org.eclipse.birt.report.engine.layout.pdf.font.FontInfo; -import org.eclipse.birt.report.engine.nLayout.area.style.BorderInfo; +import org.eclipse.birt.report.engine.nLayout.area.style.AreaConstants; import org.eclipse.birt.report.engine.nLayout.area.style.TextStyle; +/** + * Class to define abstract page + * + * @since 3.3 + * + */ public abstract class AbstractPage implements IPage { protected float pageWidth, pageHeight; + /** + * Constructor + * + * @param pageWidth page width + * @param pageHeight page height + */ public AbstractPage(int pageWidth, int pageHeight) { this.pageWidth = convertToPoint(pageWidth); this.pageHeight = convertToPoint(pageHeight); @@ -116,7 +128,7 @@ public void showHelpText(String text, int textX, int textY, int width, int heigh protected void drawDecorationLine(float textX, float textY, float width, float lineWidth, float verticalOffset, Color color) { textY = textY + verticalOffset; - drawLine(textX, textY, textX + width, textY, lineWidth, color, BorderInfo.BORDER_STYLE_SOLID); // $NON-NLS-1$ + drawLine(textX, textY, textX + width, textY, lineWidth, color, AreaConstants.BORDER_STYLE_SOLID); // $NON-NLS-1$ } protected abstract void clip(float startX, float startY, float width, float height); @@ -167,4 +179,4 @@ protected float transformY(float y, float height, float containerHeight) { return containerHeight - y - height; } -} +} \ No newline at end of file diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/emitter/IPage.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/emitter/IPage.java index befc65d0dfa..bc0626f3330 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/emitter/IPage.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/emitter/IPage.java @@ -19,8 +19,17 @@ import org.eclipse.birt.report.engine.nLayout.area.style.TextStyle; +/** + * Interface to define a page + * + * @since 3.3 + * + */ public interface IPage { + /** + * disposer of the page + */ void dispose(); /** @@ -50,11 +59,39 @@ public interface IPage { */ void drawText(String text, int textX, int textY, int width, int height, TextStyle textStyle); + /** + * Draw the image + * + * @param imageId image id + * @param imageData image data + * @param extension image type + * @param imageX image x position + * @param imageY image y position + * @param height image height + * @param width image width + * @param helpText help text + * @param params map of parameters + * @throws Exception handling exception + */ void drawImage(String imageId, byte[] imageData, String extension, int imageX, int imageY, int height, int width, String helpText, Map params) throws Exception; + /** + * Draw the image + * + * @param uri image uri + * @param extension image type + * @param imageX image x position + * @param imageY image y position + * @param height image height + * @param width image width + * @param helpText help text + * @param params map of parameters + * @throws Exception handling exception + */ void drawImage(String uri, String extension, int imageX, int imageY, int height, int width, String helpText, - Map params) throws Exception; + Map params) + throws Exception; /** * Draws a line from the start position to the end position with the given line @@ -81,8 +118,33 @@ void drawImage(String uri, String extension, int imageX, int imageY, int height, */ void drawBackgroundColor(Color color, int x, int y, int width, int height); + /** + * Draw the background image + * + * @param x image x position + * @param y image y position + * @param width with + * @param height height + * @param imageWidth image width + * @param imageHeight image height + * @param repeat repeat the image on background + * @param imageUrl image URL + * @param imageData image data + * @param absPosX absolute x position + * @param absPosY absolute y position + * @throws Exception handling exception + */ void drawBackgroundImage(int x, int y, int width, int height, int imageWidth, int imageHeight, int repeat, String imageUrl, byte[] imageData, int absPosX, int absPosY) throws Exception; + /** + * Show the help text + * + * @param text help text + * @param x x position + * @param y y position + * @param width width + * @param height height + */ void showHelpText(String text, int x, int y, int width, int height); } diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/font/FontHandler.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/font/FontHandler.java index 405a44bfafd..c06e0110c42 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/font/FontHandler.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/font/FontHandler.java @@ -57,7 +57,7 @@ public class FontHandler { private FontMappingManager fontManager = null; - private Map fonts = new HashMap(); + private Map fonts = new HashMap(); /** * the characters which prefer to use the font of their previous character. @@ -67,10 +67,11 @@ public class FontHandler { /** * The constructor * + * @param fontManager + * * @param textContent the textContent whose font need to be handled * @param fontSubstitution If it set to false, we needn't check if the character * exists in the selected font. - * @param format the output format type */ public FontHandler(FontMappingManager fontManager, ITextContent textContent, boolean fontSubstitution) { this.fontManager = fontManager; @@ -132,11 +133,18 @@ public FontHandler(FontMappingManager fontManager, String fontFamilies[], int fo /** * Gets the FontInfo Object. + * + * @return Return the font object */ public FontInfo getFontInfo() { return new FontInfo(bf, fontSize, fontStyle, fontWeight, simulation); } + /** + * Check is font changed + * + * @return Return the check of changed font + */ public boolean isFontChanged() { return isFontChanged; } @@ -144,6 +152,8 @@ public boolean isFontChanged() { /** * Selects a proper font for a character. * + * @param character character to validate the font + * * @return true: we find a font which can be used to display the character. * false: no font can display the character. */ @@ -158,7 +168,7 @@ public boolean selectFont(char character) { } else { isFontChanged = true; bf = candidateFont; - simulation = needSimulate(bf); + simulation = needSimulate(); } return candidateFont.charExists(character); } @@ -228,7 +238,7 @@ public BaseFont getMappedFont(char c) { } private BaseFont createBaseFont(String physicalFont) { - BaseFont font = (BaseFont) fonts.get(physicalFont); + BaseFont font = fonts.get(physicalFont); if (font == null) { if (fonts.containsKey(physicalFont)) { return null; @@ -244,7 +254,7 @@ private BaseFont createBaseFont(String physicalFont) { * the proper style for the font. The "simulate" flag will be set if we need to * simulate it. */ - private boolean needSimulate(BaseFont font) { + private boolean needSimulate() { if (fontStyle == Font.NORMAL) { return false; } @@ -264,9 +274,8 @@ private boolean needSimulate(BaseFont font) { if (fontWeight > 400 && fontWeight != 700) { // not a regular bold font. return true; - } else { - return false; } + return false; } return true; } diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/font/FontInfo.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/font/FontInfo.java index 8eff6449ef0..28f89026a33 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/font/FontInfo.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/font/FontInfo.java @@ -20,6 +20,13 @@ import com.lowagie.text.Font; import com.lowagie.text.pdf.BaseFont; +/** + * + * Definition of the font information + * + * @since 3.3 + * + */ public class FontInfo { private BaseFont bf; @@ -38,6 +45,15 @@ public class FontInfo { private float linethroughPosition; private float overlinePosition; + /** + * Constructor 1 + * + * @param bf base font + * @param fontSize font size + * @param fontStyle font style + * @param fontWeight font weight + * @param simulation font simulation + */ public FontInfo(BaseFont bf, float fontSize, int fontStyle, int fontWeight, boolean simulation) { this.bf = bf; this.fontStyle = fontStyle; @@ -47,6 +63,11 @@ public FontInfo(BaseFont bf, float fontSize, int fontStyle, int fontWeight, bool setupFontSize(); } + /** + * Constructor 2 + * + * @param fontInfo font info object + */ public FontInfo(FontInfo fontInfo) { this.bf = fontInfo.bf; this.fontStyle = fontInfo.fontStyle; @@ -56,6 +77,11 @@ public FontInfo(FontInfo fontInfo) { setupFontSize(); } + /** + * Set the font size + * + * @param fontSize font size + */ public void setFontSize(float fontSize) { this.fontSize = fontSize; setupFontSize(); @@ -111,46 +137,101 @@ protected void setupFontSize() { overlinePosition = 0; } + /** + * Set the font simulation + * + * @param simulation simulation should be available + */ public void setSimulation(boolean simulation) { this.simulation = simulation; } + /** + * Get the base font + * + * @return Return the base font + */ public BaseFont getBaseFont() { return this.bf; } + /** + * Get the font size + * + * @return Return the font size + */ public float getFontSize() { return this.fontSize; } + /** + * Get the font style + * + * @return Return the font style + */ public int getFontStyle() { return this.fontStyle; } + /** + * Get the font weight + * + * @return Return the font weight + */ public int getFontWeight() { return this.fontWeight; } + /** + * Get the simulation of the font + * + * @return Return the simulation of the font + */ public boolean getSimulation() { return this.simulation; } + /** + * Get the line width of the font + * + * @return Return the line width of the font + */ public float getLineWidth() { return this.lineWidth; } + /** + * Get the overline position of the font + * + * @return Return theoverline position of the font + */ public int getOverlinePosition() { return (int) (overlinePosition * PDFConstants.LAYOUT_TO_PDF_RATIO); } + /** + * Get the underline position of the font + * + * @return Return the underline position of the font + */ public int getUnderlinePosition() { return (int) (underlinePosition * PDFConstants.LAYOUT_TO_PDF_RATIO); } + /** + * Get the line though position of the font + * + * @return Return the line though position of the font + */ public int getLineThroughPosition() { return (int) (linethroughPosition * PDFConstants.LAYOUT_TO_PDF_RATIO); } + /** + * Get the font baseline + * + * @return Return the font baseline + */ public int getBaseline() { return (int) (baselinePosition * PDFConstants.LAYOUT_TO_PDF_RATIO); } @@ -172,6 +253,11 @@ public float getWordWidth(String word) { return bf.getWidthPoint(word, fontSize); } + /** + * Get italic adjusted font + * + * @return Get italic adjusted font + */ public int getItalicAdjust() { // get width for text with simulated italic font. if (simulation && (Font.ITALIC == fontStyle || Font.BOLDITALIC == fontStyle)) { @@ -189,6 +275,11 @@ public float getWordHeight() { return fontHeight; } + /** + * Get the font name + * + * @return Return the font name + */ public String getFontName() { assert bf != null; String[][] familyFontNames = bf.getFamilyFontName(); diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/text/Chunk.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/text/Chunk.java index 50612f5a456..aafc6c3f1ad 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/text/Chunk.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/text/Chunk.java @@ -29,24 +29,59 @@ public class Chunk { private int baseLevel; private int runLevel; + /** property: line break */ public static final Chunk HARD_LINE_BREAK = new Chunk("\n"); //$NON-NLS-1$ + /** + * Constructor 1 + * + * @param text chunk text + */ public Chunk(String text) { this(text, 0, Bidi.DIRECTION_LEFT_TO_RIGHT, Bidi.DIRECTION_LEFT_TO_RIGHT, null); } + /** + * Constructor 2 + * + * @param text chunk text + * @param offset offset + * @param fi font info + */ public Chunk(String text, int offset, FontInfo fi) { this(text, offset, Bidi.DIRECTION_LEFT_TO_RIGHT, Bidi.DIRECTION_LEFT_TO_RIGHT, fi); } + /** + * Constructor 3 + * + * @param chunk chunk of text + */ public Chunk(Chunk chunk) { this(chunk.text, chunk.offset, chunk.baseLevel, chunk.runLevel, null); } + /** + * Constructor 4 + * + * @param text chunk text + * @param offset text offset + * @param baseLevel base level + * @param runLevel run level + */ public Chunk(String text, int offset, int baseLevel, int runLevel) { this(text, offset, baseLevel, runLevel, null); } + /** + * Constructor 5 + * + * @param text chunk text + * @param offset text offset + * @param baseLevel base level + * @param runLevel run level + * @param fi font info + */ public Chunk(String text, int offset, int baseLevel, int runLevel, FontInfo fi) { this.text = text; this.offset = offset; @@ -56,18 +91,38 @@ public Chunk(String text, int offset, int baseLevel, int runLevel, FontInfo fi) this.fontInfo = fi; } + /** + * Set the text + * + * @param text chunk text + */ public void setText(String text) { this.text = text; } + /** + * Set the text offset + * + * @param offset text offset + */ public void setOffset(int offset) { this.offset = offset; } + /** + * Get the chunk text + * + * @return Return the chunk text + */ public String getText() { return this.text; } + /** + * Get the chunk text length + * + * @return Return the chunk text length + */ public int getLength() { if (text != null) { return text.length(); @@ -75,22 +130,47 @@ public int getLength() { return 0; } + /** + * Set the font info + * + * @param fi font info + */ public void setFontInfo(FontInfo fi) { this.fontInfo = fi; } + /** + * Get the font info + * + * @return Return the ont info + */ public FontInfo getFontInfo() { return this.fontInfo; } + /** + * Return the offset + * + * @return Get the offset + */ public int getOffset() { return this.offset; } + /** + * Set the base level + * + * @param baseLevel base level + */ public void setBaseLevel(int baseLevel) { this.baseLevel = baseLevel; } + /** + * Return the base level + * + * @return Get the base level + */ public int getBaseLevel() { return this.baseLevel; } diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/text/ChunkGenerator.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/text/ChunkGenerator.java index 094a552fb97..ce7851ea57c 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/text/ChunkGenerator.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/text/ChunkGenerator.java @@ -22,6 +22,12 @@ import com.ibm.icu.text.Bidi; +/** + * Class to generate data chunks / text segments + * + * @since 3.3 + * + */ public class ChunkGenerator { private FontMappingManager fontManager; private ITextContent textContent; @@ -32,6 +38,14 @@ public class ChunkGenerator { private ISplitter bidiSplitter = null; private ISplitter fontSplitter = null; + /** + * Constructor + * + * @param fontManager font manager + * @param textContent text content + * @param bidiProcessing bidi processing flag + * @param fontSubstitution is font substitution used flag + */ public ChunkGenerator(FontMappingManager fontManager, ITextContent textContent, boolean bidiProcessing, boolean fontSubstitution) { this.fontManager = fontManager; @@ -62,6 +76,11 @@ public ChunkGenerator(FontMappingManager fontManager, ITextContent textContent, } + /** + * Has more elements + * + * @return Return the validation result of more elements + */ public boolean hasMore() { if (text == null || text.length() == 0) { return false; @@ -79,18 +98,21 @@ public boolean hasMore() { } if (fontSplitter.hasMore()) { return true; - } else { - return false; } + return false; } + /** + * Get the next text part + * + * @return Return the next text part + */ public Chunk getNext() { while (null != fontSplitter) { if (fontSplitter.hasMore()) { return fontSplitter.getNext(); - } else { - fontSplitter = null; } + fontSplitter = null; if (null != bidiSplitter && bidiSplitter.hasMore()) { fontSplitter = new FontSplitter(fontManager, bidiSplitter.getNext(), textContent, fontSubstitution); } else { diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/ILayout.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/ILayout.java index 1d678190ea4..f56f86dda66 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/ILayout.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/ILayout.java @@ -15,7 +15,18 @@ import org.eclipse.birt.core.exception.BirtException; +/** + * Interface of the layout + * + * @since 3.3 + * + */ public interface ILayout { + /** + * The layout + * + * @throws BirtException + */ void layout() throws BirtException; } diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/impl/ImageAreaLayout.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/impl/ImageAreaLayout.java index 3458a11a835..4faa6c4294b 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/impl/ImageAreaLayout.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/impl/ImageAreaLayout.java @@ -14,8 +14,6 @@ package org.eclipse.birt.report.engine.nLayout.area.impl; -import java.io.IOException; -import java.net.MalformedURLException; import java.util.Map; import java.util.TreeMap; import java.util.logging.Level; @@ -30,10 +28,11 @@ import org.eclipse.birt.report.engine.content.IHyperlinkAction; import org.eclipse.birt.report.engine.content.IImageContent; import org.eclipse.birt.report.engine.content.IReportContent; -import org.eclipse.birt.report.engine.content.IStyle; import org.eclipse.birt.report.engine.content.ITextContent; import org.eclipse.birt.report.engine.content.impl.ActionContent; import org.eclipse.birt.report.engine.content.impl.ObjectContent; +import org.eclipse.birt.report.engine.css.engine.StyleConstants; +import org.eclipse.birt.report.engine.css.engine.value.css.CSSValueConstants; import org.eclipse.birt.report.engine.emitter.ImageReader; import org.eclipse.birt.report.engine.i18n.EngineResourceHandle; import org.eclipse.birt.report.engine.i18n.MessageConstants; @@ -45,9 +44,15 @@ import org.eclipse.birt.report.engine.nLayout.area.style.BoxStyle; import com.ibm.icu.util.ULocale; -import com.lowagie.text.BadElementException; import com.lowagie.text.Image; +/** + * + * Implementation of image layout area + * + * @since 3.3 + * + */ public class ImageAreaLayout implements ILayout { private ILayout layout = null; @@ -61,6 +66,13 @@ public class ImageAreaLayout implements ILayout { private static Pattern pattern = Pattern.compile(" ([^=]*)=\"([^\"]*)\""); + /** + * Constructor + * + * @param parent container area (parent container) + * @param context layout context + * @param content image content + */ public ImageAreaLayout(ContainerArea parent, LayoutContext context, IImageContent content) { this.parent = parent; this.content = content; @@ -109,7 +121,7 @@ protected void initialize() throws BirtException { } private ILayout createAltTextLayout(int altTextType) { - ITextContent altTextContent = createAltText((IImageContent) content, altTextType); + ITextContent altTextContent = createAltText(content, altTextType); if (null == altTextContent) { return null; } @@ -197,15 +209,13 @@ public ConcreteImageLayout(LayoutContext context, ContainerArea parent, IImageCo } /** - * get intrinsic dimension of image in pixels. Now only support png, bmp, jpg, + * Get intrinsic dimension of image in pixels. Now only support png, bmp, jpg, * gif. * - * @return - * @throws IOException - * @throws MalformedURLException - * @throws BadElementException + * @param image image to get the dimension + * @return Return the image size as dimension */ - protected Dimension getIntrinsicDimension(IImageContent content, Image image) { + protected Dimension getIntrinsicDimension(Image image) { if (image != null) { return new Dimension((int) (image.getPlainWidth() * 1000 / resolutionX * 72), (int) (image.getPlainHeight() * 1000 / resolutionY * 72)); @@ -240,7 +250,7 @@ protected Dimension getSpecifiedDimension(IImageContent content, int pWidth, boo resolutionY = PropertyUtil.getImageDpi(content, imageFileDpiY, context.getDpi()); try { - intrinsic = getIntrinsicDimension(content, imageObject); + intrinsic = getIntrinsicDimension(imageObject); } catch (Exception e) { logger.log(Level.SEVERE, e.getLocalizedMessage()); } @@ -297,8 +307,9 @@ public void layout() throws BirtException { if ("pdf".equalsIgnoreCase(context.getFormat()) && reader.getType() == ImageReader.TYPE_FLASH_OBJECT) { innerTextInserted = true; innerText = createInnerTextLayout(); - innerText.content.getStyle().setProperty(IStyle.STYLE_TEXT_ALIGN, IStyle.CENTER_VALUE); - innerText.setVerticalAlign(IStyle.MIDDLE_VALUE); + innerText.content.getStyle().setProperty(StyleConstants.STYLE_TEXT_ALIGN, + CSSValueConstants.CENTER_VALUE); + innerText.setVerticalAlign(CSSValueConstants.MIDDLE_VALUE); innerText.setIgnoreReordering(true); // save current root status if (PropertyUtil.isInlineElement(image)) { @@ -619,10 +630,10 @@ private int[] getAbsoluteArea(int[] area, IImageArea imageArea) { // the image map of SVG chart is in Point. int imageX = imageArea.getX(); int imageY = imageArea.getY(); - result[0] = imageX + (int) (area[0] * 1000); - result[2] = (int) (area[2] * 1000); - result[1] = imageY + (int) (area[1] * 1000); - result[3] = (int) (area[3] * 1000); + result[0] = imageX + (area[0] * 1000); + result[2] = (area[2] * 1000); + result[1] = imageY + (area[1] * 1000); + result[3] = (area[3] * 1000); } else { for (int i = 0; i < 4;) { area[i] = getTranslatedLengthX(area[i]); diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/impl/TextAreaLayout.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/impl/TextAreaLayout.java index cd7c935c780..9b685002856 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/impl/TextAreaLayout.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/impl/TextAreaLayout.java @@ -24,16 +24,25 @@ import org.eclipse.birt.report.engine.content.IContent; import org.eclipse.birt.report.engine.content.IStyle; import org.eclipse.birt.report.engine.content.ITextContent; +import org.eclipse.birt.report.engine.css.engine.StyleConstants; +import org.eclipse.birt.report.engine.css.engine.value.css.CSSValueConstants; import org.eclipse.birt.report.engine.layout.pdf.font.FontInfo; import org.eclipse.birt.report.engine.layout.pdf.util.PropertyUtil; import org.eclipse.birt.report.engine.nLayout.LayoutContext; import org.eclipse.birt.report.engine.nLayout.area.ILayout; +import org.eclipse.birt.report.engine.nLayout.area.style.AreaConstants; import org.eclipse.birt.report.engine.nLayout.area.style.TextStyle; import org.w3c.dom.css.CSSValue; import com.ibm.icu.text.ArabicShaping; import com.ibm.icu.text.ArabicShapingException; +/** + * Implementation of the text area layout + * + * @since 3.3 + * + */ public class TextAreaLayout implements ILayout { protected static Logger logger = Logger.getLogger(TextAreaLayout.class.getName()); /** @@ -46,7 +55,7 @@ public class TextAreaLayout implements ILayout { private ITextContent textContent = null; - private static HashSet splitChar = new HashSet(); + private static HashSet splitChar = new HashSet(); private ArrayList listenerList = null; @@ -62,6 +71,13 @@ public class TextAreaLayout implements ILayout { splitChar.add(Character.valueOf('\n')); } + /** + * Constructor + * + * @param parent parent + * @param context layout context + * @param content content + */ public TextAreaLayout(ContainerArea parent, LayoutContext context, IContent content) { parentLM = (InlineStackingArea) parent; ITextContent textContent = (ITextContent) content; @@ -102,6 +118,11 @@ protected LineArea getLineParent() { } while (true); } + /** + * Add listener + * + * @param listener text listener + */ public void addListener(ITextListener listener) { if (listenerList == null) { listenerList = new ArrayList<>(); @@ -109,31 +130,41 @@ public void addListener(ITextListener listener) { listenerList.add(listener); } + /** + * Built the text style + * + * @param content content + * @param fontInfo font info + * @return Return the created text style + */ public static TextStyle buildTextStyle(IContent content, FontInfo fontInfo) { IStyle style = content.getComputedStyle(); TextStyle textStyle = new TextStyle(fontInfo); - CSSValue direction = style.getProperty(IStyle.STYLE_DIRECTION); - if (IStyle.RTL_VALUE.equals(direction)) { - textStyle.setDirection(TextStyle.DIRECTION_RTL); + CSSValue direction = style.getProperty(StyleConstants.STYLE_DIRECTION); + if (CSSValueConstants.RTL_VALUE.equals(direction)) { + textStyle.setDirection(AreaConstants.DIRECTION_RTL); } - textStyle.setFontSize(PropertyUtil.getDimensionValue(style.getProperty(IStyle.STYLE_FONT_SIZE))); - textStyle.setLetterSpacing(PropertyUtil.getDimensionValue(style.getProperty(IStyle.STYLE_LETTER_SPACING))); - textStyle.setWordSpacing(PropertyUtil.getDimensionValue(style.getProperty(IStyle.STYLE_WORD_SPACING))); - textStyle.setLineThrough(style.getProperty(IStyle.STYLE_TEXT_LINETHROUGH) == IStyle.LINE_THROUGH_VALUE); - textStyle.setOverLine(style.getProperty(IStyle.STYLE_TEXT_OVERLINE) == IStyle.OVERLINE_VALUE); - CSSValue underLine = style.getProperty(IStyle.STYLE_TEXT_UNDERLINE); - if (underLine == IStyle.UNDERLINE_VALUE) { + textStyle.setFontSize(PropertyUtil.getDimensionValue(style.getProperty(StyleConstants.STYLE_FONT_SIZE))); + textStyle.setLetterSpacing( + PropertyUtil.getDimensionValue(style.getProperty(StyleConstants.STYLE_LETTER_SPACING))); + textStyle.setWordSpacing(PropertyUtil.getDimensionValue(style.getProperty(StyleConstants.STYLE_WORD_SPACING))); + textStyle.setLineThrough( + style.getProperty(StyleConstants.STYLE_TEXT_LINETHROUGH) == CSSValueConstants.LINE_THROUGH_VALUE); + textStyle + .setOverLine(style.getProperty(StyleConstants.STYLE_TEXT_OVERLINE) == CSSValueConstants.OVERLINE_VALUE); + CSSValue underLine = style.getProperty(StyleConstants.STYLE_TEXT_UNDERLINE); + if (underLine == CSSValueConstants.UNDERLINE_VALUE) { textStyle.setUnderLine(true); } - textStyle.setAlign(style.getProperty(IStyle.STYLE_TEXT_ALIGN)); + textStyle.setAlign(style.getProperty(StyleConstants.STYLE_TEXT_ALIGN)); IStyle s = content.getStyle(); - Color color = PropertyUtil.getColor(s.getProperty(IStyle.STYLE_COLOR)); + Color color = PropertyUtil.getColor(s.getProperty(StyleConstants.STYLE_COLOR)); if (color != null) { textStyle.setColor(color); } else if (content.getHyperlinkAction() != null) { textStyle.setColor(Color.BLUE); } else { - textStyle.setColor(PropertyUtil.getColor(style.getProperty(IStyle.STYLE_COLOR))); + textStyle.setColor(PropertyUtil.getColor(style.getProperty(StyleConstants.STYLE_COLOR))); } if (content.getHyperlinkAction() != null) { textStyle.setHasHyperlink(true); @@ -169,6 +200,12 @@ protected boolean checkAvailableSpace() { return false; } + /** + * Add text area + * + * @param textArea text area + * @throws BirtException + */ public void addTextArea(TextArea textArea) throws BirtException { parentLM.add(textArea); textArea.setParent(parentLM); @@ -177,13 +214,16 @@ public void addTextArea(TextArea textArea) throws BirtException { if (listenerList != null) { for (Iterator i = listenerList.iterator(); i.hasNext();) { ITextListener listener = i.next(); - listener.onAddEvent((TextArea) textArea); + listener.onAddEvent(textArea); } } } /** - * true if succeed to new a line. + * Set new line, true if succeed to new a line. + * + * @param endParagraph end paragraph + * @throws BirtException */ public void newLine(boolean endParagraph) throws BirtException { parentLM.endLine(endParagraph); @@ -195,10 +235,20 @@ public void newLine(boolean endParagraph) throws BirtException { } } + /** + * Get the free space + * + * @return Return the free space + */ public int getFreeSpace() { return parentLM.getCurrentMaxContentWidth(); } + /** + * Transform the text content + * + * @param textContent text content + */ public void transform(ITextContent textContent) { String transformType = textContent.getComputedStyle().getTextTransform(); if (transformType.equalsIgnoreCase("uppercase")) //$NON-NLS-1$ @@ -236,6 +286,9 @@ private String capitalize(String text) { return new String(array); } + /** + * Add listener to the end of the text area + */ public void close() { if (listenerList != null) { for (Iterator i = listenerList.iterator(); i.hasNext();) { @@ -245,6 +298,9 @@ public void close() { } } + /** + * Initialize method + */ public void initialize() { } diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/style/TextStyle.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/style/TextStyle.java index a3fa72b070d..eaf16a61c03 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/style/TextStyle.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/style/TextStyle.java @@ -16,10 +16,16 @@ import java.awt.Color; -import org.eclipse.birt.report.engine.content.IStyle; +import org.eclipse.birt.report.engine.css.engine.value.css.CSSValueConstants; import org.eclipse.birt.report.engine.layout.pdf.font.FontInfo; import org.w3c.dom.css.CSSValue; +/** + * Class to implement the text style + * + * @since 3.3 + * + */ public class TextStyle extends AreaConstants { protected int fontSize = 9000; @@ -31,9 +37,23 @@ public class TextStyle extends AreaConstants { protected boolean hasHyperlink = false; protected int direction = 0; protected Color color = Color.BLACK; - protected CSSValue align = IStyle.LEFT_VALUE; + protected CSSValue align = CSSValueConstants.LEFT_VALUE; protected FontInfo fontInfo = null; + /** + * Constructor 1 + * + * @param fontInfo font info + * @param color text color + * @param align text alignment + * @param fontSize font size + * @param letterSpacing letter spacing + * @param wordSpacing word spacing + * @param underLine text is underlined + * @param lineThrough test use line through + * @param overLine text is overlined + * @param direction text direction + */ public TextStyle(FontInfo fontInfo, Color color, CSSValue align, int fontSize, int letterSpacing, int wordSpacing, boolean underLine, boolean lineThrough, boolean overLine, int direction) { this.fontSize = fontSize; @@ -48,6 +68,11 @@ public TextStyle(FontInfo fontInfo, Color color, CSSValue align, int fontSize, i this.direction = direction; } + /** + * Constructor 2 + * + * @param style text style + */ public TextStyle(TextStyle style) { this.fontSize = style.fontSize; this.color = style.color; @@ -62,98 +87,218 @@ public TextStyle(TextStyle style) { this.hasHyperlink = style.isHasHyperlink(); } + /** + * Constructor 3 + * + * @param fontInfo font info object + */ public TextStyle(FontInfo fontInfo) { this.fontInfo = fontInfo; } + /** + * Get the text alignment + * + * @return Return the text alignment + */ public CSSValue getAlign() { return align; } + /** + * Set the text alignment + * + * @param align text alignment + */ public void setAlign(CSSValue align) { this.align = align; } + /** + * Set the text color + * + * @param color color of the text + */ public void setColor(Color color) { this.color = color; } + /** + * Get the text color + * + * @return Return the text color + */ public Color getColor() { return color; } + /** + * Set the font size + * + * @param fontSize font size + */ public void setFontSize(int fontSize) { this.fontSize = fontSize; } + /** + * Set the font info + * + * @param fontInfo font info + */ public void setFontInfo(FontInfo fontInfo) { this.fontInfo = fontInfo; } + /** + * Set the letter spacing + * + * @param letterSpacing letter spacing + */ public void setLetterSpacing(int letterSpacing) { this.letterSpacing = letterSpacing; } + /** + * Set the word spacing + * + * @param wordSpacing word spacing + */ public void setWordSpacing(int wordSpacing) { this.wordSpacing = wordSpacing; } + /** + * Set the text underline + * + * @param underLine text is underlined + */ public void setUnderLine(boolean underLine) { this.underLine = underLine; } + /** + * Set the line through + * + * @param lineThrough text is lined through + */ public void setLineThrough(boolean lineThrough) { this.lineThrough = lineThrough; } + /** + * Set the overline + * + * @param overLine the text is overlined + */ public void setOverLine(boolean overLine) { this.overLine = overLine; } + /** + * Set the text direction + * + * @param direction text direction + */ public void setDirection(int direction) { this.direction = direction; } + /** + * Check if the text direction is RtL + * + * @return Return the check result of RtL + */ public boolean isRtl() { return direction == DIRECTION_RTL; } + /** + * Get the font size + * + * @return Return the font size + */ public int getFontSize() { return fontSize; } + /** + * Get the font info + * + * @return Return the font info + */ public FontInfo getFontInfo() { return fontInfo; } + /** + * Get the letter spacing + * + * @return Return the letter spacing + */ public int getLetterSpacing() { return letterSpacing; } + /** + * Get the word spacing + * + * @return Return the word spacing + */ public int getWordSpacing() { return wordSpacing; } + /** + * Check if the text is underlined + * + * @return Return the check result if the text is underlined + */ public boolean isUnderline() { return underLine; } + /** + * Check if the text use line-through + * + * @return Return the check result if the text is line-through + */ public boolean isLinethrough() { return lineThrough; } + /** + * Check if the text is overlined + * + * @return Return the check result if the text is overlined + */ public boolean isOverline() { return overLine; } + /** + * Get the text direction + * + * @return Return the text direction + */ public int getDirection() { return direction; } + /** + * Check if the text has a hyperlink + * + * @return Return the check if the text has a hyperlink + */ public boolean isHasHyperlink() { return hasHyperlink; } + /** + * Set a boolean flag to mark that the text use a hyperlink + * + * @param hasHyperlink the text use a hyperlink + */ public void setHasHyperlink(boolean hasHyperlink) { this.hasHyperlink = hasHyperlink; } diff --git a/viewer/org.eclipse.birt.axis.overlay/src/org/eclipse/birt/axis/utility/UTF8Encoder.java b/viewer/org.eclipse.birt.axis.overlay/src/org/eclipse/birt/axis/utility/UTF8Encoder.java index 09a434aacf7..6b3bb003e32 100644 --- a/viewer/org.eclipse.birt.axis.overlay/src/org/eclipse/birt/axis/utility/UTF8Encoder.java +++ b/viewer/org.eclipse.birt.axis.overlay/src/org/eclipse/birt/axis/utility/UTF8Encoder.java @@ -12,13 +12,13 @@ *******************************************************************************/ /* * Copyright 2001-2004 The Apache Software Foundation. - * + * * Licensed 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. @@ -40,7 +40,7 @@ *
* This is a mod version over original axis implementation to handle the * Unicode Extension-B cases. May need update when Axis changes. - * + * * @author Jens Schumann * @see encoding.org * @see UTF 8 explained @@ -48,9 +48,9 @@ public class UTF8Encoder extends AbstractXMLEncoder { /** - * gets the encoding supported by this encoder - * - * @return string + * Gets the encoding supported by this encoder + * + * @return Return the encoding of this encoder */ @Override public String getEncoding() { @@ -59,7 +59,7 @@ public String getEncoding() { /** * write the encoded version of a given string - * + * * @param writer writer to write this string to * @param xmlString string to be encoded */