KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lowagie > text > Cell


1 /*
2  * $Id: Cell.java 2752 2007-05-15 14:58:33Z blowagie $
3  * $Name$
4  *
5  * Copyright 1999, 2000, 2001, 2002 by Bruno Lowagie.
6  *
7  * The contents of this file are subject to the Mozilla Public License Version 1.1
8  * (the "License"); you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the License.
14  *
15  * The Original Code is 'iText, a free JAVA-PDF library'.
16  *
17  * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
18  * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
19  * All Rights Reserved.
20  * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
21  * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
22  *
23  * Contributor(s): all the names of the contributors are added in the source code
24  * where applicable.
25  *
26  * Alternatively, the contents of this file may be used under the terms of the
27  * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
28  * provisions of LGPL are applicable instead of those above. If you wish to
29  * allow use of your version of this file only under the terms of the LGPL
30  * License and not to allow others to use your version of this file under
31  * the MPL, indicate your decision by deleting the provisions above and
32  * replace them with the notice and other provisions required by the LGPL.
33  * If you do not delete the provisions above, a recipient may use your version
34  * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
35  *
36  * This library is free software; you can redistribute it and/or modify it
37  * under the terms of the MPL as stated above or under the terms of the GNU
38  * Library General Public License as published by the Free Software Foundation;
39  * either version 2 of the License, or any later version.
40  *
41  * This library is distributed in the hope that it will be useful, but WITHOUT
42  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
43  * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
44  * details.
45  *
46  * If you didn't download this code from the following link, you should check if
47  * you aren't using an obsolete version:
48  * http://www.lowagie.com/iText/
49  */

50
51 package com.lowagie.text;
52
53 import java.util.ArrayList JavaDoc;
54 import java.util.Iterator JavaDoc;
55
56 import com.lowagie.text.pdf.PdfPCell;
57
58 /**
59  * A <CODE>Cell</CODE> is a <CODE>Rectangle</CODE> containing other
60  * <CODE>Element</CODE>s.
61  * <P>
62  * A <CODE>Cell</CODE> must be added to a <CODE>Table</CODE>.
63  * The <CODE>Table</CODE> will place the <CODE>Cell</CODE> in
64  * a <CODE>Row</CODE>.
65  * <P>
66  * Example:
67  * <BLOCKQUOTE><PRE>
68  * Table table = new Table(3);
69  * table.setBorderWidth(1);
70  * table.setBorderColor(new Color(0, 0, 255));
71  * table.setCellpadding(5);
72  * table.setCellspacing(5);
73  * <STRONG>Cell cell = new Cell("header");</STRONG>
74  * <STRONG>cell.setHeader(true);</STRONG>
75  * <STRONG>cell.setColspan(3);</STRONG>
76  * table.addCell(cell);
77  * <STRONG>cell = new Cell("example cell with colspan 1 and rowspan 2");</STRONG>
78  * <STRONG>cell.setRowspan(2);</STRONG>
79  * <STRONG>cell.setBorderColor(new Color(255, 0, 0));</STRONG>
80  * table.addCell(cell);
81  * table.addCell("1.1");
82  * table.addCell("2.1");
83  * table.addCell("1.2");
84  * table.addCell("2.2");
85  * </PRE></BLOCKQUOTE>
86  *
87  * @see Rectangle
88  * @see Element
89  * @see Table
90  * @see Row
91  */

