1   /*
2    * Created by IntelliJ IDEA.
3    * User: owen
4    * Date: Jan 30, 2003
5    * Time: 10:29:22 AM
6    * CVS Revision: $Revision: 1.7 $
7    * Last CVS Commit: $Date: 2004/01/22 01:15:21 $
8    * Author of last CVS Commit: $Author: dloeng $
9    * To change this template use Options | File Templates.
10   */
11  package com.atlassian.core.bean;
12  
13  public class MathBean
14  {
15      public int getPercentageWidth(int numberOfColumns, int column)
16      {
17          int columnWidth = divide(100, numberOfColumns);
18          if (numberOfColumns == column)
19              return subtract(100, multiply(columnWidth, subtract(numberOfColumns, 1)));
20          else
21              return columnWidth;
22      }
23  
24      public long getPercentage(double portion, double total)
25      {
26  
27          long columnWidth = Math.round((portion / total) * 100);
28          return columnWidth;
29      }
30  
31      public long getPercentage(long portion, long total)
32      {
33          long columnWidth = Math.round(((double) portion / (double) total) * 100);
34          return columnWidth;
35      }
36  
37      public int add(int i1, int i2)
38      {
39          return i1 + i2;
40      }
41  
42      public int subtract(int i1, int i2)
43      {
44          return i1 - i2;
45      }
46  
47      public long substract(long i1, long i2)
48      {
49          return i1 - i2;
50      }
51  
52      public int multiply(int i1, int i2)
53      {
54          return i1 * i2;
55      }
56  
57      public int divide(int i1, int i2)
58      {
59          return i1 / i2;
60      }
61  
62      public long divide(long l1, long l2)
63      {
64          return l1 / l2;
65      }
66  
67      public long max(long l1, long l2)
68      {
69          return Math.max(l1, l2);
70      }
71  
72      public long min(long l1, long l2)
73      {
74          return Math.min(l1, l2);
75      }
76  }