Source Code Cross Referenced for DataTableCellRenderer.java in  » Report » jmagallanes-1.0 » com » calipso » reportgenerator » userinterface » 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 » Report » jmagallanes 1.0 » com.calipso.reportgenerator.userinterface 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.calipso.reportgenerator.userinterface;
002:
003:        import com.calipso.reportgenerator.common.ReportResult;
004:        import com.calipso.reportgenerator.common.QueryMetric;
005:        import com.calipso.reportgenerator.common.ReportMetricSpec;
006:        import com.calipso.reportgenerator.reportcalculator.SharedFloat;
007:        import javax.swing.table.DefaultTableCellRenderer;
008:        import javax.swing.*;
009:        import java.awt.*;
010:        import java.text.NumberFormat;
011:        import java.text.DecimalFormat;
012:
013:        /**
014:         * Genera el Render para dibujar la tabla a partir de la informacion obtenida del colorConditionManager
015:         */
016:        public class DataTableCellRenderer extends DefaultTableCellRenderer {
017:            private ColorConditionManager conditionManager;
018:            private ReportResult reportResult;
019:            private Color defaultColor;
020:
021:            /**
022:             * Crea un Objeto DataTableCellRender
023:             * @param conditionManager
024:             * @param reportResult
025:             * @param background
026:             */
027:            public DataTableCellRenderer(
028:                    ColorConditionManager conditionManager,
029:                    ReportResult reportResult, Color background) {
030:                this .conditionManager = conditionManager;
031:                this .reportResult = reportResult;
032:                this .defaultColor = background;
033:            }
034:
035:            /**
036:             * Retorna el componente para la JTable table para una  columna fila determinada
037:             * @param table
038:             * @param value
039:             * @param isSelected
040:             * @param hasFocus
041:             * @param row
042:             * @param column
043:             * @return
044:             */
045:            public Component getTableCellRendererComponent(JTable table,
046:                    Object value, boolean isSelected, boolean hasFocus,
047:                    int row, int column) {
048:                MetricInfo metricInfo = getMetricInfo(column);
049:                String formattedValue = metricInfo
050:                        .getFormattedValue((SharedFloat) value);
051:                //    String formattedValue = value.toString();
052:                Component comp = super .getTableCellRendererComponent(table,
053:                        formattedValue, isSelected, hasFocus, row, column);
054:                if (!isSelected) {
055:                    Color color = getColorFromValue(value, metricInfo.getName());
056:                    comp.setBackground(color);
057:                }
058:                return comp;
059:            }
060:
061:            /**
062:             *  Retorna un MetricInfo para una columna determinada
063:             * @param column
064:             * @return
065:             */
066:            private MetricInfo getMetricInfo(int column) {
067:                ReportMetricSpec reportMetricSpec;
068:                int metricIndex = column % getMetricCount();
069:                QueryMetric metric = (QueryMetric) reportResult
070:                        .getReportQuery().getVisibleMetrics().get(metricIndex);
071:                reportMetricSpec = reportResult.getMetricFromName(metric
072:                        .getName());
073:                return new MetricInfo(metric.getName());
074:            }
075:
076:            /**
077:             * Retorna la cantidad de metricas
078:             * @return
079:             */
080:            private int getMetricCount() {
081:                return reportResult.getReportQuery().getVisibleMetrics().size();
082:            }
083:
084:            /**
085:             *Retorna el color con que se pintará el componente
086:             * @param value
087:             * @param metricName
088:             * @return
089:             */
090:            private Color getColorFromValue(Object value, String metricName) {
091:                if (conditionManager != null) {
092:                    //conditionManager.getColor(value, metricName, defaultColor);
093:                    ColorCondition condition = conditionManager.getColor(value,
094:                            metricName, defaultColor);
095:                    if (condition != null
096:                            && condition.getMetricState().getVisible()) {
097:                        return condition.getColor();
098:                    }
099:                }
100:                return Color.WHITE;
101:            }
102:
103:            /**
104:             * Setea el ColorConditionManager
105:             * @param colorConditionManager
106:             */
107:            public void setColorConditionManager(
108:                    ColorConditionManager colorConditionManager) {
109:                this .conditionManager = colorConditionManager;
110:            }
111:
112:            /**
113:             * Setea el ReportResult
114:             * @param reportResult
115:             */
116:            public void setReportResult(ReportResult reportResult) {
117:                this .reportResult = reportResult;
118:            }
119:
120:            /**
121:             * Clase para identificar las propiedades de las metricas
122:             */
123:            private class MetricInfo {
124:
125:                private String name;
126:
127:                /**
128:                 * Crea un objeto MetricInfo
129:                 * @param name
130:                 */
131:                public MetricInfo(String name) {
132:                    this .name = name;
133:                }
134:
135:                /**
136:                 * Retorna el nombre de la metrica
137:                 * @return
138:                 */
139:                public String getName() {
140:                    return name;
141:                }
142:
143:                /**
144:                 * Setea el nombre de la metrica
145:                 * @param name
146:                 */
147:                public void setName(String name) {
148:                    this .name = name;
149:                }
150:
151:                public String getFormattedValue(SharedFloat value) {
152:                    //return NumberFormat.getNumberInstance(com.calipso.reportgenerator.common.LanguageTraslator.getLocale()).format(value.floatValue());
153:
154:                    if ((value == null)
155:                            || ((value.getValue().equals(new Float(Float.NaN))))
156:                            || ((value.getValue().equals(new Float(
157:                                    Float.NEGATIVE_INFINITY))))
158:                            || ((value.getValue().equals(new Float(
159:                                    Float.POSITIVE_INFINITY))))) {
160:                        return "";
161:                    } else {
162:                        return new DecimalFormat("###,###,###,####,##0.00")
163:                                .format(value.floatValue());
164:
165:                    }
166:                }
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.