public void init(){
try {
image = getImage(new URL(getDocumentBase(), "http://miramonte.homelinux.net/portal/pic/muc2.jpg"));
} catch(Exception ioe) {
System.out.println("Fehler beim erstellen des Bild-Pfades");
}
}
public void paint (Graphics g) {
getImageSize();
int dx2 = max_x_int - min_x_int;
int dy2 = max_y_int - min_y_int;
g.drawImage( image, 0, 0, dx2+2*frame, dy2+2*frame, min_x_int-frame, min_y_int-frame, max_x_int+frame, max_y_int+frame, this );
readKoord(g, dx2, dy2);
}
public void getImageSize(){
String getParam = "([^;]+)";
try {
URL url = new URL(getCodeBase(), "http://miramonte.homelinux.net/portal/applets/trackingtool.txt");
InputStream in = url.openStream();
BufferedReader read = new BufferedReader(new InputStreamReader(in));
double min_x = 1000.0, max_x = 0.0, min_y = 1000.0, max_y = 0.0;
String min_x_tmp = "";
String min_y_tmp = "";
String max_x_tmp = "";
String max_y_tmp = "";
double x_tmp_double = 0.0;
double y_tmp_double = 0.0;
String text = "";
double tmp = 0;
int index = 0;
Pattern regex = Pattern.compile(getParam);
while((text = read.readLine()) != null){
Matcher match = regex.matcher(text);
int counter = 0;
while(match.find()){
if(counter == 0){
counter++;
x_tmp_string = match.group();
x_tmp_double = new Double(x_tmp_string).doubleValue();
if(x_tmp_double < min_x) {
if(getXPixel(x_tmp_double) < 0){
//nichts
}else{
min_x = x_tmp_double;
}
}
if(x_tmp_double > max_x) {
if(getXPixel(x_tmp_double) < 0){
//nichts
}else{
max_x = x_tmp_double;
}
}
}else if(counter == 1){
counter++;
y_tmp_string = match.group();
y_tmp_double = new Double(y_tmp_string).doubleValue();
if(y_tmp_double > max_y) {
if(getYPixel(y_tmp_double) < 0){
//nichts
}else{
max_y = y_tmp_double;
}
}
if(y_tmp_double < min_y) {
if(getYPixel(y_tmp_double) < 0){
//nichts
}else{
min_y = y_tmp_double;
}
}
}
}
}
int tmp_y = 0;
min_x_int = getXPixel(min_x);
max_x_int = getXPixel(max_x);
min_y_int = getYPixel(min_y);
max_y_int = getYPixel(max_y);
if(min_y_int > max_y_int){
tmp_y = min_y_int;
min_y_int = max_y_int;
max_y_int = tmp_y;
}
} catch (Exception e) {
System.out.println("Fehler beim lesen der Koordinaten aus LogFile"+e);
}
}