lacam.utils
Class Toolkit

java.lang.Object
  extended bylacam.utils.Toolkit

public class Toolkit
extends java.lang.Object

This is the toolbox of the lacam system containing all the things that might be usefull to all classes in the system as well as plugins using the system.

Author:
Dimitrij Zub

Constructor Summary
Toolkit()
           
 
Method Summary
static dbis.util.graphic.objects.graphs.GraphNode createTaskNode(TaskDescriptor descriptor, int x, int y, boolean save_to_config, java.lang.String identifier)
          Creates a GraphNode with an attached TaskNodeListener which can be attached to the desktop.
static double[] gauss(double[][] A, double[] b)
          Gaussion algorithm to solve linear equations (Ax = b).
static int gcd(int n, int d)
          Determines the greatest common divisor of two numbers.
static java.lang.String getAttributeValue(org.w3c.dom.Node node, java.lang.String attribute_name)
           
static int[] getCenterCoordinates(int width, int height)
           
static byte[] getObjectFromFile(java.lang.String name, java.io.File plugin)
          Loads the desired file from a file, which may be a folder or a zip archive
static double getRSquare(double[] rowData, int norder)
           
static int hasNamedParameter(org.w3c.dom.NodeList parameterlist, java.lang.String name)
           
static boolean isPrime(long x)
          Determines if a number is a prime using the sieve of Eratosthenes
static java.lang.String makeStatement(java.lang.String pattern, java.lang.Object[] args)
          Just replaces the {..} in the pattern with the value given in args
static double[] normalize_eucl(double[] vector)
          Normalizes the given vector according to the Euclidian norm
static double[] normalize_one(double[] vector)
          Normalizes the given vector according to the One-norm
static double[] ols_regression(double[][] rawData, int norder)
          Calculates OLS Regression on a given dataset.
static double[] ols_regression(double[] data, int norder)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Toolkit

public Toolkit()
Method Detail

getObjectFromFile

public static byte[] getObjectFromFile(java.lang.String name,
                                       java.io.File plugin)
Loads the desired file from a file, which may be a folder or a zip archive

Parameters:
name - name/path of the object to load
plugin - the plugin file
Returns:
byte[] representing the file

makeStatement

public static java.lang.String makeStatement(java.lang.String pattern,
                                             java.lang.Object[] args)
Just replaces the {..} in the pattern with the value given in args

Parameters:
pattern - The pattern to use
args - The values to use
Returns:
The String with replaced values
See Also:
MessageFormat

getAttributeValue

public static java.lang.String getAttributeValue(org.w3c.dom.Node node,
                                                 java.lang.String attribute_name)
Returns:
The value of the desired attribute form the attributes list of the node

hasNamedParameter

public static int hasNamedParameter(org.w3c.dom.NodeList parameterlist,
                                    java.lang.String name)
Parameters:
parameterlist - The parameterlist of the descriptor ndoe
name - The name of the parameter
Returns:
The index of the parameter with the given name

getCenterCoordinates

public static int[] getCenterCoordinates(int width,
                                         int height)

ols_regression

public static double[] ols_regression(double[] data,
                                      int norder)

ols_regression

public static double[] ols_regression(double[][] rawData,
                                      int norder)
Calculates OLS Regression on a given dataset. Used to determine trend.

Parameters:
rawData - The array containing the points to use for regression. The format is rawData[i][0] = y, rawData[i][1] = x
norder - The dimension of the ols_regression
See Also:
gauss(double[][], double[])

getRSquare

public static double getRSquare(double[] rowData,
                                int norder)

gauss

public static double[] gauss(double[][] A,
                             double[] b)
Gaussion algorithm to solve linear equations (Ax = b). Used with linear regression.

Parameters:
A - The A of the equation
b - The b of the equation
Returns:
The x which solves the equation

normalize_eucl

public static double[] normalize_eucl(double[] vector)
Normalizes the given vector according to the Euclidian norm

Parameters:
vector - The vector to normalize
Returns:
The normalized vector

normalize_one

public static double[] normalize_one(double[] vector)
Normalizes the given vector according to the One-norm

Parameters:
vector - The vector to normlalize
Returns:
The normalized vector

isPrime

public static boolean isPrime(long x)
Determines if a number is a prime using the sieve of Eratosthenes

Parameters:
x - any number to test.
Returns:
true, if x is a prime. false otherwise.

gcd

public static int gcd(int n,
                      int d)
Determines the greatest common divisor of two numbers.

Parameters:
n - number 1
d - number 2
Returns:
Greatest common divisor of n and d.

createTaskNode

public static dbis.util.graphic.objects.graphs.GraphNode createTaskNode(TaskDescriptor descriptor,
                                                                        int x,
                                                                        int y,
                                                                        boolean save_to_config,
                                                                        java.lang.String identifier)
Creates a GraphNode with an attached TaskNodeListener which can be attached to the desktop. This GraphNode can be appended to any GraphicsContainer.

Parameters:
descriptor - The TaskDescriptor of the Task to start on click-Event
x - The x-Position of the node
y - The y-Position of the node
save_to_config - True if the Node should be appended to Config (make node persistent if node not persistent yet)
identifier - The identifier of the Node (Ust a Timestamp here)
See Also:
MainGUIForm.updateDesktopItems()