Source Code Cross Referenced for ImageMapUtilities.java in  » Chart » jfreechart » org » jfree » chart » imagemap » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Chart » jfreechart » org.jfree.chart.imagemap 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ===========================================================
002:         * JFreeChart : a free chart library for the Java(tm) platform
003:         * ===========================================================
004:         *
005:         * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
006:         *
007:         * Project Info:  http://www.jfree.org/jfreechart/index.html
008:         *
009:         * This library is free software; you can redistribute it and/or modify it 
010:         * under the terms of the GNU Lesser General Public License as published by 
011:         * the Free Software Foundation; either version 2.1 of the License, or 
012:         * (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful, but 
015:         * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
016:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
017:         * License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library; if not, write to the Free Software
021:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
022:         * USA.  
023:         *
024:         * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
025:         * in the United States and other countries.]
026:         *
027:         * ----------------------
028:         * ImageMapUtilities.java
029:         * ----------------------
030:         * (C) Copyright 2004-2007, by Richard Atkinson and Contributors.
031:         *
032:         * Original Author:  Richard Atkinson;
033:         * Contributor(s):   David Gilbert (for Object Refinery Limited);
034:         *
035:         * $Id: ImageMapUtilities.java,v 1.3.2.3 2007/02/06 11:28:53 mungady Exp $
036:         *
037:         * Changes
038:         * -------
039:         * 02-Aug-2004 : Initial version (RA);
040:         * 13-Jan-2005 : Renamed ImageMapUtilities (DG);
041:         * 19-Jan-2005 : Reversed order of tags for chart entities to get correct
042:         *               layering (DG);
043:         * ------------- JFREECHART 1.0.x ---------------------------------------------
044:         * 06-Feb-2006 : API doc updates (DG);
045:         * 
046:         */
047:
048:        package org.jfree.chart.imagemap;
049:
050:        import java.io.IOException;
051:        import java.io.PrintWriter;
052:
053:        import org.jfree.chart.ChartRenderingInfo;
054:        import org.jfree.chart.entity.ChartEntity;
055:        import org.jfree.chart.entity.EntityCollection;
056:        import org.jfree.util.StringUtils;
057:
058:        /**
059:         * Collection of utility methods related to producing image maps.  
060:         * Functionality was originally in {@link org.jfree.chart.ChartUtilities}.
061:         */
062:        public class ImageMapUtilities {
063:
064:            /**
065:             * Writes an image map to an output stream.
066:             *
067:             * @param writer  the writer (<code>null</code> not permitted).
068:             * @param name  the map name (<code>null</code> not permitted).
069:             * @param info  the chart rendering info (<code>null</code> not permitted).
070:             *
071:             * @throws java.io.IOException if there are any I/O errors.
072:             */
073:            public static void writeImageMap(PrintWriter writer, String name,
074:                    ChartRenderingInfo info) throws IOException {
075:
076:                // defer argument checking...
077:                ImageMapUtilities.writeImageMap(writer, name, info,
078:                        new StandardToolTipTagFragmentGenerator(),
079:                        new StandardURLTagFragmentGenerator());
080:
081:            }
082:
083:            /**
084:             * Writes an image map to an output stream.
085:             *
086:             * @param writer  the writer (<code>null</code> not permitted).
087:             * @param name  the map name (<code>null</code> not permitted).
088:             * @param info  the chart rendering info (<code>null</code> not permitted).
089:             * @param useOverLibForToolTips  whether to use OverLIB for tooltips
090:             *                               (http://www.bosrup.com/web/overlib/).
091:             *
092:             * @throws java.io.IOException if there are any I/O errors.
093:             */
094:            public static void writeImageMap(PrintWriter writer, String name,
095:                    ChartRenderingInfo info, boolean useOverLibForToolTips)
096:                    throws IOException {
097:
098:                ToolTipTagFragmentGenerator toolTipTagFragmentGenerator = null;
099:                if (useOverLibForToolTips) {
100:                    toolTipTagFragmentGenerator = new OverLIBToolTipTagFragmentGenerator();
101:                } else {
102:                    toolTipTagFragmentGenerator = new StandardToolTipTagFragmentGenerator();
103:                }
104:                ImageMapUtilities.writeImageMap(writer, name, info,
105:                        toolTipTagFragmentGenerator,
106:                        new StandardURLTagFragmentGenerator());
107:
108:            }
109:
110:            /**
111:             * Writes an image map to an output stream.
112:             *
113:             * @param writer  the writer (<code>null</code> not permitted).
114:             * @param name  the map name (<code>null</code> not permitted).
115:             * @param info  the chart rendering info (<code>null</code> not permitted).
116:             * @param toolTipTagFragmentGenerator  a generator for the HTML fragment
117:             *     that will contain the tooltip text (<code>null</code> not permitted 
118:             *     if <code>info</code> contains tooltip information).
119:             * @param urlTagFragmentGenerator  a generator for the HTML fragment that
120:             *     will contain the URL reference (<code>null</code> not permitted if 
121:             *     <code>info</code> contains URLs).
122:             *
123:             * @throws java.io.IOException if there are any I/O errors.
124:             */
125:            public static void writeImageMap(PrintWriter writer, String name,
126:                    ChartRenderingInfo info,
127:                    ToolTipTagFragmentGenerator toolTipTagFragmentGenerator,
128:                    URLTagFragmentGenerator urlTagFragmentGenerator)
129:                    throws IOException {
130:
131:                writer.println(ImageMapUtilities.getImageMap(name, info,
132:                        toolTipTagFragmentGenerator, urlTagFragmentGenerator));
133:            }
134:
135:            /**
136:             * Creates an image map element that complies with the XHTML 1.0
137:             * specification.
138:             *
139:             * @param name  the map name (<code>null</code> not permitted).
140:             * @param info  the chart rendering info (<code>null</code> not permitted).
141:             *
142:             * @return The map element.
143:             */
144:            public static String getImageMap(String name,
145:                    ChartRenderingInfo info) {
146:                return ImageMapUtilities.getImageMap(name, info,
147:                        new StandardToolTipTagFragmentGenerator(),
148:                        new StandardURLTagFragmentGenerator());
149:            }
150:
151:            /**
152:             * Creates an image map element that complies with the XHTML 1.0
153:             * specification.
154:             *
155:             * @param name  the map name (<code>null</code> not permitted).
156:             * @param info  the chart rendering info (<code>null</code> not permitted).
157:             * @param toolTipTagFragmentGenerator  a generator for the HTML fragment
158:             *     that will contain the tooltip text (<code>null</code> not permitted 
159:             *     if <code>info</code> contains tooltip information).
160:             * @param urlTagFragmentGenerator  a generator for the HTML fragment that
161:             *     will contain the URL reference (<code>null</code> not permitted if 
162:             *     <code>info</code> contains URLs).
163:             *
164:             * @return The map tag.
165:             */
166:            public static String getImageMap(String name,
167:                    ChartRenderingInfo info,
168:                    ToolTipTagFragmentGenerator toolTipTagFragmentGenerator,
169:                    URLTagFragmentGenerator urlTagFragmentGenerator) {
170:
171:                StringBuffer sb = new StringBuffer();
172:                sb.append("<map id=\"" + name + "\" name=\"" + name + "\">");
173:                sb.append(StringUtils.getLineSeparator());
174:                EntityCollection entities = info.getEntityCollection();
175:                if (entities != null) {
176:                    int count = entities.getEntityCount();
177:                    for (int i = count - 1; i >= 0; i--) {
178:                        ChartEntity entity = entities.getEntity(i);
179:                        if (entity.getToolTipText() != null
180:                                || entity.getURLText() != null) {
181:                            String area = entity.getImageMapAreaTag(
182:                                    toolTipTagFragmentGenerator,
183:                                    urlTagFragmentGenerator);
184:                            if (area.length() > 0) {
185:                                sb.append(area);
186:                                sb.append(StringUtils.getLineSeparator());
187:                            }
188:                        }
189:                    }
190:                }
191:                sb.append("</map>");
192:                return sb.toString();
193:
194:            }
195:
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.