Re: [visad] How can I apply logarithmic scaling to Display.Text position?


> I am struggling to define a FunctionType that will correctly position the
> labels when logarithmic scaling is applied.

I managed to solve this using the following code to include a LogCoordinateSystem in the range of the annotation function:

// Height Types.
final RealType heightType = RealType.getRealType("Height");
final RealType logHeightType = RealType.getRealType("LogHeight", CommonUnit.promiscuous);
heightTupleType = new RealTupleType(
heightType, new LogCoordinateSystem(new RealTupleType(logHeightType)), null);
annotationType = TextType.getTextType("Annotation");
annotationTupleType = new TupleType(new MathType[]{heightTupleType, annotationType});

// Create a function from domain (retention time and m/z) to text annotation.
annotationFunction = new FunctionType(domainTuple, annotationTupleType);

The full code is in the project svn repository:

The final piece of the puzzle is applying logarithmic scaling to the heights of bounding boxes that are used to highlight individual surface peaks. The box heights match the peak heights and are created using GriddedSets:

pointTupletype = new RealTupleType(retentionTimeType, mzType, heightType);

// Create the box set.
return GriddedSet.create(
        new float[][]{
                {rtMin, rtMax, rtMin, rtMax, rtMin, rtMax, rtMin, rtMax,
                 rtMin, rtMin, rtMin, rtMin, rtMax, rtMax, rtMax, rtMax,},
                {mzMin, mzMin, mzMin, mzMin, mzMax, mzMax, mzMax, mzMax,
                 mzMin, mzMax, mzMin, mzMax, mzMin, mzMax, mzMin, mzMax},
                {heightMin, heightMin, heightMax, heightMax, heightMax,
                 heightMax, heightMin, heightMin, heightMin, heightMin,
                 heightMax, heightMax, heightMax, heightMax, heightMin,
        new int[]{2, 8});

The boxes are rendered correctly for linear scaling of the height axis but not for logarithmic scaling. Presumably to get this working the GriddedSet (or similar) must reference the LogCoordinateSystem defined earlier but how?

I'd be grateful for any suggestions.

Code for this class is here:


This message may contain confidential information. If you are not the designated recipient, please notify the sender immediately, and delete the original and any copies. Any use of the message by you is prohibited.

  • 2011 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: