Fixed antialiasing rendering II

This commit is contained in:
Robert Vokac 2024-03-27 17:41:25 +01:00
parent 68970bf04e
commit cd00cae782
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055

View File

@ -93,14 +93,14 @@ public class ProgressFuelGauge extends Widget implements GetProperty {
int endY = (int) (startY + length * Math.sin(angle));
((Graphics2D)brush).setStroke(new BasicStroke(3f));
brush.drawLine(startX, startY, endX, endY);
//
length = (int) (ovalWidth / 2d * 0.9d);
angle = Math.PI * 2 * (donePercent() * 0.25d + 2.5d * 0.25d + 0.5d);
endX = (int) (startX + length * Math.cos(angle));
endY = (int) (startY + length * Math.sin(angle));
int endX2 = (int) (startX + length * Math.cos(angle));
int endY2 = (int) (startY + length * Math.sin(angle));
brush.drawLine(startX, startY, endX, endY);
brush.drawLine(startX, startY, endX2, endY2);
//
((Graphics2D)brush).setStroke(new BasicStroke(1f));
int length_ = (int) (ovalWidth * 1.5d);
@ -113,17 +113,9 @@ public class ProgressFuelGauge extends Widget implements GetProperty {
// tBrush.drawOval(startX, startY + 8, length_ * 2, length_ * 2);
tBrush.drawArc(startX, startY - 1 , length_ * 2, length_ * 2, -45, 90);
tBrush.drawArc(startX, startY + 5, length_ * 2, length_ * 2, -40, 80);
brush.setColor(visibility.isStronglyColored() ? Color.BLACK
: visibility.isWeaklyColored() ? Color.GRAY
: Color.LIGHT_GRAY);
int width_ = (int) (ovalWidth / 4d);
brush.fillOval(
(int) (startX - width_ / 2d),
(int) (startY - width_ / 2d),
width_,
width_
);
brush.setColor(Color.WHITE);
Function<Double, Integer> getAngle = (d -> (int)(-45 + 90 * d));
brush.setColor(visibility.isStronglyColored() ? Color.RED : (visibility.isWeaklyColored() ?
@ -137,7 +129,21 @@ public class ProgressFuelGauge extends Widget implements GetProperty {
tBrush.drawBorder(startX, startY, 5, length_ - 4, getAngle.apply(0.25d), 2f, brush.getColor());
tBrush.drawBorder(startX, startY, 6, length_ - 7, getAngle.apply(0.5d), 7f, brush.getColor());
tBrush.drawBorder(startX, startY, 5, length_ - 4, getAngle.apply(0.75d), 2f, brush.getColor());
tBrush.drawBorder(startX, startY, 6, length_ - 7, getAngle.apply(1d), 7f, brush.getColor());
tBrush.drawBorder(startX, startY, 6, length_ - 7, getAngle.apply(1.d - 0.02d), 7f, brush.getColor());
//
((Graphics2D)brush).setStroke(new BasicStroke(3f));
brush.drawLine(startX, startY, endX, endY);
//
brush.setColor(visibility.isStronglyColored() ? Color.BLACK
: visibility.isWeaklyColored() ? Color.GRAY
: Color.LIGHT_GRAY);
brush.fillOval(
(int) (startX - width_ / 2d),
(int) (startY - width_ / 2d),
width_,
width_
);
brush.setColor(Color.WHITE);
//tBrush.drawBorder(startX, startY, 10, length_ - 4 - 5, getAngle.apply(donePercent()), 3f, brush.getColor());
this.setToolTipText(NumberFormats.FORMATTER_TWO_DECIMAL_PLACES.format(donePercent() * 100d) + "%");