at.tuwien.ifs.somtoolbox.reportgenerator
Class SemanticInterpreterGrid

java.lang.Object
  extended by at.tuwien.ifs.somtoolbox.reportgenerator.SemanticInterpreterGrid

public class SemanticInterpreterGrid
extends Object

This class gives a semantic interpretation of the Coordinates of the Units of a SOM.It calculates North/South/east/West and Middle Regions of the given Array of UnitNodes. This is used for the semantic Report of the ReportGenerator.

Author:
Martin Waitzbauer (0226025)

Field Summary
private  EditableReportProperties EP
           
 SemanticInterpreterGrid fatherGrid
           
private  int[] Gravity
           
private  int GridSize
           
private  String imgDir
           
 SemanticNode[][] labels
           
static int NUMBER_OF_REGIONS
           
private  QMContainer qm
           
private  int Region
           
 HashMap<Integer,SemanticClass>[] SemanticClasses
           
 HashMap<Integer,SemanticClass> SemanticClassesIndex
           
private  TestRunResult TestRun
           
 int totalEmptyNodes
           
private  int type
           
 Unit[] units
           
 int XLength
           
 int YLength
           
 
Constructor Summary
SemanticInterpreterGrid(Unit[] units, TestRunResult testrun, boolean master, int Region, int type, String imgDir)
           
 
Method Summary
 void addClasstoGrid(int j)
          adds a class from ClassCointainer to this SemanticClass Hashmap, used if the Grid is non Regular
private  ArrayList<Integer> compareArrayLists(ArrayList<Integer> a1, ArrayList<Integer> a2)
          Compares two array lists and return how many elements are equal
FIXME: move to a generic utility class
private  int[] computeAxisPartition(int axislength)
          Combines the used partitions for one axis (for easier handling)
private  int[] computeMiddlePartition(int axislength)
          Computes the Middle Partition (& let it grow) for the given axis
private  int[] computeSidePartition(int axislength, int type)
          Computes the areas for the left(type==1) or right (type==2) side of the Middle part for the given Axis and divides the parts equally among the granularity measures defines by the [] Gravity
 int[] concatArrays(int[] a, int[] b)
          Concatenates two arrays.
 void createClassReport(int j)
          Creates a Class Report on Class with index j, saves it in the SemantiClass currClass and puts it on the SemanticNode
 String createClassReportOnGrid(int indexReport, int clusterlevelReport, ArrayList QMReportIntersection)
          Creates a 3 fold Report
 String createQMComparisonReportonGrid(String qualifier, int Region)
          Creates a Comparison report on all Quality Measures(qualifier=null), or on a specific Quality Measure(=Name), on the given Region, or on the whole grid if the Region is 0
 Unit[] cutArray(int x1, int x2, int y1, int y2)
          helper method, cuts a double array from this.units defined by X and Y
 void getClassesfromFatherGrid()
          Puts the Fathers Grid Classes in this grid
 SemanticClass getClassfromGrid(int index)
           
private  ArrayList[] getclassTrail(ArrayList l)
          Goes through the given list and tries to see which classes are connected
 HashMap<Integer,SemanticClass> getClusterLevelClasses()
          Gets the specific Classes for the Cluster Area, Used if this.fatherGrid != null & Index = 0
static int[] getDistance(int[] PointA, int[] PointB)
           
 ArrayList<ArrayList<SemanticNode>> getEmptyNodeTrail(ArrayList<SemanticNode> EmptyNodes)
          Returns a list containing all connect/unconnected parts of the empty units
 ArrayList<Integer> getMaxRegionValue(ArrayList[] regions, Integer[] wantedRegions)
          Returns the MAX Value of the Region (Region values need to be summed and cast into the array at the specific Region index)
private  SemanticNode getNode(int[] c)
          returns the Semantic Node for given coordinates
 Unit[] getNonEmptyUnits()
          Returns an array containing nonempty units
FIXME: refactor this, make a method in GrowingLayer, based on GrowingLayer.getNumberOfNotEmptyUnits()
 int getNumberofSharedClasses(boolean clusterarea)
          Returns the Number of all shared Classes within this Grid
private  int[] getPartition(int axislength)
          Estimates the Areas for the Middle part of the given Axis
 ArrayList[] getQMIntersectionList(String Name1, String Name2, Unit[] units, int type)
          Returns a 9 field arrayList containing intersection units of QM Name1 & Name2, on units, that were chosen with the comparing operation type
static String getRegion(int i)
          Returns the String Name for the region with index i
