JavaDoc
This commit is contained in:
@@ -107,16 +107,54 @@ public class SVGFactory {
|
||||
|
||||
}
|
||||
|
||||
double step_x = (max_x - min_x); //TODO
|
||||
double step_y = (max_y - min_y); //TODO
|
||||
double range_x = max_x-min_x;
|
||||
double range_y = max_y-min_y;
|
||||
|
||||
int target = 10; // Ideal Number of Gradation
|
||||
|
||||
//TODO
|
||||
double step_x = niceStep(range_x,target);
|
||||
double step_y = niceStep(range_y,target);
|
||||
|
||||
double nicemin_x = roundMin(min_x,step_x);
|
||||
double nicemax_x = roundMax(max_x,step_x);
|
||||
double nicemin_y = roundMin(min_y,step_y);
|
||||
double nicemax_y = roundMax(max_y,step_y);
|
||||
|
||||
HashSet<ValeursXY> axe_x = new HashSet<>();
|
||||
HashSet<ValeursXY> axe_y = new HashSet<>();
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction de calcul d'un step rond
|
||||
* Cette fonction est basé sur une idée demandée à ChatGPT
|
||||
* @param range écart entre la plus petite et la plus grande valeur
|
||||
* @param targetTicks nombre de gradation ideal
|
||||
* @return
|
||||
*/
|
||||
public static double niceStep(double range, int targetTicks) {
|
||||
|
||||
double rawStep = range / targetTicks;
|
||||
|
||||
double exponent = Math.floor(Math.log10(rawStep));
|
||||
double fraction = rawStep / Math.pow(10, exponent);
|
||||
|
||||
double niceFraction;
|
||||
|
||||
if (fraction < 1.5)
|
||||
niceFraction = 1;
|
||||
else if (fraction < 3)
|
||||
niceFraction = 2;
|
||||
else if (fraction < 7)
|
||||
niceFraction = 5;
|
||||
else
|
||||
niceFraction = 10;
|
||||
|
||||
return niceFraction * Math.pow(10, exponent);
|
||||
}
|
||||
|
||||
/**
|
||||
* retourne une valeur arrondi "joli" adapter à un graphique
|
||||
* @param value
|
||||
|
||||
Reference in New Issue
Block a user