Ignore:
Timestamp:
09/05/14 19:33:12 (10 years ago)
Author:
rkrimmel
Message:

Used Eclipse code cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/matrix/StaticTriangleMatrix.java

    r1707 r1733  
    33import java.io.Serializable; 
    44 
    5 public class StaticTriangleMatrix implements ITriangleMatrix,Serializable { 
    6          
     5public class StaticTriangleMatrix implements ITriangleMatrix, Serializable { 
     6 
    77        /** 
    88         *  
    99         */ 
    1010        private static final long serialVersionUID = 7599542322424894866L; 
    11         private float[] matrix; 
     11        private final float[] matrix; 
    1212        protected int size; 
    13          
    14          
     13 
    1514        public StaticTriangleMatrix(int size) { 
    1615                this.size = size; 
    17                 matrix = new float [size*(size+1)/2]; 
    18         } 
    19          
    20         public float get(int first, int second) { 
    21                 int row = Math.min(first, second); 
    22                 int col = Math.max(first, second); 
    23                 return matrix[row*size-(row*(row+1)/2 - (size-col))]; 
    24                  
    25         } 
    26          
    27         public void set(int first, int second, float value) { 
    28                 int row = Math.min(first, second); 
    29                 int col = Math.max(first, second); 
    30                 matrix[row*size-(row*(row+1)/2 - (size-col))] = value; 
     16                matrix = new float[(size * (size + 1)) / 2]; 
    3117        } 
    3218 
     19        @Override 
     20        public float get(int first, int second) { 
     21                final int row = Math.min(first, second); 
     22                final int col = Math.max(first, second); 
     23                return matrix[(row * size) - (((row * (row + 1)) / 2) - (size - col))]; 
     24 
     25        } 
     26 
     27        @Override 
     28        public void increaseSize(int count) throws Exception { 
     29                throw new Exception( 
     30                                "Cannot call this function on this implementation of ITriangle Matrix"); 
     31 
     32        } 
     33 
     34        @Override 
    3335        public void initialize(float value) { 
    34                 for (int i=0; i < matrix.length; i++) { 
     36                for (int i = 0; i < matrix.length; i++) { 
    3537                        matrix[i] = value; 
    3638                } 
    3739        } 
    38          
    3940 
    40          
     41        @Override 
     42        public void set(int first, int second, float value) { 
     43                final int row = Math.min(first, second); 
     44                final int col = Math.max(first, second); 
     45                matrix[(row * size) - (((row * (row + 1)) / 2) - (size - col))] = value; 
     46        } 
     47 
     48        @Override 
     49        public int size() { 
     50                return size; 
     51        } 
     52 
     53        @Override 
    4154        public String toString() { 
    4255                String result = ""; 
    4356                for (int i = 0; i < size; i++) { 
    44                         for(int j = 0; j< size; j++) { 
    45                                 if(i<j) { 
    46                                         if(Float.isInfinite(this.get(i,j))) { 
     57                        for (int j = 0; j < size; j++) { 
     58                                if (i < j) { 
     59                                        if (Float.isInfinite(this.get(i, j))) { 
    4760                                                result = result + " -------"; 
     61                                        } else { 
     62                                                result = result 
     63                                                                + String.format("%+8.2f", this.get(i, j)); 
    4864                                        } 
    49                                         else { 
    50                                                 result = result + String.format("%+8.2f",this.get(i,j)); 
    51                                         } 
    52                                 } 
    53                                 else { 
     65                                } else { 
    5466                                        result = result + ("        "); 
    5567                                } 
     
    5971                return result; 
    6072        } 
    61  
    62         @Override 
    63         public void increaseSize(int count) throws Exception { 
    64                 throw new Exception("Cannot call this function on this implementation of ITriangle Matrix"); 
    65                  
    66         } 
    67  
    68         @Override 
    69         public int size() { 
    70                 return size; 
    71         } 
    7273} 
Note: See TracChangeset for help on using the changeset viewer.