//
// ImageTransform.java
//

/*
VisBio application for visualization of multidimensional
biological image data. Copyright (C) 2002-2004 Curtis Rueden.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

package loci.visbio.data;

import loci.visbio.util.VisUtil;
import visad.*;

/** ImageTransform is a DataTransform superclass that provides image data. */
public abstract class ImageTransform extends DataTransform {

  // -- Fields --

  /** X-axis type. */
  protected RealType xType;

  /** Y-axis type. */
  protected RealType yType;

  /** Z-axis type. */
  protected RealType zType;

  /** Range types. */
  private RealType[] rangeTypes;

  /** MathType of generated images. */
  private FunctionType functionType;


  // -- Constructors --

  /** Constructs an uninitialized image transform. */
  public ImageTransform() { this(null, null); }

  /** Creates an image transform with the given transform as its parent. */
  public ImageTransform(DataTransform parent, String name) {
    super(parent, name);

    // initialize internal MathTypes
    xType = VisUtil.getRealType(name + "_X");
    yType = VisUtil.getRealType(name + "_Y");
    zType = VisUtil.getRealType(name + "_Z");
  }


  // -- ImageTransform API methods --

  /** Gets the width in pixels of each image. */
  public abstract int getImageWidth();

  /** Gets the height in pixels of each image. */
  public abstract int getImageHeight();

  /** Gets number of range components at each pixel. */
  public abstract int getRangeCount();

  /** Gets the RealType used for the X-axis. */
  public RealType getXType() { return xType; }

  /** Gets the RealType used for the Y-axis. */
  public RealType getYType() { return yType; }

  /** Gets the RealType used for the Z-axis. */
  public RealType getZType() { return zType; }

  /** Gets the RealTypes used for the range components. */
  public RealType[] getRangeTypes() {
    if (rangeTypes == null) {
      rangeTypes = new RealType[getRangeCount()];
      for (int i=0; i<rangeTypes.length; i++) {
        String s = "range" + i;
        rangeTypes[i] = VisUtil.getRealType(name + "_" + s);
      }
    }
    return rangeTypes;
  }

  /** Gets MathType of images generated by this image transform. */
  public FunctionType getType() {
    if (functionType == null) {
      try {
        RealTupleType domain = new RealTupleType(xType, yType);
        RealTupleType range = new RealTupleType(rangeTypes);
        functionType = new FunctionType(domain, range);
      }
      catch (VisADException exc) { exc.printStackTrace(); }
    }
    return functionType;
  }


  // -- DataTransform API methods --

  /** Retrieves a set of mappings for displaying this transform effectively. */
  public ScalarMap[] getSuggestedMaps() {
    RealType[] range = getRangeTypes();
    ScalarMap[] maps = new ScalarMap[2 + range.length];
    try {
      maps[0] = new ScalarMap(getXType(), Display.XAxis);
      maps[1] = new ScalarMap(getYType(), Display.YAxis);
      for (int i=0; i<range.length; i++) {
        maps[i + 2] = new ScalarMap(range[i], Display.RGBA);
      }
    }
    catch (VisADException exc) { exc.printStackTrace(); }
    return maps;
  }

  /** Most image transforms are not rendered immediately. */
  public boolean isImmediate() { return false; }

}

@@ -3042,17 +3042,20 @@
 pleType(
-r
+getR
 angeType
@@ -3055,16 +3055,18 @@
 ngeTypes
+()
 );%0A     
@@ -3517,26 +3517,21 @@
 alarMap(
-getX
+x
 Type
-()
 , Displa
@@ -3570,26 +3570,21 @@
 alarMap(
-getY
+y
 Type
-()
 , Displa

Fix range types bug.