Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/virtuosotechnologies/asaph/standardgui/BodyEditorSize.java


1   /*
2   ================================================================================
3   
4     FILE:  BodyEditorSize.java
5     
6     PROJECT:
7     
8       Virtuoso Utilities
9     
10    CONTENTS:
11    
12      A simple object that contains the size and position of an subeditor
13      in the song body editor
14    
15    PROGRAMMERS:
16    
17      Daniel Azuma (DA)  <dazuma@kagi.com>
18    
19    COPYRIGHT:
20    
21      Copyright (C) 2003  Daniel Azuma  (dazuma@kagi.com)
22      
23      This program is free software; you can redistribute it and/or
24      modify it under the terms of the GNU General Public License as
25      published by the Free Software Foundation; either version 2
26      of the License, or (at your option) any later version.
27      
28      This program is distributed in the hope that it will be useful,
29      but WITHOUT ANY WARRANTY; without even the implied warranty of
30      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31      GNU General Public License for more details.
32      
33      You should have received a copy of the GNU General Public
34      License along with this program; if not, write to
35        Free Software Foundation, Inc.
36        59 Temple Place, Suite 330
37        Boston, MA 02111-1307 USA
38  
39  ================================================================================
40  */
41  
42  
43  package com.virtuosotechnologies.asaph.standardgui;
44  
45  
46  /**
47   * A simple object that contains the size and position of an subeditor
48   * in the song body editor
49   */
50  /*package*/ class BodyEditorSize
51  {
52    private float left_;
53    private float right_;
54    private float bottom_;
55    
56    
57    /**
58     * Constructor
59     */
60    /*package*/ BodyEditorSize()
61    {
62      left_ = 0;
63      right_ = 0;
64      bottom_ = 0;
65    }
66    
67    
68    /**
69     * Constructor
70     */
71    /*package*/ BodyEditorSize(
72      float left,
73      float right,
74      float bottom)
75    {
76      left_ = left;
77      right_ = right;
78      bottom_ = bottom;
79    }
80    
81    
82    /**
83     * Copy constructor
84     */
85    /*package*/ BodyEditorSize(
86      BodyEditorSize orig)
87    {
88      left_ = orig.left_;
89      right_ = orig.right_;
90      bottom_ = orig.bottom_;
91    }
92    
93    
94    /**
95     * "Adds" a size to this one. The returned size consists of the
96     * max of left/right sizes, and with the bottom size added.
97     */
98    /*package*/ BodyEditorSize addSize(
99      float left,
100     float right,
101     float bottom)
102   {
103     return new BodyEditorSize(
104       Math.min(left, left_),
105       Math.max(right, right_),
106       bottom_ + bottom);
107   }
108   
109   
110   /**
111    * Returns the left position.
112    */
113   /*package*/ float getLeft()
114   {
115     return left_;
116   }
117   
118   
119   /**
120    * Returns the right position.
121    */
122   /*package*/ float getRight()
123   {
124     return right_;
125   }
126   
127   
128   /**
129    * Returns the bottom position (height).
130    */
131   /*package*/ float getBottom()
132   {
133     return bottom_;
134   }
135   
136   
137   /**
138    * Checks whether two dimension objects have equal values.
139    */
140   public boolean equals(
141     Object obj)
142   {
143     if (obj instanceof BodyEditorSize)
144     {
145       BodyEditorSize bes = (BodyEditorSize)obj;
146       return bes.left_ == left_ &&
147         bes.right_ == right_ &&
148         bes.bottom_ == bottom_;
149     }
150     return false;
151   }
152   
153   
154   /**
155    * Returns the hash code for this <code>FloatDimension</code>.
156    *
157    * @return a hash code for this <code>FloatDimension</code>
158    */
159   public int hashCode()
160   {
161     return Float.floatToRawIntBits(left_) +
162       Float.floatToRawIntBits(right_) +
163       Float.floatToRawIntBits(bottom_);
164   }
165   
166   
167   /**
168    * Returns a string representation of the values of this 
169    * <code>FloatDimension</code> object's <code>height</code> and 
170    * <code>width</code> fields. This method is intended to be used only 
171    * for debugging purposes, and the content and format of the returned 
172    * string may vary between implementations. The returned string may be 
173    * empty but may not be <code>null</code>.
174    * 
175    * @return a string representation of this <code>Dimension</code> 
176    *     object
177    */
178   public String toString()
179   {
180     return "BodyEditorSize[left="+left_+",right="+right_+",bottom="+bottom_+"]";
181   }
182 }