git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1802793 13f79535-47bb-0310-9956-ffa450edef68tags/fop-2_3
lineDataInfo.setY2(lineDataInfo.getY1()); | lineDataInfo.setY2(lineDataInfo.getY1()); | ||||
int ex2 = Math.round(x2); | int ex2 = Math.round(x2); | ||||
int spaceWidth = (int) (BorderPainter.DASHED_BORDER_SPACE_RATIO * dashWidth); | int spaceWidth = (int) (BorderPainter.DASHED_BORDER_SPACE_RATIO * dashWidth); | ||||
while (lineDataInfo.getX2() <= ex2) { | |||||
while (lineDataInfo.getX2() <= ex2 && dashWidth > 0) { | |||||
dataStream.createLine(lineDataInfo); | dataStream.createLine(lineDataInfo); | ||||
lineDataInfo.setX1(lineDataInfo.getX2() + spaceWidth); | lineDataInfo.setX1(lineDataInfo.getX2() + spaceWidth); | ||||
lineDataInfo.setX2(lineDataInfo.getX1() + dashWidth); | lineDataInfo.setX2(lineDataInfo.getX1() + dashWidth); | ||||
lineDataInfo.setY2(lineDataInfo.getY1() + dashWidth); | lineDataInfo.setY2(lineDataInfo.getY1() + dashWidth); | ||||
int ey2 = Math.round(y2); | int ey2 = Math.round(y2); | ||||
int spaceWidth = (int) (BorderPainter.DASHED_BORDER_SPACE_RATIO * dashWidth); | int spaceWidth = (int) (BorderPainter.DASHED_BORDER_SPACE_RATIO * dashWidth); | ||||
while (lineDataInfo.getY2() <= ey2) { | |||||
while (lineDataInfo.getY2() <= ey2 && dashWidth > 0) { | |||||
dataStream.createLine(lineDataInfo); | dataStream.createLine(lineDataInfo); | ||||
lineDataInfo.setY1(lineDataInfo.getY2() + spaceWidth); | lineDataInfo.setY1(lineDataInfo.getY2() + spaceWidth); | ||||
lineDataInfo.setY2(lineDataInfo.getY1() + dashWidth); | lineDataInfo.setY2(lineDataInfo.getY1() + dashWidth); |
generator.setColor(col); | generator.setColor(col); | ||||
if (horz) { | if (horz) { | ||||
float dashedWidth = BorderPainter.dashWidthCalculator(w, h); | float dashedWidth = BorderPainter.dashWidthCalculator(w, h); | ||||
float ym = y1 + (h / 2); | |||||
generator.setDashLine(dashedWidth, dashedWidth * BorderPainter.DASHED_BORDER_SPACE_RATIO) | |||||
.setLineWidth(h) | |||||
.strokeLine(x1, ym, x2, ym); | |||||
if (dashedWidth != 0) { | |||||
float ym = y1 + (h / 2); | |||||
generator.setDashLine(dashedWidth, dashedWidth * BorderPainter.DASHED_BORDER_SPACE_RATIO) | |||||
.setLineWidth(h) | |||||
.strokeLine(x1, ym, x2, ym); | |||||
} | |||||
} else { | } else { | ||||
float dashedWidth = BorderPainter.dashWidthCalculator(h, w); | float dashedWidth = BorderPainter.dashWidthCalculator(h, w); | ||||
float xm = x1 + (w / 2); | |||||
generator.setDashLine(dashedWidth, dashedWidth * BorderPainter.DASHED_BORDER_SPACE_RATIO) | |||||
.setLineWidth(w) | |||||
.strokeLine(xm, y1, xm, y2); | |||||
if (dashedWidth != 0) { | |||||
float xm = x1 + (w / 2); | |||||
generator.setDashLine(dashedWidth, dashedWidth * BorderPainter.DASHED_BORDER_SPACE_RATIO) | |||||
.setLineWidth(w) | |||||
.strokeLine(xm, y1, xm, y2); | |||||
} | |||||
} | } | ||||
break; | break; | ||||
case Constants.EN_DOTTED: | case Constants.EN_DOTTED: |
gen.useColor(col); | gen.useColor(col); | ||||
if (horz) { | if (horz) { | ||||
float dashWidth = BorderPainter.dashWidthCalculator(w, h); | float dashWidth = BorderPainter.dashWidthCalculator(w, h); | ||||
gen.useDash("[" + dashWidth + " " + BorderPainter.DASHED_BORDER_SPACE_RATIO | |||||
* dashWidth + "] 0"); | |||||
if (dashWidth != 0) { | |||||
gen.useDash("[" + dashWidth + " " + BorderPainter.DASHED_BORDER_SPACE_RATIO | |||||
* dashWidth + "] 0"); | |||||
} | |||||
gen.useLineCap(0); | gen.useLineCap(0); | ||||
gen.useLineWidth(h); | gen.useLineWidth(h); | ||||
float ym = y1 + (h / 2); | float ym = y1 + (h / 2); | ||||
drawLine(gen, x1, ym, x2, ym); | drawLine(gen, x1, ym, x2, ym); | ||||
} else { | } else { | ||||
float dashWidth = BorderPainter.dashWidthCalculator(h, w); | float dashWidth = BorderPainter.dashWidthCalculator(h, w); | ||||
gen.useDash("[" + dashWidth + " " + BorderPainter.DASHED_BORDER_SPACE_RATIO | |||||
* dashWidth + "] 0"); | |||||
if (dashWidth != 0) { | |||||
gen.useDash("[" + dashWidth + " " + BorderPainter.DASHED_BORDER_SPACE_RATIO | |||||
* dashWidth + "] 0"); | |||||
} | |||||
gen.useLineCap(0); | gen.useLineCap(0); | ||||
gen.useLineWidth(w); | gen.useLineWidth(w); | ||||
float xm = x1 + (w / 2); | float xm = x1 + (w / 2); |
import org.junit.Before; | import org.junit.Before; | ||||
import org.junit.Test; | import org.junit.Test; | ||||
import static org.junit.Assert.assertNull; | |||||
import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||
import org.apache.fop.afp.AFPBorderPainter; | import org.apache.fop.afp.AFPBorderPainter; | ||||
line = lineDataInfo; | line = lineDataInfo; | ||||
} | } | ||||
} | } | ||||
@Test | |||||
public void testDrawBorderLineDashed2() throws Exception { | |||||
BorderPaintingInfo paintInfo = new BorderPaintingInfo(0, 0, 0, 0, false, Constants.EN_DASHED, Color.BLACK); | |||||
borderPainter.paint(paintInfo); | |||||
ds.endDocument(); | |||||
assertNull(line); | |||||
} | |||||
} | } |
import org.junit.Before; | import org.junit.Before; | ||||
import org.junit.Test; | import org.junit.Test; | ||||
import static org.mockito.Matchers.any; | |||||
import static org.mockito.Matchers.endsWith; | import static org.mockito.Matchers.endsWith; | ||||
import static org.mockito.Mockito.mock; | import static org.mockito.Mockito.mock; | ||||
import static org.mockito.Mockito.never; | |||||
import static org.mockito.Mockito.verify; | import static org.mockito.Mockito.verify; | ||||
import org.apache.fop.fo.Constants; | |||||
import org.apache.fop.pdf.PDFNumber; | import org.apache.fop.pdf.PDFNumber; | ||||
public class PDFGraphicsPainterTestCase { | public class PDFGraphicsPainterTestCase { | ||||
verify(generator).add(op("c", args)); | verify(generator).add(op("c", args)); | ||||
} | } | ||||
@Test | |||||
public void testDrawBorderLineDashed() { | |||||
sut.drawBorderLine(0, 0, 0, 0, true, true, Constants.EN_DASHED, null); | |||||
verify(generator, never()).add(any(String.class)); | |||||
} | |||||
private void testTransformCoordinatesF(float... args) { | private void testTransformCoordinatesF(float... args) { | ||||
verify(generator).add(opf("cm", args)); | verify(generator).add(opf("cm", args)); | ||||
} | } |
/* | |||||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||||
* contributor license agreements. See the NOTICE file distributed with | |||||
* this work for additional information regarding copyright ownership. | |||||
* The ASF licenses this file to You 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. | |||||
* See the License for the specific language governing permissions and | |||||
* limitations under the License. | |||||
*/ | |||||
/* $Id$ */ | |||||
package org.apache.fop.render.ps; | |||||
import java.awt.Color; | |||||
import java.io.ByteArrayOutputStream; | |||||
import java.io.IOException; | |||||
import org.junit.Assert; | |||||
import org.junit.Test; | |||||
import org.apache.xmlgraphics.ps.PSGenerator; | |||||
import org.apache.fop.fo.Constants; | |||||
public class PSGraphicsPainterTestCase { | |||||
@Test | |||||
public void testDrawBorderLineDashed() throws IOException { | |||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(); | |||||
PSGenerator generator = new PSGenerator(bos); | |||||
PSGraphicsPainter sut = new PSGraphicsPainter(generator); | |||||
sut.drawBorderLine(0, 0, 0, 0, true, true, Constants.EN_DASHED, Color.BLACK); | |||||
Assert.assertEquals(bos.toString(), "0 LW\n0 0 M 0 0 L S N\n"); | |||||
} | |||||
} |