/*----------------------------------------------------------------------+ | Title: Functional_PickscheFormel.java | | | | Autor: Timo Ehmke | | ehmke@uni-flensburg.de | | | | Beginn: 16.08.99 | | Letzte Änderung: 16.08.99 | +----------------------------------------------------------------------*/ public class Functional_PickscheFormel extends Functional{ int type, numBorder, numInside, n, step, choice; String term; PolygonElement polygon; PointElement V[]; int minX, maxX, minY, maxY; PointElement P; public void init(int numElem, String[] eList, Slate sl, Measure parent) { slate = sl; numElement = numElem; elementList = eList; String c = elementList[1]; polygon = (PolygonElement) slate.lookupElement(elementList[2]); parent.addParent(polygon); step = slate.GRID_SIZE; V = polygon.V; n = polygon.n; P = new PointElement(); if (c.equals("r")) { choice = 0; } // if if (c.equals("i")) { choice = 1; } // if } public double getValue() { // Bestimme minX, minY, maxX und maxY minX = Integer.MAX_VALUE; minY = Integer.MAX_VALUE; maxX = Integer.MIN_VALUE; maxY = Integer.MIN_VALUE; for (int i=0;imaxX) { maxX = (int) Math.round( V[i].x ); } // if if (V[i].y>maxY) { maxY = (int) Math.round( V[i].y ); } // if } // for /* System.out.println("minX = " + minX); System.out.println("minY = " + minY); System.out.println("maxX = " + maxX); System.out.println("maxY = " + maxY); System.out.println("step = " + step); System.out.println(); */ switch (choice) { case 0: numBorder = 0; for (int i=minX;i<=maxX;i+=step) { for (int j=minY;j<=maxY;j+=step) { P.x = i; P.y = j; // Prüfe, ob P auf dem Rand des Polygons liegt label: for (int k=0;k