mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
New improvements
This commit is contained in:
parent
477950eb49
commit
b2da0777ed
@ -10,6 +10,8 @@ import java.awt.RenderingHints;
|
|||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
|
||||||
public class Battery extends JPanel {
|
public class Battery extends JPanel {
|
||||||
|
|
||||||
@ -24,11 +26,11 @@ public class Battery extends JPanel {
|
|||||||
public static final Color HIGH_HIGHLIGHTED = new Color(158, 227, 158);
|
public static final Color HIGH_HIGHLIGHTED = new Color(158, 227, 158);
|
||||||
public static final Color HIGHEST_HIGHLIGHTED = Color.green;
|
public static final Color HIGHEST_HIGHLIGHTED = Color.green;
|
||||||
private int height_ = 0;
|
private int height_ = 0;
|
||||||
private int square;
|
|
||||||
private double donePercent = 0;
|
private double donePercent = 0;
|
||||||
|
|
||||||
private boolean highlight = false;
|
private boolean highlight = false;
|
||||||
private int width_;
|
private int width_;
|
||||||
|
NumberFormat formatter3 = new DecimalFormat("#0.000");
|
||||||
|
|
||||||
public void setHighlight(boolean highlight) {
|
public void setHighlight(boolean highlight) {
|
||||||
this.highlight = highlight;
|
this.highlight = highlight;
|
||||||
@ -92,8 +94,7 @@ public class Battery extends JPanel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintComponent(Graphics g) {
|
public void paintComponent(Graphics g) {
|
||||||
if(Math.random() > 0.9)
|
highlight = Utils.highlightTxt.exists();
|
||||||
{highlight = Utils.highlightTxt.exists();}
|
|
||||||
if (height_ == 0) {
|
if (height_ == 0) {
|
||||||
this.height_ = Math.min(getWidth(), getHeight());
|
this.height_ = Math.min(getWidth(), getHeight());
|
||||||
this.width_= (int)(this.height_* 0.6);
|
this.width_= (int)(this.height_* 0.6);
|
||||||
@ -113,8 +114,9 @@ public class Battery extends JPanel {
|
|||||||
MEDIUM : (donePercent < 0.9 ? HIGH : HIGHEST)));
|
MEDIUM : (donePercent < 0.9 ? HIGH : HIGHEST)));
|
||||||
}
|
}
|
||||||
g2d.fillRect(width_/4,height_ - (int)(height_ * donePercent),width_, (int)(height_ * donePercent));
|
g2d.fillRect(width_/4,height_ - (int)(height_ * donePercent),width_, (int)(height_ * donePercent));
|
||||||
g2d.setColor(Color.LIGHT_GRAY);
|
g2d.setColor(highlight ? Color.BLACK : Color.LIGHT_GRAY);
|
||||||
g2d.drawString(String.valueOf((int)(donePercent * 100)) + "%",width_/2, height_/2);
|
g2d.drawString(
|
||||||
|
formatter3.format(donePercent * 100) + "%",((int)(width_ * 0.4)), height_ / 2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,12 +84,13 @@ public class ProgressCircle extends JPanel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintComponent(Graphics g) {
|
public void paintComponent(Graphics g) {
|
||||||
|
highlight = Utils.highlightTxt.exists();
|
||||||
if (side == 0) {
|
if (side == 0) {
|
||||||
this.side = Math.min(getWidth(), getHeight());
|
this.side = Math.min(getWidth(), getHeight());
|
||||||
}
|
}
|
||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
Graphics2D g2d = (Graphics2D) g;
|
Graphics2D g2d = (Graphics2D) g;
|
||||||
g2d.setColor(FOREGROUND_COLOR);
|
g2d.setColor(highlight ? Color.darkGray : FOREGROUND_COLOR);
|
||||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
// if (highlight) {
|
// if (highlight) {
|
||||||
@ -105,7 +106,7 @@ public class ProgressCircle extends JPanel {
|
|||||||
|
|
||||||
g2d.fillArc(0,0,side,side,90, -(int) angleDouble);
|
g2d.fillArc(0,0,side,side,90, -(int) angleDouble);
|
||||||
int side2 = ((int)(side/2));
|
int side2 = ((int)(side/2));
|
||||||
g2d.setColor(FOREGROUND_COLOR2);
|
g2d.setColor(highlight ? new Color(105, 175, 236) : FOREGROUND_COLOR2);
|
||||||
g2d.fillArc(0+(side2/2),0+(side2/2),side2, side2,90, -(int) angleDouble2);
|
g2d.fillArc(0+(side2/2),0+(side2/2),side2, side2,90, -(int) angleDouble2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user