Originariamente inviato da Cracker1992
lblDP=la label che vorrei usare .= richiamo metodi (giusto?)
dopo che metodo uso per il mio obbietivo descritto nei precendi messaggi
e che parametri uso se devo usare parametri come faccio a indicare e usare una delle 6 parabole da paint in modo tale da rispetare gli if nei precendenti codici.
come faccio?
codice:
private void ParabolaActionPerformed(java.awt.event.ActionEvent evt) {
Double A = new Double (txtA.getText());
Double B = new Double (txtB.getText());
Double C = new Double (txtC.getText());
String AsseX = " Y = 0.0 " ;
String AsseY = " X = 0.0 " ;
String Origine = " 0.0 ; 0.0 ";
if(A!=0.0){
if(A>=0.0)
{
Double Delta = new Double (Math.pow(B, 2.0))-(4.0*(A)*(C));
if(Delta<0.0)
{
Double X1 = 0.0;
Double X2 = 0.0;
Double YV = new Double(-(Delta)) / (4.0 * A);
Double XF = new Double(-B) / (2.0 * A);
Double YF = new Double(-(Delta) / (4.0 * A)) + (1.0 / (4.0 * A));
txtF.setText(XF.toString() + "" + ";" + YF.toString());
txtV.setText(XF.toString() + "" + ";" + YV.toString());
txtD.setText("Y" + "" + "=" + XF.toString() + "" + "-" + YF.toString());
txtASimm.setText("X" + "" + "=" + XF.toString());
txtConcavita.setText("Parabola con Concavita verso l'alto");
Double AX1 = new Double(A * (Math.pow(X1, 2.0)));
Double BX2 = new Double(A * (Math.pow(X2, 1.0)));
txtP.setText("Y" + "" + "=" + AX1.toString() + "" + "+" + BX2.toString() + "" + "+" + C.toString());
txtintX1.setText(X1.toString() + "" + ";" + "0");
txtintX2.setText(X2.toString() + "" + ";" + "0");
txtintY.setText("0" + "" + ";" + "" + C.toString());
txtintD.setText("Parabola Esterna");
}
else if (Delta ==0.0)
{
Double X1 = new Double((-B)+(Math.pow(Delta, 0.5)))/(2.0*A);
Double X2 = X1;
Double YV = new Double (-(Delta))/(4.0*A);
Double XF = new Double(-B)/(2.0*A);
Double YF = new Double (-(Delta)/(4.0*A))+(1.0/(4.0*A));
txtF.setText(XF.toString() +"" +";"+YF.toString());
txtV.setText(XF.toString()+""+";"+YV.toString());
txtD.setText("Y" +""+"="+ XF.toString() + "" + "-"+ YF.toString());
txtASimm.setText("X"+""+"="+XF.toString());
txtConcavita.setText("Parabola con Concavita verso l'alto");
Double AX1 = new Double (A*(Math.pow(X1, 2.0)));
Double BX2 = new Double (A*(Math.pow(X2, 1.0)));
txtP.setText("Y"+""+"="+AX1.toString()+""+"+"+BX2.toString()+""+"+"+C.toString());
txtintX1.setText(X1.toString()+""+";"+"0");
txtintX2.setText(X2.toString()+""+";"+"0");
txtintY.setText("0"+""+";"+""+C.toString());
txtintD.setText("Parabola Seccante");
}
else if(Delta >0)
{
Double X1 = new Double((-B)+(Math.pow(Delta, 0.5)))/(2.0*A);
Double X2 = new Double((-B)-(Math.pow(Delta, 0.5)))/(2.0*A);
Double YV = new Double (-(Delta))/(4.0*A);
Double XF = new Double(-B)/(2.0*A);
Double YF = new Double (-(Delta)/(4.0*A))+(1.0/(4.0*A));
txtF.setText(XF.toString() +"" +";"+YF.toString());
txtV.setText(XF.toString()+""+";"+YV.toString());
txtD.setText("Y" +""+"="+ XF.toString() + "" + "-"+ YF.toString());
txtASimm.setText("X"+""+"="+XF.toString());
txtConcavita.setText("Parabola con Concavita verso l'alto");
Double AX1 = new Double (A*(Math.pow(X1, 2.0)));
Double BX2 = new Double (A*(Math.pow(X2, 1.0)));
txtP.setText("Y"+""+"="+AX1.toString()+""+"+"+BX2.toString()+""+"+"+C.toString());
txtintX1.setText(X1.toString()+""+";"+"0");
txtintX2.setText(X2.toString()+""+";"+"0");
txtintY.setText("0"+""+";"+""+C.toString());
txtintD.setText("Parabola Tagente");
}
}else{
Double Delta = new Double (Math.pow(B, 2.0))-(4.0*(A)*(C));
if(Delta<0.0)
{
Double X1=0.0;
Double X2=0.0;
Double YV = new Double (-(Delta))/(4.0*A);
Double XF = new Double(-B)/(2.0*A);
Double YF = new Double (-(Delta)/(4.0*A))+(1.0/(4.0*A));
txtF.setText(XF.toString() +"" +";"+YF.toString());
txtV.setText(XF.toString()+""+";"+YV.toString());
txtD.setText("Y" +""+"="+ XF.toString() + "" + "-"+ YF.toString());
txtASimm.setText("X"+""+"="+XF.toString());
txtConcavita.setText("Parabola con Concavita verso il basso");
Double AX1 = new Double (A*(Math.pow(X1, 2.0)));
Double BX2 = new Double (A*(Math.pow(X2, 1.0)));
txtP.setText("Y"+""+"="+AX1.toString()+""+"+"+BX2.toString()+""+"+"+C.toString());
txtintX1.setText(X1.toString()+""+";"+"0");
txtintX2.setText(X2.toString()+""+";"+"0");
txtintY.setText("0"+""+";"+""+C.toString());
txtintD.setText("Parabola Esterna");
}
else if (Delta ==0.0)
{
Double X1 = new Double((-B)+(Math.pow(Delta, 0.5)))/(2.0*A);
Double X2 = X1;
Double YV = new Double (-(Delta))/(4.0*A);
Double XF = new Double(-B)/(2.0*A);
Double YF = new Double (-(Delta)/(4.0*A))+(1.0/(4.0*A));
txtF.setText(XF.toString() +"" +";"+YF.toString());
txtV.setText(XF.toString()+""+";"+YV.toString());
txtD.setText("Y" +""+"="+ XF.toString() + "" + "-"+ YF.toString());
txtASimm.setText("X"+""+"="+XF.toString());
txtConcavita.setText("Parabola con Concavita verso il basso");
Double AX1 = new Double (A*(Math.pow(X1, 2.0)));
Double BX2 = new Double (A*(Math.pow(X2, 1.0)));
txtP.setText("Y"+""+"="+AX1.toString()+""+"+"+BX2.toString()+""+"+"+C.toString());
txtintX1.setText(X1.toString()+""+";"+"0");
txtintX2.setText(X2.toString()+""+";"+"0");
txtintY.setText("0"+""+";"+""+C.toString());
txtintD.setText("Parabola Seccante");
}
else if(Delta >0)
{
Double X1 = new Double((-B)+(Math.pow(Delta, 0.5)))/(2.0*A);
Double X2 = new Double((-B)-(Math.pow(Delta, 0.5)))/(2.0*A);
Double YV = new Double (-(Delta))/(4.0*A);
Double XF = new Double(-B)/(2.0*A);
Double YF = new Double (-(Delta)/(4.0*A))+(1.0/(4.0*A));
txtF.setText(XF.toString() +"" +";"+YF.toString());
txtV.setText(XF.toString()+""+";"+YV.toString());
txtD.setText("Y" +""+"="+ XF.toString() + "" + "-"+ YF.toString());
txtASimm.setText("X"+""+"="+XF.toString());
txtConcavita.setText("Parabola con Concavita verso il basso");
Double AX1 = new Double (A*(Math.pow(X1, 2.0)));
Double BX2 = new Double (A*(Math.pow(X2, 1.0)));
txtP.setText("Y"+""+"="+AX1.toString()+""+"+"+BX2.toString()+""+"+"+C.toString());
txtintX1.setText(X1.toString()+""+";"+"0");
txtintX2.setText(X2.toString()+""+";"+"0");
txtintY.setText("0"+""+";"+""+C.toString());
txtintD.setText("Parabola Tagente");
}
}
}else
{
txtA.setText("");
txtB.setText("");
txtC.setText("");
txtD.setText("");
txtintD.setText("");
txtintX1.setText("");
txtintX2.setText("");
txtintY.setText("");
txtV.setText("");
txtF.setText("");
txtP.setText("");
txtASimm.setText("");
}
}
txtA = textfield a per immetere il valore di a
stessa cosa con b e c in quanto a e b sono i coeficenti di X^2 e X^1 e c il termine noto tutte e tre compogono l'equazione di secondo grado della parabola Y=AX^2+BX^1+C
^=elevato ad n,il mio programma prevente tutti numeri a,b,c,x1ex2,delta,ecc... apparneti all'insieme dei numeri razzionali.
in questo programma ogni txt rappresenta un texfield inserita in una maschera dove inserisco 3 dati di input il valore di a,b,c e poi un bottone Parabola che alla azione del mio click su esso mi fa apparire negli altri txt dei risultati dettati nelle istruzioni date da me per far in modo di vizualizare un po' di dati precisi per la costruzione della parabola ma io no vorrei limitare a solo risultati ma anche vorrei infine una label o qualcosa l'importante che mi appari in qualche modo al fondo un immagine assomigliate alla raperesentazione grafica di una parabola dati tutti parametri che le parabole hanno seguendo le regole matematiche di geometria alatica vorrei che il programmino o meglio il computer mi esegua tale disegno ma non cosa fare come si fa??????
ogni di esso txt c'è un corrispodente lbl = label ettichetta per indicare di cosa parlo.
txtD=Direttrice
txtF=Fuoco
txtV=Vertice
txtintx1=intersezione con x1
txtintx2 = con x2
intY = intersezione con y
txtP = equazione parabola P=PARABOLA
txtASimm = Asse Simmetria
txtConcavità = concavita che serverve emmetere una stringa di testo in ouput per in idicare se la concavita della parabola è verso l'alto o il basso a seconda dei casi.