92
93 public class Cell extends Rectangle implements TextElementArray {
94
95     // membervariables
96

97     /**
98      * The <CODE>ArrayList</CODE> of <CODE>Element</CODE>s
99      * that are part of the content of the Cell.
100      */

101     protected ArrayList JavaDoc arrayList = null;
102
103     /** The horizontal alignment of the cell content. */
104     protected int horizontalAlignment = Element.ALIGN_UNDEFINED;
105
106     /** The vertical alignment of the cell content. */
107     protected int verticalAlignment = Element.ALIGN_UNDEFINED;
108
109     /**
110      * The width of the cell as a String.
111      * It can be an absolute value "100" or a percentage "20%".
112      */

113     protected float width;
114     protected boolean percentage = false;
115
116     /** The colspan of the cell. */
117     protected int colspan = 1;
118
119     /** The rowspan of the cell. */
120     protected int rowspan = 1;
121
122     /** The leading of the content inside the cell. */
123     float leading = Float.NaN;
124
125     /** Is this <CODE>Cell</CODE> a header? */
126     protected boolean header;
127
128     /**
129      * Maximum number of lines allowed in the cell.
130      * The default value of this property is not to limit the maximum number of lines
131      * (contributed by dperezcar@fcc.es)
132      */

133     protected int maxLines = Integer.MAX_VALUE;
134     
135     /**
136      * If a truncation happens due to the {@link #maxLines} property, then this text will
137      * be added to indicate a truncation has happened.
138      * Default value is null, and means avoiding marking the truncation.
139      * A useful value of this property could be e.g. "..."
140      * (contributed by dperezcar@fcc.es)
141      */

142     String JavaDoc showTruncation;
143
144     /**
145      * Indicates that the largest ascender height should be used to determine the
146      * height of the first line. Note that this only has an effect when rendered
147      * to PDF. Setting this to true can help with vertical alignment problems.
148      */

149     protected boolean useAscender = false;
150
151     /**
152      * Indicates that the largest descender height should be added to the height of
153      * the last line (so characters like y don't dip into the border). Note that
154      * this only has an effect when rendered to PDF.
155      */

156     protected boolean useDescender = false;
157
158     /**
159      * Adjusts the cell contents to compensate for border widths. Note that
160      * this only has an effect when rendered to PDF.
161      */

162     protected boolean useBorderPadding;
163     
164     /** Does this <CODE>Cell</CODE> force a group change? */
165     protected boolean groupChange = true;
166
167     // constructors
168

169     /** Constructs an empty <CODE>Cell</CODE>. */
170     public Cell() {
171         // creates a Rectangle with BY DEFAULT a border of 0.5
172
super(0, 0, 0, 0);
173         setBorder(UNDEFINED);
174         setBorderWidth(0.5f);
175         // initializes the arraylist
176
arrayList = new ArrayList JavaDoc();
177     }
178
179     /**
180      * Constructs an empty <CODE>Cell</CODE> (for internal use only).
181      *
182      * @param dummy a dummy value
183      */

184     public Cell(boolean dummy) {
185         this();
186         arrayList.add(new Paragraph(0));
187     }
188
189     /**
190      * Constructs a <CODE>Cell</CODE> with a certain content.<p>
191      * The <CODE>String</CODE> will be converted into a <CODE>Paragraph</CODE>.
192      * @param content a <CODE>String</CODE>
193      */

194     public Cell(String JavaDoc content) {
195         this();
196         try {
197             addElement(new Paragraph(content));
198         }
199         catch(BadElementException bee) {
200         }
201     }
202
203     /**
204      * Constructs a <CODE>Cell</CODE> with a certain <CODE>Element</CODE>.<p>
205      * if the element is a <CODE>ListItem</CODE>, <CODE>Row</CODE> or
206      * <CODE>Cell</CODE>, an exception will be thrown.
207      *
208      * @param element the element
209      * @throws BadElementException when the creator was called with a <CODE>ListItem</CODE>, <CODE>Row</CODE> or <CODE>Cell</CODE>
210      */

211     public Cell(Element element) throws BadElementException {
212         this();
213         if(element instanceof Phrase) {
214             setLeading(((Phrase)element).getLeading());
215         }
216         addElement(element);
217     }
218
219     // implementation of the Element-methods
220

221     /**
222      * Processes the element by adding it (or the different parts) to an
223      * <CODE>ElementListener</CODE>.
224      *
225      * @param listener an <CODE>ElementListener</CODE>
226      * @return <CODE>true</CODE> if the element was processed successfully
227      */

228     public boolean process(ElementListener listener) {
229         try {
230             return listener.add(this);
231         }
232         catch(DocumentException de) {
233             return false;
234         }
235     }
236
237     /**
238      * Gets the type of the text element.
239      *
240      * @return a type
241      */

242     public int type() {
243         return Element.CELL;
244     }
245
246     /**
247      * Gets all the chunks in this element.
248      *
249      * @return an <CODE>ArrayList</CODE>
250      */

251     public ArrayList JavaDoc getChunks() {
252         ArrayList JavaDoc tmp = new ArrayList JavaDoc();
253         for (Iterator JavaDoc i = arrayList.iterator(); i.hasNext(); ) {
254             tmp.addAll(((Element) i.next()).getChunks());
255         }
256         return tmp;
257     }
258
259     // Getters and setters
260

261     /**
262      * Gets the horizontal alignment.
263      *
264      * @return a value
265      */

266     public int getHorizontalAlignment() {
267         return horizontalAlignment;
268     }
269
270     /**
271      * Sets the horizontal alignment.
272      * @param value the new value
273      */

274     public void setHorizontalAlignment(int value) {
275         horizontalAlignment = value;
276     }
277
278     /**
279      * Sets the alignment of this cell.
280      * This methods allows you to set the alignment as a String.
281      * @param alignment the new alignment as a <CODE>String</CODE>
282      */

283     public void setHorizontalAlignment(String JavaDoc alignment) {
284         setHorizontalAlignment(ElementTags.alignmentValue(alignment));
285     }
286
287     /**
288      * Gets the vertical alignment.
289      * @return a value
290      */

291     public int getVerticalAlignment() {
292         return verticalAlignment;
293     }
294
295     /**
296      * Sets the vertical alignment.
297      * @param value the new value
298      */

299     public void setVerticalAlignment(int value) {
300         verticalAlignment = value;
301     }
302
303     /**
304      * Sets the alignment of this paragraph.
305      *
306      * @param alignment the new alignment as a <CODE>String</CODE>
307      */

308     public void setVerticalAlignment(String JavaDoc alignment) {
309         setVerticalAlignment(ElementTags.alignmentValue(alignment));
310     }
311
312     /**
313      * Sets the width.
314      *
315      * @param value the new value
316      */

317     public void setWidth(float value) {
318         this.width = value;
319     }
320     
321     /**
322      * Sets the width.
323      * It can be an absolute value "100" or a percentage "20%"
324      *
325      * @param value the new value
326      */

327     public void setWidth(String JavaDoc value) {
328         if (value.endsWith("%")) {
329             value = value.substring(0, value.length() - 1);
330             percentage = true;
331         }
332         width = Integer.parseInt(value);
333     }
334     
335     /**
336      * Gets the width.
337      */

338     public float getWidth() {
339         return width;
340     }
341
342     /**
343      * Gets the width as a String.
344      *
345      * @return a value
346      */

347     public String JavaDoc getWidthAsString() {
348         String JavaDoc w = String.valueOf(width);
349         if (w.endsWith(".0")) w = w.substring(0, w.length() - 2);
350         if (percentage) w += "%";
351         return w;
352     }
353
354     /**
355      * Sets the colspan.
356      *
357      * @param value the new value
358      */

359     public void setColspan(int value) {
360         colspan = value;
361     }
362
363     /**
364      * Gets the colspan.
365      * @return a value
366      */

367     public int getColspan() {
368         return colspan;
369     }
370
371     /**
372      * Sets the rowspan.
373      *
374      * @param value the new value
375      */

376     public void setRowspan(int value) {
377         rowspan = value;
378     }
379
380     /**
381      * Gets the rowspan.
382      * @return a value
383      */

384     public int getRowspan() {
385         return rowspan;
386     }
387
388     /**
389      * Sets the leading.
390      *
391      * @param value the new value
392      */

393     public void setLeading(float value) {
394         leading = value;
395     }
396
397     /**
398      * Gets the leading.
399      *
400      * @return a value
401      */

402     public float getLeading() {
403         if (Float.isNaN(leading)) {
404             return 16;
405         }
406         return leading;
407     }
408
409     /**
410      * Sets header.
411      *
412      * @param value the new value
413      */

414     public void setHeader(boolean value) {
415         header = value;
416     }
417
418     /**
419      * Is this <CODE>Cell</CODE> a header?
420      *
421      * @return a value
422      */

423     public boolean isHeader() {
424         return header;
425     }
426     
427     /**
428      * Setter for {@link #maxLines}
429      * @param value the maximum number of lines
430      */

431     public void setMaxLines(int value) {
432         maxLines = value;
433     }
434     
435     /**
436      * Getter for {@link #maxLines}
437      * @return the maxLines value
438      */

439     public int getMaxLines() {
440         return maxLines;
441     }
442         
443     /**
444      * Setter for {@link #showTruncation}
445      * @param value Can be null for avoiding marking the truncation.
446      */

447     public void setShowTruncation(String JavaDoc value) {
448         showTruncation = value;
449     }
450     
451     /**
452      * Getter for {@link #showTruncation}
453      * @return the showTruncation value
454      */

455     public String JavaDoc getShowTruncation() {
456         return showTruncation;
457     }
458
459     /**
460      * Sets the value of {@link #useAscender}.
461      * @param use use ascender height if true
462      */

463     public void setUseAscender(boolean use) {
464         useAscender = use;
465     }
466
467     /**
468      * Gets the value of {@link #useAscender}
469      * @return useAscender
470      */

471     public boolean isUseAscender() {
472         return useAscender;
473     }
474
475     /**
476      * Sets the value of {@link #useDescender}.
477      * @param use use descender height if true
478      */

479     public void setUseDescender(boolean use) {
480         useDescender = use;
481     }
482
483     /**
484      * gets the value of {@link #useDescender }
485      * @return useDescender
486      */

487     public boolean isUseDescender() {
488         return useDescender;
489     }
490
491     /**
492      * Sets the value of {@link #useBorderPadding}.
493      * @param use adjust layour for borders if true
494      */

495     public void setUseBorderPadding(boolean use) {
496         useBorderPadding = use;
497     }
498
499     /**
500      * Gets the value of {@link #useBorderPadding}.
501      * @return useBorderPadding
502      */

503     public boolean isUseBorderPadding() {
504         return useBorderPadding;
505     }
506
507     /**
508      * Does this <CODE>Cell</CODE> force a group change?
509      *
510      * @return a value
511      */

512     public boolean getGroupChange() {
513         return groupChange;
514     }
515
516     /**
517      * Sets group change.
518      *
519      * @param value the new value
520      */

521     public void setGroupChange(boolean value) {
522         groupChange = value;
523     }
524     
525 // arraylist stuff
526

527     /**
528      * Gets the number of <CODE>Element</CODE>s in the Cell.
529      *
530      * @return a <CODE>size</CODE>.
531      */

532     public int size() {
533         return arrayList.size();
534     }
535
536     /**
537      * Gets an iterator of <CODE>Element</CODE>s.
538      *
539      * @return an <CODE>Iterator</CODE>.
540      */

541     public Iterator JavaDoc getElements() {
542         return arrayList.iterator();
543     }
544     
545     /**
546      * Clears all the <CODE>Element</CODE>s of this <CODE>Cell</CODE>.
547      */

548     public void clear() {
549         arrayList.clear();
550     }
551
552     /**
553      * Checks if the <CODE>Cell</CODE> is empty.
554      *
555      * @return <CODE>false</CODE> if there are non-empty <CODE>Element</CODE>s in the <CODE>Cell</CODE>.
556      */

557     public boolean isEmpty() {
558         switch(size()) {
559             case 0:
560                 return true;
561             case 1:
562                 Element element = (Element) arrayList.get(0);
563                 switch (element.type()) {
564                     case Element.CHUNK:
565                         return ((Chunk) element).isEmpty();
566                     case Element.ANCHOR:
567                     case Element.PHRASE:
568                     case Element.PARAGRAPH:
569                         return ((Phrase) element).isEmpty();
570                     case Element.LIST:
571                         return ((List) element).isEmpty();
572                 }
573             return false;
574             default:
575                 return false;
576         }
577     }
578     
579     /**
580      * Makes sure there is at least 1 object in the Cell.
581      *
582      * Otherwise it might not be shown in the table.
583      */

584     void fill() {
585         if (size() == 0) arrayList.add(new Paragraph(0));
586     }
587
588     /**
589      * Checks if this <CODE>Cell</CODE> is a placeholder for a (nested) table.
590      *
591      * @return true if the only element in this cell is a table
592      */

593     public boolean isTable() {
594         return (size() == 1)
595             && (((Element)arrayList.get(0)).type() == Element.TABLE);
596     }
597     
598     /**
599      * Adds an element to this <CODE>Cell</CODE>.
600      * <P>
601      * Remark: you can't add <CODE>ListItem</CODE>s, <CODE>Row</CODE>s, <CODE>Cell</CODE>s,
602      * <CODE>JPEG</CODE>s, <CODE>GIF</CODE>s or <CODE>PNG</CODE>s to a <CODE>Cell</CODE>.
603      *
604      * @param element The <CODE>Element</CODE> to add
605      * @throws BadElementException if the method was called with a <CODE>ListItem</CODE>, <CODE>Row</CODE> or <CODE>Cell</CODE>
606      */

607     public void addElement(Element element) throws BadElementException {
608         if (isTable()) {
609             Table table = (Table) arrayList.get(0);
610             Cell tmp = new Cell(element);
611             tmp.setBorder(NO_BORDER);
612             tmp.setColspan(table.getColumns());
613             table.addCell(tmp);
614             return;
615         }
616         switch(element.type()) {
617             case Element.LISTITEM:
618             case Element.ROW:
619             case Element.CELL:
620                 throw new BadElementException("You can't add listitems, rows or cells to a cell.");
621             case Element.LIST:
622                 List list = (List)element;
623                 if (Float.isNaN(leading)) {
624                     setLeading(list.getTotalLeading());
625                 }
626                 if (list.isEmpty()) return;
627                 arrayList.add(element);
628                 return;
629             case Element.ANCHOR:
630             case Element.PARAGRAPH:
631             case Element.PHRASE:
632                 Phrase p = (Phrase)element;
633                 if (Float.isNaN(leading)) {
634                     setLeading(p.getLeading());
635                 }
636                 if (p.isEmpty()) return;
637                 arrayList.add(element);
638                 return;
639             case Element.CHUNK:
640                 if (((Chunk) element).isEmpty()) return;
641                 arrayList.add(element);
642                 return;
643             case Element.TABLE:
644                 Table table = new Table(3);
645                 float[] widths = new float[3];
646                 widths[1] = ((Table)element).getWidth();
647                 switch(((Table)element).getAlignment()) {
648                     case Element.ALIGN_LEFT:
649                         widths[0] = 0f;
650                         widths[2] = 100f - widths[1];
651                         break;
652                     case Element.ALIGN_CENTER:
653                         widths[0] = (100f - widths[1]) / 2f;
654                         widths[2] = widths[0];
655                         break;
656                     case Element.ALIGN_RIGHT:
657                         widths[0] = 100f - widths[1];
658                         widths[2] = 0f;
659                 }
660                 table.setWidths(widths);
661                 Cell tmp;
662                 if (arrayList.isEmpty()) {
663                     table.addCell(getDummyCell());
664                 }
665                 else {
666                     tmp = new Cell();
667                     tmp.setBorder(NO_BORDER);
668                     tmp.setColspan(3);
669                     for (Iterator JavaDoc i = arrayList.iterator(); i.hasNext(); ) {
670                         tmp.add(i.next());
671                     }
672                     table.addCell(tmp);
673                 }
674                 tmp = new Cell();
675                 tmp.setBorder(NO_BORDER);
676                 table.addCell(tmp);
677                 table.insertTable((Table)element);
678                 tmp = new Cell();
679                 tmp.setBorder(NO_BORDER);
680                 table.addCell(tmp);
681                 table.addCell(getDummyCell());
682                 clear();
683                 arrayList.add(table);
684                 return;
685             default:
686                 arrayList.add(element);
687         }
688     }
689
690     /**
691      * Add an <CODE>Object</CODE> to this cell.
692      *
693      * @param o the object to add
694      * @return always <CODE>true</CODE>
695      */

696     public boolean add(Object JavaDoc o) {
697         try {
698             this.addElement((Element) o);
699             return true;
700         }
701         catch(ClassCastException JavaDoc cce) {
702             throw new ClassCastException JavaDoc("You can only add objects that implement the Element interface.");
703         }
704         catch(BadElementException bee) {
705             throw new ClassCastException JavaDoc(bee.getMessage());
706         }
707     }
708
709     // helper methods
710

711     /**
712      * Get dummy cell used when merging inner tables.
713      * @return a cell with colspan 3 and no border
714      */

715     private static Cell getDummyCell() {
716         Cell cell = new Cell(true);
717         cell.setColspan(3);
718         cell.setBorder(NO_BORDER);
719         return cell;
720     }
721
722     /**
723      * Creates a PdfPCell based on this Cell object.
724      * @return a PdfPCell
725      * @throws BadElementException
726      */

727     public PdfPCell createPdfPCell() throws BadElementException {
728         if (rowspan > 1) throw new BadElementException("PdfPCells can't have a rowspan > 1");
729         if (isTable()) return new PdfPCell(((Table)arrayList.get(0)).createPdfPTable());
730         PdfPCell cell = new PdfPCell();
731         cell.setVerticalAlignment(verticalAlignment);
732         cell.setHorizontalAlignment(horizontalAlignment);
733         cell.setColspan(colspan);
734         cell.setUseBorderPadding(useBorderPadding);
735         cell.setUseDescender(useDescender);
736         cell.setLeading(getLeading(), 0);
737         cell.cloneNonPositionParameters(this);
738         cell.setNoWrap(getMaxLines() == 1);
739         for (Iterator JavaDoc i = getElements(); i.hasNext(); ) {
740             Element e = (Element)i.next();
741             if (e.type() == Element.PHRASE || e.type() == Element.PARAGRAPH) {
742                 Paragraph p = new Paragraph((Phrase)e);
743                 p.setAlignment(horizontalAlignment);
744                 e = p;
745             }
746             cell.addElement(e);
747         }
748         return cell;
749     }
750
751     // unsupported Rectangle methods
752

753     /**
754      * This method throws an <CODE>UnsupportedOperationException</CODE>.
755      * @return NA
756      * @deprecated Use {@link #getTop()} instead
757      */

758     public float top() {
759         return getTop();
760     }
761
762     /**
763      * This method throws an <CODE>UnsupportedOperationException</CODE>.
764      * @return NA
765      */

766     public float getTop() {
767         throw new UnsupportedOperationException JavaDoc("Dimensions of a Cell can't be calculated. See the FAQ.");
768     }
769
770     /**
771      * This method throws an <CODE>UnsupportedOperationException</CODE>.
772      * @return NA
773      * @deprecated Use {@link #getBottom()} instead
774      */

775     public float bottom() {
776         return getBottom();
777     }
778
779     /**
780      * This method throws an <CODE>UnsupportedOperationException</CODE>.
781      * @return NA
782      */

783     public float getBottom() {
784         throw new UnsupportedOperationException JavaDoc("Dimensions of a Cell can't be calculated. See the FAQ.");
785     }
786
787     /**
788      * This method throws an <CODE>UnsupportedOperationException</CODE>.
789      * @return NA
790      * @deprecated Use {@link #getLeft()} instead
791      */

792     public float left() {
793         return getLeft();
794     }
795
796     /**
797      * This method throws an <CODE>UnsupportedOperationException</CODE>.
798      * @return NA
799      */

800     public float getLeft() {
801         throw new UnsupportedOperationException JavaDoc("Dimensions of a Cell can't be calculated. See the FAQ.");
802     }
803
804     /**
805      * This method throws an <CODE>UnsupportedOperationException</CODE>.
806      * @return NA
807      * @deprecated Use {@link #getRight()} instead
808      */

809     public float right() {
810         return getRight();
811     }
812
813     /**
814      * This method throws an <CODE>UnsupportedOperationException</CODE>.
815      * @return NA
816      */

817     public float getRight() {
818         throw new UnsupportedOperationException JavaDoc("Dimensions of a Cell can't be calculated. See the FAQ.");
819     }
820
821     /**
822      * This method throws an <CODE>UnsupportedOperationException</CODE>.
823      * @param margin
824      * @return NA
825      */

826     public float top(int margin) {
827         throw new UnsupportedOperationException JavaDoc("Dimensions of a Cell can't be calculated. See the FAQ.");
828     }
829
830     /**
831      * This method throws an <CODE>UnsupportedOperationException</CODE>.
832      * @param margin
833      * @return NA
834      */

835     public float bottom(int margin) {
836         throw new UnsupportedOperationException JavaDoc("Dimensions of a Cell can't be calculated. See the FAQ.");
837     }
838
839     /**
840      * This method throws an <CODE>UnsupportedOperationException</CODE>.
841      * @param margin
842      * @return NA
843      */

844     public float left(int margin) {
845         throw new UnsupportedOperationException JavaDoc("Dimensions of a Cell can't be calculated. See the FAQ.");
846     }
847
848     /**
849      * This method throws an <CODE>UnsupportedOperationException</CODE>.
850      * @param margin NA
851      * @return NA
852      */

853     public float right(int margin) {
854         throw new UnsupportedOperationException JavaDoc("Dimensions of a Cell can't be calculated. See the FAQ.");
855     }
856
857     /**
858      * This method throws an <CODE>UnsupportedOperationException</CODE>.
859      * @param value NA
860      */

861     public void setTop(int value) {
862         throw new UnsupportedOperationException JavaDoc("Dimensions of a Cell are attributed automagically. See the FAQ.");
863     }
864
865     /**
866      * This method throws an <CODE>UnsupportedOperationException</CODE>.
867      * @param value NA
868      */

869     public void setBottom(int value) {
870         throw new UnsupportedOperationException JavaDoc("Dimensions of a Cell are attributed automagically. See the FAQ.");
871     }
872
873     /**
874      * This method throws an <CODE>UnsupportedOperationException</CODE>.
875      * @param value NA
876      */

877     public void setLeft(int value) {
878         throw new UnsupportedOperationException JavaDoc("Dimensions of a Cell are attributed automagically. See the FAQ.");
879     }
880
881     /**
882      * This method throws an <CODE>UnsupportedOperationException</CODE>.
883      * @param value NA
884      */

885     public void setRight(int value) {
886         throw new UnsupportedOperationException JavaDoc("Dimensions of a Cell are attributed automagically. See the FAQ.");
887     }
888     
889 // deprecated stuff
890

891     /**
892      * Returns a <CODE>Cell</CODE> that has been constructed taking in account
893      * the value of some <VAR>attributes</VAR>.
894      *
895      * @param attributes Some attributes
896      * @deprecated use ElementFactory.getCell(attributes)
897      */

898     public Cell(java.util.Properties JavaDoc attributes) {
899         this();
900         Cell tmp = com.lowagie.text.factories.ElementFactory.getCell(attributes);
901         this.cloneNonPositionParameters(tmp);
902         this.setHorizontalAlignment(tmp.getHorizontalAlignment());
903         this.setVerticalAlignment(tmp.getVerticalAlignment());
904         this.setWidth(tmp.getWidth());
905         this.setColspan(tmp.getColspan());
906         this.setRowspan(tmp.getRowspan());
907         this.setLeading(tmp.getLeading());
908         this.setHeader(tmp.isHeader());
909         this.setMaxLines(tmp.getMaxLines());
910     }
911     
912     /**
913      * Gets the horizontal alignment.
914      * @return a value
915      * @deprecated Use {@link #getHorizontalAlignment()} instead
916      */

917     public int horizontalAlignment() {
918         return getHorizontalAlignment();
919     }
920
921     /**
922      * Gets the vertical alignment.
923      * @return a value
924      * @deprecated Use {@link #getVerticalAlignment()} instead
925      */

926     public int verticalAlignment() {
927         return getVerticalAlignment();
928     }
929
930     /**
931      * Gets the width.
932      *
933      * @return a value
934      * @deprecated Use {@link #getWidthAsString()} instead
935      */

936     public String JavaDoc cellWidth() {
937         return getWidthAsString();
938     }
939     
940     /**
941      * Gets the colspan.
942      * @return a value
943      * @deprecated Use {@link #getColspan()} instead
944      */

945     public int colspan() {
946         return getColspan();
947     }
948
949     /**
950      * Gets the rowspan.
951      * @return a value
952      * @deprecated Use {@link #getRowspan()} instead
953      */

954     public int rowspan() {
955         return getRowspan();
956     }
957     
958     /**
959      * Gets the leading.
960      *
961      * @return a value
962      * @deprecated Use {@link #getLeading()} instead
963      */

964     public float leading() {
965         return getLeading();
966     }
967
968     /**
969      * Is this <CODE>Cell</CODE> a header?
970      *
971      * @return a value
972      * @deprecated Use {@link #isHeader()} instead
973      */

974     public boolean header() {
975         return isHeader();
976     }
977
978     /**
979      * Set nowrap.
980      *
981      * @param value the new value
982      * @deprecated Use setMaxLines(1) instead
983      */

984     public void setNoWrap(boolean value) {
985         if (value)
986             maxLines = 1;
987         else
988             maxLines = Integer.MAX_VALUE;
989     }
990
991     /**
992      * Get nowrap.
993      *
994      * @return a value
995      * @deprecated Use getMaxLines() == 1 instead
996      */

997     public boolean noWrap() {
998         return maxLines == 1;
999     }
1000}
1001
Popular Tags