Rysowanie w awt

0

Witam, znalazłem taki oto program, który zajmuje się rysowaniem triangulacji Delaunay'a [jest mi to potrzebne jako dodatek do referatu]. Próbowałem go skompilować, ale pojawia się błąd w wywołaniu main. Czy ktoś może spojrzeć w kod, a może to coś z Javą u mnie jest nie tak. Brak biblioteki, zła wersja?

import java.awt.Color;

public class Delaunay implements DrawListener {
    private int MAXN = 1000;                    // maximum number of points
    private int N = 0;                          // number of points
    private Point[] points = new Point[MAXN];   // user-selected points
    private Draw draw;                          // the drawing GUI

    // create an empty Delaunay triangulation GUI
    public Delaunay() {
        draw = new Draw();
        draw.addListener(this);
        draw.show();
    }

    // callback when the user clicks at (x, y)
    public void mousePressed(double x, double y) {
        points[N++] = new Point(x, y);
        draw.clear(Color.LIGHT_GRAY);
        draw.setPenColor(Color.BLACK);
        for (int i = 0; i < N; i++)
            points[i].draw(draw);
        draw.setPenColor(Color.BLUE);


        // determine if i-j-k is a circle with no interior points 
        for (int i = 0; i < N; i++) {
            for (int j = i+1; j < N; j++) {
                for (int k = j+1; k < N; k++) {
                    boolean isTriangle = true;
                    for (int a = 0; a < N; a++) {
                        if (a == i || a == j || a == k) continue;
                        if (points[a].inside(points[i], points[j], points[k])) {
                           isTriangle = false;
                           break;
                        }
                    }
                    if (isTriangle) {
                        points[i].drawTo(points[j], draw);
                        points[i].drawTo(points[k], draw);
                        points[j].drawTo(points[k], draw);
                    }
                }
            }
        }

        draw.show();
    }

    // other callbacks
    public void keyTyped(char c) { draw.save("delaunay" + c + ".png"); }
    public void mouseDragged(double x, double y) { }
    public void mouseReleased(double x, double y) { }


    // test client
    public static void main(String[] args) {
        Delaunay delaunay = new Delaunay();
    }
   
}
0

Program korzysta z niestandardowych klas javy (Draw, DrawListener). Aby skompilować musisz mieć te klasy.

0

No to chyba nic z tego nie będzie, a szkoda. Myślałem, że program jest tak napisany, że od razu się odpali. Dzięki za szybką odpowiedź!!

0

Znalazłem te dwie klasy, ale teraz przy kompilowaniu tego głównego programu pojawia się 'could not find the main class' :/

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