Преглед изворни кода

Factorized creation of gradient bounds


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP-2393_gradient-rendering@1609518 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-2_0
Vincent Hennebert пре 10 година
родитељ
комит
cf24cc5673
1 измењених фајлова са 16 додато и 18 уклоњено
  1. 16
    18
      src/java/org/apache/fop/svg/PDFGraphics2D.java

+ 16
- 18
src/java/org/apache/fop/svg/PDFGraphics2D.java Прегледај датотеку



List<Color> colors = createGradientColors(gp); List<Color> colors = createGradientColors(gp);


float[] fractions = gp.getFractions();
List<Double> theBounds = new java.util.ArrayList<Double>();
for (int count = 0; count < fractions.length; count++) {
float offset = fractions[count];
if (0f < offset && offset < 1f) {
theBounds.add(new Double(offset));
}
}
List<Double> bounds = createGradientBounds(gp);


//Gradients are currently restricted to sRGB //Gradients are currently restricted to sRGB
PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB); PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
PDFGradientFactory gradientFactory = new PDFGradientFactory(this); PDFGradientFactory gradientFactory = new PDFGradientFactory(this);
PDFPattern myPat = gradientFactory.createGradient(false, colSpace, colors, theBounds,
PDFPattern myPat = gradientFactory.createGradient(false, colSpace, colors, bounds,
theCoords, matrix); theCoords, matrix);
currentStream.write(myPat.getColorSpaceOut(fill)); currentStream.write(myPat.getColorSpaceOut(fill));




List<Color> colors = createGradientColors(gp); List<Color> colors = createGradientColors(gp);


float[] fractions = gp.getFractions();
List<Double> theBounds = new java.util.ArrayList<Double>();
for (int count = 0; count < fractions.length; count++) {
float offset = fractions[count];
if (0f < offset && offset < 1f) {
theBounds.add(new Double(offset));
}
}
List<Double> bounds = createGradientBounds(gp);


//Gradients are currently restricted to sRGB //Gradients are currently restricted to sRGB
PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB); PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
PDFGradientFactory gradientFactory = new PDFGradientFactory(this); PDFGradientFactory gradientFactory = new PDFGradientFactory(this);
PDFPattern myPat = gradientFactory.createGradient(true, colSpace, colors, theBounds,
PDFPattern myPat = gradientFactory.createGradient(true, colSpace, colors, bounds,
theCoords, matrix); theCoords, matrix);
currentStream.write(myPat.getColorSpaceOut(fill)); currentStream.write(myPat.getColorSpaceOut(fill));


return gradientColors; return gradientColors;
} }


private List<Double> createGradientBounds(MultipleGradientPaint gradient) {
// TODO is the conversion to double necessary?
float[] fractions = gradient.getFractions();
List<Double> bounds = new java.util.ArrayList<Double>(fractions.length);
for (float offset : fractions) {
if (0f < offset && offset < 1f) {
bounds.add(Double.valueOf(offset));
}
}
return bounds;
}

private boolean createPattern(PatternPaint pp, boolean fill) { private boolean createPattern(PatternPaint pp, boolean fill) {
preparePainting(); preparePainting();



Loading…
Откажи
Сачувај