Can you override a public static method?

Can you override a public static method?

A static method belongs to a class, not to a particular object, because you can call them without having an object instantiated. Methods are over rided which are inherited from an object. Since Static methods (although inherited) are not bound to a particular object, are not overridden.
Though you have a method in the subclass with the same signatures but if you try to call super.____() you will get the error
non-static variable super cannot be referenced from a static context

Similar Messages

  • Problem to override a public static variable

    Hello,
    I have a problem when trying to override a public static value.
    Here is my example.
    I have one class defining var szName
    public class myClass1 {
    public static String szName = "First Name";
    And an extention
    public class myClass2 extends myClass1{
    public static String szName = "F. N.";
    In my main class if I do:
    myClass2 myObject = new myClass2();
    System.out.println("szName = " + myObject.szName);
    I get "szName = First Name" instead of "szName = F. N."
    Can somebody explain me what is wrong?
    Thanks in advance.
    Alain.

    You can only override non-private, non-static, methods. Other stuff may be hidden or shadowed, but not overridden.
    For anthing other than a non-private, non-static method, it's the compile-time type of the reference, not the runtime class of the object, that determines which class' version gets used.
    The code you provided prints F.N, not First Name as you state. I assume you meant this line myClass2 myObject = new myClass2();to look like this
    myClass1 myObject = new myClass2();If you had done that, then you'd have seen First Name, becuase myClass1 is of type myObjecdt1, and the compiler doesn't even see what's on the RHS of equals for this.

  • JDev 3.2 Deployment wizard failed to show public static methods in step #3.

    JDeveloper 3.2 and 3.1 Deployment Wizard ( step #3) does not show any public static methods being deployed as Java stored procedures. The "settings" button is disabled.
    Is this a demo version of the tool ?

    It's probably easier to add them all and remove the ones you don't want. Admittedly this is a bit cumbersome, because the 3.2 navigator doesn't allow multiple selection..
    (one area that's much better in 9i :) )
    Brian

  • Can we override jspinit,jspdestroy,jspservice methods in our own jsps?

    iam new to java.
    iam now learning these topics.
    can we override jspinit,jspdestroy,jspservice methods in our own jsps?
    plz send me with explanation.

    well, the JSP will become the content of the jspservice method.
    So yes, you can override that one (in fact there's no way you will NOT override it when creating a JSP :) ).
    But indeed, you should not even have the beginnings of any thought about "methods" or "overriding" anything when writing JSPs.
    You should not in fact use a single line of Java code when writing them.

  • Can you call a public method in a custom skin?

    I made a custom skin for a button. In the skin there's a method to change some text. Can I call this method from my application?
    I get an error message when I try to call it like a normal object:
    uploadNewBtn.setNewPhotosLabel("test");
    Error 1061: Call to a possibly undefined method setNewPhotosLabel through a reference with static type spark.components:Button.

    You said it yourself, the method is inside skin not the HostComponent (button in your case). Obviously you cannot call it.
    There is a skin protperty inside SkinnableComponent, but it is typed as UIComponent so you still cannot cal it on the skin without casting. I don't know your use case, so in theory you either push the text/label from the host towards the skin, or you listen or bind from the skin on the hostcomponent.
    C

  • Private construtor, public static method

    Hi,
    I'm having a problem trying to use a class' method. The class' constructor is private, and the methods are public static....
    I created an object that belongs to the class, but then when I try to apply the methods to the object, the do not appear (qhen I write the period). Does anybody know why this happens...
    Thanks and regards

    Ok,
    I'll show you the code I'm trying to use. In case you want to see more from it, I downloaded it from http://info.synapse.ru/software/jpitsa/
    Just to give you a more clear idea, I unzipped the jar file which contained the code, and I got two classes with the same name on the same folder (one is a read-only file). The class I'm trying to use is called "Methods". The particular method I'm trying to use from that class is the one called hilbert, which does the Hilbert Transform (which is a Mathematical transformartion for signal processing).
    Thanks for your help. Here comes my code:
    * Spectral Analysis Module
    * @author Denis Mishin ([email protected])
    package jpitsa.core;
    import java.util.LinkedList;
    public final class Methods implements Params {
        private Methods() { }
         * Discrete Fourier Transform. <BR>
         * This method can be applied to data with any data points, not only a power of 2,
         * but works significantly slower then DFFT algorithm
         * @param source the data to transform
         * @param direct true if transform is direct, false for inverse
         * @param fullSpectrum  as fourier transform is symmetrical, it is possible to use only one part of it.\
         *      then the spectrum is created for 1/2 N points. reverse transform will work pretty well.
         * @see jpitsa.core.ComplexVector
        public static ComplexVector DFT (ComplexVector source, boolean direct) {
            ComplexVector result;
            float[] resIm, resRe;
            float[] srcIm, srcRe;
            float isign = (direct == true) ? 1f : -1f;
            srcIm = source.getDataImaginaryPart();
            srcRe = source.getDataRealPart();
            int N = srcIm.length;
            float mf = (direct == true) ? 1f : 1f/(float)N;
            resIm = new float[N];
            resRe = new float[N];
            double fac;
            double f1, fCos, fSin;
            f1 = isign*2*Math.PI/(float)N;
            for (int n=0; n < N/2; n++) {
                for (int k=0; k < (N-1); k++) {
                    fac = (float)(f1*(double)(k*n));
                    fCos = Math.cos(fac);
                    fSin = Math.sin(fac);
                    resRe[n] += srcRe[k]*fCos - srcIm[k]*fSin;
                    resIm[n] += srcRe[k]*fSin + srcIm[k]*fCos;
                resRe[n] *= mf;
                resIm[n] *= mf;
                resRe[N-1-n] = resRe[n];
                resIm[N-1-n] = resIm[n];
            return new ComplexVector(resRe, resIm);
         * This method computes Discrete Fast Fourier Transform from a given
         * complex array. Return type is also a complex array.
         * Objectives: only data of 2^n points can be processed. Thus providing number of aliasing effects.
         * @see jpitsa.core.ComplexVector
        public static ComplexVector DFFT (ComplexVector source, boolean direct) {
            ComplexVector   result;
            float[] data;
            int isign, ndat;
            isign = (direct == true) ? 1 : -1;
            data = source.getPackedData();
            ndat = (data.length-1)/2;
            four1 (data, ndat, isign);
            //System.out.println("ndat="+ndat);
            // too big values .... [mar-99]
            if(!direct) {
                for(int i=0; i < ndat*2-1; i++)
                    data[i] /= ndat;
            result = new ComplexVector();
            result.setPackedData(data);
            return result;
         * Computes a spectrum of TimeSeries
         * @return spectrum truncated to Nyquist frequency
        public static ComplexVector spectrum(TimeSeries source) {
          float sampfreq = source.getSamplingFrequency();
          ComplexVector spec = DFFT(new ComplexVector(source.getData(),null), true);
          float[] srcReal, srcImag, tgtReal, tgtImag;
          srcReal = spec.getDataRealPart();
          srcImag = spec.getDataImaginaryPart();
          tgtReal = new float[srcReal.length/2];
          tgtImag = new float[srcImag.length/2];
          System.arraycopy(srcReal, 0, tgtReal, 0, tgtReal.length);
          System.arraycopy(srcImag, 0, tgtImag, 0, tgtImag.length);
          return new ComplexVector(tgtReal, tgtImag);
         * Return given spectrum part of time series object
         * @param source source data
         * @param part defines which part of transform to extract (AMPLITUDE, PHASE, REAL, IMAGINARY)
         * @return spectrum (FrequencySeries) object
        public static FrequencySeries spectrum(TimeSeries source, int part) {
            ComplexVector spec = spectrum(source);
            float sPart[] = extractPart(spec, part);
            sPart[0] = sPart[1];
            return new FrequencySeries(sPart,source.getSamplingFrequency()/((float)(2*sPart.length)));
        public static FrequencySeries spectrum(TimeSeries source, int part, int smooth_win) {
            ComplexVector spec = spectrum(source);
            float sPart[] = extractPart(spec, part);
            sPart[0] = sPart[1];
            sPart = smooth(sPart, smooth_win);
            return new FrequencySeries(sPart, source.getSamplingFrequency()/((float)(2*sPart.length)));
    public static FrequencySeries power_spectrum(TimeSeries src)
        float tr_wrk[];              /* pntr to work trace                   */
        float tr_tap[];              /* pntr to taper                        */
        float tr_ans[];              /* pntr to answer                       */
    //    float *tr_src[];                /* pntr to source trace               */
        float t_samp;               /* sampling rate of trace               */
        float delta_f;          /* delta f of resulting power spec     */
        float wss;               /* window squared and summed          */
        float sumsq;          /* sum of the input trace squared     */
        float avesq;          /* ave of the input trace squared     */
        float pow_sum;          /* PSD Sum                    */
        int i1, i2;                 /* index of the zoom in spr_zoom        */
        int n1, n2, n3, n4;         /* taper window size                    */
        int i,j;                    /* loop vars                            */
        int index;                  /* index into data from cha_list        */
        int n_dat;                  /* size of trace                        */
        int done;                   /* tells us if we are done with io      */
        int io_res;                 /* result of an io operation            */
        int n_fft;                  /* number of points in fft window       */      
        int n_chk;                  /* temp to check that n_fft is pwr of 2 */
        int i_st;               /* start of window for fft          */
        int ask_each;               /* see if we ask for input each loop    */
        int io_taper;               /* taper method we are going to use     */
        boolean zero_pad;               /* true when we have to zero pad window */
        int sc_type;          /* type of scale ie lin-lin          */
        int selection_method;     /* selection used for zoom          */
        int status;               /* status of zoom               */
        int n;               /* number of fft's used for answer     */
          get the size of the trace
         float[] tr_src = src.getData();
         n_dat = tr_src.length;
         i1 = 0; i2 = tr_src.length-1;
         n_fft = next2power(n_dat); // check!!!!
         dt_copy_header(buffer[0],data[index]);
         dt_copy_header(buffer[1],data[index]);
         dt_copy_header(buffer[2],data[index]);
         dt_head_access(buffer[0],RCD_NDAT,(void *)&n_fft);
         dt_head_access(buffer[1],RCD_NDAT,(void *)&n_fft);
         n = n_fft/2 + 1;
    //     dt_head_access(buffer[2],RCD_NDAT,(void *)&n);
         tr_wrk = new float[n_fft+1];
         System.arraycopy(tr_src, 0, tr_wrk, 0, tr_src.length);
         tr_tap = new float[tr_wrk.length];
         System.arraycopy(tr_wrk, 0, tr_tap, 0, tr_wrk.length);
         //tr_wrk = dt_trace_access(buffer,0,    0);
         //tr_tap = dt_trace_access(buffer,1    ,0);
         //tr_tap = // taper_it
         tr_ans = new float[n];
         //tr_ans = dt_trace_access(buffer,2    ,0);
         //tr_src = dt_trace_access(data  ,index,0);
          calculate the mean squared amplitude
         sumsq = 0f;
         for (j=i1; j<i2; j++) {
             sumsq += tr_src[j] * tr_src[j];
         avesq = sumsq / (float)(n_dat);
          get the taper values.  Buffer 0 gets tapered even thought there is nothing there
         n1 = 0;
         n2 = n3 = n_fft/2 - 1;
         n4 = n_fft - 1;
         Taper.doTapering(tr_tap, n1, n2, n3, n4, n_fft, WELCH_WINDOW);
          init the result
         for (j=0; j<n_fft/2; j++) {
             tr_ans[j] = 0;
          calculate wss (window squared and summed)
         wss = 0f;
         for (j=0; j<n_fft; j++) {
             wss += tr_tap[j] * tr_tap[j];
         wss *= (float)n_fft;
          calculate fft's until we need to pad with zeros
         t_samp = src.getSamplingInterval();
         zero_pad = false;
         i_st = i1;
         n = 0;
         while (!zero_pad) {
              load work array and taper
             for (j=0; j<n_fft; j++) {
              if ((i_st + j) > i2) {
                  tr_wrk[j] = 0f;
                  zero_pad = true;
              } else {
                  tr_wrk[j] = tr_src[i_st+j] * tr_tap[j];
              calculate fft
             n++;
             realft(tr_wrk,n_fft/2,1);
              accum results
             tr_ans[0] += tr_wrk[0]*tr_wrk[0];
             for (j=2; j<n_fft; j+=2) {
              tr_ans[j/2] += 2.0 * (tr_wrk[j]*tr_wrk[j] + tr_wrk[j+1]*tr_wrk[j+1]);
             tr_ans[n_fft/2] += tr_wrk[1]*tr_wrk[1];
             i_st += n_fft/2;
          normalize
         for (j=0; j<=n_fft/2; j++) {
             tr_ans[j] /= ((float)n*wss);
          integrate result
         delta_f = t_samp*n_fft;
         pow_sum = tr_ans[0];
         for (j=1; j<n_fft/2; j++) {
             pow_sum += tr_ans[j];
         pow_sum += tr_ans[n_fft/2];
          convert to units^2/Hz
         for (j=0; j<n_fft/2; j++) {
             tr_ans[j] = tr_ans[j]/delta_f;
         //delta_f = (t_samp*n_fft);
        return new FrequencySeries(tr_ans, src.getSamplingFrequency()/ (float) tr_ans.length);
        //source.getSamplingFrequency()/((float)(2*sPart.length))
        public static FrequencySeries powspec1(TimeSeries src, int m) {
            float[] rawdata = src.getData();
            float[] res = PowSpec.spctrm(rawdata, m, rawdata.length/2, true);
            return new FrequencySeries(res, src.getSamplingFrequency()/2f);
         * returns coherence spectrum of two traces
         * result is a complex vector truncated to Nyquist frequency
        public static ComplexVector coherenceSpectrum (TimeSeries trace1, TimeSeries trace2) {
          if (trace1.getSamplingFrequency() != trace2.getSamplingFrequency())
            throw new IllegalArgumentException("Sampling freqs do not match");
          if (trace1.getDataLength() != trace2.getDataLength())
            throw new IllegalArgumentException("vectors length do not match");
          ComplexVector spec1, spec2, cohSpec;
          spec1 = spectrum(trace1);
          spec2 = spectrum(trace2);
          return (ComplexVector)spec1.mul(spec2.conjugate());
         * returns a given part of coherence spectrum of two traces
        public static FrequencySeries coherenceSpectrum (TimeSeries trace1, TimeSeries trace2, int part) {
          float[] res = extractPart(coherenceSpectrum(trace1,trace2), part);
          return new FrequencySeries(res, trace1.getSamplingFrequency()/(float)(2*res.length));
         * XCorellation of two vectors
         * @param v1 first vector
         * @param v2 second vector
        public static Vector1D corellation(Vector1D v1, Vector1D v2) {
          if (v1.getDataLength() != v2.getDataLength())
            throw new IllegalArgumentException("vectors length do not match");
          ComplexVector sp1, sp2, res;
          sp1 = DFFT(new ComplexVector(v1.getData(),null), true);
          sp2 = DFFT(new ComplexVector(v2.getData(),null), true);
          res = DFFT((ComplexVector)sp1.mul(sp2.conjugate()), false);
          float[] data = res.getDataAmplitudePart();
          float[] data2 = new float[data.length/2];
          System.arraycopy(data,0, data2, 0, data2.length); data2[0] = data2[1];     
          return new Vector1D(data2);
         * Computes a sonogram for a trace
         * This is an optimized algorithm,
        public static Matrix sonogram(TimeSeries data, float stepSec, float window, int taperType, float taperFraction) {
          LinkedList frq = new LinkedList();
          float sampling = data.getSamplingFrequency();
          int step = Math.round(sampling*stepSec);
          DataWindow currentWindow = data.getWindow();
          data.setMessagesAllowed(false);
          DataWindow win = new DataWindow();
          win.startOffset = currentWindow.startOffset;
          win.length      = Math.round(window*sampling);
          boolean computing = true;
          float[] tgt = null;
          int leng = 0;
          if (step < 1)
            step = 1;
          System.err.println("COMPUTING SONOGRAM: step="+stepSec+" ("+step+") length="+window+" ("+win.length+")");
          while (computing) {
            data.setWindow(win);
            ComplexVector spec;
            float[] src = taper(data, taperFraction, taperType).getTotalData();
            spec = DFFT(new ComplexVector(src,null), DIRECT);
            leng = spec.getDataPointsNumber() / 2;
            tgt = new float[leng];
            spec.getDataAmplitudePart(tgt);
            src = extractPart(spec, AMPLITUDE, tgt);
            tgt = new float[ftlen];
            System.arraycopy(src,0,tgt,0,tgt.length);
            tgt = src;
            // --- THIS CODE SHOULD BE REMOVED
            for (int i=0; i < tgt.length; i++)
                tgt[i] = (tgt[i] > 0) ? (float)Math.log(tgt) : tgt[i];
    //tgt = smooth(tgt, Math.round(.05f*tgt.length));
    // --- THIS CODE SHOULD BE REMOVED
    //System.err.println("Step: "+win.startOffset+":"+win.length);
    frq.add(tgt);
    win.startOffset += step;
    if (win.getEnd() > currentWindow.getEnd())
    computing = false;
    data.setWindow(currentWindow);
    data.setMessagesAllowed(true);
    Matrix m;
    m = new Matrix(frq.size(), leng);
    for (int i=0; i < frq.size(); i++)
    m.setColumn(i,(float[])frq.get(i));
    m.setBounds(data.getActiveRegionOffsetSeconds(), data.getActiveRegionOffsetSeconds()+data.getDuration(),
    0f, data.getSamplingFrequency()/2f);
    return m;
    public static double[] toDouble(float[] data) {
    double[] ret = new double[data.length];
    for (int i=0; i < data.length; i++)
    ret[i] = data[i];
    return ret;
    * Differentiate a trace
    public static TimeSeries differentiate (TimeSeries src) {
    int ndat;
    float t_samp;
    int i;
    float[] tr;
    float buff;
    float buff0;
    ndat = src.getDataLength();
    t_samp = 1f/src.getSamplingFrequency();
    tr = src.getData();
    buff0 = tr[0];
    tr[0] *= 2f/t_samp;
    for(i=1;i<ndat;i++)
    buff = tr[i];
    tr[i] = (tr[i] - buff0)/t_samp;
    buff0 = buff;
    return (TimeSeries)src.newInstance(tr);
    * Integrate a trace
    * @param source source trace
    * @param method method to use: Trapezoid or Tick rule
    * @return integrated trace
    public static TimeSeries integrate(TimeSeries source, int method) {
    if (method == Params.TRAPEZOID)
    return Integrate.trapRule(source);
    else if (method == Params.TICK)
    return Integrate.tickRule(source);
    else
    throw new IllegalArgumentException("Invalid method "+method);
    * Integrates a trace using Tick's rule
    * @param source source trace
    * @return integrated trace
    public static TimeSeries integrate(TimeSeries source) {
    return integrate(source, Params.TICK);
    * Trace resampling
    * @param data source trace
    * @param newSampFreq new sampling frequency
    * @return new resampled trace
    public static TimeSeries resample(TimeSeries data, float newSampFreq) {
    float sampFreq = data.getSamplingFrequency();
    float[] newdata = interpolate(data.getData(), sampFreq, newSampFreq);
    TimeSeries res = (TimeSeries)data.newInstance(newdata);
    res.samplingFrequency = newSampFreq;
    return res;
    * Generic moving average window smoothing. <BR>
    * @param src source array
    * @param nx2 half window length
    public static Vector1D smooth(Vector1D src, int nx2) {
    return src.newInstance( smooth(src.getData(), nx2) );
    * Generic moving average window smoothing
    * @param src source array
    * @param nx2 half window length
    public static float[] smooth(float[] src, int nx2) {
    int ndat = src.length;
    float[] res = new float[ndat];
    //System.arraycopy(src, 0, res, 0, ndat);
    float sum1, sum2;
    int i, j, k;
    //System.err.println("NX2 = "+nx2);
    jpitsa.Out.cerr.println("data = "+src.length+"NX2 = "+nx2);
    for(i=nx2;i<=ndat-(nx2+1);i++) {
    sum1=0f; sum2=0f;
    for(j=1;j<=nx2;j++) {
    sum1 = sum1 + src[i-j];
    sum2 = sum2 + src[i+j];
    res[i] = (sum1+sum2+src[i])/(float)(2*nx2+1);
    for(i=1;i<=nx2-1;i++) {
    sum1=0f;
    sum2=0f;
    k = 0;
    for(j=1;j<=i;j++) {
    sum1 = sum1+ src[i-j];
    sum2 = sum2+ src[i+j];
    k = j;
    res[i] = (sum1+sum2+src[i])/(float)(2*k+1);
    for(i=1;i<=nx2-1;i++) {
    sum1 = sum2 = 0f;
    k = 0;
    for(j=1;j<=i;j++) {
    sum1 = sum1+ src[ndat-1-i-j];
    sum2 = sum2+ src[ndat-1-i+j];
    k = j;
    res[ndat-1-i] = (sum1+sum2+src[ndat-1-i])/(float)(2*k+1);
    res[ndat-1] = src[ndat-1];
    res[0] = src[0];
    return res;
    * Generic 4-point spline interpolation method.
    * @param data source data
    * @param oldSampFreq source sampling frequency (1/sampling interval)
    * @param newSampFreq target sampling frequency
    public static float[] interpolate(float[] data, // source data
    float oldSampFreq, // old sampling freq. [Hz]
    float newSampFreq) // new samp. freq. [Hz]
    int n_int = 4; /* degree of polynomial for interpoltion */
    float xa[]= new float[n_int+1]; /* interpolation buffer */
    float ya[]= new float[n_int+1]; /* interpolation buffer */
    int closest_sample=-1, int_start_sample=-1;
    float delta_value = 0f; /* error estimate for interpolated value */
    // this is because PITSA and JPITSA use different schemes for sampling freq. storing
    float t_samp_old = 1f / oldSampFreq;
    float t_samp_new = 1f / newSampFreq;
    int ndat = data.length;
    float x1=t_samp_old/t_samp_new;
    x1 *= (float)ndat;
    int ndat2 = Math.round(x1+5e-1f); // Number of data in new arrary
    float[] tr1 = data;
    float[] b1 = new float[ndat2];
    float[] prom_res= new float[2]; // temp. buffer for polint() procedure
    // 4-point Spline interpolation procedure
    float new_x;
    for (int j = 0; j < ndat2;j++){
    new_x = (float)j*t_samp_new;
    /* determine index of closest sample in trace */
    closest_sample = (int)(new_x/t_samp_old);
    if ((closest_sample >= (int)((float)n_int/2.)) &&
    (closest_sample <= ndat - (int)((float)n_int/2.) - 1))
    int_start_sample = closest_sample - (int)((float)n_int/2.) - 1;
    }else if (closest_sample < (int)((float)n_int/2.)) {
    int_start_sample = -1;
    }else if (closest_sample > ndat - (int)((float)n_int/2.) - 1) {
    int_start_sample = ndat -1 - n_int;
    for (int jj = 1;jj <= n_int; jj++) {
    ya[jj] = tr1[int_start_sample + jj];
    xa[jj] = (int_start_sample + jj)*t_samp_old;
    prom_res[0] = x1; prom_res[1] = delta_value;
    polint(xa,ya,n_int,new_x, prom_res);
    b1[j] = x1 = prom_res[0]; delta_value = prom_res[1];
    return b1;
    * Generic 4-point spline interpolation method.
    * @param data source data
    * @param newLength number of points in a new array
    public static float[] interpolate(float[] data, int newLength) {
    int n_int = 4; /* degree of polynomial for interpoltion */
    float xa[]= new float[n_int+1]; /* interpolation buffer */
    float ya[]= new float[n_int+1]; /* interpolation buffer */
    int closest_sample=-1, int_start_sample=-1;
    float delta_value = 0f; /* error estimate for interpolated value */
    // this is because PITSA and JPITSA use different schemes for sampling freq. storing
    float t_samp_old = 1f / oldSampFreq;
    float t_samp_new = 1f / newSampFreq;
    int ndat = data.length;
    float x1=t_samp_old/t_samp_new;
    x1 *= (float)ndat;
    int ndat2 = Math.round(x1+5e-1f); // Number of data in new arrary
    int ndat = data.length;
    int ndat2 = newLength;
    float t_samp_old = 1f;
    float t_samp_new = ((float)ndat)/((float)ndat2);
    float x1 = (float)ndat2;
    float[] tr1 = data;
    float[] b1 = new float[ndat2];
    float[] prom_res= new float[2]; // temp. buffer for polint() procedure
    // 4-point Spline interpolation procedure
    float new_x;
    for (int j = 0; j < ndat2;j++){
    new_x = (float)j*t_samp_new;
    /* determine index of closest sample in trace */
    closest_sample = (int)(new_x/t_samp_old);
    if ((closest_sample >= (int)((float)n_int/2.)) &&
    (closest_sample <= ndat - (int)((float)n_int/2.) - 1))
    int_start_sample = closest_sample - (int)((float)n_int/2.) - 1;
    }else if (closest_sample < (int)((float)n_int/2.)) {
    int_start_sample = -1;
    }else if (closest_sample > ndat - (int)((float)n_int/2.) - 1) {
    int_start_sample = ndat -1 - n_int;
    for (int jj = 1;jj <= n_int; jj++) {
    ya[jj] = tr1[int_start_sample + jj];
    xa[jj] = (int_start_sample + jj)*t_samp_old;
    prom_res[0] = x1; prom_res[1] = delta_value;
    polint(xa,ya,n_int,new_x, prom_res);
    b1[j] = x1 = prom_res[0]; delta_value = prom_res[1];
    return b1;
    * Butterworth Band Pass Filter
    * implements Band, Low and High Pass filters
    * All three Butterworth filters are recursive time domain filters
    * using the bilinear z-transform design after Stearns (1984)
    * They are applied in section of 30 dB/decade or 12 Db/octave for
    * the slope of the transition band. They may be given zero phase
    * characteristic by filterin the reversed filtered time seris
    * again (forwards-backwards filtering)
    * Finally, the trace is reversed to its original orientation
    * based on spr_bp_bworth (spr/spr_bpbt.c)
    * @author Denis Mishin ([email protected]) - Java code
    * @author PITSA team - original C code
    * @param trace input trace
    * @param flo low cut corner frequency [Hz]
    * @param fhi high cut corner frequency [Hz]
    * @param ns number of filter passes [Hz]
    * @param is_zph TRUE -> zero phase filter
    * @return new filtered trace
    public static TimeSeries bandpassFilter(TimeSeries trace,
    float flo,
    float fhi,
    int ns,
    boolean is_zph)
    final int MAX_SEC = 10;
    int i, k; /* index */
    int n,m,mm;
    int ndat; /* number of points in trace */
    double tsa;
    double a[] = new double[MAX_SEC+1];
    double b[] = new double[MAX_SEC+1];
    double c[] = new double[MAX_SEC+1];
    double d[] = new double[MAX_SEC+1];
    double e[] = new double[MAX_SEC+1];
    double f[][] = new double[MAX_SEC+1][6];
    double temp;
    double c1,c2,c3;
    double w1,w2,wc,q,p,r,s,cs,x;
    float tr[];
    ndat = trace.getDataLength();
    tsa = 1f / trace.getSamplingFrequency();
    tr = trace.getData();
    // remove mean
    float mean = mean(tr);
    for (i=0; i < tr.length; i++)
    tr[i] -= mean;
    /* design filter weights */
    /* bandpass */
    w1 = java.lang.Math.sin(flo*java.lang.Math.PI*tsa)/java.lang.Math.cos(flo*java.lang.Math.PI*tsa);
    w2 = java.lang.Math.sin(fhi*java.lang.Math.PI*tsa)/java.lang.Math.cos(fhi*java.lang.Math.PI*tsa);
    wc=w2-w1;
    q=wc*wc +2.0*w1*w2;
    s=w1*w1*w2*w2;
    for (k=1;k<=ns;k++)
    c1 = (float)(k+ns);
    c2 = (float)(4*ns);
    c3 = (2.0*c1-1.0)*java.lang.Math.PI/c2;
    cs = java.lang.Math.cos(c3);
    p = -2.0*wc*cs;
    r = p*w1*w2;
    x = 1.0+p+q+r+s;
    a[k]= wc*wc/x;
    b[k]= (-4.0 -2.0*p+ 2.0*r+4.0*s)/x;
    c[k]= (6.0 - 2.0*q +6.0*s)/x;
    d[k]= (-4.0 +2.0*p -2.0*r +4.0*s)/x;
    e[k]= (1.0 - p q-r s)/x;
    /* set initial values to 0 */
    for(n=0;n<=MAX_SEC;n++)
    for(m=0;m<=5;m++)
    f[n][m]=0.0;
    /* filtering */
    for (m=1;m<=ndat;m++) {
    f[1][5]= tr[m-1];
    /* go thru ns filter sections */
    for(n=1;n<=ns;n++)
    temp=a[n]*(f[n][5]-2.0*f[n][3] +f[n][1]);
    temp=temp-b[n]*f[n+1][4]-c[n]*f[n+1][3];
    f[n+1][5]=temp-d[n]*f[n+1][2]-e[n]*f[n+1][1];
    /* update past values */
    for(n=1;n<=ns+1;n++)
    for(mm=1;mm<=4;mm++)
    f[n][mm]=f[n][mm+1];
    /* set present data value and continue */
    tr[m-1] = (float)f[ns+1][5];
    // System.out.println("tr ["+(m-1)+"] = "+tr[m-1]);
    if (is_zph == true) {
    /* filtering reverse signal*/
    for (m=ndat;m>=1;m--) {
    f[1][5]= (double)tr[m-1];
    /* go thru ns filter sections */
    for(n=1;n<=ns;n++)
    temp=a[n]*(f[n][5]-2.0*f[n][3] +f[n][1]);
    temp=temp-b[n]*f[n+1][4]-c[n]*f[n+1][3];
    f[n+1][5]=temp-d[n]*f[n+1][2]-e[n]*f[n+1][1];
    /* update past values */
    for(n=1;n<=ns+1;n++)
    for(mm=1;mm<=4;mm++)
    f[n][mm]=f[n][mm+1];
    /* set present data value and continue */
    tr[m-1] = (float)f[ns+1][5];
    // restore mean
    for (i=0; i < tr.length; i++)
    tr[i] += mean;
    return (TimeSeries)trace.newInstance(tr);
    * Gaussian filter. <BR>
    * Removes mean by default
    public static TimeSeries gaussianFilter(TimeSeries src, float fCent, float alpha) {
    return gaussianFilter(src, fCent, alpha, true);
    * Gaussian bandpass filter
    * @param src source trace
    * @param fCent central frequency value
    * @param alpha bandwidth
    * @param rmean remove mean first flag
    * @return new filtered vector
    public static TimeSeries gaussianFilter(TimeSeries src, float fCent, float alpha, boolean rmean) {
    float[] fc = new float[1]; fc[0] = fCent;
    float[] al = new float[1]; al[0] = alpha;
    return gaussianFilter(src, fc, al, rmean);
    * Gaussian bandpass filter
    * @param src source trace
    * @param fCent central frequency values
    * @param alpha bandwidths
    public static TimeSeries gaussianFilter(TimeSeries src, float fCent[], float alpha[], boolean rmean) {
    float[] sourceData = src.getData();
    float mean = 0f;
    int i;
    if (rmean) {
    mean = mean(sourceData);
    for (i=0; i < sourceData.length; i++)
    sourceData[i] -= mean;
    ComplexVector spec = DFFT(new ComplexVector(src.getData(),null), true);
    int npoints = spec.getDataPointsNumber();
    float nyq = src.getSamplingFrequency()/2f;
    // ---- computing the Gaussian distribution function
    float[] gaus = new float[npoints];
    float freqIncrement = (2f*nyq)/((float)npoints);
    int cp = 0; float f = 0f;
    while (f <= nyq && cp < (npoints/2) ) {
    gaus[cp] = Filter.gaussianWindow(f,fCent,alpha);
    cp++; f += freqIncrement;
    int last_index = gaus.length-1;
    for (cp=0; cp < (npoints/2); cp++)
         gaus[last_index - 1] = gaus[cp];
    float[] real = extractPart(spec,Params.REAL);
    float[] imag = extractPart(spec,Params.IMAGINARY);
    //System.out.println("Gaus: real.length="+real.length+" spec.length="+npoints+
    //     " stop at "+f+" nyq="+nyq);
    real = multiplicate(real,gaus);
    imag = multiplicate(imag,gaus);
    //real = glue(real, invert(real));
    //imag = glue(imag, invert(imag));
    ComplexVector inv = DFFT(new ComplexVector(real,imag), Params.INVERSE);
    real = extractPart(inv, Params.REAL);
    float[] data = new float[real.length/2];
    System.arraycopy(real,0,data,0,data.length);
    TimeSeries result = new TimeSeries(data, nyq*2f);
    float[] data = sourceData;
    System.arraycopy(real,0,data,0,data.length);
    if (rmean) {
    for (i=0; i < data.length; i++)
    data[i] += mean;
    TimeSeries result = (TimeSeries)src.newInstance(data);
    return result;
    * Discretisation of source trace data
    * Discretization will treat the input trace as a pseudo-continuous trace from which

  • Can't get ClassLoader from static method.

    I'm trying to get the ClassLoader within a static method getInstance().
    public class PropertyManager {
    public static PropertyManager getInstance(String fileName) {
    //The following line returns null
    ClassLoader cl = (new Object()).getClass().getClassLoader();
    URL url = cl.getResource(fileName);
    etc...
    However if getInstance gets called from e.g. a statless session bean, a null
    is returned instead of a valid ClassLoader.
    The same code executed from a standalone java program (e.g. from
    main(String[] args)) returns a valid ClassLoader
    Why does getClassLoader behave differently in WebLogic than in a standalone
    java program?
    Thanks for you help.
    Bernie

    Sorry for the confusion. I wrote a couple of more test programs and was able
    to confirm that WL behaves exacltly the same as java does. For some reason
    my intial tests were messed up...
    getClassLoader() executed from a static method always returns null (in WL as
    well as in a java standalone program).
    In this case ClassLoader.getSystemClassLoader() will return a valid class
    loader.
    Thanks for your help.
    Bernie
    "Rob Woollen" <[email protected]> wrote in message
    news:[email protected]..
    Bernhard Lenz wrote:
    I tried that as well, but getClassLoader() still returns null when
    executed
    in WL.
    I'm still not clear how getClassLoader() gets affected by running withinWL.
    >>
    >
    Very odd. Where is this class located? in the server's classpath, in ajar or
    war file? Does getClass().getClassLoader work from a non-static method inthis
    class?
    -- Rob
    "Rob Woollen" <[email protected]> wrote in message
    news:[email protected]..
    You want PropertyManager.class.getClassLoader()
    -- Rob
    Bernhard Lenz wrote:
    I'm trying to get the ClassLoader within a static method
    getInstance().
    >>>>
    public class PropertyManager {
    public static PropertyManager getInstance(String fileName) {
    //The following line returns null
    ClassLoader cl = (new Object()).getClass().getClassLoader();
    URL url = cl.getResource(fileName);
    etc...
    However if getInstance gets called from e.g. a statless sessionbean, a
    null
    is returned instead of a valid ClassLoader.
    The same code executed from a standalone java program (e.g. from
    main(String[] args)) returns a valid ClassLoader
    Why does getClassLoader behave differently in WebLogic than in astandalone
    java program?
    Thanks for you help.
    Bernie

  • Can you override passcode lock - phone died

    hi i have an iphone 4 16gb, i was using it normally yesterday, the battery drained out, and today in the morning i plugged it in to charge it and it wont come up, i used different cables thinking the usb was wrong tried the pc and the wall outlet but no it wont turn on any more, the phone is still under warranty so i can take it to my carrier to have it checked , the problem is, i have a passcode lock and there is information (photos) that i dont want anybody to have acces to, my question would be if i take it to repair and they manage to turn it on, would they be able to see my stuff, can they override the passcode, or is there any other way they can have acces to that info???........... seriously id rather loose the phone if they can have acces to my stuff. any help???

    there is information (photos) that i dont want anybody to have acces to,
    Sensitive information like that should have never been put into any phone.
    if i take it to repair and they manage to turn it on, would they be able to see my stuff
    Probably.
    can they override the passcode
    There is a procedure on the Internet to do just that.
    id rather loose the phone if they can have acces to my stuff. any help??
    If you are that concerned, the phone should be destroyed.

  • Why can't inner classes have static methods?

    I just tried to add a static method to an inner class, which would have been useful for extracting constants about said inner class, and it turns out that is not allowed.
    Of course I have other ways to code what I wanted, but I'm curious as to why this restriction was set in place. Anybody know?

    Probably because an inner class is tied to an instance of the enclosing class. I think that, conceptually at least, the inner class' definition itself only exists in the context of an instance of the enclosing class. While I'm sure it would have been technically possible to allow it, it would be confusing and not make a whole lot of sense--what is the static context for the inner class, since the class only exists in a non-static context?

  • Why global var can be initialized with a static method and not by other static global var declared after its usage

    Take this:
    class test
    static int i=j;
    static int j=10;
    this will give illegal forward reference ....
    but this will compile successfully ..
    class test
    static int i=test1();
    static test1()
    return 20;
    plz assume we have main method in both cases ..
    java would be loading all static members first and would be assigning default values .. and then will be running all the initializers from to bottom ..
    Why second case is a compile success and not first .. as in second also test1 method is declared after its usage ..
    Plz help.
    Thanks
    Abhishek Roshan

    Why second case is a compile success and not first .. as in second also test1 method is declared after its usage ..
    Because the implementors of Java intentionally chose to do it that way.
    There are TWO stages to the process: preparation (which occurs first) and initialization.
    See the Java Language Spec section 12.4.1 'When Initialization Occurs
    The intent is that a class or interface type has a set of initializers that put it in a consistent state, and that this state is the first state that is observed by other classes. The static initializers and class variable initializers are executed in textual order, and may not refer to class variables declared in the class whose declarations appear textually after the use, even though these class variables are in scope (§8.3.2.3). This restriction is designed to detect, at compile time, most circular or otherwise malformed initializations.
    Note the clause beginning 'may not refer to class variables'. And the authors give the reason for that restriction in the last sentence: detect circular initializations.
    Then if you check that referenced section 8.3.2.3 you will find this
    http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.3.2.3
    8.3.2.3. Restrictions on the use of Fields during Initialization
    The declaration of a member needs to appear textually before it is used only if the member is an instance (respectively static) field of a class or interface C and all of the following conditions hold:
      The usage occurs in an instance (respectively static) variable initializer of C or in an instance (respectively static) initializer of C.
      The usage is not on the left hand side of an assignment.
      The usage is via a simple name.
      C is the innermost class or interface enclosing the usage.
    When a method is used (your example 2) no circular initialization can occur because methods are not 'initialized'.

  • How can you get  the public variables from object that extends JLabel?

    I'm using the mouseClickedListener method e.getComponent(); to get the component that is clicked on the sceen. The component i clicked is type "object" and extends a jlabel, and i really need to acces a variable from it. Heres the code i'm using-
    MouseListener listenerDown=new java.awt.event.MouseListener() {
            public void mousePressed(MouseEvent e){
                paintAll();
                mX=e.getX();
                mY=e.getY();
            public void mouseClicked(MouseEvent e) {
                Component c = e.getComponent();
                drawResizeBox(c);
                selected=c;
            public void mouseReleased(MouseEvent e) {
            public void mouseEntered(MouseEvent e) {
            public void mouseExited(MouseEvent e) {
    package javapoint;
    import java.awt.Color;
    import java.awt.Graphics2D;
    import java.awt.Image;
    import java.awt.Rectangle;
    import java.awt.RenderingHints;
    import java.awt.geom.Line2D;
    import java.awt.image.BufferedImage;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JLabel;
    public class object extends JLabel{
        public object(Rectangle rect,int id){
            idNum=id;
            Rect=rect;
            BufferedImage image = new BufferedImage((int)rect.getWidth()+1, (int)rect.getHeight()+1, BufferedImage.TYPE_INT_ARGB);
            Graphics2D g = (Graphics2D) image.getGraphics();       
            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g.drawRect((int)rect.getX(), (int)rect.getY(), (int)rect.getWidth(), (int)rect.getHeight());
            Icon icon = new ImageIcon((Image)image);
            setIcon(icon);
            setBounds((int)rect.getX()-1, (int)rect.getY()-1, (int)rect.getWidth()+1, (int)rect.getHeight()+1);
            mainFrame.slideArr[mainFrame.sIndx].add(this);
            setVisible(true);
            r=true;       
        object(Oval oval,int id){
            idNum=id;       
            setBounds(oval.getX(), oval.getY(), oval.getWidth(), oval.getHeight());
            getGraphics().drawOval(oval.getX(), oval.getY(), oval.getWidth(), oval.getHeight());
            o=true;
            setVisible(true);
        object(Line2D line,int id){
            idNum=id;       
            setBounds((int)line.getX1(), (int)line.getY1(), (int)line.getX2(), (int)line.getY2()); //Not gunna work
            getGraphics().drawLine((int)line.getX1(), (int)line.getY1(), (int)line.getX2(), (int)line.getY2());
            l=true;
            setVisible(true);
        object(Icon icon,int id){
            idNum=id;
            setIcon(icon);
            setBounds(50,50,icon.getIconWidth(),icon.getIconHeight());
            i=true;
            setVisible(true);
        void drawObject(object obj){
            if(r){
                Rectangle rect=obj.Rect;
                setBounds((int)rect.getX()-1, (int)rect.getY()-1, (int)rect.getWidth()+1, (int)rect.getHeight()+1);          
                Rect=rect;
                BufferedImage image = new BufferedImage((int)rect.getWidth()+1, (int)rect.getHeight()+1, BufferedImage.TYPE_INT_ARGB);
                Graphics2D g = (Graphics2D) image.getGraphics();           
                g.setColor(Color.red);
                g.drawRect(0, 0, (int)rect.getWidth(), (int)rect.getHeight());           
                Icon icon = new ImageIcon((Image)image);
                setIcon(icon);
            }else if(l){
            }else if(o){
            }else if(i){
        public boolean r=false;
        public Rectangle Rect;
        public boolean o=false;
        public Oval Oval;
        public boolean l=false;
        public Line2D Line;
        public boolean i=false;
        public Icon Icon;
        public JLabel label;
        public int idNum;
    }Edited by: ghostbust555 on Feb 12, 2010 2:14 PM

    ghostbust555 wrote:
    Well see the problem is i have an array of 200 objects.What does that have to do with anything? And if it does, why isn't it in the code you posted?
    I dont understand what you mean in your "Edit..." part. could you show some code/ explain farther? sorry if its a dumb question I'm still a bit of a novice at java.Yeah.
    object yuck = (object) e.getComponent(); // That's a cast.
    boolean yucksR = yuck.r; // Get the "r" variable from the object.

  • Can you create a custom static top third and nav bar?

    I have created an index page with a custom nav bar and main banner. Is it possible with iweb that this could remain static and just the portion below reloads when you click a nav bar link?

    You can do custom templates and so on and 'print' these to JPEG, or just Export a bunch of JPEGs and put them in iPhoto to create a book online. Not the same, I know, but in case one wanted to do one.
    There is a feature request forum, at <https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform>

  • Can you override record pcode via component record pcode?

    Normally both record peoplecode and component record peoplecode is executed for a given record/field. You can control processing in record pcode by testing on %component ... but is there a way, in the component record pcode, to prevent or completely override execution of the corresponding record pcode script?

    Ok - 84 people have viewed this and no one has replied, so I assume that the answer is, no. I'm marking this as 'answered'. Thanks, all.

  • Can you override scaled type in indesign CS6?

    I have many charts that have been made over the course of multiple years. I now need to have them all on the same page. I'd like to respecify the type without recreating all the charts from scratch. Although I am highlighting and putting in the correct point size it is not allowing me to hold it. And is giving me a (6.5 pt) sort of thing next to the 7 I am putting in. Is there any way to get rid of that old scaling so I can make all my trick charts print in the same point size?

    There's a menu in the upper right of your work area. With the text box selected, choose Redefine scaling as 100%
    (it's greyed out in my screen shot because what i had selected was not scaled, but it will be available if you have scaled content selected)

  • Can you override internal iSight with external iSight?

    I have upgraded to a MBP with the built in iSight and still have the old iSight from my iBook. I wonder if anyone has been able to override the internal iSight to use the external cam. I think it's great that it's built in, but there are times when I don't want to have to pivot the entire laptop just to display something in the room (i.e. what the dogs are doing on the floor etc.)
    Mac Book Pro   Mac OS X (10.4.6)  

    Sorry, I'm only familiar with this as far as cam chat
    programs.
    Hi, chat is what I want to do - I have a logitech cam which works fine with the ibook but I can't find a way to overide the MBP's internal isight. Even when I try the imovie tip suggested the camera doesn't get recognised in system profiler although there's power to it.
    Any ideas?

Maybe you are looking for

  • March 2015 TechNet Guru Awards! See who's boss in SharePoint 2010! It could be YOU!

    The results for March's TechNet Guru competition were posted! http://blogs.technet.com/b/wikininjas/archive/2015/04/17/the-microsoft-technet-guru-awards-march-2015.aspx Below is a summary of the medal winners for December. The last column being a few

  • Set center and size

    Hi, How can I set the center and size of a map to view a group of points (like zoom to selection function). Thank you Ali

  • Frozen on re-building library, plus connection problems (Zen Mic

    Yes, I read the FAQ :smileytongue: I JUST got my new Zen Micro and started putting songs on it. It started giving me trouble with the connection, but was ok for a little bit. After awhile I couldn't get a connection at all. My computer says there's n

  • Virtual Private Database

    Hi All, We are using Oracle 11g R2 and we would like to implement Virtual Private Database. We have an application connected to LDAP with serveral users. The users are also created in Weblogic. The Application is using only with Oracle schema with ma

  • Is Test Management available in Solman 7.1 SP5

    Hi experts, We have Solman 7.1 SP5 installed , and trying to explore more into E2E Testing.But i couldnt find "Test Management" in solman Work Center. Is Test Management available in Solman 7.1 SP5 ? if yes , How can can get it visible/access in Work