org.knime.base.util.coordinate
Class NominalCoordinate

java.lang.Object
  extended by org.knime.base.util.coordinate.Coordinate
      extended by org.knime.base.util.coordinate.NominalCoordinate

public class NominalCoordinate
extends Coordinate

This class represents a nominal coordinate defined by a given DataColumnSpec. The nominal values are arranged equidistant and in the order given in the DataColumnSpec.

Author:
Christoph Sieb, University of Konstanz, Fabian Dill, University of Konstanz

Field Summary
 
Fields inherited from class org.knime.base.util.coordinate.Coordinate
DEFAULT_ABSOLUTE_TICK_DIST
 
Constructor Summary
NominalCoordinate(DataColumnSpec dataColumnSpec)
          Constructs a nominal coordinate according to the given column spec.
 
Method Summary
 void addDesiredValues(DataValue... values)
          Adds a value which should have a tick.
protected  double calculateMappedValueInternal(DataCell domainValueCell, double absoluteLength)
          Calculates a numeric mapping assuming a column with a given number of possible values.
 void changeValuePosition(DataCell nomValue, int index)
          Changes the position of a nominal value on the axis.
 CoordinateMapping[] getReducedTickPositions(int absLength)
           
protected  CoordinateMapping[] getTickPositionsWithLabels(double absoluteLength)
          Returns an array with the position of all ticks and their corresponding nominal domain values given an absolute length.
 double getUnusedDistBetweenTicks(double absoluteLength)
          Returns the range according to the mapping in which no values can have values.
 boolean isNominal()
          Whether this coordinate is a nominal one.
 
Methods inherited from class org.knime.base.util.coordinate.Coordinate
addCoordinateFactory, addMappingMethod, addPolicy, applyMappingMethod, calculateMappedValue, calculateMappedValue, clearDesiredValues, createCoordinate, getActiveMappingMethod, getCompatibleMappingMethods, getCompatiblePolicies, getCurrentPolicy, getDataColumnSpec, getDesiredValues, getDesiredValuesSet, getDomain, getMappingMethod, getNegativeInfinity, getPolicyStategy, getPositiveInfinity, getTickPositions, getTickPositions, setActiveMappingMethod, setPolicy, setPolicy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NominalCoordinate

NominalCoordinate(DataColumnSpec dataColumnSpec)
Constructs a nominal coordinate according to the given column spec.

Parameters:
dataColumnSpec - the column spec to create this coordinate from
Method Detail

changeValuePosition

public void changeValuePosition(DataCell nomValue,
                                int index)
Changes the position of a nominal value on the axis. This is due to reordering nominal values which do not have a inherent order.

Parameters:
nomValue - the value to replace
index - the position to set the value

getUnusedDistBetweenTicks

public double getUnusedDistBetweenTicks(double absoluteLength)
Returns the range according to the mapping in which no values can have values. This distance will not occur in floating point numbers. For nominal values it is most likely to occur. For discrete values like integers, it will happen when the integer range is smaller than the available pixels.

Specified by:
getUnusedDistBetweenTicks in class Coordinate
Parameters:
absoluteLength - the absolute length available for this coordinate
Returns:
the unused mapping range per domain value

getTickPositionsWithLabels

protected CoordinateMapping[] getTickPositionsWithLabels(double absoluteLength)
Returns an array with the position of all ticks and their corresponding nominal domain values given an absolute length. The nominal values are arranged equidistant with a half the distance at the beginning of the coordinate and half the distance at the end.

Specified by:
getTickPositionsWithLabels in class Coordinate
Parameters:
absoluteLength - the absolute length the domain is mapped on
Returns:
the mapping of tick positions and corresponding domain values

getReducedTickPositions

public CoordinateMapping[] getReducedTickPositions(int absLength)
Parameters:
absLength - the available length.
Returns:
a reduced mapping with a minimum distance between the values and dots if some values were left out,

calculateMappedValueInternal

protected double calculateMappedValueInternal(DataCell domainValueCell,
                                              double absoluteLength)
Calculates a numeric mapping assuming a column with a given number of possible values. Returns the mapping of a domain value for this coordinate axis. The mapping is done according to the given absolute length.

The value is not the position on the screen. Since the java coordinate system is upside down simply subtract the returned value from the screen height to calculate the screen position.

Specified by:
calculateMappedValueInternal in class Coordinate
Parameters:
domainValueCell - the data cell with the domain value to map
absoluteLength - the absolute length on which the domain value is mapped on
Returns:
the mapped value

isNominal

public boolean isNominal()
Whether this coordinate is a nominal one. Nominal coordinates must be treated differently in some cases, i.e. when rendering in a scatterplot nominal values are very likely to be drawn above each other which requires jittering.

Specified by:
isNominal in class Coordinate
Returns:
true, if this coordinate is a nominal one

addDesiredValues

public void addDesiredValues(DataValue... values)
Adds a value which should have a tick.

Specified by:
addDesiredValues in class Coordinate
Parameters:
values - the desired value


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.