package com.ericsson.tic.vi; /** * Defines a set of data points. * * @author Sami Matilainen * @version 1.0 (2008-12-04) */ public class Data { /** Set nodes. Default set. */ public static final int SET_NODES = 1; /** Set relations. */ public static final int SET_REL = 2; ///** Set regions. */ // public final int SET_REGION = 3; /** The id of this data. */ public int id; /** The set which this data belongs to. */ public int set; /** How many dimension the data has besides Node/Rel x Category. */ public int dimension; /** The type of node which this data is tied to. nodeType.id = 0 is reserved for all nodes. */ public NodeType nodeType; /** Determines which parsing strategy to use in Parser.java. */ public int parseStrat; /** The category set this data belongs to. */ public Category category; /** The name of this data. */ public String name; /** The assumed max value for this data. */ public float max; /** The assumed min value for this data. */ public float min; /** The name used to identify this data in the indata. */ public String parseName; /** max - min */ private float maxMinusMin; /** A set of values. */ public float[][][] value; /** A set of timestamps. */ public long[][] timeStamp; /** A set of normalized values. */ public float[][][] vn; /** A tuple of color triples which define * start and end points in a gradient. */ public float[][] colors; /** * Creates a set of data points. * * @param id The id of this data. * @param name The name of this data. * @param parseName The name used to identify this data in the indata. * @param set The set which this data belongs to. * @param category The category set this data belongs to. * @param parseStrat The parsing strategy (see VI.java and Parser.java) * @param dimension How many dimension the data has besides Node/Rel x Category. * @param nodeType The type of node which this data is tied to. * nodeType.id = 0 is reserved for all nodes. * @param max The assumed max value for this data. * @param min The assumed min value for this data. * @param colors A tuple of color triples which define start and end * points in a gradient. */ public Data( int id, String name, String parseName, int set, Category category, int parseStrat, int dimension, NodeType nodeType, float max, float min, float[][] colors ) { this.id = id; this.name = name; this.parseName = parseName; this.set = set; this.category = category; this.parseStrat = parseStrat; this.dimension = dimension; this.nodeType = nodeType; this.max = max; this.min = min; this.colors = colors; this.maxMinusMin = max - min; if (set == SET_NODES) { value = new float[VI.nodeArr.length][category.cats.length][dimension]; vn = new float[VI.nodeArr.length][category.cats.length][dimension]; timeStamp = new long[VI.nodeArr.length][category.cats.length]; for (int i = 0; i < VI.nodeArr.length; i++) { for (int j = 0; j < category.cats.length; j++) { timeStamp[i][j] = 0; } } } else if (set == SET_REL) { value = new float[VI.nodeRelArr.length][category.cats.length][dimension]; vn = new float[VI.nodeRelArr.length][category.cats.length][dimension]; timeStamp = new long[VI.nodeRelArr.length][category.cats.length]; for (int i = 0; i < VI.nodeRelArr.length; i++) { for (int j = 0; j < category.cats.length; j++) { timeStamp[i][j] = 0; } } } else { // default to SET_NODES set = SET_NODES; value = new float[VI.nodeArr.length][category.cats.length][dimension]; vn = new float[VI.nodeArr.length][category.cats.length][dimension]; timeStamp = new long[VI.nodeArr.length][category.cats.length]; for (int i = 0; i < VI.nodeArr.length; i++) { for (int j = 0; j < category.cats.length; j++) { timeStamp[i][j] = 0; } } } } /** * Normalizes the value in value and writes this to vn. * * @param i1 Index 1 for value (see fields) * @param i2 Index 2 for value (see fields) */ public void normalizeValue(int i1, int i2) { for (int i = 0; i < dimension; i++) { vn[i1][i2][i] = (value[i1][i2][i] - min)/(maxMinusMin); } } }