Skip to content

Commit

Permalink
Fixing different eclipse warnings (missing comments, unused parameters,
Browse files Browse the repository at this point in the history
static constants access) (#1486)
  • Loading branch information
speckyspooky committed Nov 11, 2023
1 parent 6542247 commit 9bae6bf
Show file tree
Hide file tree
Showing 22 changed files with 625 additions and 101 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import java.awt.Color;
import java.io.IOException;
import java.util.Map;

import org.eclipse.birt.report.engine.css.engine.value.FloatValue;
import org.eclipse.birt.report.engine.emitter.odp.OdpContext;
Expand Down Expand Up @@ -130,7 +129,7 @@ protected void drawBackgroundImage(float x, float y, float width, float height,

@Override
protected void drawImage(String imageId, byte[] imageData, String extension, float imageX, float imageY,
float height, float width, String helpText, Map params) throws Exception {
float height, float width, String helpText) throws Exception {

if (extension == null && imageId != null) {
extension = "." + ImageManager.getImageExtension(imageId); //$NON-NLS-1$
Expand All @@ -143,7 +142,7 @@ protected void drawImage(String imageId, byte[] imageData, String extension, flo

@Override
protected void drawImage(String imageId, String extension, float imageX, float imageY, float height, float width,
String helpText, Map params) throws Exception {
String helpText) throws Exception {
if (imageId == null) {
return;
}
Expand Down
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 @@ -21,7 +21,6 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -212,10 +211,10 @@ protected void drawBackgroundImage(float x, float y, float width, float height,

@Override
protected void drawImage(String imageId, byte[] imageData, String extension, float imageX, float imageY,
float height, float width, String helpText, Map params) throws Exception {
float height, float width, String helpText) throws Exception {
// Flash
if (FlashFile.isFlash(null, null, extension)) {
embedFlash(null, imageData, imageX, imageY, height, width, helpText, params);
embedFlash(null, imageData, imageX, imageY, height, width, helpText);
return;
}

Expand All @@ -233,7 +232,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 All @@ -260,7 +259,7 @@ protected void drawImage(String imageId, byte[] imageData, String extension, flo
@Deprecated
@Override
protected void drawImage(String uri, String extension, float imageX, float imageY, float height, float width,
String helpText, Map params) throws Exception {
String helpText) throws Exception {
}

/**
Expand Down Expand Up @@ -650,7 +649,7 @@ protected void drawImage(Image image, float imageX, float imageY, float height,
}

protected void embedFlash(String flashPath, byte[] flashData, float x, float y, float height, float width,
String helpText, Map params) throws IOException {
String helpText) throws IOException {
y = transformY(y, height);
contentByte.saveState();
PdfFileSpecification fs = PdfFileSpecification.fileEmbedded(writer, flashPath, helpText, flashData);
Expand All @@ -663,13 +662,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 @@ -19,7 +19,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Map;

import org.eclipse.birt.report.engine.emitter.postscript.PostscriptWriter;
import org.eclipse.birt.report.engine.layout.emitter.AbstractPage;
Expand Down Expand Up @@ -100,14 +99,14 @@ protected void drawImage(String imageId, InputStream input, float imageX, float

@Override
protected void drawImage(String imageId, byte[] imageData, String extension, float imageX, float imageY,
float height, float width, String helpText, Map params) throws Exception {
float height, float width, String helpText) throws Exception {
InputStream input = new ByteArrayInputStream(imageData);
drawImage(imageId, input, imageX, imageY, height, width, helpText);
}

@Override
protected void drawImage(String uri, String extension, float imageX, float imageY, float height, float width,
String helpText, Map params) throws Exception {
String helpText) throws Exception {
if (uri == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Map;

import org.eclipse.birt.report.engine.emitter.ppt.PPTWriter;
import org.eclipse.birt.report.engine.emitter.ppt.util.PPTUtil.HyperlinkDef;
Expand Down Expand Up @@ -79,13 +78,13 @@ protected void drawBackgroundImage(float x, float y, float width, float height,

@Override
protected void drawImage(String imageId, byte[] imageData, String extension, float imageX, float imageY,
float height, float width, String helpText, Map params) throws Exception {
float height, float width, String helpText) throws Exception {
writer.drawImage(imageId, imageData, extension, imageX, imageY, height, width, helpText, link);
}

@Override
protected void drawImage(String uri, String extension, float imageX, float imageY, float height, float width,
String helpText, Map params) throws Exception {
String helpText) throws Exception {
if (uri == null) {
return;
}
Expand All @@ -95,7 +94,7 @@ protected void drawImage(String uri, String extension, float imageX, float image
while ((data = imageStream.read()) != -1) {
byteArrayOut.write(data);
}
drawImage(uri, byteArrayOut.toByteArray(), extension, imageX, imageY, height, width, helpText, params);
drawImage(uri, byteArrayOut.toByteArray(), extension, imageX, imageY, height, width, helpText);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import java.awt.Color;
import java.io.IOException;
import java.util.Map;

import org.eclipse.birt.report.engine.emitter.ppt.util.PPTUtil.HyperlinkDef;
import org.eclipse.birt.report.engine.emitter.pptx.util.PPTXUtil;
Expand Down Expand Up @@ -75,7 +74,7 @@ public void drawBackgroundImage(int x, int y, int width, int height, int imageWi

@Override
public void drawImage(String imageId, byte[] imageData, String extension, int imageX, int imageY, int height,
int width, String helpText, Map parameters) throws Exception {
int width, String helpText) throws Exception {
imageX = PPTXUtil.convertToEnums(imageX);
imageY = PPTXUtil.convertToEnums(imageY);
width = PPTXUtil.convertToEnums(width);
Expand All @@ -84,8 +83,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 {
public void drawImage(String uri, String extension, int imageX, int imageY, int height, int width, String helpText)
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 @@ -15,16 +15,27 @@
package org.eclipse.birt.report.engine.layout.emitter;

import java.awt.Color;
import java.util.Map;

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 @@ -64,20 +75,20 @@ public void drawBackgroundImage(int x, int y, int width, int height, int imageWi

@Override
public void drawImage(String imageId, byte[] imageData, String extension, int imageX, int imageY, int height,
int width, String helpText, Map params) throws Exception {
int width, String helpText) throws Exception {
drawImage(imageId, imageData, extension, convertToPoint(imageX), convertToPoint(imageY), convertToPoint(height),
convertToPoint(width), helpText, params);
convertToPoint(width), helpText);
}

/**
* @deprecated
*/
@Deprecated
@Override
public void drawImage(String uri, String extension, int imageX, int imageY, int height, int width, String helpText,
Map params) throws Exception {
public void drawImage(String uri, String extension, int imageX, int imageY, int height, int width, String helpText)
throws Exception {
drawImage(uri, extension, convertToPoint(imageX), convertToPoint(imageY), convertToPoint(height),
convertToPoint(width), helpText, params);
convertToPoint(width), helpText);
}

@Override
Expand Down Expand Up @@ -116,7 +127,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 All @@ -136,10 +147,10 @@ protected abstract void drawBackgroundImage(float x, float y, float width, float
throws Exception;

protected abstract void drawImage(String imageId, byte[] imageData, String extension, float imageX, float imageY,
float height, float width, String helpText, Map params) throws Exception;
float height, float width, String helpText) throws Exception;

protected abstract void drawImage(String uri, String extension, float imageX, float imageY, float height,
float width, String helpText, Map params) throws Exception;
float width, String helpText) throws Exception;

protected abstract void drawLine(float startX, float startY, float endX, float endY, float width, Color color,
int lineStyle);
Expand Down
Loading

0 comments on commit 9bae6bf

Please sign in to comment.