View | Details | Raw Unified | Return to bug 48237
Collapse All | Expand All

(-)test/java/org/apache/fop/traits/BorderPropsTestCase.java (-1 / +2 lines)
Lines 23-30 Link Here
23
23
24
import junit.framework.TestCase;
24
import junit.framework.TestCase;
25
25
26
import org.apache.xmlgraphics.java2d.CMYKColorSpace;
27
26
import org.apache.fop.fo.Constants;
28
import org.apache.fop.fo.Constants;
27
import org.apache.fop.util.CMYKColorSpace;
28
import org.apache.fop.util.ColorExt;
29
import org.apache.fop.util.ColorExt;
29
import org.apache.fop.util.ColorUtil;
30
import org.apache.fop.util.ColorUtil;
30
31
(-)test/java/org/apache/fop/util/ColorUtilTestCase.java (+2 lines)
Lines 24-29 Link Here
24
24
25
import junit.framework.TestCase;
25
import junit.framework.TestCase;
26
26
27
import org.apache.xmlgraphics.java2d.CMYKColorSpace;
28
27
import org.apache.fop.apps.FOUserAgent;
29
import org.apache.fop.apps.FOUserAgent;
28
import org.apache.fop.apps.FopFactory;
30
import org.apache.fop.apps.FopFactory;
29
31
(-)src/java/org/apache/fop/afp/modca/GraphicsObject.java (-1 / +18 lines)
Lines 25-30 Link Here
25
import java.util.Iterator;
25
import java.util.Iterator;
26
import java.util.List;
26
import java.util.List;
27
27
28
import org.apache.xmlgraphics.java2d.ColorConverter;
29
28
import org.apache.fop.afp.AFPDataObjectInfo;
30
import org.apache.fop.afp.AFPDataObjectInfo;
29
import org.apache.fop.afp.AFPObjectAreaInfo;
31
import org.apache.fop.afp.AFPObjectAreaInfo;
30
import org.apache.fop.afp.Completable;
32
import org.apache.fop.afp.Completable;
Lines 65-70 Link Here
65
    /** the graphics state */
67
    /** the graphics state */
66
    private final GraphicsState graphicsState = new GraphicsState();
68
    private final GraphicsState graphicsState = new GraphicsState();
67
69
70
71
    /** color  converter  */
72
    private ColorConverter colorConverter = null;
73
68
    /**
74
    /**
69
     * Default constructor
75
     * Default constructor
70
     *
76
     *
Lines 140-151 Link Here
140
     */
146
     */
141
    public void setColor(Color color) {
147
    public void setColor(Color color) {
142
        if (!color.equals(graphicsState.color)) {
148
        if (!color.equals(graphicsState.color)) {
143
            addObject(new GraphicsSetProcessColor(color));
149
            addObject(new GraphicsSetProcessColor(colorConverter.convert(color)));
144
            graphicsState.color = color;
150
            graphicsState.color = color;
145
        }
151
        }
146
    }
152
    }
147
153
154
148
    /**
155
    /**
156
     * Sets the color converter
157
     *
158
     * @param colorConverter
159
     */
160
    public void setColorConverter(ColorConverter colorConverter) {
161
       this.colorConverter = colorConverter;
162
    }
163
164
165
    /**
149
     * Sets the current position
166
     * Sets the current position
150
     *
167
     *
151
     * @param coords the x and y coordinates of the current position
168
     * @param coords the x and y coordinates of the current position
(-)src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java (-9 / +20 lines)
Lines 29-34 Link Here
29
 */
29
 */
