2 * Licensed to the Apache Software Foundation (ASF) under one or more
\r
3 * contributor license agreements. See the NOTICE file distributed with
\r
4 * this work for additional information regarding copyright ownership.
\r
5 * The ASF licenses this file to You under the Apache License, Version 2.0
\r
6 * (the "License"); you may not use this file except in compliance with
\r
7 * the License. You may obtain a copy of the License at
\r
9 * http://www.apache.org/licenses/LICENSE-2.0
\r
11 * Unless required by applicable law or agreed to in writing, software
\r
12 * distributed under the License is distributed on an "AS IS" BASIS,
\r
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
14 * See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
17 package org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf;
\r
19 import org.apache.pdfbox.cos.COSArray;
\r
20 import org.apache.pdfbox.cos.COSBase;
\r
21 import org.apache.pdfbox.cos.COSNull;
\r
22 import org.apache.pdfbox.pdmodel.common.COSObjectable;
\r
23 import org.apache.pdfbox.pdmodel.graphics.color.PDGamma;
\r
26 * An object for four colours.
\r
28 * @author <a href="mailto:Johannes%20Koch%20%3Ckoch@apache.org%3E">Johannes Koch</a>
\r
29 * @version $Revision: $
\r
31 public class PDFourColours implements COSObjectable
\r
34 private COSArray array;
\r
36 public PDFourColours()
\r
38 this.array = new COSArray();
\r
39 this.array.add(COSNull.NULL);
\r
40 this.array.add(COSNull.NULL);
\r
41 this.array.add(COSNull.NULL);
\r
42 this.array.add(COSNull.NULL);
\r
45 public PDFourColours(COSArray array)
\r
48 // ensure that array has 4 items
\r
49 if (this.array.size() < 4)
\r
51 for (int i = (this.array.size() - 1); i < 4; i++)
\r
53 this.array.add(COSNull.NULL);
\r
60 * Gets the colour for the before edge.
\r
62 * @return the colour for the before edge
\r
64 public PDGamma getBeforeColour()
\r
66 return this.getColourByIndex(0);
\r
70 * Sets the colour for the before edge.
\r
72 * @param colour the colour for the before edge
\r
74 public void setBeforeColour(PDGamma colour)
\r
76 this.setColourByIndex(0, colour);
\r
80 * Gets the colour for the after edge.
\r
82 * @return the colour for the after edge
\r
84 public PDGamma getAfterColour()
\r
86 return this.getColourByIndex(1);
\r
90 * Sets the colour for the after edge.
\r
92 * @param colour the colour for the after edge
\r
94 public void setAfterColour(PDGamma colour)
\r
96 this.setColourByIndex(1, colour);
\r
100 * Gets the colour for the start edge.
\r
102 * @return the colour for the start edge
\r
104 public PDGamma getStartColour()
\r
106 return this.getColourByIndex(2);
\r
110 * Sets the colour for the start edge.
\r
112 * @param colour the colour for the start edge
\r
114 public void setStartColour(PDGamma colour)
\r
116 this.setColourByIndex(2, colour);
\r
120 * Gets the colour for the end edge.
\r
122 * @return the colour for the end edge
\r
124 public PDGamma getEndColour()
\r
126 return this.getColourByIndex(3);
\r
130 * Sets the colour for the end edge.
\r
132 * @param colour the colour for the end edge
\r
134 public void setEndColour(PDGamma colour)
\r
136 this.setColourByIndex(3, colour);
\r
143 public COSBase getCOSObject()
\r
150 * Gets the colour by edge index.
\r
152 * @param index edge index
\r
153 * @return the colour
\r
155 private PDGamma getColourByIndex(int index)
\r
157 PDGamma retval = null;
\r
158 COSBase item = this.array.getObject(index);
\r
159 if (item instanceof COSArray)
\r
161 retval = new PDGamma((COSArray) item);
\r
167 * Sets the colour by edge index.
\r
169 * @param index the edge index
\r
170 * @param colour the colour
\r
172 private void setColourByIndex(int index, PDGamma colour)
\r
175 if (colour == null)
\r
177 base = COSNull.NULL;
\r
181 base = colour.getCOSArray();
\r
183 this.array.set(index, base);
\r