Problem z plikiem class

0

itam!
Od razu przejdę do rzeczy. Zainteresował mnie aplet JAVY, który mozna znaleźć na stronie:
http://www.script.republika.pl/skrypty/def_foto.html
Próbowałem to sklecić na swoją stronę, lecz efekt tego mizerny jest...
TU znajduje się AlexWarp - nie zmieniałem w nim nic (jestem początkujący, jesli chodzi o JAVĘ)
Co chciałem uzyskać - WŁAŚNIE TO , ale jak widać na "załączonym obrazku" wyskakuje błąd. Bardzo proszę o pomoc - co takiego robię nie tak, że nie wyświetla mi poprawnie grafy? Wszystkie pliki są w odpowiednich folderach...
Sam nie poradzę sobie - to moje pierwsze starcie z JAVĄ ...

Zrobiłem plik htm specjalnie na "potrzeby" ....
http://www.next.cal.pl/proba.htm
ale dalej nic...

A może ewentualnie ktośz Was zna inny skrypt o takim samym (lub przynajmniej zbliżonym) działaniu?

0

Hmmm... masz moze kod tego appletu ?

Czy poptostu skopiowales go z html ?

Nie rozumiem co rozumiesz przez pojecie skopiowalem go.

0

Plik AlexWarp.class na tej stronie http://www.script.republika.pl/skrypty/def_foto.html jest inny niż na tej stronie http://www.next.cal.pl/proba.htm. Ten drugi w ogóle nie jest apletem.

0

Sorry nie wiem o co Ci chodzi....

Drugi link nie dziala. a pierwszy to jest applet a z tego co ja wiem, to z appletu na stronce nie da sie wyciagnac kodu....

0

Nie pozmajesz adresu własnej strony ? Kopiowałem adres przez schowek i się dokleiła kropka.
http://www.next.cal.pl/proba.htm

0

A tu masz dowód, że strony można wyciągnąć kod apletu. (nie jestem hackerem, zajęło mi to niecałą minutę)

import java.applet.Applet;
import java.awt.*;
import java.awt.image.*;

