/*
 *
 * This software is provided by NOAA for full, free and open release.  It is
 * understood by the recipient/user that NOAA assumes no liability for any
 * errors contained in the code.  Although this software is released without
 * conditions or restrictions in its use, it is expected that appropriate
 * credit be given to its author and to the National Oceanic and Atmospheric
 * Administration should the software be included by the recipient as an
 * element in other product development.
 */
// RCS $Id: LogTransform.java,v 1.8 2003/08/22 23:02:32 dwd Exp $
package  sgtplot;

import sgtplot.util.GeoDate;
import sgtplot.util.Range2D;
import sgtplot.util.SoTRange;
import sgtplot.util.SoTValue;
import sgtplot.util.TimeRange;
import java.lang.Math;


/**
 * Transform class for creation of "log" axes. An {@link sgtplot.demo.JLogLogDemo
 * example} is available demonstrating LogTransform use.
 *
 *--------------------------------------------------------------------------
* NAME : LogTransform.java
* FUNCTION : Performs a logarithm transform on a cartesian axis.
* ORIGIN : GFI INFORMATIQUE
* PROJECT : SONC DPS
* -------------------------------------------------------------------------
* HISTORY
* VERSION : 03/07/2002 LBE
* old version had no fonctionality. It was just written
* for future evolutions. This new version complete the class
* END-HISTORY
* ------------------------------------------------------------------------
* @author Donald Denbo * @version $Revision: 1.8 $, $Date: 2003/08/22 23:02:32 $ * @since 3.0 */ public class LogTransform extends AxisTransform implements Cloneable { double at_; double bt_; double a_; double b_; int min_=-50; public LogTransform() { super(); } public LogTransform(double p1,double p2,double u1,double u2){ super(p1, p2, u1, u2); } public LogTransform(Range2D pr,Range2D ur){ super(pr, ur); } public LogTransform(double p1,double p2,GeoDate t1,GeoDate t2){ super(p1, p2, t1, t2); } public LogTransform(Range2D pr,TimeRange tr) { super(pr, tr); } public LogTransform(Range2D pr, SoTRange str){ super(pr, str); } AxisTransform copy() { LogTransform newTransform; try { newTransform = (LogTransform)clone(); } catch (CloneNotSupportedException e) { newTransform = new LogTransform(); } return (AxisTransform)newTransform; } public double getTransP(double u) { try { if(u1_<=0 || u2_<=0) { //System.out.println("ERROR Negative LOG"); throw new NegativeLogException("Can't Log negative values"); } }catch(NegativeLogException e){e.printStackTrace();} return a_*(Math.log(u)/Math.log(10)) + b_; } public double getTransP(GeoDate t) { throw new MethodNotImplementedError(); } public double getTransP(long t) { throw new MethodNotImplementedError(); } public double getTransP(SoTValue v) { if(v.isTime()) { throw new MethodNotImplementedError(); } else { double u = ((SoTValue.Double)v).getValue(); try { // if(u<=0) throw new NegativeLogException("Can't Log negative values"); }catch(NegativeLogException e){e.printStackTrace();} return a_*(Math.log(u)/Math.log(10)) + b_; } } public double getTransU(double p) { if((p-b_)/a_

Ads help maintain this website.