30
public class GraphicsSetProcessColor extends AbstractGraphicsDrawingOrder {
30
public class GraphicsSetProcessColor extends AbstractGraphicsDrawingOrder {
31
31
32
    /*
33
     * GOCA Color space support:
34
     * X'01' RGB
35
     * X'04' CMYK
36
     * X'06' Highlight color space
37
     * X'08' CIELAB
38
     * X'40' Standard OCA color space
39
     */
40
    private static final byte RGB = 0x01, CMYK = 0x04;
41
32
    private final Color color;
42
    private final Color color;
33
43
34
    private final float[] colorComponents;
44
    private final float[] colorComponents;
Lines 36-42 Link Here
36
    /**
46
    /**
37
     * Main constructor
47
     * Main constructor
38
     *
48
     *
39
     * @param color the color to set
49
     * @param color
50
     *            the color to set
40
     */
51
     */
41
    public GraphicsSetProcessColor(Color color) {
52
    public GraphicsSetProcessColor(Color color) {
42
        this.color = color;
53
        this.color = color;
Lines 50-56 Link Here
50
61
51
    /** {@inheritDoc} */
62
    /** {@inheritDoc} */
52
    byte getOrderCode() {
63
    byte getOrderCode() {
53
        return (byte)0xB2;
64
        return (byte) 0xB2;
54
    }
65
    }
55
66
56
    /** {@inheritDoc} */
67
    /** {@inheritDoc} */
Lines 60-83 Link Here
60
        byte colspace;
71
        byte colspace;
61
        int colSpaceType = color.getColorSpace().getType();
72
        int colSpaceType = color.getColorSpace().getType();
62
        if (colSpaceType == ColorSpace.TYPE_CMYK) {
73
        if (colSpaceType == ColorSpace.TYPE_CMYK) {
63
            colspace = 0x04;
74
            colspace = CMYK;
64
        } else if (colSpaceType == ColorSpace.TYPE_RGB) {
75
        } else if (colSpaceType == ColorSpace.TYPE_RGB) {
65
            colspace = 0x01;
76
            colspace = RGB;
66
        } else {
77
        } else {
67
            log.error("unsupported colorspace " + colSpaceType);
78
            log.error("unsupported colorspace " + colSpaceType);
68
            colspace = 0x01;
79
            colspace = RGB;
69
        }
80
        }
70
81
71
        // COLSIZE(S)
82
        // COLSIZE(S)
72
        byte[] colsizes = new byte[] {0x00, 0x00, 0x00, 0x00};
83
        byte[] colsizes = new byte[] {0x00, 0x00, 0x00, 0x00};
73
        for (int i = 0; i < colorComponents.length; i++) {
84
        for (int i = 0; i < colorComponents.length; i++) {
74
            colsizes[i] = (byte)8;
85
            colsizes[i] = (byte) 8;
75
        }
86
        }
76
87
77
        int len = getDataLength();
88
        int len = getDataLength();
78
        byte[] data = new byte[len];
89
        byte[] data = new byte[len];
79
        data[0] = getOrderCode(); // GSPCOL order code
90
        data[0] = getOrderCode(); // GSPCOL order code
80
        data[1] = (byte)(len - 2); // LEN
91
        data[1] = (byte) (len - 2); // LEN
81
        data[2] = 0x00; // reserved; must be zero
92
        data[2] = 0x00; // reserved; must be zero
82
        data[3] = colspace; // COLSPCE
93
        data[3] = colspace; // COLSPCE
83
        data[4] = 0x00; // reserved; must be zero
94
        data[4] = 0x00; // reserved; must be zero
Lines 91-97 Link Here
91
102
92
        // COLVALUE(S)
103
        // COLVALUE(S)
93
        for (int i = 0; i < colorComponents.length; i++) {
104
        for (int i = 0; i < colorComponents.length; i++) {
94
            data[i + 12] = (byte)(colorComponents[i] * 255);
105
            data[i + 12] = (byte) (colorComponents[i] * 255);
95
        }
106
        }
96
107
97
        os.write(data);
108
        os.write(data);
Lines 101-104 Link Here
101
    public String toString() {
112
    public String toString() {
102
        return "GraphicsSetProcessColor(col=" + color + ")";
113
        return "GraphicsSetProcessColor(col=" + color + ")";
103
    }
114
    }
104
}
115
}
(-)src/java/org/apache/fop/afp/AFPPaintingState.java (-56 / +84 lines)
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} */
(-)src/java/org/apache/fop/afp/AFPDataObjectFactory.java (+3 lines)
Lines 165-170 Link Here
165
        AFPGraphics2D g2d = graphicsObjectInfo.getGraphics2D();
165
        AFPGraphics2D g2d = graphicsObjectInfo.getGraphics2D();
166
        g2d.setGraphicsObject(graphicsObj);
166
        g2d.setGraphicsObject(graphicsObj);
167
167
168
        //set color converter (i.e. an rgb to grayscale converter)
169
        graphicsObj.setColorConverter(g2d.getPaintingState().getColorConverter());
170
        
168
        // paint to graphics object
171
        // paint to graphics object
169
        Graphics2DImagePainter painter = graphicsObjectInfo.getPainter();
172
        Graphics2DImagePainter painter = graphicsObjectInfo.getPainter();
170
        Rectangle2D area = graphicsObjectInfo.getArea();
173
        Rectangle2D area = graphicsObjectInfo.getArea();
(-)src/java/org/apache/fop/pdf/PDFColor.java (-1 / +1 lines)
Lines 26-32 Link Here
26
import java.util.List;
26
import java.util.List;
27
import java.util.ArrayList;
27
import java.util.ArrayList;
28
28
29
import org.apache.fop.util.CMYKColorSpace;
29
import org.apache.xmlgraphics.java2d.CMYKColorSpace;
30
import org.apache.fop.util.ColorExt;
30
import org.apache.fop.util.ColorExt;
31
31
32
/**
32
/**
(-)src/java/org/apache/fop/util/ColorUtil.java (+2 lines)
Lines 27-32 Link Here
27
import org.apache.commons.logging.Log;
27
import org.apache.commons.logging.Log;
28
import org.apache.commons.logging.LogFactory;
28
import org.apache.commons.logging.LogFactory;
29
29
30
import org.apache.xmlgraphics.java2d.CMYKColorSpace;
31
30
import org.apache.fop.apps.FOUserAgent;
32
import org.apache.fop.apps.FOUserAgent;
31
import org.apache.fop.fo.expr.PropertyException;
33
import org.apache.fop.fo.expr.PropertyException;
32
34
(-)src/java/org/apache/fop/util/CMYKColorSpace.java (-81 lines)
Lines 1-81 Link Here
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *      http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
/* $Id$ */
19
20
package org.apache.fop.util;
21
22
import java.awt.color.ColorSpace;
23
24
/**
25
 * This class represents an uncalibrated CMYK color space. It is used by
26
 * the JpegImage class.
27
 */
28
public class CMYKColorSpace extends ColorSpace {
29
30
    private static CMYKColorSpace instance;
31
32
    /**
33
     * @see java.awt.color.ColorSpace#ColorSpace(int, int)
34
     */
35
    protected CMYKColorSpace(int type, int numcomponents) {
36
        super(type, numcomponents);
37
    }
38
39
    /**
40
     * Returns an instance of an uncalibrated CMYK color space.
41
     * @return CMYKColorSpace the requested color space object
42
     */
43
    public static CMYKColorSpace getInstance() {
44
        if (instance == null) {
45
            instance = new CMYKColorSpace(TYPE_CMYK, 4);
46
        }
47
        return instance;
48
    }
49
50
    /**
51
     * {@inheritDoc}
52
     */
53
    public float[] toRGB(float[] colorvalue) {
54
        return new float [] {
55
            (1 - colorvalue[0]) * (1 - colorvalue[3]),
56
            (1 - colorvalue[1]) * (1 - colorvalue[3]),
57
            (1 - colorvalue[2]) * (1 - colorvalue[3])};
58
    }
59
60
    /**
61
     * {@inheritDoc}
62
     */
63
    public float[] fromRGB(float[] rgbvalue) {
64
        throw new UnsupportedOperationException("NYI");
65
    }
66
67
    /**
68
     * {@inheritDoc}
69
     */
70
    public float[] toCIEXYZ(float[] colorvalue) {
71
        throw new UnsupportedOperationException("NYI");
72
    }
73
74
    /**
75
     * {@inheritDoc}
76
     */
77
    public float[] fromCIEXYZ(float[] colorvalue) {
78
        throw new UnsupportedOperationException("NYI");
79
    }
80
81
}

Return to bug 48237