44import com .cleanroommc .modularui .drawable .GuiDraw ;
55import com .cleanroommc .modularui .drawable .text .TextRenderer ;
66import com .cleanroommc .modularui .utils .Alignment ;
7- import com .cleanroommc .modularui .utils .FloatArrayMath ;
7+ import com .cleanroommc .modularui .utils .DAM ;
88
99import net .minecraft .client .renderer .BufferBuilder ;
1010
@@ -24,14 +24,14 @@ public class GraphAxis {
2424
2525 public final GuiAxis axis ;
2626
27- public float [] majorTicks = new float [8 ];
28- public float [] minorTicks = new float [16 ];
27+ public double [] majorTicks = new double [8 ];
28+ public double [] minorTicks = new double [16 ];
2929 public TextRenderer .Line [] tickLabels = new TextRenderer .Line [8 ];
3030 private float maxLabelWidth = 0 ;
3131 public MajorTickFinder majorTickFinder = new AutoMajorTickFinder (true );
3232 public MinorTickFinder minorTickFinder = new AutoMinorTickFinder (2 );
3333 public String label ;
34- public float min , max ;
34+ public double min , max ;
3535 public boolean autoLimits = true ;
3636
3737 public GraphAxis (GuiAxis axis ) {
@@ -44,21 +44,21 @@ void compute(List<Plot> plots) {
4444 this .min = 0 ;
4545 this .max = 0 ;
4646 } else if (plots .size () == 1 ) {
47- this .min = FloatArrayMath .min (plots .get (0 ).getData (this .axis ));
48- this .max = FloatArrayMath .max (plots .get (0 ).getData (this .axis ));
47+ this .min = DAM .min (plots .get (0 ).getData (this .axis ));
48+ this .max = DAM .max (plots .get (0 ).getData (this .axis ));
4949 } else {
50- float min = Float .MAX_VALUE , max = Float .MIN_VALUE ;
50+ double min = Double .MAX_VALUE , max = Double .MIN_VALUE ;
5151 for (Plot plot : plots ) {
52- float m = FloatArrayMath .min (plot .getData (this .axis ));
52+ double m = DAM .min (plot .getData (this .axis ));
5353 if (m < min ) min = m ;
54- m = FloatArrayMath .max (plot .getData (this .axis ));
54+ m = DAM .max (plot .getData (this .axis ));
5555 if (m > max ) max = m ;
5656 }
5757 this .min = min ;
5858 this .max = max ;
5959 }
6060 if (this .axis .isVertical ()) {
61- float padding = (this .max - this .min ) * 0.05f ;
61+ double padding = (this .max - this .min ) * 0.05f ;
6262 this .max += padding ;
6363 this .min -= padding ;
6464 }
@@ -74,12 +74,12 @@ void compute(List<Plot> plots) {
7474 }
7575 textRenderer .setScale (TICK_LABEL_SCALE );
7676 this .maxLabelWidth = 0 ;
77- float maxDiff = FloatArrayMath .max (FloatArrayMath .diff (this .majorTicks ));
77+ double maxDiff = DAM .max (DAM .diff (this .majorTicks ));
7878 int significantPlaces = (int ) Math .abs (Math .log10 (maxDiff )) + 2 ;
7979 DecimalFormat format = new DecimalFormat ();
8080 format .setMaximumFractionDigits (significantPlaces );
8181 for (int i = 0 ; i < this .tickLabels .length ; i ++) {
82- if (Float .isNaN (this .majorTicks [i ])) break ;
82+ if (Double .isNaN (this .majorTicks [i ])) break ;
8383 this .tickLabels [i ] = textRenderer .line (format .format (this .majorTicks [i ]));
8484 if (this .tickLabels [i ].getWidth () > this .maxLabelWidth ) {
8585 this .maxLabelWidth = this .tickLabels [i ].getWidth ();
@@ -106,7 +106,7 @@ void applyPadding(GraphView graphView) {
106106 }
107107
108108 void drawGridLines (BufferBuilder buffer , GraphView view , GraphAxis other , boolean major , float d , int r , int g , int b , int a ) {
109- float [] pos = major ? this .majorTicks : this .minorTicks ;
109+ double [] pos = major ? this .majorTicks : this .minorTicks ;
110110 float dHalf = d / 2 ;
111111 if (axis .isHorizontal ()) {
112112 float otherMin = view .g2sY (other .max );
@@ -120,7 +120,7 @@ void drawGridLines(BufferBuilder buffer, GraphView view, GraphAxis other, boolea
120120 }
121121
122122 void drawTicks (BufferBuilder buffer , GraphView view , GraphAxis other , boolean major , float thickness , float length , int r , int g , int b , int a ) {
123- float [] pos = major ? this .majorTicks : this .minorTicks ;
123+ double [] pos = major ? this .majorTicks : this .minorTicks ;
124124 float dHalf = thickness / 2 ;
125125 if (axis .isHorizontal ()) {
126126 float otherMin = view .g2sY (other .min );
@@ -131,30 +131,30 @@ void drawTicks(BufferBuilder buffer, GraphView view, GraphAxis other, boolean ma
131131 }
132132 }
133133
134- private void drawLinesOnHorizontal (BufferBuilder buffer , GraphView view , float [] pos , float dHalf ,
134+ private void drawLinesOnHorizontal (BufferBuilder buffer , GraphView view , double [] pos , float dHalf ,
135135 float crossLow , float crossHigh , int r , int g , int b , int a ) {
136- for (float p : pos ) {
137- if (Float .isNaN (p )) break ;
136+ for (double p : pos ) {
137+ if (Double .isNaN (p )) break ;
138138 if (p < min || p > max ) continue ;
139139
140- p = view .g2sX (p );
140+ float fp = view .g2sX (p );
141141
142- float x0 = p - dHalf ;
143- float x1 = p + dHalf ;
142+ float x0 = fp - dHalf ;
143+ float x1 = fp + dHalf ;
144144 GuiDraw .drawRectRaw (buffer , x0 , crossLow , x1 , crossHigh , r , g , b , a );
145145 }
146146 }
147147
148- private void drawLinesOnVertical (BufferBuilder buffer , GraphView view , float [] pos , float dHalf ,
148+ private void drawLinesOnVertical (BufferBuilder buffer , GraphView view , double [] pos , float dHalf ,
149149 float crossLow , float crossHigh , int r , int g , int b , int a ) {
150- for (float p : pos ) {
151- if (Float .isNaN (p )) break ;
150+ for (double p : pos ) {
151+ if (Double .isNaN (p )) break ;
152152 if (p < min || p > max ) continue ;
153153
154- p = view .g2sY (p );
154+ float fp = view .g2sY (p );
155155
156- float y0 = p - dHalf ;
157- float y1 = p + dHalf ;
156+ float y0 = fp - dHalf ;
157+ float y1 = fp + dHalf ;
158158 GuiDraw .drawRectRaw (buffer , crossLow , y0 , crossHigh , y1 , r , g , b , a );
159159 }
160160 }
@@ -166,8 +166,8 @@ void drawLabels(GraphView view, GraphAxis other) {
166166 textRenderer .setAlignment (Alignment .TopCenter , 100 );
167167 float y = view .g2sY (other .min ) + TICK_LABEL_OFFSET ;
168168 for (int i = 0 ; i < this .majorTicks .length ; i ++) {
169- float pos = this .majorTicks [i ];
170- if (Float .isNaN (pos )) break ;
169+ double pos = this .majorTicks [i ];
170+ if (Double .isNaN (pos )) break ;
171171 if (pos < min || pos > max ) continue ;
172172 textRenderer .setPos ((int ) (view .g2sX (pos ) - 50 ), (int ) y );
173173 textRenderer .draw (this .tickLabels [i ].getText ());
@@ -177,8 +177,8 @@ void drawLabels(GraphView view, GraphAxis other) {
177177 textRenderer .setAlignment (Alignment .CenterRight , this .maxLabelWidth , 20 );
178178 float x = view .g2sX (other .min ) - TICK_LABEL_OFFSET - this .maxLabelWidth ;
179179 for (int i = 0 ; i < this .majorTicks .length ; i ++) {
180- float pos = this .majorTicks [i ];
181- if (Float .isNaN (pos )) break ;
180+ double pos = this .majorTicks [i ];
181+ if (Double .isNaN (pos )) break ;
182182 if (pos < min || pos > max ) continue ;
183183 textRenderer .setPos ((int ) x , (int ) (view .g2sY (pos ) - 10 ));
184184 textRenderer .draw (this .tickLabels [i ].getText ());
@@ -190,11 +190,11 @@ public GuiAxis getAxis() {
190190 return axis ;
191191 }
192192
193- public float getMax () {
193+ public double getMax () {
194194 return max ;
195195 }
196196
197- public float getMin () {
197+ public double getMin () {
198198 return min ;
199199 }
200200
0 commit comments