mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
Added color smileys III
This commit is contained in:
parent
a1766e7730
commit
3250003eb3
@ -2,15 +2,20 @@ package org.nanoboot.utils.timecalc.swing.common;
|
|||||||
|
|
||||||
import org.nanoboot.utils.timecalc.app.GetProperty;
|
import org.nanoboot.utils.timecalc.app.GetProperty;
|
||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
|
import org.nanoboot.utils.timecalc.swing.progress.ProgressSmileyIcon;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.common.ProgressSmiley;
|
||||||
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
||||||
import org.nanoboot.utils.timecalc.utils.property.Property;
|
import org.nanoboot.utils.timecalc.utils.property.Property;
|
||||||
import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
||||||
|
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.Timer;
|
import javax.swing.Timer;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
|
|
||||||
@ -33,6 +38,7 @@ public class Widget extends JPanel implements
|
|||||||
protected int side = 0;
|
protected int side = 0;
|
||||||
protected double donePercent = 0;
|
protected double donePercent = 0;
|
||||||
protected boolean mouseOver = false;
|
protected boolean mouseOver = false;
|
||||||
|
protected JLabel smileyIcon;
|
||||||
|
|
||||||
public Widget() {
|
public Widget() {
|
||||||
setBackground(BACKGROUND_COLOR);
|
setBackground(BACKGROUND_COLOR);
|
||||||
@ -109,4 +115,53 @@ public class Widget extends JPanel implements
|
|||||||
public Property getProperty() {
|
public Property getProperty() {
|
||||||
return visibilityProperty;
|
return visibilityProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void paintSmiley(Visibility visibility, Graphics2D brush, int x, int y) {
|
||||||
|
if(!mouseOver) {
|
||||||
|
if(this.smileyIcon != null) {
|
||||||
|
this.remove(smileyIcon);
|
||||||
|
}
|
||||||
|
|
||||||
|
//nothing more to do
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
boolean colored = smileysColoredProperty.isEnabled();
|
||||||
|
if(visibility.isGray()) {
|
||||||
|
colored = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!colored){
|
||||||
|
if(!visibility.isStronglyColored()) {
|
||||||
|
brush.setColor(Color.GRAY);
|
||||||
|
}
|
||||||
|
if(visibility.isGray()) {
|
||||||
|
brush.setColor(Color.LIGHT_GRAY);
|
||||||
|
}
|
||||||
|
if(visibility.isStronglyColored()) {
|
||||||
|
brush.setColor(Color.BLACK);
|
||||||
|
}
|
||||||
|
Color currentColor= brush.getColor();
|
||||||
|
brush.setColor(visibility.isStronglyColored() ? Color.WHITE : BACKGROUND_COLOR);
|
||||||
|
brush.fillRect(
|
||||||
|
x,y,
|
||||||
|
20,
|
||||||
|
20
|
||||||
|
);
|
||||||
|
brush.setColor(currentColor);
|
||||||
|
brush.setFont(MEDIUM_FONT);
|
||||||
|
brush.drawString(
|
||||||
|
ProgressSmiley.forProgress(donePercent).getCharacter(),
|
||||||
|
x,y + 16
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if(colored) {
|
||||||
|
ImageIcon imageIcon = ProgressSmileyIcon.forSmiley(ProgressSmiley.forProgress(donePercent)).getIcon();
|
||||||
|
if(this.smileyIcon != null) {
|
||||||
|
this.remove(smileyIcon);
|
||||||
|
}
|
||||||
|
this.smileyIcon = new JLabel(imageIcon);
|
||||||
|
smileyIcon.setBounds(x,y,15, 15);
|
||||||
|
this.add(smileyIcon);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,6 @@ public class Battery extends Widget {
|
|||||||
private int totalHeight = 0;
|
private int totalHeight = 0;
|
||||||
private int totalWidth;
|
private int totalWidth;
|
||||||
private String label = null;
|
private String label = null;
|
||||||
private JLabel smileyIcon;
|
|
||||||
|
|
||||||
protected Battery(String name) {
|
protected Battery(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -200,53 +199,15 @@ public class Battery extends Widget {
|
|||||||
brush.setFont(BIG_FONT);
|
brush.setFont(BIG_FONT);
|
||||||
brush.drawString(
|
brush.drawString(
|
||||||
CHARCHING, ((int) (totalWidth * 0.45)),
|
CHARCHING, ((int) (totalWidth * 0.45)),
|
||||||
(donePercent < 0.5 ? totalHeight / 4 * 3 : totalHeight / 4 * 1) + 10
|
(donePercent < 0.5 ? totalHeight / 4 * 3 :
|
||||||
|
totalHeight / 4 * 1) + 10
|
||||||
);
|
);
|
||||||
if(mouseOver && smileysColoredProperty.isDisabled()){//no colored
|
|
||||||
//paint smiley
|
|
||||||
if(!visibility.isStronglyColored()) {
|
|
||||||
brush.setColor(Color.GRAY);
|
|
||||||
}
|
|
||||||
if(visibility.isGray()) {
|
|
||||||
brush.setColor(Color.LIGHT_GRAY);
|
|
||||||
}
|
|
||||||
if(visibility.isStronglyColored()) {
|
|
||||||
brush.setColor(Color.BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
Color currentColor= brush.getColor();
|
paintSmiley(visibility, brush, ((int) (totalWidth * 0.45)) + 15,
|
||||||
brush.setColor(visibility.isStronglyColored() ? Color.WHITE : BACKGROUND_COLOR);
|
(donePercent < 0.5 ? totalHeight / 4 * 3 :
|
||||||
brush.fillRect(
|
totalHeight / 4 * 1) + 8 - 16);
|
||||||
((int) (totalWidth * 0.45)) + 15,
|
|
||||||
(donePercent < 0.5 ? totalHeight / 4 * 3 : totalHeight / 4 * 1) + 8 - 16,
|
|
||||||
20,
|
|
||||||
20
|
|
||||||
);
|
|
||||||
brush.setColor(currentColor);
|
|
||||||
brush.setColor(Color.BLACK);
|
|
||||||
brush.setFont(MEDIUM_FONT);
|
|
||||||
brush.drawString(
|
|
||||||
ProgressSmiley.forProgress(donePercent).getCharacter(),
|
|
||||||
((int) (totalWidth * 0.45)) + 15,
|
|
||||||
(donePercent < 0.5 ? totalHeight / 4 * 3 : totalHeight / 4 * 1) + 8
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
brush.setFont(currentFont);
|
brush.setFont(currentFont);
|
||||||
}
|
|
||||||
if(mouseOver && smileysColoredProperty.isEnabled()) {//colored
|
|
||||||
ImageIcon imageIcon = ProgressSmileyIcon.forSmiley(ProgressSmiley.forProgress(donePercent)).getIcon();
|
|
||||||
if(this.smileyIcon != null) {
|
|
||||||
this.remove(smileyIcon);
|
|
||||||
}
|
|
||||||
this.smileyIcon = new JLabel(imageIcon);
|
|
||||||
smileyIcon.setBounds(((int) (totalWidth * 0.45)) + 15,
|
|
||||||
(donePercent < 0.5 ? totalHeight / 4 * 3 : totalHeight / 4 * 1) - 7,15, 15);
|
|
||||||
this.add(smileyIcon);
|
|
||||||
} else {
|
|
||||||
if(this.smileyIcon != null) {
|
|
||||||
this.remove(smileyIcon);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Color currentColor = brush.getColor();
|
Color currentColor = brush.getColor();
|
||||||
|
@ -15,8 +15,6 @@ import java.awt.RenderingHints;
|
|||||||
|
|
||||||
public class ProgressCircle extends Widget {
|
public class ProgressCircle extends Widget {
|
||||||
|
|
||||||
private JLabel smileyIcon;
|
|
||||||
|
|
||||||
public ProgressCircle() {
|
public ProgressCircle() {
|
||||||
setPreferredSize(new Dimension(200, 200));
|
setPreferredSize(new Dimension(200, 200));
|
||||||
}
|
}
|
||||||
@ -52,46 +50,9 @@ public class ProgressCircle extends Widget {
|
|||||||
NumberFormats.FORMATTER_ZERO_DECIMAL_PLACES
|
NumberFormats.FORMATTER_ZERO_DECIMAL_PLACES
|
||||||
.format(donePercent * 100) + "%",
|
.format(donePercent * 100) + "%",
|
||||||
(int) (side / 8d * 0d), (int) (side / 8d * 7.5d));
|
(int) (side / 8d * 0d), (int) (side / 8d * 7.5d));
|
||||||
if(mouseOver && smileysColoredProperty.isDisabled()){//no colored
|
paintSmiley(visibility, brush, (int) (side / 8d * 0d) + 30,
|
||||||
if(!visibility.isStronglyColored()) {
|
(int) (side / 8d * 7.5d - 16d));
|
||||||
brush.setColor(Color.GRAY);
|
|
||||||
}
|
|
||||||
if(visibility.isGray()) {
|
|
||||||
brush.setColor(Color.LIGHT_GRAY);
|
|
||||||
}
|
|
||||||
if(visibility.isStronglyColored()) {
|
|
||||||
brush.setColor(Color.BLACK);
|
|
||||||
}
|
|
||||||
Color currentColor= brush.getColor();
|
|
||||||
brush.setColor(visibility.isStronglyColored() ? Color.WHITE : BACKGROUND_COLOR);
|
|
||||||
brush.fillRect(
|
|
||||||
(int) (side / 8d * 0d) + 30,
|
|
||||||
(int) (side / 8d * 7.5d - 16d),
|
|
||||||
20,
|
|
||||||
20
|
|
||||||
);
|
|
||||||
brush.setColor(currentColor);
|
|
||||||
brush.setFont(MEDIUM_FONT);
|
|
||||||
brush.drawString(
|
|
||||||
ProgressSmiley.forProgress(donePercent).getCharacter(),
|
|
||||||
(int) (side / 8d * 0d) + 30,
|
|
||||||
(int) (side / 8d * 7.5d)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if(mouseOver && smileysColoredProperty.isEnabled()) {//colored
|
|
||||||
ImageIcon imageIcon = ProgressSmileyIcon.forSmiley(ProgressSmiley.forProgress(donePercent)).getIcon();
|
|
||||||
if(this.smileyIcon != null) {
|
|
||||||
this.remove(smileyIcon);
|
|
||||||
}
|
|
||||||
this.smileyIcon = new JLabel(imageIcon);
|
|
||||||
smileyIcon.setBounds((int) (side / 8d * 0d) + 30,
|
|
||||||
(int) (side / 8d * 7.5d) - 15,15, 15);
|
|
||||||
this.add(smileyIcon);
|
|
||||||
} else {
|
|
||||||
if(this.smileyIcon != null) {
|
|
||||||
this.remove(smileyIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -16,7 +16,6 @@ import java.awt.RenderingHints;
|
|||||||
public class ProgressSquare extends Widget {
|
public class ProgressSquare extends Widget {
|
||||||
|
|
||||||
private int square;
|
private int square;
|
||||||
private JLabel smileyIcon;
|
|
||||||
|
|
||||||
public ProgressSquare() {
|
public ProgressSquare() {
|
||||||
setPreferredSize(new Dimension(400, 400));
|
setPreferredSize(new Dimension(400, 400));
|
||||||
@ -85,46 +84,8 @@ public class ProgressSquare extends Widget {
|
|||||||
.format(donePercent * 100) + "%",
|
.format(donePercent * 100) + "%",
|
||||||
(int) (side / 8d * 3d),
|
(int) (side / 8d * 3d),
|
||||||
(int) (side / 8d * (donePercent > 0.5 ? 3d : 5d)));
|
(int) (side / 8d * (donePercent > 0.5 ? 3d : 5d)));
|
||||||
if(mouseOver && smileysColoredProperty.isDisabled()){//no colored
|
paintSmiley(visibility, brush, (int) (side / 8d * 3d) + 65,
|
||||||
if(!visibility.isStronglyColored()) {
|
(int) ((side / 8d * (donePercent > 0.5 ? 3d : 5d)) - 16d));
|
||||||
brush.setColor(Color.GRAY);
|
|
||||||
}
|
|
||||||
if(visibility.isGray()) {
|
|
||||||
brush.setColor(Color.LIGHT_GRAY);
|
|
||||||
}
|
|
||||||
if(visibility.isStronglyColored()) {
|
|
||||||
brush.setColor(Color.BLACK);
|
|
||||||
}
|
|
||||||
Color currentColor= brush.getColor();
|
|
||||||
brush.setColor(visibility.isStronglyColored() ? Color.WHITE : BACKGROUND_COLOR);
|
|
||||||
brush.fillRect(
|
|
||||||
(int) (side / 8d * 3d) + 65,
|
|
||||||
(int) ((side / 8d * (donePercent > 0.5 ? 3d : 5d)) - 16d),
|
|
||||||
20,
|
|
||||||
20
|
|
||||||
);
|
|
||||||
brush.setColor(currentColor);
|
|
||||||
brush.setFont(MEDIUM_FONT);
|
|
||||||
brush.drawString(
|
|
||||||
ProgressSmiley.forProgress(donePercent).getCharacter(),
|
|
||||||
(int) (side / 8d * 3d) + 65,
|
|
||||||
(int) (side / 8d * (donePercent > 0.5 ? 3d : 5d))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if(mouseOver && smileysColoredProperty.isEnabled()) {//colored
|
|
||||||
ImageIcon imageIcon = ProgressSmileyIcon.forSmiley(ProgressSmiley.forProgress(donePercent)).getIcon();
|
|
||||||
if(this.smileyIcon != null) {
|
|
||||||
this.remove(smileyIcon);
|
|
||||||
}
|
|
||||||
this.smileyIcon = new JLabel(imageIcon);
|
|
||||||
smileyIcon.setBounds((int) (side / 8d * 3d) + 65,
|
|
||||||
(int) (side / 8d * (donePercent > 0.5 ? 3d : 5d)) - 15,15, 15);
|
|
||||||
this.add(smileyIcon);
|
|
||||||
} else {
|
|
||||||
if(this.smileyIcon != null) {
|
|
||||||
this.remove(smileyIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ visibility.only-grey-or-none.enabled=false
|
|||||||
jokes.enabled=true
|
jokes.enabled=true
|
||||||
commands.enabled=true
|
commands.enabled=true
|
||||||
toasts.enabled=true
|
toasts.enabled=true
|
||||||
smileys.colored=false
|
smileys.colored=true
|
||||||
|
|
||||||
#todo
|
#todo
|
||||||
smileys.enabled=true
|
smileys.enabled=true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user