import java.awt.*;
import java.awt.Font;
import java.awt.image.ColorModel;
import java.awt.image.DirectColorModel;
import java.awt.image.WritableRaster;
import java.awt.event.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;
import java.awt.Cursor;
import java.applet.Applet;
import java.io.*;
import java.awt.image.*;
import java.awt.datatransfer.*;
import java.awt.datatransfer.Transferable;
import java.net.URL;
import java.awt.Color;
import javax.imageio.ImageIO;
public class Funktionsplotter_3D extends Applet implements MouseListener,MouseMotionListener,ActionListener,ItemListener,AdjustmentListener,KeyListener
{
TextArea JavaLog;
Image Logo;
Image Pufferbild;
BufferedImage BPufferbild;
Image Pufferbild1;
BufferedImage BPufferbild1;
Image IPicH;
Image IKauf;
Image IKzu;
Image Iwurzel;
Image Iwurzel3;
Image IPi;
Image testimg1;
Image testimg2;
BufferedImage testimg;
Image IKlammer;
Graphics gAllg;
Graphics gP1;
Graphics gP2;
Graphics gPH;
Graphics gra;
Graphics gPB;
Graphics gPB1;
Graphics gAllgemein;
Graphics gIPicH;
Color CSbar;
Color CSbar1;
boolean Agetestet = false;
boolean appgültig = true;
Label Label7;
Label Label6;
Label Label5;
Label Label4;
Label Label3;
Label Label2;
Label Label1;
Label Label40;
Button Command21;
Button Command11;
Button Command10;
Button Command9;
Button Command8;
Button Command7;
Button Command50;
Image [] Picture1 = new Image [2];
Image [] Images = new Image [1];
CheckboxGroup CG1 = new CheckboxGroup();
Checkbox [] Option1 = new Checkbox [1];
Checkbox [] Check1 = new Checkbox [1];
Scrollbar [] HScroll1 = new Scrollbar [3];
Scrollbar [] VScroll1 = new Scrollbar [2];
TextField [] TextF = new TextField [6];
Label [] LabelF = new Label [1];
Button [] ButtonF = new Button [1];
public void init()
{
int n;
gAllg = this.getGraphics();
gra = gAllg;;
JavaLog = new TextArea(15,80);
add(JavaLog);
setLayout(null);
JavaLog.setLocation(50,500);
InJAVA = true;
FBold = true;
FItalic = false;
FName = "Lucida Console";
FSize = 16;
FStrikethrough = false;
FUnderline = false;
CSbar = new Color(0,240,200);
CSbar1 = new Color(0,50,50);
IKauf = getImage (getCodeBase(),"Formelzeichen/IKlammerAuf.jpg");
IKzu = getImage (getCodeBase(),"Formelzeichen/IKlammerZu.jpg");
Iwurzel = getImage (getCodeBase(),"Formelzeichen/Iwurzel.jpg");
Iwurzel3 = getImage (getCodeBase(),"Formelzeichen/Iwurzel3.jpg");
IPi = getImage (getCodeBase(),"Formelzeichen/IPi.jpg");
testimg1 = getImage (getCodeBase(),"Data/dat.jpg");
testimg2 = getImage (getCodeBase(),"Data/dat1.jpg");
Loadwait();
PufferErstesMal = 0;
LineMax = 0;
LineX1[0] = 0;
LineY1[0] = 0;
LineX2[0] = 0;
LineY2[0] = 0;
LineR[0] = 0;
LineG[0] = 0;
LineB[0] = 0;
Label7 = new Label ("Anzahl Funktionswerte:");
Label7.setBounds(362,72,203,15);
Label7.setFont(new Font("Lucida Console", Font.BOLD, 16));
add(Label7);
Label6 = new Label ("bis");
Label6.setBounds(110,118,35,15);
Label6.setFont(new Font("Lucida Console", Font.BOLD, 16));
add(Label6);
Label5 = new Label ("z von");
Label5.setBounds(12,118,51,15);
Label5.setFont(new Font("Lucida Console", Font.BOLD, 16));
add(Label5);
Label4 = new Label ("bis");
Label4.setBounds(110,94,35,15);
Label4.setFont(new Font("Lucida Console", Font.BOLD, 16));
add(Label4);
Label3 = new Label ("x von");
Label3.setBounds(12,94,51,15);
Label3.setFont(new Font("Lucida Console", Font.BOLD, 16));
add(Label3);
Label2 = new Label ("Intervall:");
Label2.setBounds(12,72,91,15);
Label2.setFont(new Font("Lucida Console", Font.BOLD, 16));
add(Label2);
Label1 = new Label ("f(x,z) = ");
Label1.setBounds(12,48,77,17);
Label1.setFont(new Font("Lucida Console", Font.BOLD, 16));
add(Label1);
Label40 = new Label ("Zoom:");
Label40.setBounds(634,374,49,13);
Label40.setFont(new Font("Lucida Console", Font.BOLD, 16));
add(Label40);
Command21 = new Button ("Funktion zeichnen");
Command21.setBounds(12,156,207,19);
Command21.addActionListener (this);
Command21.setFont(new Font("Lucida Console", Font.BOLD, 16));
add(Command21);
Command11 = new Button ("Zentrieren");
Command11.setBounds(654,506,101,17);
Command11.addActionListener (this);
Command11.setFont(new Font("Lucida Console", Font.BOLD, 16));
add(Command11);
Command10 = new Button ("Runter");
Command10.setBounds(662,474,77,17);
Command10.addActionListener (this);
Command10.setFont(new Font("Lucida Console", Font.BOLD, 16));
add(Command10);
Command9 = new Button ("Rechts");
Command9.setBounds(702,450,69,17);
Command9.addActionListener (this);
Command9.setFont(new Font("Lucida Console", Font.BOLD, 16));
add(Command9);
Command8 = new Button ("Links");
Command8.setBounds(634,450,61,17);
Command8.addActionListener (this);
Command8.setFont(new Font("Lucida Console", Font.BOLD, 16));
add(Command8);
Command7 = new Button ("Hoch");
Command7.setBounds(666,426,69,17);
Command7.addActionListener (this);
Command7.setFont(new Font("Lucida Console", Font.BOLD, 16));
add(Command7);
Command50 = new Button ("Zufallsfunktion");
Command50.setBounds(458,154,149,19);
Command50.addActionListener (this);
Command50.setFont(new Font("Lucida Console", Font.BOLD, 16));
add(Command50);
TextF[0] = new TextField("sin(x)+cos(z)");
TextF[0].setBounds(92,46,521,19);
TextF[0].setFont(new Font("Lucida Console", Font.BOLD, 16));
TextF[0].setVisible(true);
add(TextF[0]);
TextF[1] = new TextField("-5");
TextF[1].setBounds(66,92,41,19);
TextF[1].setFont(new Font("Lucida Console", Font.BOLD, 16));
TextF[1].setVisible(true);
add(TextF[1]);
TextF[2] = new TextField("5");
TextF[2].setBounds(150,92,41,19);
TextF[2].setFont(new Font("Lucida Console", Font.BOLD, 16));
TextF[2].setVisible(true);
add(TextF[2]);
TextF[3] = new TextField("-5");
TextF[3].setBounds(66,116,41,19);
TextF[3].setFont(new Font("Lucida Console", Font.BOLD, 16));
TextF[3].setVisible(true);
add(TextF[3]);
TextF[4] = new TextField("5");
TextF[4].setBounds(150,116,41,19);
TextF[4].setFont(new Font("Lucida Console", Font.BOLD, 16));
TextF[4].setVisible(true);
add(TextF[4]);
TextF[5] = new TextField("2500");
TextF[5].setBounds(570,70,43,19);
TextF[5].setFont(new Font("Lucida Console", Font.BOLD, 16));
TextF[5].setVisible(true);
add(TextF[5]);
LabelF[0] = new Label("");
LabelF[0].setBounds(0,0,0,0);
LabelF[0].setFont(new Font("Lucida Console", Font.BOLD, 16));
LabelF[0].setVisible(true);
add(LabelF[0]);
ButtonF[0] = new Button("");
ButtonF[0].setBounds(0,0,0,0);
ButtonF[0].setFont(new Font("Lucida Console", Font.BOLD, 16));
ButtonF[0].setVisible(true);
ButtonF[0].addActionListener (this);
add(ButtonF[0]);
OptionMax = 0;
OptionExist = false;
Option1[0] = new Checkbox("" ,CG1,false);
Option1[0].setBounds(0,0,0,0);
Option1[0].setFont(new Font("Lucida Console", Font.BOLD, 16));
Option1[0].setVisible(true);
Option1[0].setState(false);
Option1[0].setLabel("");
Option1[0].setCheckboxGroup(CG1);
Option1[0].addItemListener (this);
add(Option1[0]);
Check1[0] = new Checkbox("" ,false);
Check1[0].setBounds(0,0,0,0);
Check1[0].setFont(new Font("Lucida Console", Font.BOLD, 16));
Check1[0].setVisible(true);
Check1[0].setState(false);
Check1[0].setLabel("");
add(Check1[0]);
PicMax = 1;
PicExist = true;
Picture_Name [0] = "Picture1";
Picture_ScaleHeight [0] = 37;
Picture_ScaleWidth [0] = 63;
Picture_Left [0] = 874;
Picture_Top [0] = 14;
Picture_Name [1] = "Picture1";
Picture_ScaleHeight [1] = 411;
Picture_ScaleWidth [1] = 593;
Picture_Left [1] = 10;
Picture_Top [1] = 176;
ImageMax = 0;
ImageExist = false;
Image_Name [0] = "";
Image_Left [0] = 0;
Image_Top [0] = 0;
HScrollExist = true;
VScrollExist = true;
HScroll1[0] = new Scrollbar();
HScroll1[0].setBounds(876,52,71,21);
HScroll1[0].setOrientation(Scrollbar.HORIZONTAL);
HScroll1[0].setVisibleAmount(20);
HScroll1[0].setValue(0);
HScroll1[0].setMinimum(0);
HScroll1[0].setMaximum(100+20);
HScroll1[0].setVisible(true);
HScroll1[0].addAdjustmentListener (this);
add(HScroll1[0]);
HScroll1[1] = new Scrollbar();
HScroll1[1].setBounds(12,592,597,21);
HScroll1[1].setOrientation(Scrollbar.HORIZONTAL);
HScroll1[1].setVisibleAmount(20);
HScroll1[1].setValue(0);
HScroll1[1].setMinimum(0);
HScroll1[1].setMaximum(100+20);
HScroll1[1].setVisible(true);
HScroll1[1].addAdjustmentListener (this);
add(HScroll1[1]);
HScroll1[2] = new Scrollbar();
HScroll1[2].setBounds(634,394,105,21);
HScroll1[2].setOrientation(Scrollbar.HORIZONTAL);
HScroll1[2].setVisibleAmount(20);
HScroll1[2].setValue(0);
HScroll1[2].setMinimum(0);
HScroll1[2].setMaximum(100+20);
HScroll1[2].setVisible(true);
HScroll1[2].addAdjustmentListener (this);
add(HScroll1[2]);
VScroll1[0] = new Scrollbar();
VScroll1[0].setBounds(944,24,21,57);
VScroll1[0].setOrientation(Scrollbar.VERTICAL);
VScroll1[0].setVisibleAmount(20);
VScroll1[0].setValue(0);
VScroll1[0].setMinimum(0);
VScroll1[0].setMaximum(100+20);
VScroll1[0].setVisible(true);
VScroll1[0].addAdjustmentListener (this);
add(VScroll1[0]);
VScroll1[1] = new Scrollbar();
VScroll1[1].setBounds(608,176,21,415);
VScroll1[1].setOrientation(Scrollbar.VERTICAL);
VScroll1[1].setVisibleAmount(20);
VScroll1[1].setValue(0);
VScroll1[1].setMinimum(0);
VScroll1[1].setMaximum(100+20);
VScroll1[1].setVisible(true);
VScroll1[1].addAdjustmentListener (this);
add(VScroll1[1]);
addMouseListener(this);
addKeyListener(this);
addMouseMotionListener(this);
if (JavaLogAn == false)
{
JavaLog.setVisible(false);
}
}
private void D3Zeichnen( )
{
int i = 0 ;
int j = 0 ;
int i1 = 0 ;
String s0 = "" ;
String s1 = "" ;
String s2 = "" ;
String s3 = "" ;
int is0 = 0 ;
int is1 = 0 ;
double dax = 0 ;
double day = 0 ;
double dbx = 0 ;
double dby = 0 ;
double dcx = 0 ;
double dcy = 0 ;
double dc1x = 0 ;
double dc1y = 0 ;
double dp1x = 0 ;
double dp1y = 0 ;
double dp2x = 0 ;
double dp2y = 0 ;
double dnz = 0 ;
double dez = 0 ;
double dc1norm = 0 ;
double dc1nx = 0 ;
double dc1ny = 0 ;
double Gxr = 0 ;
double Gyr = 0 ;
int ii = 0 ;
int iPGr = 0 ;
int iPGg = 0 ;
int iPGb = 0 ;
double dfr = 0 ;
double dfg = 0 ;
double dfb = 0 ;
int i2 = 0 ;
boolean fgültig = false ;
Gi = 1;
Gr = 0;
Gg = 0;
Gb = 0 ;
xstart = 0;
ystart = 0;
PBildB1 = Picture_ScaleWidth[1];
PBildH1 = Picture_ScaleHeight[1];
InitPufferbild();
dnz = 0.9;
dez = 0.1;
Gr = 50;
Gg = 50;
Gb = 250;
for ( i1 = 0 ; i1 <= iLlänge - 2 ; i1+= 1 )
{
for ( i = 0 ; i <= iLlänge - 3 ; i+= 1 )
{
Gx1 = ED3Feldx[i1 * iLlänge + i];
Gy1 = ED3Feldy[i1 * iLlänge + i];
Gx2 = ED3Feldx[i1 * iLlänge + i + 1];
Gy2 = ED3Feldy[i1 * iLlänge + i + 1];
fgültig = true;
if ( ED3NaN[i1 * iLlänge + i] == false || ED3NaN[i1 * iLlänge + i + 1] == false )
{
fgültig = false;
}
if ( fgültig == true )
{
Linie2DOhneSchnitt();
}
Gx1 = ED3Feldx[i * iLlänge + i1];
Gy1 = ED3Feldy[i * iLlänge + i1];
Gx2 = ED3Feldx[(i + 1) * iLlänge + i1];
Gy2 = ED3Feldy[(i + 1) * iLlänge + i1];
fgültig = true;
if ( ED3NaN[i * iLlänge + i1] == false || ED3NaN[(i + 1) * iLlänge + i1] == false )
{
fgültig = false;
}
if ( fgültig == true )
{
Linie2DOhneSchnitt();
}
}
}
Gr = 0;
Gg = 0;
Gb = 0;
Gx1 = 10;
Gy1 = 10;
Text(s3DText);
Thread.currentThread().yield();
JavaLogSchliessen();
if ( GrafikInPuffer )
{
if ( InJAVA == false )
{
GrafikInPuffer = false;
Löschen();
GrafikInPuffer = true;
}
ClipPufferbild();
}
Gi = 0;
}
private void PufferOffset()
{
gAllgemein = this.getGraphics();
PictureOffX = Picture_Left[Gi];
PictureOffY = Picture_Top[Gi];
Picture_B = Picture_ScaleWidth[Gi];
Picture_H = Picture_ScaleHeight[Gi];
if (GrafikInPuffer == true)
{
if (Gi == 0)
{
gAllgemein = gPB;
gPB.setFont(new Font("Lucida Console", Font.BOLD, 16));
}
if (Gi == 1)
{
gAllgemein = gPB1;
gPB1.setFont(new Font("Lucida Console", Font.BOLD, 16));
}
PictureOffX = 0;
PictureOffY = 0;
Picture_B = PBildB;
Picture_H = PBildH;
}
gAllgemein.setFont(new Font("Lucida Console", Font.BOLD, 16));
}
private void Linie2DOhneSchnitt()
{
if (appgültig == true)
{
PufferOffset();
Graphics gra = gAllgemein;
int Ix1;
int Ix2;
int Iy1;
int Iy2;
int IxMin;
int IyMin;
int IxMax;
int IyMax;
Ix1 = CIntD(Gx1)+PictureOffX;
Iy1 = CIntD(Gy1)+PictureOffY;
Ix2 = CIntD(Gx2)+PictureOffX;
Iy2 = CIntD(Gy2)+PictureOffY;
IxMin = PictureOffX;
IyMin = PictureOffY;
IxMax = PictureOffX + Picture_B -1;
IyMax = PictureOffY + Picture_H -1;
Color GC = new Color(Gr,Gg,Gb);
Color GCXOR = new Color(255,255,255);
gra.setColor(GC);
if (GXor == true)
{
gra.setXORMode(GC);
gra.setColor(GCXOR);
}
gra.drawLine(Ix1,Iy1,Ix2,Iy2);
gra.setPaintMode();
gra.setColor(GC);
}
}
private void InitPufferbild()
{
if (appgültig == true)
{
TextPixelLength(("a"));
if (Gi == 0)
{
Pufferbild = new BufferedImage(PBildB,PBildH,BufferedImage.TYPE_INT_ARGB);
gPB = Pufferbild.getGraphics();
}
if (Gi == 1)
{
Pufferbild1 = new BufferedImage(Picture_ScaleWidth[Gi],Picture_ScaleHeight[Gi],BufferedImage.TYPE_INT_ARGB);
gPB1 = Pufferbild1.getGraphics();
}
IPicH = new BufferedImage(Picture_ScaleWidth[Gi],Picture_ScaleHeight[Gi],BufferedImage.TYPE_INT_ARGB);
gIPicH = IPicH.getGraphics();
gIPicH.setColor(this.getBackground());
PufferErstesMal = PufferErstesMal +1;
if (PufferErstesMal > 2)
{
PufferErstesMal = 2;
}
}
}
private void ClipPufferbild()
{
if (appgültig == true)
{
double DBildB;
double DBildH;
double DPBildB;
double DPBildH;
double Zx1 = 0;
double Zy1 = 0;
double Qx1 = 0;
double Qy1 = 0;
double Zx2;
double Zy2;
double Qx2;
double Qy2;
DBildB = 0;
DBildH = 0;
DPBildB = 0;
DPBildH = 0;
double HZx1 = 0;
double HZy1 = 0;
double HZx2 = 0;
double HZy2 = 0;
AmClippen = true;
DBildB = CDblI(Picture_ScaleWidth[Gi]);
DBildH = CDblI(Picture_ScaleHeight[Gi]);
DPBildB = CDblI(PBildB);
DPBildH = CDblI(PBildH);
Zx1=CDblI(Picture_Left[Gi]);
Zy1=CDblI(Picture_Top[Gi]);
Qx1=CDblI(PBildOffX);
Qy1=CDblI(PBildOffY);
if (Gi == 1)
{
Qx1=0;
Qy1=0;
DPBildB = DBildB;
DPBildH = DBildH;
}
Zx2=Zx1+DPBildB;
Qx2=DPBildB;
Zy2=Zy1+DPBildH;
Qy2=DPBildH;
if (DPBildB > DBildB)
{
Zx2=Zx1+DBildB;
Qx2=Qx1+DBildB;
}
if (DPBildH > DBildH)
{
Zy2=Zy1+DBildH;
Qy2=Qy1+DBildH;
}
HZx1=Zx1-CDblI(Picture_Left[Gi]);
HZx2=Zx2-CDblI(Picture_Left[Gi]);
HZy1=Zy1-CDblI(Picture_Top[Gi]);
HZy2=Zy2-CDblI(Picture_Top[Gi]);
Graphics gra = this.getGraphics();
gIPicH.fillRect(0,0,Picture_ScaleWidth[Gi],Picture_ScaleHeight[Gi]);
gIPicH.drawImage (Pufferbild,CIntD(HZx1),CIntD(HZy1),CIntD(HZx2),CIntD(HZy2),CIntD(Qx1),CIntD(Qy1),CIntD(Qx2),CIntD(Qy2),this);
gra.drawImage(IPicH,Picture_Left[Gi],Picture_Top[Gi],Picture_Left[Gi]+Picture_ScaleWidth[Gi],Picture_Top[Gi]+Picture_ScaleHeight[Gi],0,0,Picture_ScaleWidth[Gi],Picture_ScaleHeight[Gi],this);
AmClippen = false;
}
}
}