public class AlexWarp extends Applet
    implements Runnable
{

    public void run()
    {
        Initialize();
        while(mStartup != null) 
        {
            try
            {
                Thread.sleep(500L);
            }
            catch(InterruptedException _ex) { }
            if(!mReady)
            {
                mStatus += ".";
                showStatus(mStatus);
            }
        }
    }

    void Initialize()
    {
        mStatus = "Loading image...";
        showStatus(mStatus);
        mReady = false;
        mCanUndo = false;
        mRedo = false;
        mUndoButton.disable();
        mImage = getImage(getCodeBase(), mImageName);
        while((mWidth = mImage.getWidth(this)) < 0) 
            try
            {
                Thread.sleep(100L);
            }
            catch(InterruptedException _ex) { }
        while((mHeight = mImage.getHeight(this)) < 0) 
            try
            {
                Thread.sleep(100L);
            }
            catch(InterruptedException _ex) { }
        mPixels = new int[mWidth * mHeight];
        mOldPixels = new int[mWidth * mHeight];
        PixelGrabber pixelgrabber = new PixelGrabber(mImage, 0, 0, mWidth, mHeight, mPixels, 0, mWidth);
        boolean flag = false;
        do
        {
            try
            {
                flag = pixelgrabber.grabPixels(500L);
            }
            catch(InterruptedException _ex)
            {
                mStatus = "AlexWarp interrupted.";
                showStatus(mStatus);
                return;
            }
            mStatus += ".";
            showStatus(mStatus);
        } while(!flag);
        if((pixelgrabber.status() & 0x80) != 0)
        {
            mStatus = "AlexWarp interrupted.";
            showStatus(mStatus);
            return;
        } else
        {
            mReady = true;
            mStatus = "Ready for warping. Click and drag in the image to warp it.";
            showStatus(mStatus);
            repaint();
            return;
        }
    }

    void DoneWithWarping()
    {
        mImage = createImage(new MemoryImageSource(mWidth, mHeight, mPixels, 0, mWidth));
        mUndoButton.enable();
        mUndoButton.setLabel("Undo");
        mRedo = false;
        mCanUndo = true;
        repaint();
        mReady = true;
        mWarper = null;
        mStatus = "Ready for warping. Click and drag in the image to warp it.";
        showStatus(mStatus);
    }

    public void paint(Graphics g)
    {
        if(mImage != null)
            g.drawImage(mImage, 30, 35, this);
        if(mFromPoint != null && mToPoint != null)
        {
            g.setColor(Color.red);
            g.drawLine(mFromPoint.x, mFromPoint.y, mToPoint.x, mToPoint.y);
            g.setColor(Color.black);
        }
    }

    public void update(Graphics g)
    {
        paint(g);
    }

    public void start()
    {
        if(mImage == null)
        {
            Button button = new Button("Undo");
            add(button);
            button.disable();
            mUndoButton = button;
            button = new Button("Stop");
            add(button);
            button = new Button("Reset");
            add(button);
            mImageName = getParameter("image");
            if(mImageName == null)
                mImageName = "warp.gif";
            mStartup = new Thread(this);
            mStartup.start();
        }
    }

    public void stop()
    {
        if(mStartup != null)
            mStartup.stop();
        mStartup = null;
        if(mWarper != null)
            mWarper.stop();
        mWarper = null;
    }

    public boolean action(Event event, Object obj)
    {
        if("Undo".equals(obj) || "Redo".equals(obj))
        {
            int ai[] = mPixels;
            mPixels = mOldPixels;
            mOldPixels = ai;
            mImage = createImage(new MemoryImageSource(mWidth, mHeight, mPixels, 0, mWidth));
            mRedo = !mRedo;
            mUndoButton.setLabel(mRedo ? "Redo" : "Undo");
            repaint();
            return true;
        }
        if("Stop".equals(obj))
        {
            if(mWarper != null)
            {
                mWarper.stop();
                mWarper = null;
                mReady = true;
                mCanUndo = false;
                mUndoButton.disable();
                repaint();
                mStatus = "Ready for warping. Click and drag in the image to warp it.";
                showStatus(mStatus);
            }
            return true;
        }
        if("Reset".equals(obj))
        {
            if(mWarper != null)
            {
                mWarper.stop();
                mWarper = null;
            }
            if(mStartup != null)
            {
                mStartup.stop();
                mStartup = new Thread(this);
                mStartup.start();
            }
            return true;
        } else
        {
            return false;
        }
    }

    public boolean mouseDown(Event event, int i, int j)
    {
        if(!PointInImage(i, j) || !mReady)
        {
            return false;
        } else
        {
            mFromPoint = new Point(i, j);
            return true;
        }
    }

    public boolean mouseDrag(Event event, int i, int j)
    {
        if(mFromPoint == null)
        {
            return false;
        } else
        {
            mToPoint = ClipToImage(mFromPoint, i, j);
            repaint();
            return true;
        }
    }

    public boolean mouseUp(Event event, int i, int j)
    {
        if(mFromPoint == null)
        {
            return false;
        } else
        {
            mReady = false;
            mStatus = "Warping...";
            showStatus(mStatus);
            int ai[] = mOldPixels;
            mOldPixels = mPixels;
            mPixels = ai;
            Point point = ClipToImage(mFromPoint, i, j);
            mWarper = new ImageWarper(this, mOldPixels, mPixels, mWidth, mHeight, new Point(point.x - 30, point.y - 35), new Point(mFromPoint.x - 30, mFromPoint.y - 35));
            mWarper.start();
            mFromPoint = mToPoint = null;
            return true;
        }
    }

    boolean PointInImage(int i, int j)
    {
        return i >= 30 && i < 30 + mWidth && j >= 35 && j < 35 + mHeight;
    }

    Point ClipToImage(Point point, int i, int j)
    {
        int k = i - point.x;
        int l = j - point.y;
        if(k == 0)
        {
            if(j < 35)
                j = 35;
            if(j >= 35 + mHeight)
                j = (35 + mHeight) - 1;
        } else
        if(l == 0)
        {
            if(i < 30)
                i = 30;
            if(i >= 30 + mWidth)
                i = (30 + mWidth) - 1;
        } else
        {
            double d = (double)l / (double)k;
            if(i < 30)
            {
                i = 30;
                j = point.y + (int)(d * (double)(i - point.x));
            }
            if(i >= 30 + mWidth)
            {
                i = (30 + mWidth) - 1;
                j = point.y + (int)(d * (double)(i - point.x));
            }
            if(j < 35)
            {
                j = 35;
                i = point.x + (int)((double)(j - point.y) / d);
            }
            if(j >= 35 + mHeight)
            {
                j = (35 + mHeight) - 1;
                i = point.x + (int)((double)(j - point.y) / d);
            }
        }
        return new Point(i, j);
    }

    public AlexWarp()
    {
        mStatus = "";
        mReady = false;
        mCanUndo = false;
        mRedo = false;
    }

    Thread mStartup;
    ImageWarper mWarper;
    String mImageName;
    Image mImage;
    int mPixels[];
    int mOldPixels[];
    int mWidth;
    int mHeight;
    String mStatus;
    Point mFromPoint;
    Point mToPoint;
    boolean mReady;
    boolean mCanUndo;
    boolean mRedo;
    Button mUndoButton;
    final int kHOffset = 30;
    final int kVOffset = 35;
}
0
bogdans napisał(a)

