Browse Source

Removed a Cast

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

+ 26
- 13
test/java/org/apache/fop/render/intermediate/BorderPainterTestCase.java View File



protected final BorderPainter sut; protected final BorderPainter sut;


private final T thisInstance;

private final BorderPropsBuilder<T> beforeBuilder; private final BorderPropsBuilder<T> beforeBuilder;


private final BorderPropsBuilder<T> afterBuilder; private final BorderPropsBuilder<T> afterBuilder;
private final BorderPropsBuilder<T> endBuilder; private final BorderPropsBuilder<T> endBuilder;


public BorderPainterTester(int xOrigin, int yOrigin, int width, int height) { public BorderPainterTester(int xOrigin, int yOrigin, int width, int height) {
this.thisInstance = (T) this;
if (width <= 0 || height <= 0) { if (width <= 0 || height <= 0) {
throw new IllegalArgumentException("Cannot test degenerate borders"); throw new IllegalArgumentException("Cannot test degenerate borders");
} }
beforeBuilder = new BorderPropsBuilder<T>(this.thisInstance);
afterBuilder = new BorderPropsBuilder<T>(this.thisInstance);
startBuilder = new BorderPropsBuilder<T>(this.thisInstance);
endBuilder = new BorderPropsBuilder<T>(this.thisInstance);
beforeBuilder = new BorderPropsBuilder<T>(getThis());
afterBuilder = new BorderPropsBuilder<T>(getThis());
startBuilder = new BorderPropsBuilder<T>(getThis());
endBuilder = new BorderPropsBuilder<T>(getThis());
this.borderExtent = new Rectangle(xOrigin, yOrigin, width, height); this.borderExtent = new Rectangle(xOrigin, yOrigin, width, height);
this.graphicsPainter = mock(GraphicsPainter.class); this.graphicsPainter = mock(GraphicsPainter.class);
this.sut = new BorderPainter(graphicsPainter); this.sut = new BorderPainter(graphicsPainter);
} }


protected abstract T getThis();

public BorderPropsBuilder<T> beforeBorder() { public BorderPropsBuilder<T> beforeBorder() {
return beforeBuilder; return beforeBuilder;
} }
endBuilder.setWidth(width); endBuilder.setWidth(width);
afterBuilder.setWidth(width); afterBuilder.setWidth(width);
startBuilder.setWidth(width); startBuilder.setWidth(width);
return thisInstance;
return getThis();
} }


public T setCornerRadii(int radius) { public T setCornerRadii(int radius) {
setEndBefore(xRadius, yRadius); setEndBefore(xRadius, yRadius);
setEndAfter(xRadius, yRadius); setEndAfter(xRadius, yRadius);
setStartAfter(xRadius, yRadius); setStartAfter(xRadius, yRadius);
return thisInstance;
return getThis();
} }


public T setStartBefore(int xRadius, int yRadius) { public T setStartBefore(int xRadius, int yRadius) {
startBuilder.setRadiusStart(xRadius); startBuilder.setRadiusStart(xRadius);
beforeBuilder.setRadiusStart(yRadius); beforeBuilder.setRadiusStart(yRadius);
return thisInstance;
return getThis();
} }


public T setEndBefore(int xRadius, int yRadius) { public T setEndBefore(int xRadius, int yRadius) {
endBuilder.setRadiusStart(xRadius); endBuilder.setRadiusStart(xRadius);
beforeBuilder.setRadiusEnd(yRadius); beforeBuilder.setRadiusEnd(yRadius);
return thisInstance;
return getThis();
} }


public T setEndAfter(int xRadius, int yRadius) { public T setEndAfter(int xRadius, int yRadius) {
endBuilder.setRadiusEnd(xRadius); endBuilder.setRadiusEnd(xRadius);
afterBuilder.setRadiusEnd(yRadius); afterBuilder.setRadiusEnd(yRadius);
return thisInstance;
return getThis();
} }


public T setStartAfter(int xRadius, int yRadius) { public T setStartAfter(int xRadius, int yRadius) {
startBuilder.setRadiusEnd(xRadius); startBuilder.setRadiusEnd(xRadius);
afterBuilder.setRadiusStart(yRadius); afterBuilder.setRadiusStart(yRadius);
return thisInstance;
return getThis();
} }


public final void test() throws IOException { public final void test() throws IOException {
verify(graphicsPainter, times(numBorders)).closePath(); verify(graphicsPainter, times(numBorders)).closePath();
verify(graphicsPainter, times(numBorders)).restoreGraphicsState(); verify(graphicsPainter, times(numBorders)).restoreGraphicsState();
verify(graphicsPainter, times(numBorders)).clip(); verify(graphicsPainter, times(numBorders)).clip();
}


@Override
protected DrawRectangularBordersTester getThis() {
return this;
} }
} }


return yWidth > yRadius ? yWidth : xWidth > 0 ? Math.max(xRadius, xWidth) : 0; return yWidth > yRadius ? yWidth : xWidth > 0 ? Math.max(xRadius, xWidth) : 0;
} }


@Override
protected DrawRoundedBordersTester getThis() {
return this;
}

} }


private static final class ClipBackgroundTester extends BorderPainterTester<ClipBackgroundTester> { private static final class ClipBackgroundTester extends BorderPainterTester<ClipBackgroundTester> {
} }
} }
} }

@Override
protected ClipBackgroundTester getThis() {
return this;
}
} }





Loading…
Cancel
Save