1 42 43 package org.jfree.data.xy; 44 45 46 54 public class NormalizedMatrixSeries extends MatrixSeries { 55 56 57 public static final double DEFAULT_SCALE_FACTOR = 1.0; 58 59 63 private double m_scaleFactor = DEFAULT_SCALE_FACTOR; 64 65 66 private double m_totalSum; 67 68 75 public NormalizedMatrixSeries(String name, int rows, int columns) { 76 super(name, rows, columns); 77 78 84 this.m_totalSum = Double.MIN_VALUE; 85 } 86 87 96 public Number getItem(int itemIndex) { 97 int i = getItemRow(itemIndex); 98 int j = getItemColumn(itemIndex); 99 100 double mij = get(i, j) * this.m_scaleFactor; 101 Number n = new Double (mij / this.m_totalSum); 102 103 return n; 104 } 105 106 114 public void setScaleFactor(double factor) { 115 this.m_scaleFactor = factor; 116 } 117 118 119 125 public double getScaleFactor() { 126 return this.m_scaleFactor; 127 } 128 129 130 133 public void update(int i, int j, double mij) { 134 this.m_totalSum -= get(i, j); 135 this.m_totalSum += mij; 136 137 super.update(i, j, mij); 138 } 139 140 143 public void zeroAll() { 144 this.m_totalSum = 0; 145 super.zeroAll(); 146 } 147 } 148 | Popular Tags |