A tu masz dowód, że strony można wyciągnąć kod apletu. (nie jestem hackerem, zajęło mi to niecałą minutę)

import java.applet.Applet;
import java.awt.*;
import java.awt.image.*;

public class AlexWarp extends Applet
    implements Runnable
{

    public void run()
    {
        Initialize();
        while(mStartup != null) 
        {
            try
            {
                Thread.sleep(500L);
            }
            catch(InterruptedException _ex) { }
            if(!mReady)
            {
                mStatus += ".";
                showStatus(mStatus);
            }
        }
    }

    void Initialize()
    {
        mStatus = "Loading image...";
        showStatus(mStatus);
        mReady = false;
        mCanUndo = false;
        mRedo = false;
        mUndoButton.disable();
        mImage = getImage(getCodeBase(), mImageName);
        while((mWidth = mImage.getWidth(this)) < 0) 
            try
            {
                Thread.sleep(100L);
            }
            catch(InterruptedException _ex) { }
        while((mHeight = mImage.getHeight(this)) < 0) 
            try
            {
                Thread.sleep(100L);
            }
            catch(InterruptedException _ex) { }
        mPixels = new int[mWidth * mHeight];
        mOldPixels = new int[mWidth * mHeight];
        PixelGrabber pixelgrabber = new PixelGrabber(mImage, 0, 0, mWidth, mHeight, mPixels, 0, mWidth);
        boolean flag = false;
        do
        {
            try
            {
                flag = pixelgrabber.grabPixels(500L);
            }
            catch(InterruptedException _ex)
            {
                mStatus = "AlexWarp interrupted.";
                showStatus(mStatus);
                return;
            }
            mStatus += ".";
            showStatus(mStatus);
        } while(!flag);
        if((pixelgrabber.status() & 0x80) != 0)
        {
            mStatus = "AlexWarp interrupted.";
            showStatus(mStatus);
            return;
        } else
        {
            mReady = true;
            mStatus = "Ready for warping. Click and drag in the image to warp it.";
            showStatus(mStatus);
            repaint();
            return;
        }
    }

    void DoneWithWarping()
    {
        mImage = createImage(new MemoryImageSource(mWidth, mHeight, mPixels, 0, mWidth));
        mUndoButton.enable();
        mUndoButton.setLabel("Undo");
        mRedo = false;
        mCanUndo = true;
        repaint();
        mReady = true;
        mWarper = null;
        mStatus = "Ready for warping. Click and drag in the image to warp it.";
        showStatus(mStatus);
    }

    public void paint(Graphics g)
    {
        if(mImage != null)
            g.drawImage(mImage, 30, 35, this);
        if(mFromPoint != null && mToPoint != null)
        {
            g.setColor(Color.red);
            g.drawLine(mFromPoint.x, mFromPoint.y, mToPoint.x, mToPoint.y);
            g.setColor(Color.black);
        }
    }

    public void update(Graphics g)
    {
        paint(g);
    }

    public void start()
    {
        if(mImage == null)
        {
            Button button = new Button("Undo");
            add(button);
            button.disable();
            mUndoButton = button;
            button = new Button("Stop");
            add(button);
            button = new Button("Reset");
            add(button);
            mImageName = getParameter("image");
            if(mImageName == null)
                mImageName = "warp.gif";
            mStartup = new Thread(this);
            mStartup.start();
        }
    }

    public void stop()
    {
        if(mStartup != null)
            mStartup.stop();
        mStartup = null;
        if(mWarper != null)
            mWarper.stop();
        mWarper = null;
    }

    public boolean action(Event event, Object obj)
    {
        if("Undo".equals(obj) || "Redo".equals(obj))
        {
            int ai[] = mPixels;
            mPixels = mOldPixels;
            mOldPixels = ai;
            mImage = createImage(new MemoryImageSource(mWidth, mHeight, mPixels, 0, mWidth));
            mRedo = !mRedo;
            mUndoButton.setLabel(mRedo ? "Redo" : "Undo");
            repaint();
            return true;
        }
        if("Stop".equals(obj))
        {
            if(mWarper != null)
            {
                mWarper.stop();
                mWarper = null;
                mReady = true;
                mCanUndo = false;
                mUndoButton.disable();
                repaint();
                mStatus = "Ready for warping. Click and drag in the image to warp it.";
                showStatus(mStatus);
            }
            return true;
        }
        if("Reset".equals(obj))
        {
            if(mWarper != null)
            {
                mWarper.stop();
                mWarper = null;
            }
            if(mStartup != null)
            {
                mStartup.stop();
                mStartup = new Thread(this);
                mStartup.start();
            }
            return true;
        } else
        {
            return false;
        }
    }

    public boolean mouseDown(Event event, int i, int j)
    {
        if(!PointInImage(i, j) || !mReady)
        {
            return false;
        } else
        {
            mFromPoint = new Point(i, j);
            return true;
        }
    }

    public boolean mouseDrag(Event event, int i, int j)
    {
        if(mFromPoint == null)
        {
            return false;
        } else
        {
            mToPoint = ClipToImage(mFromPoint, i, j);
            repaint();
            return true;
        }
    }

    public boolean mouseUp(Event event, int i, int j)
    {
        if(mFromPoint == null)
        {
            return false;
        } else
        {
            mReady = false;
            mStatus = "Warping...";
            showStatus(mStatus);
            int ai[] = mOldPixels;
            mOldPixels = mPixels;
            mPixels = ai;
            Point point = ClipToImage(mFromPoint, i, j);
            mWarper = new ImageWarper(this, mOldPixels, mPixels, mWidth, mHeight, new Point(point.x - 30, point.y - 35), new Point(mFromPoint.x - 30, mFromPoint.y - 35));
            mWarper.start();
            mFromPoint = mToPoint = null;
            return true;
        }
    }

    boolean PointInImage(int i, int j)
    {
        return i >= 30 && i < 30 + mWidth && j >= 35 && j < 35 + mHeight;
    }

    Point ClipToImage(Point point, int i, int j)
    {
        int k = i - point.x;
        int l = j - point.y;
        if(k == 0)
        {
            if(j < 35)
                j = 35;
            if(j >= 35 + mHeight)
                j = (35 + mHeight) - 1;
        } else
        if(l == 0)
        {
            if(i < 30)
                i = 30;
            if(i >= 30 + mWidth)
                i = (30 + mWidth) - 1;
        } else
        {
            double d = (double)l / (double)k;
            if(i < 30)
            {
                i = 30;
                j = point.y + (int)(d * (double)(i - point.x));
            }
            if(i >= 30 + mWidth)
            {
                i = (30 + mWidth) - 1;
                j = point.y + (int)(d * (double)(i - point.x));
            }
            if(j < 35)
            {
                j = 35;
                i = point.x + (int)((double)(j - point.y) / d);
            }
            if(j >= 35 + mHeight)
            {
                j = (35 + mHeight) - 1;
                i = point.x + (int)((double)(j - point.y) / d);
            }
        }
        return new Point(i, j);
    }

    public AlexWarp()
    {
        mStatus = "";
        mReady = false;
        mCanUndo = false;
        mRedo = false;
    }

    Thread mStartup;
    ImageWarper mWarper;
    String mImageName;
    Image mImage;
    int mPixels[];
    int mOldPixels[];
    int mWidth;
    int mHeight;
    String mStatus;
    Point mFromPoint;
    Point mToPoint;
    boolean mReady;
    boolean mCanUndo;
    boolean mRedo;
    Button mUndoButton;
    final int kHOffset = 30;
    final int kVOffset = 35;
}

Mozesz powiedziec jak to zrobiles ?

0

Pozwolę sobie zacytować Shimmi`ego:
...trafiłem do źródła wiedzy bez drogowskazu...

1 użytkowników online, w tym zalogowanych: 0, gości: 1