Update of /cvsroot/metamorphosis/krysalis-jplugin/src/java/org/krysalis/swingx/geo
In directory sc8-pr-cvs1:/tmp/cvs-serv24886/src/java/org/krysalis/swingx/geo
Added Files:
Entita.java eq2grado.java GraphicsGeo.java High.java
Large.java Linea.java LineaComposita.java Punto.java
Spline.java SplineVert.java
Log Message:
refactoring swingx.swing.* packages to swingx.*
--- NEW FILE: Entita.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Software *
* License version 1.1_01, a copy of which has been included with this *
* distribution in the LICENSE file. *
*****************************************************************************/
package org.krysalis.swingx.geo;
import java.awt.*;
import java.io.*;
/**
* Description of the Interface
*
*@author Luca Jun Barozzi
*@created 16 settembre 2001
*/
public interface Entita extends Serializable {
/**
* Description of the Method
*
*@param Porig Description of Parameter
*@param Pdest Description of Parameter
*/
public void sposta(Punto Porig, Punto Pdest);
/**
* Description of the Method
*
*@param Prot Description of Parameter
*@param alfa Description of Parameter
*/
public void ruota(Punto Prot, double alfa);
/**
* Description of the Method
*
*@param c Description of Parameter
*@param ScalaX Description of Parameter
*@param ScalaY Description of Parameter
*@param altezzaRiquadro Description of Parameter
*@param g Description of Parameter
*/
public void disegna(Color c,
double ScalaX,
//fattori per cui moltiplicare
double ScalaY,
//i valori da disegnare
int altezzaRiquadro,
//per invertire la coordinata y
Graphics g);
}
--- NEW FILE: eq2grado.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Software *
* License version 1.1_01, a copy of which has been included with this *
* distribution in the LICENSE file. *
*****************************************************************************/
package org.krysalis.swingx.geo;
// risoluzione di un'equazione di secondo grado utile al calcolo di intersezione
// tra entita' geometriche
/**
* Description of the Class
*
*@author Luca Jun Barozzi
*@created 16 settembre 2001
*/
class eq2grado {
double a, b, c;
double[] s = new double[2];
/**
* Constructor for the eq2grado object
*
*@param a Description of Parameter
*@param b Description of Parameter
*@param c Description of Parameter
*/
eq2grado(double a, double b, double c) {
this.a = a;
this.b = b;
this.c = c;
double delta = b * b - 4 * a * c;
if (delta >= 0) {
s[0] = (-b + Math.sqrt(delta)) / (2 * a);
s[1] = (-b - Math.sqrt(delta)) / (2 * a);
} else {
System.out.println("non esiste un'intersezione reale");
}
}
}
--- NEW FILE: GraphicsGeo.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Software *
* License version 1.1_01, a copy of which has been included with this *
* distribution in the LICENSE file. *
*****************************************************************************/
package org.krysalis.swingx.geo;
import java.awt.*;
/**
* Description of the Class
*
*@author Luca Jun Barozzi
*@created 16 settembre 2001
*/
public class GraphicsGeo implements Cloneable {
Punto GeoPorig, GeoPlimite;
//Limiti Geometrici
Punto SchPorig, SchPlimite;
//limiti di schermo
double schLarg,
schAlt,
geoLarg,
geoAlt;
double scala;
//non deformazioni ma solo scalaxy
/**
* Constructor for the GraphicsGeo object
*
*@param GeoPorig Description of Parameter
*@param GeoPlimite Description of Parameter
*@param SchPorig Description of Parameter
*@param SchPlimite Description of Parameter
*/
public GraphicsGeo(Punto GeoPorig,
Punto GeoPlimite,
Punto SchPorig,
Punto SchPlimite
) {
this.GeoPorig = GeoPorig;
this.GeoPlimite = GeoPlimite;
this.SchPorig = SchPorig;
this.SchPlimite = SchPlimite;
schLarg = SchPlimite.x - SchPorig.x;
schAlt = SchPlimite.y - SchPorig.y;
geoLarg = GeoPlimite.x - GeoPorig.x;
geoAlt = GeoPlimite.y - GeoPorig.y;
//se si deve scalare in alt
if ((schLarg / schAlt) < (geoLarg / geoAlt)) {
scala = schLarg / geoLarg;
} else {
scala = schAlt / geoAlt;
}
}
/**
* Description of the Method
*
*@return Description of the Returned Value
*/
public Object clone() {
Object o = null;
try {
o = super.clone();
((GraphicsGeo) o).GeoPorig = (Punto) GeoPorig.clone();
((GraphicsGeo) o).GeoPlimite = (Punto) GeoPlimite.clone();
((GraphicsGeo) o).SchPorig = (Punto) SchPorig.clone();
((GraphicsGeo) o).SchPlimite = (Punto) SchPlimite.clone();
} catch (CloneNotSupportedException e) {
System.out.println("MyObject can't clone");
}
return o;
}
/**
* Description of the Method
*
*@param g Description of Parameter
*@param c Description of Parameter
*@param Entita Description of Parameter
*/
public void disegna(Graphics g, Color c, Entita Entita) {
Entita.disegna(c, scala, scala, (int) schAlt, g);
}
}
--- NEW FILE: High.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Software *
* License version 1.1_01, a copy of which has been included with this *
* distribution in the LICENSE file. *
*****************************************************************************/
package org.krysalis.swingx.geo;
/**
* Description of the Interface
*
*@author Luca Jun Barozzi
*@created 16 settembre 2001
*/
public interface High {
/**
* Description of the Method
*
*@param y Description of Parameter
*@return Description of the Returned Value
*/
public double xval(double y);
/**
* Description of the Method
*
*@param y Description of Parameter
*@return Description of the Returned Value
*/
public boolean ycompreso(double y);
}
--- NEW FILE: Large.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Software *
* License version 1.1_01, a copy of which has been included with this *
* distribution in the LICENSE file. *
*****************************************************************************/
package org.krysalis.swingx.geo;
/**
* Description of the Interface
*
*@author Luca Jun Barozzi
*@created 16 settembre 2001
*/
public interface Large {
/**
* Description of the Method
*
*@param x Description of Parameter
*@return Description of the Returned Value
*/
public double yval(double x);
/**
* Description of the Method
*
*@param x Description of Parameter
*@return Description of the Returned Value
*/
public boolean xcompreso(double x);
}
--- NEW FILE: Linea.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Software *
* License version 1.1_01, a copy of which has been included with this *
* distribution in the LICENSE file. *
*****************************************************************************/
package org.krysalis.swingx.geo;
import java.awt.*;
/**
* Description of the Class
*
*@author Luca Jun Barozzi
*@created 16 settembre 2001
*/
public class Linea implements Entita, Large, High, Cloneable {
/**
* Description of the Field
*/
public final static double DINFINITESIMAL = 0.0000001;
Punto P1, P2;
double m, n;
//linea tra due punti
/**
* Constructor for the Linea object
*
*@param P1 Description of Parameter
*@param P2 Description of Parameter
*/
Linea(Punto P1, Punto P2) {
this.P1 = P1;
this.P2 = P2;
m = deltaY() / deltaX();
n = -m * P1.x + P1.y;
}
// assi cartesiani
/**
* Constructor for the Linea object
*
*@param asse Description of Parameter
*/
Linea(String asse) {
if (asse.equals("ASSEX")) {
P1 = new Punto();
P2 = P1.relativo(1, 0);
m = 0;
n = 0;
}
if (asse.equals("ASSEY")) {
P1 = new Punto();
P2 = P1.relativo(1, Math.PI / 2);
m = Math.PI / 2;
n = 0;
}
}
//linea definita secondo le intersezioni con gli assi cartesiano
/**
* Constructor for the Linea object
*
*@param m Description of Parameter
*@param n Description of Parameter
*/
Linea(double m, double n) {
this.m = m;
this.n = n;
P1 = new Punto(0, n);
if (!Double.isInfinite(m)) {
P2 = new Punto(-n / m, 0);
}
if (m == 0) {
P2 = new Punto(1, n);
}
}
/*
* / linea bisettrice dell'angolo tra due linee
* Linea(Linea l1, Linea l2, boolean unodeidue) {
* P1= new Punto(l1, l2);
* Circonferenza Ci= new Circonferenza(P1, 50);
* duePunti dp1= new duePunti(l1, Ci);
* duePunti dp2= new duePunti(l2, Ci);
* Linea La=new Linea(dp1.P1, dp2.P1);
* Linea Lb=new Linea(dp1.P1, dp2.P2);
* if (unodeidue) P2=Lb.medio(); else P2=La.medio();
* m=deltaY()/deltaX();
* n=-m*P1.x + P1.y;
* }
*/
/**
*@return Description of the Returned Value
*/
/**
* fine costruttori linea ***
*
*@return Description of the Returned Value
*/
/**
* fine costruttori linea ***
*
*@return Description of the Returned Value
*/
public Object clone() {
Object o = null;
try {
o = super.clone();
((Linea) o).P1 = (Punto) P1.clone();
((Linea) o).P2 = (Punto) P2.clone();
} catch (CloneNotSupportedException e) {
System.out.println("MyObject can't clone");
}
return o;
}
// mi dice se il valore x e' compreso negli estremi della linea
/**
* Description of the Method
*
*@param x Description of Parameter
*@return Description of the Returned Value
*/
public boolean xcompreso(double x) {
if (((x > P2.x) && (x < P1.x)) || ((x > P1.x) && (x < P2.x))) {
return true;
} else {
return false;
}
}
// mi dice se il valore y e' compreso negli estremi della linea
/**
* Description of the Method
*
*@param y Description of Parameter
*@return Description of the Returned Value
*/
public boolean ycompreso(double y) {
if (((y > P2.y) && (y < P1.y)) || ((y > P1.y) && (y < P2.y))) {
return true;
} else {
return false;
}
}
// NON RESTITUISCE PER VERT E ORIZZ !!!!!!!
/**
* Description of the Method
*
*@param x Description of Parameter
*@return Description of the Returned Value
*/
public double yval(double x) {
return (m * x + n);
}
// NON RESTITUISCE PER VERT E ORIZZ !!!!!!!
/**
* Description of the Method
*
*@param y Description of Parameter
*@return Description of the Returned Value
*/
public double xval(double y) {
return ((y - n) / m);
}
// mi dice se la linea ha un coeff ang >= di quello impostato
/**
* Description of the Method
*
*@param coeffAng Description of Parameter
*@return Description of the Returned Value
*/
public boolean verticale(double coeffAng) {
boolean b;
double ex = deltaX();
double ey = deltaY();
if (Math.abs(ey) >= Math.abs(coeffAng * ex)) {
b = true;
} else {
b = false;
}
return b;
}
// mi dice se la linea ha un coeff ang <= di quello impostato
/**
* Description of the Method
*
*@param coeffAng Description of Parameter
*@return Description of the Returned Value
*/
public boolean orizzontale(double coeffAng) {
boolean b;
double ex = deltaX();
double ey = deltaY();
if (Math.abs(ey) <= Math.abs(coeffAng * ex)) {
b = true;
} else {
b = false;
}
return b;
}
// restituisce il Punto con l'x piu' alto
/**
* Description of the Method
*
*@return Description of the Returned Value
*/
public Punto pDx() {
Punto PTemp;
if (P1.x > P2.x) {
PTemp = new Punto(P1.x, P1.y);
} else {
PTemp = new Punto(P2.x, P2.y);
}
return PTemp;
}
// restituisce il Punto con l'x piu' basso
/**
* Description of the Method
*
*@return Description of the Returned Value
*/
public Punto pSx() {
Punto PTemp;
if (P1.x < P2.x) {
PTemp = new Punto(P1.x, P1.y);
} else {
PTemp = new Punto(P2.x, P2.y);
}
return PTemp;
}
/**
* Description of the Method
*
*@return Description of the Returned Value
*/
public String toString() {
return (new String("Line P1.x,P2.y,P1.x,P2.y" + " " + P1.x + " " + P1.y + " " + P2.x + " " + P2.y));
}
// Fa in modo che P1.x<P2.x
/**
* Description of the Method
*/
public void ordinaSxDx() {
if (P1.x > P2.x) {
try {
Punto P3 = (Punto) P1.clone();
P1.x = P2.x;
P1.y = P2.y;
P2.x = P3.x;
P2.y = P3.y;
} catch (Exception e) {
System.out.println("Punto can't clone");
}
}
}
// Fa in modo che P1.y<P2.y
/**
* Description of the Method
*/
public void ordinaInfSup() {
if (P1.y > P2.y) {
try {
Punto P3 = (Punto) P1.clone();
P1.x = P2.x;
P1.y = P2.y;
P2.x = P3.x;
P2.y = P3.y;
} catch (Exception e) {
System.out.println("Punto can't clone");
}
}
}
/**
* Indica il "primo" punto appartenente alla linea corrente che si trova
* alla distanza specificata dal punto indicato. Non lancia
* eccezioni!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*
*@param PA il punto dal quale valutare la distanza
*@param distanza la distanza tra P1 e il punto da trovare return il punto
* distante quanto richiesto da P1 appartenente alla linea corrente
*@return Description of the Returned Value
*/
public Punto aDistanza(Punto PA, double distanza) {
Punto PTemp1 = (Punto) this.P1.clone();
Punto PTemp2 = (Punto) this.P2.clone();
Punto PTempM;
double distanza1 = (new Linea(PA, PTemp1)).lunghezza();
double distanza2 = (new Linea(PA, PTemp2)).lunghezza();
double distanzaM;
if ((distanza > distanza1) && (distanza < distanza2)
|| (distanza < distanza1) && (distanza > distanza2)) {
do {
PTempM = (new Linea(PTemp1, PTemp2)).medio();
distanzaM = (new Linea(PA, PTempM)).lunghezza();
if ((distanza > distanza1) && (distanza < distanzaM)
|| (distanza < distanza1) && (distanza > distanzaM)) {
PTemp2 = PTempM;
} else if (Math.abs(distanza1 - distanza) < DINFINITESIMAL) {
return PTemp1;
} else if (Math.abs(distanza2 - distanza) < DINFINITESIMAL) {
return PTemp2;
} else {
PTemp1 = PTempM;
}
distanza1 = (new Linea(PA, PTemp1)).lunghezza();
distanza2 = (new Linea(PA, PTemp2)).lunghezza();
} while (Math.abs(distanzaM - distanza) > DINFINITESIMAL);
return PTempM;
} else if (Math.abs(distanza1 - distanza) < DINFINITESIMAL) {
return P1;
} else if (Math.abs(distanza2 - distanza) < DINFINITESIMAL) {
return P2;
} else {
return null;
}
}
/*
* public String toString()
* {
* return new String("P1:"+P1+" P2:"+P2+"\n");
* }
*/
/**
*@param Porig Description of Parameter
*@param Pdest Description of Parameter
*/
/**
* metodi minimi ********
*
*@param Porig Description of Parameter
*@param Pdest Description of Parameter
*/
/**
* metodi minimi ********
*
*@param Porig Description of Parameter
*@param Pdest Description of Parameter
*/
// sposta la liena parallelamente allo spoostamento Porig - Pdest
public void sposta(Punto Porig, Punto Pdest) {
P1.sposta(Porig, Pdest);
P2.sposta(Porig, Pdest);
m = deltaY() / deltaX();
n = -m * P1.x + P1.y;
}
// ruota di un anglo specificato la linea intorno ad un punto
/**
* Description of the Method
*
*@param Prot Description of Parameter
*@param alfa Description of Parameter
*/
public void ruota(Punto Prot, double alfa) {
P1.ruota(Prot, alfa);
P2.ruota(Prot, alfa);
m = deltaY() / deltaX();
n = -m * P1.x + P1.y;
}
// disegna la linea
/**
* Description of the Method
*
*@param c Description of Parameter
*@param ScalaX Description of Parameter
*@param ScalaY Description of Parameter
*@param altezzaRiquadro Description of Parameter
*@param g Description of Parameter
*/
public void disegna(Color c,
double ScalaX,
//fattori per cui moltiplicare
double ScalaY,
//i valori da disegnare
int altezzaRiquadro,
Graphics g) {
int schX0;
int schY0;
int schX1;
int schY1;
g.setColor(c);
schX0 = (int) (P1.x * ScalaX);
schY0 = (int) (P1.y * ScalaY);
schX1 = (int) (P2.x * ScalaX);
schY1 = (int) (P2.y * ScalaY);
g.drawLine(schX0, altezzaRiquadro - schY0, schX1, altezzaRiquadro - schY1);
}
// differenza delle ascisse degli estremi
/**
* Description of the Method
*
*@return Description of the Returned Value
*/
double deltaX() {
return P2.x - P1.x;
}
// differenza delle coordinate degli estremi
/**
* Description of the Method
*
*@return Description of the Returned Value
*/
double deltaY() {
return P2.y - P1.y;
}
// angolo in radianti nel pianoo XY rispetto all'asse delle ascisse X
/**
* Description of the Method
*
*@return Description of the Returned Value
*/
double angoloXY() {
double ang = 0;
if ((deltaX() < 0) && (deltaY() < 0)) {
ang = Math.atan(m) + Math.PI;
}
if ((deltaX() < 0) && (deltaY() >= 0)) {
ang = Math.atan(m) + Math.PI;
}
if ((deltaX() >= 0) && (deltaY() < 0)) {
ang = 2 * Math.PI + Math.atan(m);
}
if ((deltaX() >= 0) && (deltaY() >= 0)) {
ang = Math.atan(m);
}
return ang;
}
// distanza tra i punti estremi o lunghezza della linea
/**
* Description of the Method
*
*@return Description of the Returned Value
*/
double lunghezza() {
return Math.sqrt(Math.pow(deltaX(), 2) + Math.pow(deltaY(), 2));
}
// punto medio della linea
/**
* Description of the Method
*
*@return Description of the Returned Value
*/
Punto medio() {
return new Punto((P1.x + P2.x) / 2, (P1.y + P2.y) / 2);
}
// linea perpendicolare alla linea in corso passante per un punto P
/**
* Description of the Method
*
*@param p Description of Parameter
*@return Description of the Returned Value
*/
Linea perp(Punto p) {
double x;
double y;
double m2;
double n2;
if (!Double.isInfinite(m) && (m != 0)) {
m2 = -1 / m;
n2 = -m2 * p.x + p.y;
x = (n2 - n) / (m - m2);
y = m2 * x + n2;
Linea lperp = new Linea(p, new Punto(x, y));
lperp.m = m2;
lperp.n = n2;
return lperp;
} else {
if (Double.isInfinite(m)) {
x = P1.x;
y = p.y;
Linea lperp = new Linea(p, new Punto(x, y));
if (lperp.P1 == lperp.P2) {
lperp = new Linea(lperp.P1, new Punto(lperp.P1.x + 1, lperp.P1.y));
}
lperp.m = 0;
lperp.n = p.y;
return lperp;
} else {
// (m==0)
x = p.x;
y = P1.y;
Linea lperp = new Linea(p, new Punto(x, y));
lperp.m = Double.POSITIVE_INFINITY;
lperp.n = Double.POSITIVE_INFINITY;
return lperp;
}
}
}
// linea parallela alla linea in corso passante per il punto P
/**
* Description of the Method
*
*@param p Description of Parameter
*@return Description of the Returned Value
*/
Linea parallela(Punto p) {
if (!Double.isInfinite(m)) {
return new Linea(m, -m * p.x + p.y);
} else {
return new Linea(new Punto(p.x, p.y), new Punto(p.x, P1.y));
}
}
// proiezione di una linea esterna sulla linea in corso
/**
* Description of the Method
*
*@param l Description of Parameter
*@return Description of the Returned Value
*/
Linea proiezione(Linea l) {
Punto Pl1 = new Punto(new Linea(P1, P2), perp(l.P1));
Punto Pl2 = new Punto(new Linea(P1, P2), perp(l.P2));
return new Linea(Pl1, Pl2);
}
// angolo tra la linea in corso e un'altra linea
/**
* Description of the Method
*
*@param l Description of Parameter
*@param unodeidue Description of Parameter
*@return Description of the Returned Value
*/
double angolo(Linea l, boolean unodeidue) {
double ang = Math.abs(angoloXY() - l.angoloXY());
ang = ang - ((int) (ang / Math.PI)) * Math.PI;
if (unodeidue) {
return ang;
} else {
return Math.abs(Math.PI - ang);
}
}
/*
* / circonferenza tangente alla linea in corso con centro in un punto qualsiasi
* Circonferenza tangente(Punto centro) {
* return new Circonferenza(centro, perp(centro).lunghezza());
* }
*/
/**
* Description of the Method
*
*@param Ls Description of Parameter
*@return Description of the Returned Value
*/
Linea simmetrica(Linea Ls) {
return new Linea(P1.simmetrico(Ls), P2.simmetrico(Ls));
}
}
--- NEW FILE: LineaComposita.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Software *
* License version 1.1_01, a copy of which has been included with this *
* distribution in the LICENSE file. *
*****************************************************************************/
package org.krysalis.swingx.geo;
import java.awt.*;
import java.util.*;
/*
* ***********************************************************
* Vector v=new Vector();
* v.addElement(e);
* for (int i=0; i<v.size(); i++) {
* ((entita) v.elementAt(i)).sposta(Porig, Pdest);
* v.removeAllElements();
*
*/
/**
* Description of the Class
*
*@author Luca Jun Barozzi
*@created 16 settembre 2001
*/
public class LineaComposita implements Entita, Large, High, Cloneable {
/**
* Description of the Field
*/
public int corrente;
/**
* Description of the Field
*/
public Vector VElementi;
/**
* Constructor for the LineaComposita object
*/
public LineaComposita() {
this.VElementi = new Vector();
corrente = 0;
}
// Bisognera' estendere Vector
/**
* Adds a feature to the Element attribute of the LineaComposita object
*
*@param Obj The feature to be added to the Element attribute
*/
public void addElement(Object Obj) {
VElementi.addElement(Obj);
}
/**
* Description of the Method
*
*@return Description of the Returned Value
*/
public Object clone() {
Object o = null;
try {
o = super.clone();
Vector Clonedo = new Vector();
for (int j = 0; j < (this.VElementi).size(); j++) {
if ((VElementi.elementAt(j)) instanceof Spline) {
Clonedo.addElement(((Spline) this.VElementi.elementAt(j)).clone());
}
if ((VElementi.elementAt(j)) instanceof SplineVert) {
Clonedo.addElement(((SplineVert) this.VElementi.elementAt(j)).clone());
}
if ((VElementi.elementAt(j)) instanceof Linea) {
Clonedo.addElement(((Linea) this.VElementi.elementAt(j)).clone());
}
if ((VElementi.elementAt(j)) instanceof Punto) {
Clonedo.addElement(((Punto) this.VElementi.elementAt(j)).clone());
}
/*
* if(o instanceof Cloneable)
* {
* ((LineaComposita)o).VElementi.setElementAt((Cloneable)(VElementi.elementAt(j)).clone(), j) ;
* }
*/
}
((LineaComposita) o).VElementi = Clonedo;
} catch (CloneNotSupportedException e) {
System.out.println("MyObject can't clone");
}
return o;
}
/**
* Description of the Method
*
*@param x Description of Parameter
*@return Description of the Returned Value
*/
public boolean xcompreso(double x) {
for (int j = 0; j < VElementi.size(); j++) {
Large EntitaCorrente = ((Large) VElementi.elementAt(j));
if ((EntitaCorrente.xcompreso(x)) == true) {
return true;
}
}
return false;
}
/**
* Description of the Method
*
*@param y Description of Parameter
*@return Description of the Returned Value
*/
public boolean ycompreso(double y) {
for (int j = 0; j < VElementi.size(); j++) {
High EntitaCorrente = ((High) VElementi.elementAt(j));
if ((EntitaCorrente.ycompreso(y)) == true) {
return true;
}
}
return false;
}
/**
* Description of the Method
*
*@param x Description of Parameter
*@return Description of the Returned Value
*/
public double yval(double x) {
for (int j = 0; j < VElementi.size(); j++) {
Large EntitaCorrente = ((Large) VElementi.elementAt(j));
if ((EntitaCorrente.xcompreso(x)) == true) {
return EntitaCorrente.yval(x);
}
}
return 0;
}
/**
* Description of the Method
*
*@param y Description of Parameter
*@return Description of the Returned Value
*/
public double xval(double y) {
for (int j = 0; j < VElementi.size(); j++) {
High EntitaCorrente = ((High) VElementi.elementAt(j));
if ((EntitaCorrente.ycompreso(y)) == true) {
return EntitaCorrente.xval(y);
}
}
return 0;
}
/**
*@param Porig Description of Parameter
*@param Pdest Description of Parameter
*/
/**
* metodi minimi ********
*
*@param Porig Description of Parameter
*@param Pdest Description of Parameter
*/
/**
* metodi minimi ********
*
*@param Porig Description of Parameter
*@param Pdest Description of Parameter
*/
// sposta il punto in corso parallelamente allo spostamento Porig-Pdest
public void sposta(Punto Porig, Punto Pdest) {
for (int j = 0; j < VElementi.size(); j++) {
((Entita) VElementi.elementAt(j)).sposta(Porig, Pdest);
}
}
// ruota di un anglo specificato il punto in corso intorno ad un punto specificato
/**
* Description of the Method
*
*@param Prot Description of Parameter
*@param alfa Description of Parameter
*/
public void ruota(Punto Prot, double alfa) {
for (int j = 0; j < VElementi.size(); j++) {
((Entita) VElementi.elementAt(j)).ruota(Prot, alfa);
}
}
// disegna
/**
* Description of the Method
*
*@param c Description of Parameter
*@param ScalaX Description of Parameter
*@param ScalaY Description of Parameter
*@param altezzaRiquadro Description of Parameter
*@param g Description of Parameter
*/
public void disegna(Color c,
double ScalaX,
//fattori per cui moltiplicare
double ScalaY,
//i valori da disegnare
int altezzaRiquadro,
Graphics g) {
for (int j = 0; j < VElementi.size(); j++) {
((Entita) VElementi.elementAt(j)).disegna(c, ScalaX, ScalaY, altezzaRiquadro, g);
}
}
}
--- NEW FILE: Punto.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Software *
* License version 1.1_01, a copy of which has been included with this *
* distribution in the LICENSE file. *
*****************************************************************************/
package org.krysalis.swingx.geo;
import java.awt.*;
/**
* Description of the Class
*
*@author Luca Jun Barozzi
*@created 16 settembre 2001
*/
class Punto implements Entita, Cloneable {
/**
* Description of the Field
*/
public double x, y;
// public per rendere facile l'utilizzo
// Origine (0, 0)
/**
* Constructor for the Punto object
*/
Punto() {
x = 0;
y = 0;
}
/**
* Constructor for the Punto object
*
*@param x Description of Parameter
*@param y Description of Parameter
*/
Punto(double x, double y) {
this.x = x;
this.y = y;
}
// punto di intersezione tra due linee
/**
* Constructor for the Punto object
*
*@param L1 Description of Parameter
*@param L2 Description of Parameter
*/
Punto(Linea L1, Linea L2) {
if (L1.m != L2.m) {
if (!Double.isInfinite(L1.m) && !Double.isInfinite(L2.m)) {
x = (L2.n - L1.n) / (L1.m - L2.m);
y = L2.m * x + L2.n;
} else {
if (Double.isInfinite(L1.m)) {
x = L1.P1.x;
y = L2.m * x + L2.n;
}
if (Double.isInfinite(L2.m)) {
x = L2.P1.x;
y = L1.m * x + L1.n;
}
}
} else {
System.out.println("le linee sono parallele");
}
}
// punto di intersezione tra due linee definite dalle intersezioni
// com gli assi cartesioni
/**
* Constructor for the Punto object
*
*@param m1 Description of Parameter
*@param n1 Description of Parameter
*@param m2 Description of Parameter
*@param n2 Description of Parameter
*/
Punto(double m1, double n1, double m2, double n2) {
Punto p = new Punto(new Linea(m1, n1), new Linea(m2, n2));
x = p.x;
y = p.y;
}
// punto polare rispetto ad un punto dato
/**
* Constructor for the Punto object
*
*@param P Description of Parameter
*@param ro Description of Parameter
*@param teta Description of Parameter
*/
Punto(Punto P, double ro, double teta) {
x = P.x + ro * Math.cos(teta);
y = P.y + ro * Math.sin(teta);
}
/**
* Punto intersezione tra LineaComposita e Linea capisce da solo se la
* linea è "verticale" o "orizzontale" NNNNBBBB.: ora prende SOLO LE
* ORIZZONTALI!
*
*@param LineaComposita Description of Parameter
*@param Linea Description of Parameter
*/
Punto(LineaComposita LineaComposita, Linea Linea) {
double angolo;
double angoloInverso;
double xTemp;
double yTemp;
Punto CentroAssi = new Punto(0, 0);
Linea LineaTemp = (Linea) Linea.clone();
LineaComposita LineaCompositaTemp = (LineaComposita) LineaComposita.clone();
angoloInverso = ((Math.PI) / 2) - LineaTemp.angoloXY();
angolo = 0 - angoloInverso;
LineaTemp.ruota(CentroAssi, angoloInverso);
LineaCompositaTemp.ruota(CentroAssi, angoloInverso);
xTemp = (LineaTemp.pSx()).x;
yTemp = LineaCompositaTemp.yval(xTemp);
//catturare l'errore se è fuori!!!!!!!!
Punto PTemp = new Punto(xTemp, yTemp);
PTemp.ruota(CentroAssi, angolo);
this.x = PTemp.x;
this.y = PTemp.y;
}
/**
* crea il punto distante qdist dal punto in corso il quale sta sulla AGLC
* nell'elemento qelemento, punto qPto ; il punto in corso sta tra qPto-1 e
* qPto della spline. l'algoritmo e' scritto presupponendo che il punto in
* questione stia sulla AGLC Si sono fatte ipotesi di "orizzontalita'" e di
* regolarita'
*
*@return Description of the Returned Value
*/
/*
* Punto adistanza(LineaComposita LineaCompositaCorrente,int qelemento, int qPto, double qdist)
* {
* double dist= 0;
* Spline SplineCorrente;
* Punto Pinit= new Punto(x,y);
* Punto PRangeSx =
* new Punto( ((Spline) VSpline.elementAt(qSpline)).x[qPto-1],
* ((Spline) VSpline.elementAt(qSpline)).a[qPto-1] );
* Punto PRangeDx =
* new Punto( ((Spline) VSpline.elementAt(qSpline)).x[qPto],
* ((Spline) VSpline.elementAt(qSpline)).a[qPto] );
* int i= qPto;
* for(i=qSpline ; ( i<VSpline.size() ) && ( dist<= qdist); j++, i=0)
* {
* SplineCorrente= (Spline) VSpline.elementAt(j);
* for( ; ( i< SplineCorrente.N ) && ( dist<= qdist); i++)
* {
* PRangeDx.x= SplineCorrente.x[i];
* PRangeDx.y= SplineCorrente.a[i];
*/
/**
* crea il punto distante qdist dal punto in corso il quale sta sulla AGLC
* nell'elemento qelemento, punto qPto ; il punto in corso sta tra qPto-1 e
* qPto della spline. l'algoritmo e' scritto presupponendo che il punto in
* questione stia sulla AGLC Si sono fatte ipotesi di "orizzontalita'" e di
* regolarita'
*
* manca******************************
*
*@return Description of the Returned Value
*/
public Object clone() {
Object o = null;
try {
o = super.clone();
} catch (CloneNotSupportedException e) {
System.out.println("MyObject can't clone");
}
return o;
}
// manda (x)->(y) e (-y)->(x)
/**
* Description of the Method
*/
public void inverti() {
double t = 0;
t = x;
x = (-y);
y = t;
}
/**
* Description of the Method
*
*@param PTemp Description of Parameter
*@return Description of the Returned Value
*/
public boolean equals(Punto PTemp) {
if ((PTemp.x == this.x) && (PTemp.y == this.y)) {
return true;
} else {
return false;
}
}
/**
* Description of the Method
*
*@return Description of the Returned Value
*/
public String toString() {
return new String("X:" + x + " Y:" + y + "\n");
}
/**
*@param Porig Description of Parameter
*@param Pdest Description of Parameter
*/
/**
* metodi minimi ********
*
*@param Porig Description of Parameter
*@param Pdest Description of Parameter
*/
/**
* metodi minimi ********
*
*@param Porig Description of Parameter
*@param Pdest Description of Parameter
*/
// sposta il punto in corso parallelamente allo spostamento Porig-Pdest
public void sposta(Punto Porig, Punto Pdest) {
Linea lPoPd = new Linea(Porig, Pdest);
x = x + lPoPd.deltaX();
y = y + lPoPd.deltaY();
}
// ruota di un anglo specificato il punto in corso intorno ad un punto specificato
/**
* Description of the Method
*
*@param Prot Description of Parameter
*@param alfa Description of Parameter
*/
public void ruota(Punto Prot, double alfa) {
double s = Math.sin(alfa);
double c = Math.cos(alfa);
Linea Cp = new Linea(new Punto(0, 0), Prot);
double xo = x - Cp.deltaX();
double yo = y - Cp.deltaY();
double X = xo * c - yo * s;
double Y = xo * s + yo * c;
x = X + Cp.deltaX();
y = Y + Cp.deltaY();
}
// disegna il punto
/**
* Description of the Method
*
*@param c Description of Parameter
*@param ScalaX Description of Parameter
*@param ScalaY Description of Parameter
*@param altezzaRiquadro Description of Parameter
*@param g Description of Parameter
*/
public void disegna(Color c,
double ScalaX,
//fattori per cui moltiplicare
double ScalaY,
//i valori da disegnare
int altezzaRiquadro,
Graphics g) {
int schX;
int schY;
g.setColor(c);
schX = (int) (x * ScalaX);
schY = (int) (y * ScalaY);
g.drawLine(schX, altezzaRiquadro - schY, schX, altezzaRiquadro - schY);
}
// ritorna il punto di coordinate polari ro, teta relativo al punto in corso
/**
* Description of the Method
*
*@param ro Description of Parameter
*@param teta Description of Parameter
*@return Description of the Returned Value
*/
Punto polare(double ro, double teta) {
return new Punto(new Punto(x, y), ro, teta);
}
// ritorna il punto di coordinate x,y relative al punto in corso
/**
* Description of the Method
*
*@param xr Description of Parameter
*@param yr Description of Parameter
*@return Description of the Returned Value
*/
Punto relativo(double xr, double yr) {
return new Punto(x + xr, y + yr);
}
// ritorna il perimetro del triangolo costituito dal punto in corso ed altri due punti
/**
* Description of the Method
*
*@param Pb Description of Parameter
*@param Pc Description of Parameter
*@return Description of the Returned Value
*/
double perimetro(Punto Pb, Punto Pc) {
return new Linea(this, Pb).lunghezza() + new Linea(Pb, Pc).lunghezza() + new Linea(Pc, this).lunghezza();
}
// ritorna l'area del triangolo costituito dal punto in corso ed altri due punti applicando la formula di Erone
/**
* Description of the Method
*
*@param Pb Description of Parameter
*@param Pc Description of Parameter
*@return Description of the Returned Value
*/
double area(Punto Pb, Punto Pc) {
// calcola il semiperimetro (perimetro/2)
double p = perimetro(Pb, Pc) / 2;
return Math.sqrt(p * (p - new Linea(this, Pb).lunghezza()) * (p - new Linea(Pb, Pc).lunghezza()) * (p - new Linea(Pc, this).lunghezza()));
}
// Verifica se il punto in corso e' interno ad un triangolo
/**
* Description of the Method
*
*@param Pa Description of Parameter
*@param Pb Description of Parameter
*@param Pc Description of Parameter
*@return Description of the Returned Value
*/
boolean interno(Punto Pa, Punto Pb, Punto Pc) {
return (Math.abs(area(Pa, Pb) + area(Pb, Pc) + area(Pc, Pa) - Pa.area(Pb, Pc)) < .0000001);
}
/*
* / Verifica se il punto in corso e' interno ad una circonferenza data
* boolean interno(Circonferenza C) {
* return new Linea(C.centro, this).lunghezza() < C.raggio;
* }
*/
// ritorna il punto simmetrico, rispetto alla line di simetria Ls, del punto in corso
/**
* Description of the Method
*
*@param Ls Description of Parameter
*@return Description of the Returned Value
*/
Punto simmetrico(Linea Ls) {
Linea perpLs = Ls.perp(this);
Punto Pi = new Punto(Ls, perpLs);
double ro = (new Linea(this, Pi)).lunghezza() * 2;
return polare(ro, perpLs.angoloXY());
}
}
--- NEW FILE: Spline.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Software *
* License version 1.1_01, a copy of which has been included with this *
* distribution in the LICENSE file. *
*****************************************************************************/
package org.krysalis.swingx.geo;
import java.awt.Color;
import java.awt.Graphics;
/**
* Description of the Class
*
*@author Luca Jun Barozzi
*@created 16 settembre 2001
*/
public class Spline
implements Entita, Large, Cloneable {
/**
* Description of the Field
*/
protected int N;
//numero nodi?
/**
* Description of the Field
*/
protected double x[],
//sono le x dei nodi
a[],
//==y[]
b[],
c[],
d[],
h[],
alpha[],
l[],
mu[],
z[];
/**
* Togliere N e usare x.length in tutto
*
*@param N Description of Parameter
*@param x Description of Parameter
*@param y Description of Parameter
*/
public Spline(int N, double x[], double y[]) {
int i;
this.N = x.length;
this.x = new double[N];
this.a = new double[N];
this.b = new double[N];
this.c = new double[N];
this.d = new double[N];
h = new double[N];
z = new double[N];
l = new double[N];
mu = new double[N];
alpha = new double[N];
for (i = 0; i < N; i++) {
this.x[i] = x[i];
a[i] = y[i];
}
calcolaCoeff();
}
/**
* Description of the Method
*
*@return Description of the Returned Value
*/
public Object clone() {
Object o = null;
try {
o = super.clone();
} catch (CloneNotSupportedException e) {
System.out.println("MyObject can't clone");
}
((Spline) o).x = new double[N];
((Spline) o).a = new double[N];
((Spline) o).b = new double[N];
((Spline) o).c = new double[N];
((Spline) o).d = new double[N];
((Spline) o).h = new double[N];
((Spline) o).z = new double[N];
((Spline) o).l = new double[N];
((Spline) o).mu = new double[N];
((Spline) o).alpha = new double[N];
for (int i = 0; i < N; i++) {
((Spline) o).x[i] = x[i];
((Spline) o).a[i] = a[i];
((Spline) o).b[i] = b[i];
((Spline) o).c[i] = c[i];
((Spline) o).d[i] = d[i];
((Spline) o).h[i] = h[i];
((Spline) o).z[i] = z[i];
((Spline) o).l[i] = l[i];
((Spline) o).mu[i] = mu[i];
((Spline) o).alpha[i] = alpha[i];
}
return o;
}
/**
* Description of the Method
*
*@param xval Description of Parameter
*@return Description of the Returned Value
*/
public double yval(double xval) {
int j;
double df;
double df2;
double df3;
double yval = 0;
// sembra che l'if non vada bene...in SplineVert i valori sono negativi e forse al contrario...occhio!
//mi fa un out "of bounds exception" su di un array con le spline verticali!
/*
* old if((x[0]>xval) || (x[N-1]<xval)false)
*/
//debug
if (x[0] > xval) {
System.out.println(x[0] + ">" + xval);
}
//debug
if (x[N - 1] < xval) {
System.out.println(x[N - 1] + "<" + xval);
}
if ((x[0] > xval) || (x[N - 1] < xval)) {
/*
* vd.OR.
*/
/*
* errore
*/
//inserire in modo che funzioni try...catch
} else {
//qui ho messo >= invece di > per "out of bounds"
// questo funge
/*
* j=0;
* while((!((xval<=x[j+1])&&(xval>=x[j]))) && (j+1)<x.length)
* {
* j++;
* }
*/
for (j = 0; (!((xval <= x[j + 1]) && (xval >= x[j]))) && (j + 1) < x.length; j++) {
}
df = xval - x[j];
df2 = df * df;
df3 = df2 * df;
yval = a[j] + b[j] * df + c[j] * df2 + d[j] * df3;
}
return yval;
}
/*
* /restituisce il punto appartenente alla spline che sia
* /distante dist (in linea retta) dal punto della spline avente
* /coordinata x coordx
* public Punto adistanza(double coordx, double dist) {
* double ycoord;
* Punto Pris;
* ycoord = yval(xcoord);
* }
*/
// mi dice se il valore x e' compreso negli estremi della spline
/**
* Description of the Method
*
*@param xt Description of Parameter
*@return Description of the Returned Value
*/
public boolean xcompreso(double xt) {
if (((xt > x[0]) && (xt < x[N])) || ((xt < x[0]) && (xt > x[N]))) {
return true;
} else {
return false;
}
}
/**
* Indica il "primo" punto appartenente alla spline corrente che si trova
* alla distanza specificata dal punto indicato. Non lancia
* eccezioni!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*
*@param Porig Description of Parameter
*@param Pdest Description of Parameter
*/
/*
* public Punto aDistanza(Punto PA, double distanza)
* {
* Punto PTemp1 = (Punto)this.P1.clone();
* Punto PTemp2 = (Punto)this.P2.clone();
* Punto PTempM;
* double distanza1 = (new Linea(PA,PTemp1)).lunghezza();
* double distanza2 = (new Linea(PA,PTemp2)).lunghezza();
* double distanzaM;
* if((distanza>distanza1)&&(distanza<distanza2)
* || (distanza<distanza1)&&(distanza>distanza2))
* {
* do
* {
* PTempM = (new Linea(PTemp1,PTemp2)).medio();
* distanzaM = (new Linea(PA,PTempM)).lunghezza();
* if((distanza>distanza1)&&(distanza<distanzaM)
* || (distanza<distanza1)&&(distanza>distanzaM))
* {
* PTemp2 = PTempM;
* }
* else if(Math.abs(distanza1-distanza)<DINFINITESIMAL)
* {
* return PTemp1;
* }
* else if(Math.abs(distanza2-distanza)<DINFINITESIMAL)
* {
* return PTemp2;
* }
* else
* {
* PTemp1 = PTempM;
* }
* distanza1 = (new Linea(PA,PTemp1)).lunghezza();
* distanza2 = (new Linea(PA,PTemp2)).lunghezza();
* }
* while(Math.abs(distanzaM-distanza)>DINFINITESIMAL);
* return PTempM;
* }
* else if(Math.abs(distanza1-distanza)<DINFINITESIMAL)
* {
* return P1;
* }
* else if(Math.abs(distanza2-distanza)<DINFINITESIMAL)
* {
* return P2;
* }
* else
* {
* return null;
* }
* }
*/
/**
* Indica il "primo" punto appartenente alla spline corrente che si trova
* alla distanza specificata dal punto indicato. Non lancia
* eccezioni!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*
*@param Porig Description of Parameter
*@param Pdest Description of Parameter
*/
/**
* Indica il "primo" punto appartenente alla spline corrente che si trova
* alla distanza specificata dal punto indicato. Non lancia
* eccezioni!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*
* metodi minimi ********
*
*@param Porig Description of Parameter
*@param Pdest Description of Parameter
*/
/**
* Indica il "primo" punto appartenente alla spline corrente che si trova
* alla distanza specificata dal punto indicato. Non lancia
* eccezioni!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*
* metodi minimi ********
*
*@param Porig Description of Parameter
*@param Pdest Description of Parameter
*/
public void sposta(Punto Porig, Punto Pdest) {
double scostX;
double scostY;
scostX = (Pdest.x) - (Porig.x);
scostY = (Pdest.y) - (Porig.y);
for (int i = 0; i < N; i++) {
x[i] += scostX;
a[i] += scostY;
}
calcolaCoeff();
}
/**
* Description of the Method
*
*@param Prot Description of Parameter
*@param alfa Description of Parameter
*/
public void ruota(Punto Prot, double alfa) {
Punto p;
for (int i = 0; i < N; i++) {
p = new Punto(x[i], a[i]);
p.ruota(Prot, alfa);
x[i] = p.x;
a[i] = p.y;
}
calcolaCoeff();
}
//disegna
/**
* Description of the Method
*
*@param c Description of Parameter
*@param ScalaX Description of Parameter
*@param ScalaY Description of Parameter
*@param altezzaRiquadro Description of Parameter
*@param g Description of Parameter
*/
public void disegna(Color c,
double ScalaX,
//fattori per cui moltiplicare
double ScalaY,
//i valori da disegnare
int altezzaRiquadro,
Graphics g) {
int schX0;
int schY0;
int schX1;
int schY1;
int parti = 20;
double passo;
double xcorrente;
g.setColor(c);
for (int i = 0; i < N - 1; i++) {
schX0 = (int) (x[i] * ScalaX);
schY0 = (int) (a[i] * ScalaY);
schX1 = (int) (x[i + 1] * ScalaX);
schY1 = (int) (a[i + 1] * ScalaY);
g.drawLine(schX0, altezzaRiquadro - schY0, schX1, altezzaRiquadro - schY1);
xcorrente = x[i];
passo = (x[i + 1] - x[i]) / parti;
for (int j = 0; j < parti; j++) {
schX0 = (int) (xcorrente * ScalaX);
schY0 = (int) ((yval(xcorrente)) * ScalaY);
xcorrente += passo;
schX1 = (int) (xcorrente * ScalaX);
schY1 = (int) ((yval(xcorrente)) * ScalaY);
g.drawLine(schX0, altezzaRiquadro - schY0, schX1, altezzaRiquadro - schY1);
}
}
}
/**
* Description of the Method
*/
protected void calcolaCoeff() {
int i;
for (i = 0; i < N - 1; i++) {
h[i] = x[i + 1] - x[i];
}
for (i = 1; i < N - 1; i++) {
alpha[i] = 3.0 * (a[i + 1] * h[i - 1] - a[i] * (x[i + 1] - x[i - 1]) +
a[i - 1] * h[i]) / (h[i - 1] * h[i]);
}
l[0] = 1.0;
mu[0] = z[0] = 0.0;
for (i = 1; i < N - 1; i++) {
l[i] = 2.0 * (x[i + 1] - x[i - 1]) - h[i - 1] * mu[i - 1];
mu[i] = h[i] / l[i];
z[i] = (alpha[i] - h[i - 1] * z[i - 1]) / l[i];
}
l[N - 1] = 1.0;
z[N - 1] = c[N - 1] = 0.0;
for (i = N - 2; i >= 0; i--) {
c[i] = z[i] - mu[i] * c[i + 1];
b[i] = (a[i + 1] - a[i]) / h[i] - h[i] * (c[i + 1] + 2.0 * c[i]) / 3.0;
d[i] = (c[i + 1] - c[i]) / (3.0 * h[i]);
}
}
}
--- NEW FILE: SplineVert.java ---
/*****************************************************************************
* Copyright (C) The Krysalis project. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Krysalis Software *
* License version 1.1_01, a copy of which has been included with this *
* distribution in the LICENSE file. *
*****************************************************************************/
package org.krysalis.swingx.geo;
import java.awt.Color;
import java.awt.Graphics;
/**
* Description of the Class
*
*@author Luca Jun Barozzi
*@created 16 settembre 2001
*/
public class SplineVert extends Spline
implements High, Cloneable {
/**
* Constructor for the SplineVert object
*
*@param NN Description of Parameter
*@param xx Description of Parameter
*@param yy Description of Parameter
*/
public SplineVert(int NN, double xx[], double yy[]) {
super(NN, yy, xx);
double[] xt = new double[N];
for (int i = 0, f = N - 1; i < N; i++, f--) {
xt[f] = -(x[i]);
}
for (int i = 0; i < N; i++) {
x[i] = xt[i];
}
/*
* for (int i=0; i<N ; i++)
* {
* x[i] = -x[i];
* }
*/
calcolaCoeff();
}
/**
* Description of the Method
*
*@return Description of the Returned Value
*/
public Object clone() {
Object o = null;
try {
o = super.clone();
} catch (Exception e) {
System.out.println("Error In Cloning SplineVert");
}
return o;
}
/**
* Description of the Method
*
*@param y Description of Parameter
*@return Description of the Returned Value
*/
public boolean ycompreso(double y) {
return xcompreso(-y);
}
/**
* Description of the Method
*
*@param yvalt Description of Parameter
*@return Description of the Returned Value
*/
public double xval(double yvalt) {
return yval(-yvalt);
}
/*
* / mi dice se il valore x e' compreso negli estremi della spline
* public boolean xcompreso( double xt )
* {
* if( ((xt>x[0]) && (xt<x[N])) || ((xt<x[0]) && (xt>x[N])) )
* {return true; }
* else
* {return false; }
* }
*/
/**
*@param Porig Description of Parameter
*@param Pdest Description of Parameter
*/
/**
* metodi minimi ********
*
*@param Porig Description of Parameter
*@param Pdest Description of Parameter
*/
/**
* metodi minimi ********
*
*@param Porig Description of Parameter
*@param Pdest Description of Parameter
*/
public void sposta(Punto Porig, Punto Pdest) {
Porig.inverti();
Pdest.inverti();
super.sposta(Porig, Pdest);
}
/**
* Description of the Method
*
*@param Prot Description of Parameter
*@param alfa Description of Parameter
*/
public void ruota(Punto Prot, double alfa) {
Prot.inverti();
super.ruota(Prot, alfa);
}
//disegna
/**
* Description of the Method
*
*@param c Description of Parameter
*@param ScalaX Description of Parameter
*@param ScalaY Description of Parameter
*@param altezzaRiquadro Description of Parameter
*@param g Description of Parameter
*/
public void disegna(Color c,
double ScalaX,
//fattori per cui moltiplicare
double ScalaY,
//i valori da disegnare
int altezzaRiquadro,
Graphics g) {
int schX0;
int schY0;
int schX1;
int schY1;
int parti = 20;
double passo;
double xcorrente;
g.setColor(c);
for (int i = 0; i < N - 1; i++) {
schY0 = -(int) (x[i] * ScalaX);
schX0 = (int) (a[i] * ScalaY);
schY1 = -(int) (x[i + 1] * ScalaX);
schX1 = (int) (a[i + 1] * ScalaY);
g.drawLine(schX0, altezzaRiquadro - schY0, schX1, altezzaRiquadro - schY1);
xcorrente = x[i];
passo = (x[i + 1] - x[i]) / parti;
for (int j = 0; j < parti - 1; j++) {
schY0 = -(int) (xcorrente * ScalaX);
schX0 = (int) ((yval(xcorrente)) * ScalaY);
xcorrente += passo;
schY1 = -(int) (xcorrente * ScalaX);
schX1 = (int) ((yval(xcorrente)) * ScalaY);
g.drawLine(schX0, altezzaRiquadro - schY0, schX1, altezzaRiquadro - schY1);
}
schY0 = -(int) (xcorrente * ScalaX);
schX0 = (int) ((yval(xcorrente)) * ScalaY);
xcorrente += passo;
schY1 = -(int) (x[i + 1] * ScalaX);
schX1 = (int) ((yval(x[i + 1])) * ScalaY);
g.drawLine(schX0, altezzaRiquadro - schY0, schX1, altezzaRiquadro - schY1);
}
}
/**
* Description of the Method
*
*@param NNN Description of Parameter
*@param val Description of Parameter
*@return Description of the Returned Value
*/
private double[] inverti(int NNN, double val[]) {
for (int i = 0; i < NNN; i++) {
val[i] = -(val[i]);
}
return val;
}
}
/*
* public void disegna(Color c,
* double ScalaX, //fattori per cui moltiplicare
* double ScalaY, //i valori da disegnare
* int altezzaRiquadro,
* Graphics g) {
* int schX0,schY0,schX1,schY1,parti=20;
* double passo,xcorrente;
* g.setColor(c);
* for(int i=0;i<N-1;i++)
* {
* /questa parte unisce i punti con linee
* schX0=(int)((a[i])*ScalaX);
* schY0=(int)(-(x[i])*ScalaY);
* schX1=(int)((a[i+1])*ScalaX);
* schY1=(int)(-(x[i+1])*ScalaY);
* g.drawLine(schX0,altezzaRiquadro-schY0,schX1,altezzaRiquadro-schY1);
* / ************************************
* xcorrente=x[i];
* passo=(x[i+1]-x[i])/parti;
* for(int j=0;j<parti;j++)
* {
* schX0=(int)((yval(xcorrente))*ScalaX);
* schY0=(int)(-xcorrente*ScalaY);
* xcorrente += passo;
* schX1=(int)((yval(xcorrente))*ScalaX);
* schY1=(int)(-xcorrente*ScalaY);
* g.drawLine(schX0,altezzaRiquadro-schY0,schX1,altezzaRiquadro-schY1);
* }
* }
* }
* }
*/
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.