FIXME: refactor this with a hashmap or similar
 ArrayList<SemanticNode>[] getRegionOccurance(String Name, int clss)
          Return an ArrayList with the SemanticNodes of ocurrances for the given quality measure and class
 SemanticNode[][] getSemanticNodeArray()
          returns the semantic node array
 void initializeGridwithClasses(boolean regularGrid)
          Creates all the Info needed for Report
 ArrayList mergeArrayList(ArrayList l1, ArrayList l2)
           
 String printQualityMeasureReport(String qualifier)
          Prints a report on all selected Quality Measures, and adds a picture Frame if a visualization is available qualifiers is a String array, containing all Names from the quality measures
 void putClassinContainer(SemanticClass cl)
          Puts the class in the right HashMap, and checks for wanted EditableProperties
 void setFatherGrid(SemanticInterpreterGrid grid)
          Used if the Grid wasn't made from a square Grid, so we use the Class Descriptions from a squared one in SOMDEscriptionHTLM
 void setSemanticGrid()
          Puts this semanticGrid on the QuMContainer, uised or calculations ONLY the masterGrid should be set here, witch is the one covering the whole Map
 String showClassInfos(ArrayList<Integer> classes, Integer type)
          Creates a table that shows thew class infos if QMIntersectionClasshMap != Null, we also include a column showing
 String simplifyRegionDescription(ArrayList[] regions)
          Returns a simplified Region description (i.e region 3,6,9 lie all on the right side of the grid
FIXME: refactor this
static Unit[] sortNodes(Unit[] units)
          Sort the Unit array according to the Coordinates
FIXME: refactor this with some generic java sorting algorithm, implementing a special Comparator first if needed
 String testQM(String QM_compare, String QM_to, ArrayList[] semanticNodes, int type)
          Tests the SemanticNodes found in the ArrayList-array about QM specific properties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XLength

public int XLength

YLength

public int YLength

Region

private int Region

imgDir

private String imgDir

TestRun

private TestRunResult TestRun

labels

public SemanticNode[][] labels

units

public Unit[] units

Gravity

private int[] Gravity

fatherGrid

public SemanticInterpreterGrid fatherGrid

type

private int type

GridSize

private int GridSize

NUMBER_OF_REGIONS

public static int NUMBER_OF_REGIONS

SemanticClasses

public HashMap<Integer,SemanticClass>[] SemanticClasses

SemanticClassesIndex

public HashMap<Integer,SemanticClass> SemanticClassesIndex

totalEmptyNodes

public int totalEmptyNodes

EP

private EditableReportProperties EP

qm

private QMContainer qm
Constructor Detail

SemanticInterpreterGrid

public SemanticInterpreterGrid(Unit[] units,
                               TestRunResult testrun,
                               boolean master,
                               int Region,
                               int type,
                               String imgDir)
Method Detail

getPartition

private int[] getPartition(int axislength)
Estimates the Areas for the Middle part of the given Axis


computeMiddlePartition

private int[] computeMiddlePartition(int axislength)
Computes the Middle Partition (& let it grow) for the given axis


computeSidePartition

private int[] computeSidePartition(int axislength,
                                   int type)
Computes the areas for the left(type==1) or right (type==2) side of the Middle part for the given Axis and divides the parts equally among the granularity measures defines by the [] Gravity


computeAxisPartition

private int[] computeAxisPartition(int axislength)
Combines the used partitions for one axis (for easier handling)


getSemanticNodeArray

public SemanticNode[][] getSemanticNodeArray()
returns the semantic node array


initializeGridwithClasses

public void initializeGridwithClasses(boolean regularGrid)
Creates all the Info needed for Report

Parameters:
regularGrid - true if the Grid is regular squared

createClassReportOnGrid

public String createClassReportOnGrid(int indexReport,
                                      int clusterlevelReport,
                                      ArrayList QMReportIntersection)
Creates a 3 fold Report

Parameters:
indexReport - = Number of the GridNumber to be analyzed
clusterlevelReport - number of the Clusterlevel to be analyzed
QMReportIntersection - [0] = Name of Quality Measure, [1] = 1 = MAX, 2 = MIN, [3..length] intersectio nunits of the QM to be analyzed

getDistance

public static int[] getDistance(int[] PointA,
                                int[] PointB)

createClassReport

public void createClassReport(int j)
Creates a Class Report on Class with index j, saves it in the SemantiClass currClass and puts it on the SemanticNode


cutArray

public Unit[] cutArray(int x1,
                       int x2,
                       int y1,
                       int y2)
helper method, cuts a double array from this.units defined by X and Y


getNode

private SemanticNode getNode(int[] c)
returns the Semantic Node for given coordinates


compareArrayLists

private ArrayList<Integer> compareArrayLists(ArrayList<Integer> a1,
                                             ArrayList<Integer> a2)
Compares two array lists and return how many elements are equal
FIXME: move to a generic utility class


getclassTrail

private ArrayList[] getclassTrail(ArrayList l)
Goes through the given list and tries to see which classes are connected


setFatherGrid

public void setFatherGrid(SemanticInterpreterGrid grid)
Used if the Grid wasn't made from a square Grid, so we use the Class Descriptions from a squared one in SOMDEscriptionHTLM


getEmptyNodeTrail

public ArrayList<ArrayList<SemanticNode>> getEmptyNodeTrail(ArrayList<SemanticNode> EmptyNodes)
Returns a list containing all connect/unconnected parts of the empty units


sortNodes

public static Unit[] sortNodes(Unit[] units)
Sort the Unit array according to the Coordinates
FIXME: refactor this with some generic java sorting algorithm, implementing a special Comparator first if needed


addClasstoGrid

public void addClasstoGrid(int j)
adds a class from ClassCointainer to this SemanticClass Hashmap, used if the Grid is non Regular

Parameters:
j - classindex

concatArrays

public int[] concatArrays(int[] a,
                          int[] b)
Concatenates two arrays.
FIXME: use ArrayUtils.addAll(int[], int[]) instead


getRegion

public static String getRegion(int i)
Returns the String Name for the region with index i
FIXME: refactor this with a hashmap or similar


putClassinContainer

public void putClassinContainer(SemanticClass cl)
Puts the class in the right HashMap, and checks for wanted EditableProperties


getClassfromGrid

public SemanticClass getClassfromGrid(int index)

getClusterLevelClasses

public HashMap<Integer,SemanticClass> getClusterLevelClasses()
Gets the specific Classes for the Cluster Area, Used if this.fatherGrid != null & Index = 0


getNumberofSharedClasses

public int getNumberofSharedClasses(boolean clusterarea)
Returns the Number of all shared Classes within this Grid


printQualityMeasureReport

public String printQualityMeasureReport(String qualifier)
Prints a report on all selected Quality Measures, and adds a picture Frame if a visualization is available qualifiers is a String array, containing all Names from the quality measures


getRegionOccurance

public ArrayList<SemanticNode>[] getRegionOccurance(String Name,
                                                    int clss)
Return an ArrayList with the SemanticNodes of ocurrances for the given quality measure and class


simplifyRegionDescription

public String simplifyRegionDescription(ArrayList[] regions)
Returns a simplified Region description (i.e region 3,6,9 lie all on the right side of the grid
FIXME: refactor this


getMaxRegionValue

public ArrayList<Integer> getMaxRegionValue(ArrayList[] regions,
                                            Integer[] wantedRegions)
Returns the MAX Value of the Region (Region values need to be summed and cast into the array at the specific Region index)

Parameters:
regions - [9] double/int
wantedRegions - specifies a selectrion of Region, NULL if whole map regions wanted

createQMComparisonReportonGrid

public String createQMComparisonReportonGrid(String qualifier,
                                             int Region)
Creates a Comparison report on all Quality Measures(qualifier=null), or on a specific Quality Measure(=Name), on the given Region, or on the whole grid if the Region is 0


showClassInfos

public String showClassInfos(ArrayList<Integer> classes,
                             Integer type)
Creates a table that shows thew class infos if QMIntersectionClasshMap != Null, we also include a column showing

Parameters:
classes - the class indices
type - 1,2,3,4 reports
Returns:
a html-formatted table that shows the class infos

mergeArrayList

public ArrayList mergeArrayList(ArrayList l1,
                                ArrayList l2)

getQMIntersectionList

public ArrayList[] getQMIntersectionList(String Name1,
                                         String Name2,
                                         Unit[] units,
                                         int type)
Returns a 9 field arrayList containing intersection units of QM Name1 & Name2, on units, that were chosen with the comparing operation type

Parameters:
Name1 - QualityMeasure1
Name2 - QualityMeasure2
units - Array of units.
type - the type (see QMContainer.getComparedQMRegionOccurances(String, String, Unit[], int)
Returns:
a 9 field arrayList containing intersection units of QM Name1 & Name2

setSemanticGrid

public void setSemanticGrid()
Puts this semanticGrid on the QuMContainer, uised or calculations ONLY the masterGrid should be set here, witch is the one covering the whole Map


testQM

public String testQM(String QM_compare,
                     String QM_to,
                     ArrayList[] semanticNodes,
                     int type)
Tests the SemanticNodes found in the ArrayList-array about QM specific properties

Parameters:
QM_compare - the QM Identifier that is QM_to is compared to if QM_compare == null, we dont make a comparison, but just a test of the quality Measure
type - 1 = MAX, 2 = MIN
Returns:
The test results.

getClassesfromFatherGrid

public void getClassesfromFatherGrid()
Puts the Fathers Grid Classes in this grid


getNonEmptyUnits

public Unit[] getNonEmptyUnits()
Returns an array containing nonempty units
FIXME: refactor this, make a method in GrowingLayer, based on GrowingLayer.getNumberOfNotEmptyUnits()