1 37 38 package org.jfree.data; 39 40 50 public class NormalizedMatrixSeries extends MatrixSeries { 51 52 53 public static final double DEFAULT_SCALE_FACTOR = 1.0; 54 55 58 private double m_scaleFactor = DEFAULT_SCALE_FACTOR; 59 60 61 private double m_totalSum; 62 63 70 public NormalizedMatrixSeries(String name, int rows, int columns) { 71 super(name, rows, columns); 72 73 79 m_totalSum = Double.MIN_VALUE; 80 } 81 82 91 public Number getItem(int itemIndex) { 92 int i = getItemRow(itemIndex); 93 int j = getItemColumn(itemIndex); 94 95 double mij = get(i, j) * m_scaleFactor; 96 Number n = new Double (mij / m_totalSum); 97 98 return n; 99 } 100 101 109 public void setScaleFactor(double factor) { 110 m_scaleFactor = factor; 111 } 112 113 114 120 public double getScaleFactor() { 121 return m_scaleFactor; 122 } 123 124 125 128 public void update(int i, int j, double mij) { 129 m_totalSum -= get(i, j); 130 m_totalSum += mij; 131 132 super.update(i, j, mij); 133 } 134 135 136 139 public void zeroAll() { 140 m_totalSum = 0; 141 super.zeroAll(); 142 } 143 } 144 | Popular Tags |