New improvements
This commit is contained in:
parent
372f73f71a
commit
8823b7d856
1
.gitignore
vendored
1
.gitignore
vendored
@ -12,3 +12,4 @@ highlighted
|
||||
proxy.txt
|
||||
out.txt
|
||||
pocasi.txt
|
||||
test.txt
|
||||
|
@ -29,6 +29,7 @@ public class AnalogClock extends JPanel {
|
||||
private static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
|
||||
|
||||
private boolean coloured = false;
|
||||
private boolean mouseOver = false;
|
||||
private int side;
|
||||
|
||||
public AnalogClock() {
|
||||
@ -55,11 +56,13 @@ public class AnalogClock extends JPanel {
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
coloured = true;
|
||||
mouseOver = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
coloured = false;
|
||||
mouseOver = false;
|
||||
}
|
||||
});
|
||||
|
||||
@ -89,15 +92,25 @@ public class AnalogClock extends JPanel {
|
||||
int minute = time.get(Calendar.MINUTE);
|
||||
int hour = time.get(Calendar.HOUR_OF_DAY);
|
||||
|
||||
drawHand(g2d, side / 2 - 10, second / 60.0, 0.5f, Color.RED);
|
||||
drawHand(g2d, side / 2 - 20, minute / 60.0 + second / 60.0 / 60.0, 2.0f,
|
||||
Color.BLUE);
|
||||
drawHand(g2d, side / 2 - 40,
|
||||
hour / 12.0 + minute / 60.0 / 12 + second / 60 / 60 / 12, 4.0f,
|
||||
Color.BLACK);
|
||||
|
||||
// Draw clock numbers and circle
|
||||
drawClockFace(g2d, centerX, centerY, side / 2 - 40);
|
||||
|
||||
drawHand(g2d, side / 2 - 10, second / 60.0, 0.5f, Color.RED);
|
||||
drawHand(g2d, (side / 2 - 10) / 4, (second > 30 ? second - 30 : second + 30) / 60.0, 0.5f, Color.RED);
|
||||
//
|
||||
double minutes = minute / 60.0 + second / 60.0 / 60.0;
|
||||
drawHand(g2d, side / 2 - 20, minutes, 2.0f,
|
||||
Color.BLUE);
|
||||
drawHand(g2d, (side / 2 - 20)/4, minutes + minutes > 0.5 ?minutes - 0.5 : minutes + (minutes > 0.5 ? (-1) : 1) * 0.5, 2.0f,
|
||||
Color.BLUE);
|
||||
//
|
||||
double hours = hour / 12.0 + minute / 60.0 / 12 + second / 60 / 60 / 12;
|
||||
drawHand(g2d, side / 2 - 40,
|
||||
hours, 4.0f,
|
||||
Color.BLACK);
|
||||
drawHand(g2d, (side / 2 - 40)/4, hours + hours > 0.5 ?hours - 0.5 : hours + (hours > 0.5 ? (-1) : 1) * 0.5, 4.0f,
|
||||
Color.BLACK);
|
||||
|
||||
}
|
||||
|
||||
private void drawHand(Graphics2D g2d, int length, double value,
|
||||
@ -107,7 +120,7 @@ public class AnalogClock extends JPanel {
|
||||
int endX = (int) (getWidth() / 2 + length * Math.cos(angle));
|
||||
int endY = (int) (getHeight() / 2 + length * Math.sin(angle));
|
||||
|
||||
g2d.setColor(Utils.highlighted.get() ? color : FOREGROUND_COLOR);
|
||||
g2d.setColor((Utils.highlighted.get() || mouseOver) ? color : FOREGROUND_COLOR);
|
||||
g2d.setStroke(new BasicStroke(stroke));
|
||||
g2d.drawLine(getWidth() / 2, getHeight() / 2, endX, endY);
|
||||
}
|
||||
@ -141,7 +154,7 @@ public class AnalogClock extends JPanel {
|
||||
private void drawClockFace(Graphics2D g2d, int centerX, int centerY,
|
||||
int radius) {
|
||||
g2d.setStroke(new BasicStroke(2.0f));
|
||||
g2d.setColor(Utils.highlighted.get() ? Color.BLACK : FOREGROUND_COLOR);
|
||||
g2d.setColor(Utils.highlighted.get() || mouseOver ? Color.BLACK : FOREGROUND_COLOR);
|
||||
// System.out.println("centerX=" + centerX);
|
||||
// System.out.println("centerY=" + centerY);
|
||||
// System.out.println("radius=" + radius);
|
||||
@ -159,32 +172,37 @@ public class AnalogClock extends JPanel {
|
||||
//}
|
||||
}
|
||||
}
|
||||
if(Math.random() > (1 - (1/200))) {
|
||||
for(int i = 0; i<12; i++) {
|
||||
colors[i] = i == 11 ? colors[0] :colors[i + 1];
|
||||
}
|
||||
// if(Math.random() > (1 - (1/200))) {
|
||||
// for(int i = 0; i<12; i++) {
|
||||
// colors[i] = i == 11 ? colors[0] :colors[i + 1];
|
||||
// }
|
||||
// }
|
||||
DateFormat formatter2 = new SimpleDateFormat("HH:mm:ss", Locale.ENGLISH);
|
||||
String now = formatter2.format(new Date());
|
||||
|
||||
if (coloured) {
|
||||
g2d.setColor(Utils.highlighted.get() || mouseOver ? Color.BLACK : FOREGROUND_COLOR);
|
||||
g2d.setFont(new Font("sans", Font.PLAIN, 12));
|
||||
DateFormat formatter = new SimpleDateFormat("EEEE : yyyy-MM-dd", Locale.ENGLISH);
|
||||
g2d.drawString(formatter.format(new Date()), ((int) (side * 0.25)),
|
||||
((int) (side * 0.35)));
|
||||
//
|
||||
g2d.drawString(now, ((int) (side * 0.25) + 30),
|
||||
((int) (side * 0.35)) + 60);
|
||||
}
|
||||
for (int i = 1; i <= 12; i++) {
|
||||
double angle = Math.PI * 2 * (i / 12.0 - 0.25);
|
||||
int dx = centerX + (int) ((radius + 20) * Math.cos(angle)) - 4;
|
||||
int dy = centerY + (int) ((radius + 20) * Math.sin(angle)) + 4;
|
||||
|
||||
if(Utils.highlighted.get() && coloured) {g2d.setColor(colors[i - 1]);};
|
||||
int seconds = Integer.valueOf(now.split(":")[2]);
|
||||
|
||||
//if(Utils.highlighted.get() && coloured && (seconds <= 5 || seconds >= 55)) {g2d.setColor(colors[i - 1]);}
|
||||
g2d.setFont(new Font("sans", Font.BOLD, 16));
|
||||
g2d.drawString(Integer.toString(i), dx, dy);
|
||||
}
|
||||
if (coloured) {
|
||||
g2d.setColor(Utils.highlighted.get() ? Color.BLACK : FOREGROUND_COLOR);
|
||||
g2d.setFont(new Font("sans", Font.BOLD, 12));
|
||||
DateFormat formatter = new SimpleDateFormat("EEEE : yyyy-MM-dd", Locale.ENGLISH);
|
||||
g2d.drawString(formatter.format(new Date()), ((int) (side * 0.25)),
|
||||
((int) (side * 0.35)));
|
||||
//
|
||||
DateFormat formatter2 = new SimpleDateFormat("HH:mm:ss", Locale.ENGLISH);
|
||||
|
||||
g2d.drawString(formatter2.format(new Date()), ((int) (side * 0.25) + 30),
|
||||
((int) (side * 0.35)) + 60);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,6 +27,7 @@ public class Battery extends JPanel {
|
||||
public static final Color HIGHEST_HIGHLIGHTED = Color.green;
|
||||
private int height_ = 0;
|
||||
private double donePercent = 0;
|
||||
private boolean mouseOver = false;
|
||||
|
||||
private int width_;
|
||||
NumberFormat formatter3 = new DecimalFormat("#0.000");
|
||||
@ -53,12 +54,12 @@ public class Battery extends JPanel {
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
|
||||
mouseOver = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
|
||||
mouseOver = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -75,14 +76,14 @@ public class Battery extends JPanel {
|
||||
}
|
||||
super.paintComponent(g);
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.setColor(Utils.highlighted.get() ? Color.YELLOW : FOREGROUND_COLOR);
|
||||
g2d.setColor(Utils.highlighted.get() || mouseOver ? Color.YELLOW : FOREGROUND_COLOR);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
g2d.fillRect(width_/4,1,width_, height_ - 2);
|
||||
g2d.setColor(Utils.highlighted.get() ? Color.BLACK : Color.LIGHT_GRAY);
|
||||
g2d.setColor(Utils.highlighted.get() || mouseOver ? Color.BLACK : Color.LIGHT_GRAY);
|
||||
g2d.drawRect(width_/4 - 1,0,width_+1, height_ + 0);
|
||||
if(Utils.highlighted.get()) {
|
||||
if(Utils.highlighted.get() || mouseOver) {
|
||||
g2d.setColor(donePercent < 0.1 ? LOW_HIGHLIGHTED : (donePercent < 0.75 ?
|
||||
MEDIUM_HIGHLIGHTED : (donePercent < 0.9 ? HIGH_HIGHLIGHTED : HIGHEST_HIGHLIGHTED)));
|
||||
} else {
|
||||
@ -90,7 +91,7 @@ public class Battery extends JPanel {
|
||||
MEDIUM : (donePercent < 0.9 ? HIGH : HIGHEST)));
|
||||
}
|
||||
g2d.fillRect(width_/4,height_ - (int)(height_ * donePercent),width_, (int)(height_ * donePercent));
|
||||
g2d.setColor(Utils.highlighted.get() ? Color.BLACK : Color.LIGHT_GRAY);
|
||||
g2d.setColor(Utils.highlighted.get() || mouseOver ? Color.BLACK : Color.LIGHT_GRAY);
|
||||
g2d.drawString(
|
||||
formatter3.format(donePercent * 100) + "%",((int)(width_ * 0.4)), height_ / 2);
|
||||
|
||||
|
@ -12,7 +12,7 @@ public class Main {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
while (true) {
|
||||
boolean test = false;
|
||||
boolean test = new File("test.txt").exists();
|
||||
File starttimeTxt = new File("starttime.txt");
|
||||
File overtimeTxt = new File("overtime.txt");
|
||||
String lastStartTime = Utils.readTextFromFile(starttimeTxt);
|
||||
|
@ -19,6 +19,7 @@ public class ProgressCircle extends JPanel {
|
||||
private static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
|
||||
private int side = 0;
|
||||
private double donePercent = 0;
|
||||
private boolean mouseOver = false;
|
||||
|
||||
public ProgressCircle() {
|
||||
setPreferredSize(new Dimension(200, 200));
|
||||
@ -42,12 +43,12 @@ public class ProgressCircle extends JPanel {
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
|
||||
mouseOver = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
|
||||
mouseOver = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -63,7 +64,7 @@ public class ProgressCircle extends JPanel {
|
||||
}
|
||||
super.paintComponent(g);
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.setColor(Utils.highlighted.get() ? Color.darkGray : FOREGROUND_COLOR);
|
||||
g2d.setColor(Utils.highlighted.get() || mouseOver ? Color.darkGray : FOREGROUND_COLOR);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
// if (highlight) {
|
||||
@ -79,7 +80,7 @@ public class ProgressCircle extends JPanel {
|
||||
|
||||
g2d.fillArc(0,0,side,side,90, -(int) angleDouble);
|
||||
int side2 = ((int)(side/2));
|
||||
g2d.setColor(Utils.highlighted.get() ? new Color(105, 175, 236) : FOREGROUND_COLOR2);
|
||||
g2d.setColor(Utils.highlighted.get() || mouseOver ? new Color(105, 175, 236) : FOREGROUND_COLOR2);
|
||||
g2d.fillArc(0+(side2/2),0+(side2/2),side2, side2,90, -(int) angleDouble2);
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ public class ProgressSquare extends JPanel {
|
||||
private int side = 0;
|
||||
private int square;
|
||||
private double donePercent = 0;
|
||||
private boolean mouseOver = false;
|
||||
|
||||
public ProgressSquare() {
|
||||
setPreferredSize(new Dimension(400, 400));
|
||||
@ -41,12 +42,12 @@ public class ProgressSquare extends JPanel {
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
|
||||
mouseOver = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
|
||||
mouseOver = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -77,26 +78,26 @@ public class ProgressSquare extends JPanel {
|
||||
// System.out.println("x=" + x);
|
||||
// System.out.println("y=" + y);
|
||||
if (y > 1) {
|
||||
if(Utils.highlighted.get()) g2d.setColor(Color.GRAY);
|
||||
if(Utils.highlighted.get() || mouseOver) g2d.setColor(Color.GRAY);
|
||||
g2d.fillRect(side - 4, side - 4, 4, 4);
|
||||
g2d.fillRect(1, side - 4, 4, 4);
|
||||
|
||||
g2d.setColor(FOREGROUND_COLOR);
|
||||
g2d.fillRect(1, 1, side, y - 1);
|
||||
if (x > 1) {
|
||||
if(Utils.highlighted.get()) g2d.setColor(Color.GRAY);
|
||||
if(Utils.highlighted.get() || mouseOver) g2d.setColor(Color.GRAY);
|
||||
g2d.drawRect(1, y, x - 1, 1);
|
||||
}
|
||||
if(Utils.highlighted.get()) g2d.setColor(Color.GRAY);
|
||||
if(Utils.highlighted.get() || mouseOver) g2d.setColor(Color.GRAY);
|
||||
g2d.fillRect(side - 4, 1, 4, 4);
|
||||
g2d.fillRect(1, 1, 4, 4);
|
||||
|
||||
if(Utils.highlighted.get()) g2d.setColor(Color.GRAY);
|
||||
if(Utils.highlighted.get() || mouseOver) g2d.setColor(Color.GRAY);
|
||||
g2d.drawLine(1, 1, x, y);
|
||||
// g2d.drawLine(1+1, 1+1, x+1, y+1);
|
||||
g2d.drawLine(1, 1 + 1, x, y + 1);
|
||||
g2d.drawLine(1, 1 + 1, x, y + 1);
|
||||
if(Utils.highlighted.get()) {
|
||||
if(Utils.highlighted.get() || mouseOver) {
|
||||
g2d.setColor(Color.BLUE);
|
||||
g2d.drawLine(x - 10, y - 10, x + 10, y + 10);
|
||||
g2d.drawLine(x + 10, y - 10, x - 10, y + 10);
|
||||
|
Loading…
x
Reference in New Issue
Block a user