org.knime.base.node.viz.plotter.scatter
Class DotInfoArray

java.lang.Object
  extended by org.knime.base.node.viz.plotter.scatter.DotInfoArray

public class DotInfoArray
extends Object

Class that holds all DotInfos. You can modify the DotInfos if you need to. Just sort them after the modifications are done. Some functions of this class depend on the fact that the Array is sorted.

Author:
ohl University of Konstanz, Christoph Sieb University of Konstanz

Field Summary
static int X_THEN_Y_SORT_POLICY
          To be passed in the sort method to determine the first and second order criteria.
static int Y_THEN_X_SORT_POLICY
          To be passed in the sort method to determine the first and second order criteria.
 
Constructor Summary
DotInfoArray(DotInfo[] dots)
          Creates a new array container for DotInfos.
DotInfoArray(int size)
          Creates a new empty container for DotInfos.
 
Method Summary
static int calculateDotSize(int basicSize, double dotSize)
          Returns one side of the square making up a dot.
 DotInfo[] getDots()
           
 List<DotInfo> getDotsAt(int x, int y, int dotSize)
          Returns a list of dots that sit on the specified coordinates.
 List<DotInfo> getDotsContainedIn(int x1, int y1, int x2, int y2, int dotSize)
          Returns a list of dots that sit in the specified rectangle (including the boundaries of the rectangle).
 int length()
           
 void sort(int sortPolicy)
          Sorts (or re-sorts) the array of DotInfos by the X and Y coordinates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

X_THEN_Y_SORT_POLICY

public static final int X_THEN_Y_SORT_POLICY
To be passed in the sort method to determine the first and second order criteria. Here: first x then y

See Also:
Constant Field Values

Y_THEN_X_SORT_POLICY

public static final int Y_THEN_X_SORT_POLICY
To be passed in the sort method to determine the first and second order criteria. Here: first y then x

See Also:
Constant Field Values
Constructor Detail

DotInfoArray

public DotInfoArray(int size)
Creates a new empty container for DotInfos. Reserving space for size elements (cannot be resized!)

Parameters:
size - the number of elements to be stored in this array.

DotInfoArray

public DotInfoArray(DotInfo[] dots)
Creates a new array container for DotInfos. The reference to the array passed in will be taken over.

Parameters:
dots - A reference to an array that will become part of this object
Method Detail

sort

public void sort(int sortPolicy)
Sorts (or re-sorts) the array of DotInfos by the X and Y coordinates.

Parameters:
sortPolicy - determines which coordinate is the first and second order cirteria. This results in two order criterias: first x then y and vice versa. The following two policies are available DotInfoArray.X_THEN_Y_SORT_POLICY and DotInfoArray.Y_THEN_X_SORT_POLICY.

length

public int length()
Returns:
the number of DotInfos stored in this structure.

getDots

public DotInfo[] getDots()
Returns:
an array of DotInfo. This is not a copy of the array but a reference to the internal datastructure of this object. It is shared by many. Don't mess with it!

getDotsAt

public List<DotInfo> getDotsAt(int x,
                               int y,
                               int dotSize)
Returns a list of dots that sit on the specified coordinates. It takes into account the size of each dot, so if the rectangle drawn covers the coordinates the dot will be included. This function really depends on the array being sorted!!

Parameters:
x - the X coordinate.
y - the Y coordinate.
dotSize - the size (width and height) of one dot.
Returns:
always a non-null ArrayList of DotInfos. It is of length null, if no dots are set yet or cover the coordinates.

getDotsContainedIn

public List<DotInfo> getDotsContainedIn(int x1,
                                        int y1,
                                        int x2,
                                        int y2,
                                        int dotSize)
Returns a list of dots that sit in the specified rectangle (including the boundaries of the rectangle). It takes into account the size of each dot.

Parameters:
x1 - the X coordinate of one corner of the rectangle
y1 - the Y coordinate of one corner of the rectangle
x2 - the X coordinate of the opposite corner
y2 - the Y coordinate of the opposite corner
dotSize - the width and height of each dot
Returns:
always a non-null ArrayList of DotInfos. It is of length null, if no dots are set yet or sit on/in the specified rectangle.

calculateDotSize

public static final int calculateDotSize(int basicSize,
                                         double dotSize)
Returns one side of the square making up a dot. Every dot may have a individual size [0,1] which is also considered as well as the general user-defined size of the dots [1, 150]. A dot with individual size 0.5 is considered to have the general dot size.

Parameters:
basicSize - the user defined dot size.
dotSize - the individual and relative dot size [0,1].
Returns:
the side length of the square making up a dot.


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.