Lines 24-37
Link Here
|
24 |
import org.apache.commons.logging.Log; |
24 |
import org.apache.commons.logging.Log; |
25 |
import org.apache.commons.logging.LogFactory; |
25 |
import org.apache.commons.logging.LogFactory; |
26 |
|
26 |
|
|
|
27 |
import org.apache.xmlgraphics.java2d.ColorConverter; |
28 |
|
27 |
import org.apache.fop.afp.fonts.AFPPageFonts; |
29 |
import org.apache.fop.afp.fonts.AFPPageFonts; |
28 |
import org.apache.fop.util.AbstractPaintingState; |
30 |
import org.apache.fop.util.AbstractPaintingState; |
|
|
31 |
import org.apache.fop.util.DefaultColorConverter; |
32 |
import org.apache.fop.util.GrayScaleColorConverter; |
29 |
|
33 |
|
30 |
/** |
34 |
/** |
31 |
* This keeps information about the current painting state when writing to an AFP datastream. |
35 |
* This keeps information about the current painting state when writing to an |
|
|
36 |
* AFP datastream. |
32 |
*/ |
37 |
*/ |
33 |
public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState |
38 |
public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState implements |
34 |
implements Cloneable { |
39 |
Cloneable { |
35 |
|
40 |
|
36 |
private static final long serialVersionUID = 8206711712452344473L; |
41 |
private static final long serialVersionUID = 8206711712452344473L; |
37 |
|
42 |
|
Lines 46-54
Link Here
|
46 |
/** color image support */ |
51 |
/** color image support */ |
47 |
private boolean colorImages = false; |
52 |
private boolean colorImages = false; |
48 |
|
53 |
|
49 |
/** true if certain image formats may be embedded unchanged in their native format. */ |
54 |
/** color image handler */ |
|
|
55 |
private ColorConverter colorConverter = GrayScaleColorConverter.getInstance(); |
56 |
|
57 |
/** |
58 |
* true if certain image formats may be embedded unchanged in their native |
59 |
* format. |
60 |
*/ |
50 |
private boolean nativeImagesSupported = false; |
61 |
private boolean nativeImagesSupported = false; |
51 |
/** true if CMYK images (requires IOCA FS45 suppport on the target platform) may be generated */ |
62 |
/** |
|
|
63 |
* true if CMYK images (requires IOCA FS45 suppport on the target platform) |
64 |
* may be generated |
65 |
*/ |
52 |
private boolean cmykImagesSupported; |
66 |
private boolean cmykImagesSupported; |
53 |
|
67 |
|
54 |
/** default value for image depth */ |
68 |
/** default value for image depth */ |
Lines 60-72
Link Here
|
60 |
/** the current page */ |
74 |
/** the current page */ |
61 |
private transient AFPPagePaintingState pagePaintingState = new AFPPagePaintingState(); |
75 |
private transient AFPPagePaintingState pagePaintingState = new AFPPagePaintingState(); |
62 |
|
76 |
|
63 |
// /** reference orientation */ |
77 |
// /** reference orientation */ |
64 |
// private int orientation = 0; |
78 |
// private int orientation = 0; |
65 |
|
79 |
|
66 |
/** a unit converter */ |
80 |
/** a unit converter */ |
67 |
private final transient AFPUnitConverter unitConv = new AFPUnitConverter(this); |
81 |
private final transient AFPUnitConverter unitConv = new AFPUnitConverter(this); |
68 |
|
82 |
|
69 |
|
|
|
70 |
/** |
83 |
/** |
71 |
* Sets the rotation to be used for portrait pages, valid values are 0 |
84 |
* Sets the rotation to be used for portrait pages, valid values are 0 |
72 |
* (default), 90, 180, 270. |
85 |
* (default), 90, 180, 270. |
Lines 75-87
Link Here
|
75 |
* The rotation in degrees. |
88 |
* The rotation in degrees. |
76 |
*/ |
89 |
*/ |
77 |
public void setPortraitRotation(int rotation) { |
90 |
public void setPortraitRotation(int rotation) { |
78 |
if (rotation == 0 || rotation == 90 || rotation == 180 |
91 |
if (rotation == 0 || rotation == 90 || rotation == 180 || rotation == 270) { |
79 |
|| rotation == 270) { |
|
|
80 |
portraitRotation = rotation; |
92 |
portraitRotation = rotation; |
81 |
} else { |
93 |
} else { |
82 |
throw new IllegalArgumentException( |
94 |
throw new IllegalArgumentException("The portrait rotation must be one" |
83 |
"The portrait rotation must be one" |
95 |
+ " of the values 0, 90, 180, 270"); |
84 |
+ " of the values 0, 90, 180, 270"); |
|
|
85 |
|
96 |
|
86 |
} |
97 |
} |
87 |
} |
98 |
} |
Lines 103-115
Link Here
|
103 |
* The rotation in degrees. |
114 |
* The rotation in degrees. |
104 |
*/ |
115 |
*/ |
105 |
public void setLandscapeRotation(int rotation) { |
116 |
public void setLandscapeRotation(int rotation) { |
106 |
if (rotation == 0 || rotation == 90 || rotation == 180 |
117 |
if (rotation == 0 || rotation == 90 || rotation == 180 || rotation == 270) { |
107 |
|| rotation == 270) { |
|
|
108 |
landscapeRotation = rotation; |
118 |
landscapeRotation = rotation; |
109 |
} else { |
119 |
} else { |
110 |
throw new IllegalArgumentException( |
120 |
throw new IllegalArgumentException("The landscape rotation must be one" |
111 |
"The landscape rotation must be one" |
121 |
+ " of the values 0, 90, 180, 270"); |
112 |
+ " of the values 0, 90, 180, 270"); |
|
|
113 |
} |
122 |
} |
114 |
} |
123 |
} |
115 |
|
124 |
|
Lines 152-164
Link Here
|
152 |
} |
161 |
} |
153 |
|
162 |
|
154 |
/** |
163 |
/** |
155 |
* Sets whether images are color or not |
164 |
* Sets whether images are color or not and instantiates a ColorHandler |
156 |
* |
165 |
* |
157 |
* @param colorImages |
166 |
* @param colorImages |
158 |
* color image output |
167 |
* color image output |
159 |
*/ |
168 |
*/ |
160 |
public void setColorImages(boolean colorImages) { |
169 |
public void setColorImages(boolean colorImages) { |
161 |
this.colorImages = colorImages; |
170 |
this.colorImages = colorImages; |
|
|
171 |
|
172 |
if (colorImages) { |
173 |
this.colorConverter = DefaultColorConverter.getInstance(); |
174 |
} |
175 |
|
162 |
} |
176 |
} |
163 |
|
177 |
|
164 |
/** |
178 |
/** |
Lines 171-179
Link Here
|
171 |
} |
185 |
} |
172 |
|
186 |
|
173 |
/** |
187 |
/** |
|
|
188 |
* Used to convert color in respect of the colorImages flag |
189 |
* |
190 |
* @return the color converter |
191 |
*/ |
192 |
public ColorConverter getColorConverter() { |
193 |
return this.colorConverter; |
194 |
} |
195 |
|
196 |
/** |
174 |
* Sets whether images are natively supported or not in the AFP environment |
197 |
* Sets whether images are natively supported or not in the AFP environment |
175 |
* |
198 |
* |
176 |
* @param nativeImagesSupported true if images are natively supported in this AFP environment |
199 |
* @param nativeImagesSupported |
|
|
200 |
* true if images are natively supported in this AFP environment |
177 |
*/ |
201 |
*/ |
178 |
public void setNativeImagesSupported(boolean nativeImagesSupported) { |
202 |
public void setNativeImagesSupported(boolean nativeImagesSupported) { |
179 |
this.nativeImagesSupported = nativeImagesSupported; |
203 |
this.nativeImagesSupported = nativeImagesSupported; |
Lines 189-198
Link Here
|
189 |
} |
213 |
} |
190 |
|
214 |
|
191 |
/** |
215 |
/** |
192 |
* Controls whether CMYK images (IOCA FS45) are enabled. By default, support is disabled |
216 |
* Controls whether CMYK images (IOCA FS45) are enabled. By default, support |
193 |
* for wider compatibility. When disabled, any CMYK image is converted to the selected |
217 |
* is disabled for wider compatibility. When disabled, any CMYK image is |
194 |
* color format. |
218 |
* converted to the selected color format. |
195 |
* @param value true to enabled CMYK images |
219 |
* |
|
|
220 |
* @param value |
221 |
* true to enabled CMYK images |
196 |
*/ |
222 |
*/ |
197 |
public void setCMYKImagesSupported(boolean value) { |
223 |
public void setCMYKImagesSupported(boolean value) { |
198 |
this.cmykImagesSupported = value; |
224 |
this.cmykImagesSupported = value; |
Lines 200-205
Link Here
|
200 |
|
226 |
|
201 |
/** |
227 |
/** |
202 |
* Indicates whether CMYK images (IOCA FS45) are enabled. |
228 |
* Indicates whether CMYK images (IOCA FS45) are enabled. |
|
|
229 |
* |
203 |
* @return true if IOCA FS45 is enabled |
230 |
* @return true if IOCA FS45 is enabled |
204 |
*/ |
231 |
*/ |
205 |
public boolean isCMYKImagesSupported() { |
232 |
public boolean isCMYKImagesSupported() { |
Lines 259-265
Link Here
|
259 |
/** |
286 |
/** |
260 |
* Sets the page width |
287 |
* Sets the page width |
261 |
* |
288 |
* |
262 |
* @param pageWidth the page width |
289 |
* @param pageWidth |
|
|
290 |
* the page width |
263 |
*/ |
291 |
*/ |
264 |
public void setPageWidth(int pageWidth) { |
292 |
public void setPageWidth(int pageWidth) { |
265 |
pagePaintingState.setWidth(pageWidth); |
293 |
pagePaintingState.setWidth(pageWidth); |
Lines 277-283
Link Here
|
277 |
/** |
305 |
/** |
278 |
* Sets the page height |
306 |
* Sets the page height |
279 |
* |
307 |
* |
280 |
* @param pageHeight the page height |
308 |
* @param pageHeight |
|
|
309 |
* the page height |
281 |
*/ |
310 |
*/ |
282 |
public void setPageHeight(int pageHeight) { |
311 |
public void setPageHeight(int pageHeight) { |
283 |
pagePaintingState.setHeight(pageHeight); |
312 |
pagePaintingState.setHeight(pageHeight); |
Lines 304-313
Link Here
|
304 |
/** |
333 |
/** |
305 |
* Sets the uri of the current image |
334 |
* Sets the uri of the current image |
306 |
* |
335 |
* |
307 |
* @param uri the uri of the current image |
336 |
* @param uri |
|
|
337 |
* the uri of the current image |
308 |
*/ |
338 |
*/ |
309 |
public void setImageUri(String uri) { |
339 |
public void setImageUri(String uri) { |
310 |
((AFPData)getData()).imageUri = uri; |
340 |
((AFPData) getData()).imageUri = uri; |
311 |
} |
341 |
} |
312 |
|
342 |
|
313 |
/** |
343 |
/** |
Lines 316-322
Link Here
|
316 |
* @return the uri of the current image |
346 |
* @return the uri of the current image |
317 |
*/ |
347 |
*/ |
318 |
public String getImageUri() { |
348 |
public String getImageUri() { |
319 |
return ((AFPData)getData()).imageUri; |
349 |
return ((AFPData) getData()).imageUri; |
320 |
} |
350 |
} |
321 |
|
351 |
|
322 |
/** |
352 |
/** |
Lines 338-347
Link Here
|
338 |
} |
368 |
} |
339 |
|
369 |
|
340 |
/** |
370 |
/** |
341 |
* Returns a point on the current page, taking the current painting state into account. |
371 |
* Returns a point on the current page, taking the current painting state |
|
|
372 |
* into account. |
342 |
* |
373 |
* |
343 |
* @param x the X-coordinate |
374 |
* @param x |
344 |
* @param y the Y-coordinate |
375 |
* the X-coordinate |
|
|
376 |
* @param y |
377 |
* the Y-coordinate |
345 |
* @return a point on the current page |
378 |
* @return a point on the current page |
346 |
*/ |
379 |
*/ |
347 |
public Point getPoint(int x, int y) { |
380 |
public Point getPoint(int x, int y) { |
Lines 370-381
Link Here
|
370 |
|
403 |
|
371 |
/** {@inheritDoc} */ |
404 |
/** {@inheritDoc} */ |
372 |
public Object clone() { |
405 |
public Object clone() { |
373 |
AFPPaintingState paintingState = (AFPPaintingState)super.clone(); |
406 |
AFPPaintingState paintingState = (AFPPaintingState) super.clone(); |
374 |
paintingState.pagePaintingState = (AFPPagePaintingState)this.pagePaintingState.clone(); |
407 |
paintingState.pagePaintingState = (AFPPagePaintingState) this.pagePaintingState.clone(); |
375 |
paintingState.portraitRotation = this.portraitRotation; |
408 |
paintingState.portraitRotation = this.portraitRotation; |
376 |
paintingState.landscapeRotation = this.landscapeRotation; |
409 |
paintingState.landscapeRotation = this.landscapeRotation; |
377 |
paintingState.bitsPerPixel = this.bitsPerPixel; |
410 |
paintingState.bitsPerPixel = this.bitsPerPixel; |
378 |
paintingState.colorImages = this.colorImages; |
411 |
paintingState.colorImages = this.colorImages; |
|
|
412 |
paintingState.colorConverter = this.colorConverter; |
379 |
paintingState.resolution = this.resolution; |
413 |
paintingState.resolution = this.resolution; |
380 |
return paintingState; |
414 |
return paintingState; |
381 |
} |
415 |
} |
Lines 383-395
Link Here
|
383 |
/** {@inheritDoc} */ |
417 |
/** {@inheritDoc} */ |
384 |
public String toString() { |
418 |
public String toString() { |
385 |
return "AFPPaintingState{" + "portraitRotation=" + portraitRotation |
419 |
return "AFPPaintingState{" + "portraitRotation=" + portraitRotation |
386 |
+ ", landscapeRotation=" + landscapeRotation |
420 |
+ ", landscapeRotation=" + landscapeRotation + ", colorImages=" + colorImages |
387 |
+ ", colorImages=" + colorImages |
421 |
+ ", bitsPerPixel=" + bitsPerPixel + ", resolution=" + resolution + ", pageState=" |
388 |
+ ", bitsPerPixel=" + bitsPerPixel |
422 |
+ pagePaintingState + super.toString() + "}"; |
389 |
+ ", resolution=" + resolution |
|
|
390 |
+ ", pageState=" + pagePaintingState |
391 |
+ super.toString() |
392 |
+ "}"; |
393 |
} |
423 |
} |
394 |
|
424 |
|
395 |
/** |
425 |
/** |
Lines 423-429
Link Here
|
423 |
/** |
453 |
/** |
424 |
* Sets the page width |
454 |
* Sets the page width |
425 |
* |
455 |
* |
426 |
* @param width the page width |
456 |
* @param width |
|
|
457 |
* the page width |
427 |
*/ |
458 |
*/ |
428 |
protected void setWidth(int width) { |
459 |
protected void setWidth(int width) { |
429 |
this.width = width; |
460 |
this.width = width; |
Lines 441-447
Link Here
|
441 |
/** |
472 |
/** |
442 |
* Sets the page height |
473 |
* Sets the page height |
443 |
* |
474 |
* |
444 |
* @param height the page height |
475 |
* @param height |
|
|
476 |
* the page height |
445 |
*/ |
477 |
*/ |
446 |
protected void setHeight(int height) { |
478 |
protected void setHeight(int height) { |
447 |
this.height = height; |
479 |
this.height = height; |
Lines 459-465
Link Here
|
459 |
/** |
491 |
/** |
460 |
* Sets the current page fonts |
492 |
* Sets the current page fonts |
461 |
* |
493 |
* |
462 |
* @param fonts the current page fonts |
494 |
* @param fonts |
|
|
495 |
* the current page fonts |
463 |
*/ |
496 |
*/ |
464 |
protected void setFonts(AFPPageFonts fonts) { |
497 |
protected void setFonts(AFPPageFonts fonts) { |
465 |
this.fonts = fonts; |
498 |
this.fonts = fonts; |
Lines 486-492
Link Here
|
486 |
/** |
519 |
/** |
487 |
* Sets the current page orientation |
520 |
* Sets the current page orientation |
488 |
* |
521 |
* |
489 |
* @param orientation the current page orientation |
522 |
* @param orientation |
|
|
523 |
* the current page orientation |
490 |
*/ |
524 |
*/ |
491 |
protected void setOrientation(int orientation) { |
525 |
protected void setOrientation(int orientation) { |
492 |
this.orientation = orientation; |
526 |
this.orientation = orientation; |
Lines 505-516
Link Here
|
505 |
|
539 |
|
506 |
/** {@inheritDoc} */ |
540 |
/** {@inheritDoc} */ |
507 |
public String toString() { |
541 |
public String toString() { |
508 |
return "AFPPagePaintingState{width=" + width |
542 |
return "AFPPagePaintingState{width=" + width + ", height=" + height + ", orientation=" |
509 |
+ ", height=" + height |
543 |
+ orientation + ", fonts=" + fonts + ", fontCount=" + fontCount + "}"; |
510 |
+ ", orientation=" + orientation |
|
|
511 |
+ ", fonts=" + fonts |
512 |
+ ", fontCount=" + fontCount |
513 |
+ "}"; |
514 |
} |
544 |
} |
515 |
} |
545 |
} |
516 |
|
546 |
|
Lines 527-533
Link Here
|
527 |
|
557 |
|
528 |
/** {@inheritDoc} */ |
558 |
/** {@inheritDoc} */ |
529 |
public Object clone() { |
559 |
public Object clone() { |
530 |
AFPData obj = (AFPData)super.clone(); |
560 |
AFPData obj = (AFPData) super.clone(); |
531 |
obj.filled = this.filled; |
561 |
obj.filled = this.filled; |
532 |
obj.imageUri = this.imageUri; |
562 |
obj.imageUri = this.imageUri; |
533 |
return obj; |
563 |
return obj; |
Lines 535-544
Link Here
|
535 |
|
565 |
|
536 |
/** {@inheritDoc} */ |
566 |
/** {@inheritDoc} */ |
537 |
public String toString() { |
567 |
public String toString() { |
538 |
return "AFPData{" + super.toString() |
568 |
return "AFPData{" + super.toString() + ", filled=" + filled + ", imageUri=" + imageUri |
539 |
+ ", filled=" + filled |
569 |
+ "}"; |
540 |
+ ", imageUri=" + imageUri |
|
|
541 |
+ "}"; |
542 |
} |
570 |
} |
543 |
|
571 |
|
544 |
/** {@inheritDoc} */ |
572 |
/** {@inheritDoc} */ |