KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nwalsh > xalan > FormatDingbatCallout


1 package com.nwalsh.xalan;
2
3 import org.xml.sax.helpers.AttributesImpl JavaDoc;
4 import org.xml.sax.SAXException JavaDoc;
5 import org.w3c.dom.*;
6 import org.apache.xml.utils.DOMBuilder;
7 import com.nwalsh.xalan.Callout;
8 import org.apache.xml.utils.AttList;
9
10 /**
11  * <p>Utility class for the Verbatim extension (ignore this).</p>
12  *
13  * <p>$Id: FormatDingbatCallout.java,v 1.1 2001/07/07 22:11:12 nwalsh Exp $</p>
14  *
15  * <p>Copyright (C) 2000, 2001 Norman Walsh.</p>
16  *
17  * <p><b>Change Log:</b></p>
18  * <dl>
19  * <dt>1.0</dt>
20  * <dd><p>Initial release.</p></dd>
21  * </dl>
22  *
23  * @author Norman Walsh
24  * <a HREF="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
25  *
26  * @see Verbatim
27  *
28  * @version $Id: FormatDingbatCallout.java,v 1.1 2001/07/07 22:11:12 nwalsh Exp $
29  **/

30
31 public class FormatDingbatCallout extends FormatCallout {
32   int graphicsMax = 0;
33
34   public FormatDingbatCallout(int max, boolean fo) {
35     graphicsMax = max;
36     stylesheetFO = fo;
37   }
38
39   public void formatCallout(DOMBuilder rtf,
40                 Callout callout) {
41     Element area = callout.getArea();
42     int num = callout.getCallout();
43     String JavaDoc label = areaLabel(area);
44
45     try {
46       if (label == null && num <= graphicsMax) {
47     AttributesImpl JavaDoc imgAttr = new AttributesImpl JavaDoc();
48     String JavaDoc ns = "";
49     String JavaDoc prefix = "";
50     String JavaDoc imgName = "";
51
52     if (stylesheetFO) {
53       ns = foURI;
54       prefix = "fo:"; // FIXME: this could be a problem...
55
imgName = "inline";
56       imgAttr.addAttribute("", "font-family", "font-family", "CDATA",
57                    "ZapfDingbats");
58     } else {
59       ns = "";
60       prefix = "";
61       imgName = "font";
62       imgAttr.addAttribute("", "face", "face", "CDATA",
63                    "ZapfDingbats");
64     }
65
66     startSpan(rtf);
67     rtf.startElement(ns, imgName, prefix+imgName, imgAttr);
68
69     char chars[] = new char[1];
70     chars[0] = (char) (0x2775 + num);
71     rtf.characters(chars, 0, 1);
72
73     rtf.endElement(ns, imgName, prefix+imgName);
74     endSpan(rtf);
75       } else {
76     formatTextCallout(rtf, callout);
77       }
78     } catch (SAXException JavaDoc e) {
79       System.out.println("SAX Exception in graphics formatCallout");
80     }
81   }
82 }
83
Popular Tags