Browse Source

Addressed Findbug and Checkstyle issues


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_RoundedCorners@1396073 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-2_0
Peter Hancock 11 years ago
parent
commit
b9e74f1261

+ 1
- 1
findbugs-exclude.xml View File

@@ -4424,7 +4424,7 @@
<Bug pattern="SF_SWITCH_FALLTHROUGH"/>
</Match>
<Match>
<Class name="org.apache.fop.render.java2d.Java2DBorderPainter"/>
<Class name="org.apache.fop.render.java2d.Java2DGraphicsPainter"/>
<Method name="drawLine"/>
<Bug pattern="SF_SWITCH_FALLTHROUGH"/>
</Match>

+ 0
- 1
src/java/org/apache/fop/afp/AFPResourceManager.java View File

@@ -242,7 +242,6 @@ public class AFPResourceManager {
private void includeObject(AbstractNamedAFPObject namedObj, AFPDataObjectInfo dataObjectInfo) {

// create the include object
AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
String objectName = namedObj.getName();

AbstractCachedObject cachedObject;

+ 1
- 1
src/java/org/apache/fop/fo/Constants.java View File

@@ -806,7 +806,7 @@ public interface Constants {
* numbers.
*/
int PR_X_NUMBER_CONVERSION_FEATURES = 285;
/** Scope for table header */
int PR_X_HEADER_COLUMN = 286;


+ 0
- 1
src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java View File

@@ -38,7 +38,6 @@ import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.expr.PropertyException;
import org.apache.fop.util.CompareUtil;

/**
* Stores all common border and padding properties.

+ 1
- 1
src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java View File

@@ -344,7 +344,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
* @param bpsStart the border traits associated with start edge
* @param bpsEnd the border traits associated with end edge
* @param level of bidirectional embedding
* @param innerBackgroundColor the background color of the block
* @param innerBackgroundColor the background color of the block
*/
protected void drawBorders( // CSOK: ParameterNumber
float startx, float starty, float width, float height,

+ 2
- 3
src/java/org/apache/fop/render/afp/AFPDocumentHandler.java View File

@@ -27,6 +27,7 @@ import java.net.URI;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.apache.fop.afp.AFPDitheredRectanglePainter;
@@ -93,8 +94,6 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler

private int roundedCornerCount = 0;

/** Medium Map referenced on previous page **/
private String lastMediumMap;
private static enum Location {
ELSEWHERE, IN_DOCUMENT_HEADER, FOLLOWING_PAGE_SEQUENCE, IN_PAGE_HEADER
}
@@ -419,7 +418,7 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
// Make a unique id
StringBuffer idBuilder = new StringBuffer("RC");

String tmp = Integer.toHexString(roundedCornerCount).toUpperCase();
String tmp = Integer.toHexString(roundedCornerCount).toUpperCase(Locale.ENGLISH);
if (tmp.length() > 6) {
//Will never happen
//log.error("Rounded corners cache capacity exceeded");

+ 5
- 21
src/java/org/apache/fop/render/afp/AFPPainter.java View File

@@ -736,16 +736,8 @@ public class AFPPainter extends AbstractIFPainter<AFPDocumentHandler> {

GeneralPath cut = new GeneralPath();
cut.moveTo(0, 0);
float borderWidthRatio = ((float) beforeWidth) / startWidth;
if (beforeWidth * startRadius > startWidth * beforeRadius) {
cut.lineTo(startRadius, borderWidthRatio * startRadius);
cut.lineTo(startRadius, 0);

} else {
cut.lineTo(startRadius, borderWidthRatio * startRadius);
cut.lineTo(startRadius, 0);
}

cut.lineTo(startRadius, ((float) startRadius * beforeWidth) / startWidth);
cut.lineTo(startRadius, 0);
clip.intersect(new Area(cut));
clip.transform(transform);
return clip;
@@ -776,16 +768,8 @@ public class AFPPainter extends AbstractIFPainter<AFPDocumentHandler> {

GeneralPath cut = new GeneralPath();
cut.moveTo(0, 0);
float borderWidthRatio = ((float) beforeWidth) / startWidth;
if (beforeWidth * startRadius > startWidth * beforeRadius) {
cut.lineTo(startRadius, borderWidthRatio * startRadius);
cut.lineTo(startRadius, 0);

} else {
cut.lineTo(startRadius, borderWidthRatio * startRadius);
cut.lineTo(startRadius, 0);
}

cut.lineTo(startRadius, ((float) startRadius * beforeWidth) / startWidth);
cut.lineTo(startRadius, 0);
clip.subtract(new Area(cut));
clip.transform(transform);
return clip;
@@ -860,7 +844,7 @@ public class AFPPainter extends AbstractIFPainter<AFPDocumentHandler> {

hints.put(ImageHandlerUtil.CONVERSION_MODE, ImageHandlerUtil.CONVERSION_MODE_BITMAP);
hints.put("TARGET_RESOLUTION",
new Integer(context.getPaintingState().getResolution()));
Integer.valueOf(context.getPaintingState().getResolution()));


try {

+ 1
- 1
src/java/org/apache/fop/render/intermediate/BezierCurvePainter.java View File

@@ -34,4 +34,4 @@ public interface BezierCurvePainter {
* @throws IOException if an I/O error occurs
*/
void cubicBezierTo(int p1x, int p1y, int p2x, int p2y, int p3x, int p3y) throws IOException;
}
}

+ 32
- 11
src/java/org/apache/fop/render/intermediate/BorderPainter.java View File

@@ -33,12 +33,31 @@ public class BorderPainter {
/** TODO remove before integration*/
public static final String ROUNDED_CORNERS = "fop.round-corners";

/** TODO Use a class to model border instead of an array
* convention index of top, bottom, right and left borders */
protected static final int TOP = 0, RIGHT = 1, BOTTOM = 2, LEFT = 3;
/** TODO Use a class to model border corners instead of an array
convention index of top-left, top-right, bottom-right and bottom-left border corners*/
protected static final int TOP_LEFT = 0, TOP_RIGHT = 1, BOTTOM_RIGHT = 2, BOTTOM_LEFT = 3;
// TODO Use a class to model border instead of an array
/** Convention index of before top */
protected static final int TOP = 0;

/** Convention index of right border */
protected static final int RIGHT = 1;

/** Convention index of bottom border */
protected static final int BOTTOM = 2;

/** Convention index of left border */
protected static final int LEFT = 3;

// TODO Use a class to model border corners instead of an array
/** Convention index of top-left border corners */
protected static final int TOP_LEFT = 0;

/** Convention index of top-right-end border corners */
protected static final int TOP_RIGHT = 1;

/** Convention index of bottom-right border corners */
protected static final int BOTTOM_RIGHT = 2;

/** Convention index of bottom-left border corners */
protected static final int BOTTOM_LEFT = 3;

private final GraphicsPainter graphicsPainter;

@@ -227,7 +246,7 @@ public class BorderPainter {
int outerx = startx - clipw[LEFT];
int clipx = outerx + clipw[LEFT];
int innerx = outerx + bw[LEFT];
saveGraphicsState();

moveTo(clipx, ey1);
@@ -281,10 +300,12 @@ public class BorderPainter {
final int width = borderRect.width - start.getClippedWidth() - end.getClippedWidth();
final int height = borderRect.height - before.getClippedWidth() - after.getClippedWidth();
//Determine scale factor if any adjacent elliptic corners overlap
double cornerCorrectionFactor = calculateCornerScaleCorrection(width, height, before, after, start, end);
double cornerCorrectionFactor = calculateCornerScaleCorrection(width, height, before, after, start,
end);
drawBorderSegment(start, before, end, 0, width, startx, starty, cornerCorrectionFactor);
drawBorderSegment(before, end, after, 1, height, startx + width, starty, cornerCorrectionFactor);
drawBorderSegment(end, after, start, 2, width, startx + width, starty + height, cornerCorrectionFactor);
drawBorderSegment(end, after, start, 2, width, startx + width, starty + height,
cornerCorrectionFactor);
drawBorderSegment(after, start, before, 3, height, startx, starty + height, cornerCorrectionFactor);
}

@@ -637,10 +658,10 @@ public class BorderPainter {
private static final Corner SQUARE = new Corner(0, 0, null, 0, 0, 0, 0);

/** The radius of the elliptic corner in the x direction */
protected final int radiusX;
private final int radiusX;

/** The radius of the elliptic corner in the y direction */
protected final int radiusY;
private final int radiusY;

/** The start and end angles of the corner ellipse */
private final CornerAngles angles;

+ 2
- 1
src/java/org/apache/fop/render/intermediate/IFRenderer.java View File

@@ -39,10 +39,11 @@ import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;

import org.apache.batik.parser.AWTTransformProducer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.apache.batik.parser.AWTTransformProducer;

import org.apache.xmlgraphics.xmp.Metadata;
import org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter;
import org.apache.xmlgraphics.xmp.schemas.DublinCoreSchema;

+ 1
- 2
src/java/org/apache/fop/render/java2d/Java2DGraphicsPainter.java View File

@@ -329,5 +329,4 @@ class Java2DGraphicsPainter implements GraphicsPainter {
this.painter.restoreGraphicsState();
this.currentPath = null;
}

}
}

+ 3
- 7
src/java/org/apache/fop/render/pdf/PDFGraphicsPainter.java View File

@@ -59,6 +59,7 @@ public class PDFGraphicsPainter implements GraphicsPainter, BezierCurvePainter {
boolean startOrBefore, int style, Color col) {
float w = x2 - x1;
float h = y2 - y1;
float colFactor;
switch (style) {
case Constants.EN_DASHED:
generator.setColor(col);
@@ -133,8 +134,7 @@ public class PDFGraphicsPainter implements GraphicsPainter, BezierCurvePainter {
break;
case Constants.EN_GROOVE:
case Constants.EN_RIDGE:
{
float colFactor = (style == Constants.EN_GROOVE ? 0.4f : -0.4f);
colFactor = (style == Constants.EN_GROOVE ? 0.4f : -0.4f);
generator.setSolidLine();
if (horz) {
Color uppercol = ColorUtil.lightenColor(col, -colFactor);
@@ -162,11 +162,9 @@ public class PDFGraphicsPainter implements GraphicsPainter, BezierCurvePainter {
.strokeLine(xm1 + w3 + w3, y1, xm1 + w3 + w3, y2);
}
break;
}
case Constants.EN_INSET:
case Constants.EN_OUTSET:
{
float colFactor = (style == Constants.EN_OUTSET ? 0.4f : -0.4f);
colFactor = (style == Constants.EN_OUTSET ? 0.4f : -0.4f);
generator.setSolidLine();
Color c = col;
if (horz) {
@@ -183,7 +181,6 @@ public class PDFGraphicsPainter implements GraphicsPainter, BezierCurvePainter {
.strokeLine(xm1, y1, xm1, y2);
}
break;
}
case Constants.EN_HIDDEN:
break;
default:
@@ -382,7 +379,6 @@ public class PDFGraphicsPainter implements GraphicsPainter, BezierCurvePainter {
String xS = format(xStart);
String xE = format(xEnd);
String yS = format(yStart);
String yE = format(yEnd);
if (style == RuleStyle.GROOVE) {
addLine("m", xS, yS)
.addLine("l", xE, yS)

+ 4
- 5
src/java/org/apache/fop/render/ps/PSGraphicsPainter.java View File

@@ -31,7 +31,6 @@ import org.apache.xmlgraphics.ps.PSGenerator;
import org.apache.fop.fo.Constants;
import org.apache.fop.render.intermediate.ArcToBezierCurveTransformer;
import org.apache.fop.render.intermediate.BezierCurvePainter;
import org.apache.fop.render.intermediate.BorderPainter;
import org.apache.fop.render.intermediate.GraphicsPainter;
import org.apache.fop.traits.RuleStyle;
import org.apache.fop.util.ColorUtil;
@@ -89,7 +88,7 @@ public class PSGraphicsPainter implements GraphicsPainter, BezierCurvePainter {
gen.useColor(col);
if (horz) {
float unit = Math.abs(2 * h);
int rep = (int)(w / unit);
int rep = (int) (w / unit);
if (rep % 2 == 0) {
rep++;
}
@@ -101,7 +100,7 @@ public class PSGraphicsPainter implements GraphicsPainter, BezierCurvePainter {
drawLine(gen, x1, ym, x2, ym);
} else {
float unit = Math.abs(2 * w);
int rep = (int)(h / unit);
int rep = (int) (h / unit);
if (rep % 2 == 0) {
rep++;
}
@@ -118,7 +117,7 @@ public class PSGraphicsPainter implements GraphicsPainter, BezierCurvePainter {
gen.useLineCap(1); //Rounded!
if (horz) {
float unit = Math.abs(2 * h);
int rep = (int)(w / unit);
int rep = (int) (w / unit);
if (rep % 2 == 0) {
rep++;
}
@@ -129,7 +128,7 @@ public class PSGraphicsPainter implements GraphicsPainter, BezierCurvePainter {
drawLine(gen, x1, ym, x2, ym);
} else {
float unit = Math.abs(2 * w);
int rep = (int)(h / unit);
int rep = (int) (h / unit);
if (rep % 2 == 0) {
rep++;
}

+ 4
- 4
src/java/org/apache/fop/traits/BorderProps.java View File

@@ -34,7 +34,7 @@ import org.apache.fop.util.ColorUtil;
*/
public class BorderProps implements Serializable {

private static final long serialVersionUID = 7053576586478548795L;
private static final long serialVersionUID = 8022237892391068187L;

public enum Mode {
SEPARATE("separate") {
@@ -155,7 +155,7 @@ public class BorderProps implements Serializable {
return true;
} else {
if (obj instanceof BorderProps) {
BorderProps other = (BorderProps)obj;
BorderProps other = (BorderProps) obj;
return (style == other.style)
&& org.apache.xmlgraphics.java2d.color.ColorUtil.isSameColor(
color, other.color)
@@ -203,7 +203,7 @@ public class BorderProps implements Serializable {
return sbuf.toString();
}

private static class BorderPropsDeserializer {
private static final class BorderPropsDeserializer {

private static final BorderPropsDeserializer INSTANCE = new BorderPropsDeserializer();

@@ -223,7 +223,7 @@ public class BorderProps implements Serializable {
m.find();
int width = Integer.parseInt(m.group());
Mode mode = Mode.SEPARATE;
if ( m.find()) {
if (m.find()) {
String ms = m.group();
if (Mode.COLLAPSE_INNER.value.equalsIgnoreCase(ms)) {
mode = Mode.COLLAPSE_INNER;

Loading…
Cancel
Save