org.knime.base.util.coordinate
Class DoubleCoordinate

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

public class DoubleCoordinate
extends NumericCoordinate

This class represents a numeric coordinate defined by a given DataColumnSpec. The class provides functionality for extension of coordinates beyond the domain length. Furthermore the label ticks can be determined dependent on given properties. All these sizes are normalized (0-1) but there are also methods to convert them to absolute values given an absolute maximum length.

Author:
Christoph Sieb, University of Konstanz, Stephan Sellien, University of Konstanz

Field Summary
 
Fields inherited from class org.knime.base.util.coordinate.Coordinate
DEFAULT_ABSOLUTE_TICK_DIST
 
Constructor Summary
protected DoubleCoordinate(DataColumnSpec dataColumnSpec)
          Constructs a Coordinate according to the given column spec and predefined default values for the coordinatePrefix, coordinatePostfix and the absoluteTickDistance.
(package private) DoubleCoordinate(DataColumnSpec dataColumnSpec, double coordinatePrefix, double coordinatePostfix, double absoluteTickDistance, String tickPolicy, int maxDomainLabelLength)
          Constructs a coordinate from the given parameters.
 
Method Summary
protected  double calculateMappedValueInternal(DataCell domainValueCell, double absoluteLength)
          Calculates a numeric mapping assuming a DoubleCell.
 String formatNumber(double number)
          Formats a number according to the maximum length allowed for a domain label.
protected  CoordinateMapping[] getTickPositionsInternal(double absoluteLength)
          Returns an array with the positions of all ticks and their corresponding domain values given an absolute length.
 boolean isMaxDomainValueSet()
          
 boolean isMinDomainValueSet()
          
 void setMaxDomainValue(double maxDomainValue)
          Sets the upper domain value.
 void setMinDomainValue(double minDomainValue)
          Sets the lower domain value.
 
Methods inherited from class org.knime.base.util.coordinate.NumericCoordinate
addDesiredValues, getDesiredValues, getMaxDomainValue, getMinDomainValue, getNegativeInfinity, getPositiveInfinity, getTickPositionsWithLabels, getUnusedDistBetweenTicks, isNominal
 
Methods inherited from class org.knime.base.util.coordinate.Coordinate
addCoordinateFactory, addMappingMethod, addPolicy, applyMappingMethod, calculateMappedValue, calculateMappedValue, clearDesiredValues, createCoordinate, getActiveMappingMethod, getCompatibleMappingMethods, getCompatiblePolicies, getCurrentPolicy, getDataColumnSpec, getDesiredValuesSet, getDomain, getMappingMethod, getPolicyStategy, 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

DoubleCoordinate

protected DoubleCoordinate(DataColumnSpec dataColumnSpec)
Constructs a Coordinate according to the given column spec and predefined default values for the coordinatePrefix, coordinatePostfix and the absoluteTickDistance.

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

DoubleCoordinate

DoubleCoordinate(DataColumnSpec dataColumnSpec,
                 double coordinatePrefix,
                 double coordinatePostfix,
                 double absoluteTickDistance,
                 String tickPolicy,
                 int maxDomainLabelLength)
Constructs a coordinate from the given parameters.

Parameters:
dataColumnSpec - the column spec to create this coordinate from
coordinatePrefix - the prefix to append before the domain size. A value larger or equal 0 is expected and is assumed to be a percent value.
coordinatePostfix - the postfix to append after the end of the domain. A value larger or equal 0 is expected and is assumed to be a percent value.
absoluteTickDistance - the distance used to calculate absolute tick positions when given an maximum length
tickPolicy - the policy to determine the position of the ticks for this coordinate
maxDomainLabelLength - the number digits after the decimal dot for rounding accuracy
Method Detail

getTickPositionsInternal

protected CoordinateMapping[] getTickPositionsInternal(double absoluteLength)
Returns an array with the positions of all ticks and their corresponding domain values given an absolute length. The pre-specified tick policy also influences the tick positions, e.g. ascending or descending.

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

formatNumber

public String formatNumber(double number)
Formats a number according to the maximum length allowed for a domain label. This constraint is set from the higher level according to the application.

Parameters:
number - the number to format
Returns:
the formated number as string

calculateMappedValueInternal

protected double calculateMappedValueInternal(DataCell domainValueCell,
                                              double absoluteLength)
Calculates a numeric mapping assuming a DoubleCell. 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 NumericCoordinate
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

isMinDomainValueSet

public boolean isMinDomainValueSet()

Specified by:
isMinDomainValueSet in class NumericCoordinate
Returns:
true if the lower domain range is set properly

isMaxDomainValueSet

public boolean isMaxDomainValueSet()

Specified by:
isMaxDomainValueSet in class NumericCoordinate
Returns:
true if the upper domain range is set properly

setMaxDomainValue

public void setMaxDomainValue(double maxDomainValue)
Sets the upper domain value.

Overrides:
setMaxDomainValue in class NumericCoordinate
Parameters:
maxDomainValue - the upper value

setMinDomainValue

public void setMinDomainValue(double minDomainValue)
Sets the lower domain value.

Overrides:
setMinDomainValue in class NumericCoordinate
Parameters:
minDomainValue - the lower 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.