Source Code Cross Referenced for MinOptMax.java in  » Graphic-Library » fop » org » apache » fop » traits » 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 » Graphic Library » fop » org.apache.fop.traits 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        /* $Id: MinOptMax.java 426576 2006-07-28 15:44:37Z jeremias $ */
019:
020:        package org.apache.fop.traits;
021:
022:        /**
023:         * This class holds the resolved (as mpoints) form of a LengthRange or
024:         * Space type Property value.
025:         * MinOptMax values are used during layout calculations. The instance
026:         * variables are package visible.
027:         */
028:        public class MinOptMax implements  java.io.Serializable, Cloneable {
029:
030:            /** Publicly visible min(imum), opt(imum) and max(imum) values.*/
031:            public int min;
032:            public int opt;
033:            public int max;
034:
035:            /**
036:             * New min/opt/max with zero values.
037:             */
038:            public MinOptMax() {
039:                this (0);
040:            }
041:
042:            /**
043:             * New min/opt/max with one fixed value.
044:             *
045:             * @param val the value for min, opt and max
046:             */
047:            public MinOptMax(int val) {
048:                this (val, val, val);
049:            }
050:
051:            /**
052:             * New min/opt/max with the three values.
053:             *
054:             * @param min the minimum value
055:             * @param opt the optimum value
056:             * @param max the maximum value
057:             */
058:            public MinOptMax(int min, int opt, int max) {
059:                // TODO: assert min<=opt<=max
060:                this .min = min;
061:                this .opt = opt;
062:                this .max = max;
063:            }
064:
065:            /**
066:             * Copy constructor.
067:             *
068:             * @param op the MinOptMax object to copy
069:             */
070:            public MinOptMax(MinOptMax op) {
071:                this .min = op.min;
072:                this .opt = op.opt;
073:                this .max = op.max;
074:            }
075:
076:            // TODO: remove this.
077:            /**
078:             * @see java.lang.Object#clone()
079:             */
080:            public Object clone() {
081:                try {
082:                    return super .clone();
083:                } catch (CloneNotSupportedException ex) {
084:                    // SHOULD NEVER OCCUR - all members are primitive types!
085:                    return null;
086:                }
087:            }
088:
089:            /**
090:             * Subtracts one MinOptMax instance from another returning a new one.
091:             * @param op1 first instance to subtract from
092:             * @param op2 second instance
093:             * @return MinOptMax new instance
094:             */
095:            public static MinOptMax subtract(MinOptMax op1, MinOptMax op2) {
096:                return new MinOptMax(op1.min - op2.max, op1.opt - op2.opt,
097:                        op1.max - op2.min);
098:            }
099:
100:            /**
101:             * Adds one MinOptMax instance to another returning a new one.
102:             * @param op1 first instance
103:             * @param op2 second instance
104:             * @return MinOptMax new instance
105:             */
106:            public static MinOptMax add(MinOptMax op1, MinOptMax op2) {
107:                return new MinOptMax(op1.min + op2.min, op1.opt + op2.opt,
108:                        op1.max + op2.max);
109:            }
110:
111:            /**
112:             * Multiplies a MinOptMax instance with a factor returning a new instance.
113:             * @param op1 MinOptMax instance
114:             * @param mult multiplier
115:             * @return MinOptMax new instance
116:             */
117:            public static MinOptMax multiply(MinOptMax op1, double mult) {
118:                // TODO: assert mult>0
119:                return new MinOptMax((int) (op1.min * mult),
120:                        (int) (op1.opt * mult), (int) (op1.max * mult));
121:            }
122:
123:            /**
124:             * Adds another MinOptMax instance to this one.
125:             * @param op the other instance
126:             */
127:            public void add(MinOptMax op) {
128:                min += op.min;
129:                opt += op.opt;
130:                max += op.max;
131:            }
132:
133:            /**
134:             * Adds min, opt and max to their counterpart components.
135:             * @param min the value to add to the minimum value
136:             * @param opt the value to add to the optimum value
137:             * @param max the value to add to the maximum value
138:             */
139:            public void add(int min, int opt, int max) {
140:                this .min += min;
141:                this .opt += opt;
142:                this .max += max;
143:                // TODO: assert min<=opt<=max
144:            }
145:
146:            /**
147:             * Adds a length to all components.
148:             * @param len the length to add
149:             */
150:            public void add(int len) {
151:                this .min += len;
152:                this .opt += len;
153:                this .max += len;
154:            }
155:
156:            /**
157:             * Subtracts another MinOptMax instance from this one.
158:             * @param op the other instance
159:             */
160:            public void subtract(MinOptMax op) {
161:                min -= op.max;
162:                opt -= op.opt;
163:                max -= op.min;
164:            }
165:
166:            /** @return true if this instance represents a zero-width length (min=opt=max=0) */
167:            public boolean isNonZero() {
168:                return (min != 0 || max != 0);
169:            }
170:
171:            /** @return true if this instance allows for shrinking or stretching */
172:            public boolean isElastic() {
173:                return (min != opt || opt != max);
174:            }
175:
176:            /** @see java.lang.Object#toString() */
177:            public String toString() {
178:                StringBuffer sb = new StringBuffer();
179:                sb.append("MinOptMax[min=");
180:                if (min != opt) {
181:                    sb.append(min).append("; ");
182:                }
183:                sb.append("opt=");
184:                if (opt != max) {
185:                    sb.append(opt).append("; ");
186:                }
187:                sb.append("max=").append(max);
188:                sb.append("]");
189:                return sb.toString();
190:            }
191:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.