Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing different eclipse warnings (missing comments, unused parameters, static constants access) (#1486) #1495

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -42,6 +42,12 @@

import com.lowagie.text.pdf.PdfTemplate;

/**
* Class to create the PDF renderer
*
* @since 3.3
*
*/
public class PDFRender extends PageDeviceRender {

/**
Expand All @@ -57,6 +63,12 @@ public class PDFRender extends PageDeviceRender {

protected HashSet<String> bookmarks = new HashSet<>();

/**
* Constructor
*
* @param services emitter service
* @throws EngineException engine exception
*/
public PDFRender(IEmitterServices services) throws EngineException {
initialize(services);
}
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

/**
Expand All @@ -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<String> bookmarks) {
this.root = root;
Expand All @@ -68,6 +76,9 @@ public TOCNode getTOCRoot() {
return this.root;
}

/**
* Create the TOC of the PDF
*/
public void createTOC() {
createTOC(root, outline, bookmarks);
}
Expand All @@ -83,15 +94,15 @@ protected void createTOC(TOCNode tocNode, PdfOutline pol, Set<String> 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);
continue;
}
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) {
Expand All @@ -113,7 +124,7 @@ protected boolean isOutlineSizeOverflow() {
return counter > MAX_COUNT;
}

protected void countOutlineSize(long size) {
protected void countOutlineSize() {
counter++;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -167,4 +179,4 @@ protected float transformY(float y, float height, float containerHeight) {
return containerHeight - y - height;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();

/**
Expand Down Expand Up @@ -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,
wimjongman marked this conversation as resolved.
Show resolved Hide resolved
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
Expand All @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class FontHandler {

private FontMappingManager fontManager = null;

private Map fonts = new HashMap();
private Map<String, BaseFont> fonts = new HashMap<String, BaseFont>();

/**
* the characters which prefer to use the font of their previous character.
Expand All @@ -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;
Expand Down Expand Up @@ -132,18 +133,27 @@ 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;
}

/**
* 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.
*/
Expand All @@ -158,7 +168,7 @@ public boolean selectFont(char character) {
} else {
isFontChanged = true;
bf = candidateFont;
simulation = needSimulate(bf);
simulation = needSimulate();
}
return candidateFont.charExists(character);
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
Loading