mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-26 07:49:25 +01:00
Code was formatted
This commit is contained in:
parent
7f58f2422a
commit
0b06f31d84
4
pom.xml
4
pom.xml
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -23,10 +23,6 @@ public class AnalogClock extends JPanel {
|
|||||||
|
|
||||||
private boolean highlight = false;
|
private boolean highlight = false;
|
||||||
|
|
||||||
public void setHighlight(boolean highlight) {
|
|
||||||
this.highlight = highlight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AnalogClock() {
|
public AnalogClock() {
|
||||||
setPreferredSize(new Dimension(400, 300));
|
setPreferredSize(new Dimension(400, 300));
|
||||||
setBackground(BACKGROUND_COLOR);
|
setBackground(BACKGROUND_COLOR);
|
||||||
@ -60,6 +56,18 @@ public class AnalogClock extends JPanel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
JFrame frame = new JFrame("Analog Clock");
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
frame.add(new AnalogClock());
|
||||||
|
frame.pack();
|
||||||
|
frame.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHighlight(boolean highlight) {
|
||||||
|
this.highlight = highlight;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintComponent(Graphics g) {
|
public void paintComponent(Graphics g) {
|
||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
@ -77,8 +85,11 @@ public class AnalogClock extends JPanel {
|
|||||||
int hour = time.get(Calendar.HOUR_OF_DAY);
|
int hour = time.get(Calendar.HOUR_OF_DAY);
|
||||||
|
|
||||||
drawHand(g2d, side / 2 - 10, second / 60.0, 0.5f, Color.RED);
|
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 - 20, minute / 60.0 + second / 60.0 / 60.0, 2.0f,
|
||||||
drawHand(g2d, side / 2 - 40, hour / 12.0 + minute / 60.0 / 12 + second / 60 / 60 / 12, 4.0f, Color.BLACK);
|
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
|
// Draw clock numbers and circle
|
||||||
drawClockFace(g2d, centerX, centerY, side / 2 - 40);
|
drawClockFace(g2d, centerX, centerY, side / 2 - 40);
|
||||||
@ -117,12 +128,4 @@ public class AnalogClock extends JPanel {
|
|||||||
g2d.drawString(Integer.toString(i), dx, dy);
|
g2d.drawString(Integer.toString(i), dx, dy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
JFrame frame = new JFrame("Analog Clock");
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
frame.add(new AnalogClock());
|
|
||||||
frame.pack();
|
|
||||||
frame.setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -8,12 +8,11 @@ import javax.swing.JOptionPane;
|
|||||||
*/
|
*/
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
while (true) {
|
while (true) {
|
||||||
boolean test = false;
|
boolean test = false;
|
||||||
String startTime = test ? "7:00" : (String) JOptionPane.showInputDialog(
|
String startTime =
|
||||||
|
test ? "7:00" : (String) JOptionPane.showInputDialog(
|
||||||
null,
|
null,
|
||||||
"Start Time:",
|
"Start Time:",
|
||||||
"Start Time",
|
"Start Time",
|
||||||
@ -22,7 +21,8 @@ public class Main {
|
|||||||
null,
|
null,
|
||||||
"7:00"
|
"7:00"
|
||||||
);
|
);
|
||||||
String overTime = test ? "0:00" : (String) JOptionPane.showInputDialog(
|
String overTime =
|
||||||
|
test ? "0:00" : (String) JOptionPane.showInputDialog(
|
||||||
null,
|
null,
|
||||||
"Overtime:",
|
"Overtime:",
|
||||||
"Overtime",
|
"Overtime",
|
||||||
@ -35,7 +35,8 @@ public class Main {
|
|||||||
TimeCalcWindow timeCalc =
|
TimeCalcWindow timeCalc =
|
||||||
new TimeCalcWindow(startTime, overTime);
|
new TimeCalcWindow(startTime, overTime);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
JOptionPane.showMessageDialog(null, "Error: " + e.getMessage(), e.getMessage(), JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "Error: " + e.getMessage(),
|
||||||
|
e.getMessage(), JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,14 +15,8 @@ public class ProgressSquare extends JPanel {
|
|||||||
private int side = 0;
|
private int side = 0;
|
||||||
private int square;
|
private int square;
|
||||||
|
|
||||||
|
|
||||||
private double donePercent = 0;
|
private double donePercent = 0;
|
||||||
|
|
||||||
public void setDonePercent(double donePercent) {
|
|
||||||
this.donePercent = donePercent;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ProgressSquare() {
|
public ProgressSquare() {
|
||||||
setPreferredSize(new Dimension(400, 400));
|
setPreferredSize(new Dimension(400, 400));
|
||||||
setBackground(BACKGROUND_COLOR);
|
setBackground(BACKGROUND_COLOR);
|
||||||
@ -30,6 +24,10 @@ public class ProgressSquare extends JPanel {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDonePercent(double donePercent) {
|
||||||
|
this.donePercent = donePercent;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintComponent(Graphics g) {
|
public void paintComponent(Graphics g) {
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -4,36 +4,46 @@ package rvc.timecalc;
|
|||||||
* that show an animate box coming from the bottom of your screen
|
* that show an animate box coming from the bottom of your screen
|
||||||
* with a notification message and/or an associated image
|
* with a notification message and/or an associated image
|
||||||
* (like msn online/offline notifications).
|
* (like msn online/offline notifications).
|
||||||
*
|
* <p>
|
||||||
* Toaster panel in windows system follow the taskbar; So if
|
* Toaster panel in windows system follow the taskbar; So if
|
||||||
* the taskbar is into the bottom the panel coming from the bottom
|
* the taskbar is into the bottom the panel coming from the bottom
|
||||||
* and if the taskbar is on the top then the panel coming from the top.
|
* and if the taskbar is on the top then the panel coming from the top.
|
||||||
*
|
* <p>
|
||||||
* This is a simple example of utilization:
|
* This is a simple example of utilization:
|
||||||
*
|
* <p>
|
||||||
* import com.nitido.utils.toaster.*;
|
* import com.nitido.utils.toaster.*;
|
||||||
* import javax.swing.*;
|
* import javax.swing.*;
|
||||||
*
|
* <p>
|
||||||
* public class ToasterTest
|
* public class ToasterTest
|
||||||
* {
|
* {
|
||||||
*
|
* <p>
|
||||||
* public static void main(String[] args)
|
* public static void main(String[] args)
|
||||||
* {
|
* {
|
||||||
* // Initialize toaster manager...
|
* // Initialize toaster manager...
|
||||||
* Toaster toasterManager = new Toaster();
|
* Toaster toasterManager = new Toaster();
|
||||||
*
|
* <p>
|
||||||
* // Show a simple toaster
|
* // Show a simple toaster
|
||||||
* toasterManager.showToaster( new ImageIcon( "mylogo.gif" ), "A simple toaster with an image" );
|
* toasterManager.showToaster( new ImageIcon( "mylogo.gif" ), "A simple toaster with an image" );
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.awt.*;
|
import javax.swing.BorderFactory;
|
||||||
import java.awt.event.ActionEvent;
|
import javax.swing.Icon;
|
||||||
import java.awt.event.ActionListener;
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JLabel;
|
||||||
import javax.swing.*;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.border.*;
|
import javax.swing.JTextArea;
|
||||||
|
import javax.swing.JWindow;
|
||||||
|
import javax.swing.border.EtchedBorder;
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to show tosters in multiplatform
|
* Class to show tosters in multiplatform
|
||||||
@ -41,55 +51,39 @@ import javax.swing.border.*;
|
|||||||
* @author daniele piras
|
* @author daniele piras
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Toaster
|
public class Toaster {
|
||||||
{
|
private static final long serialVersionUID = 1L;
|
||||||
// Width of the toster
|
|
||||||
private int toasterWidth = 300;
|
|
||||||
|
|
||||||
// Height of the toster
|
|
||||||
private int toasterHeight = 80;
|
|
||||||
|
|
||||||
// Step for the toaster
|
|
||||||
private int step = 20;
|
|
||||||
|
|
||||||
// Step time
|
|
||||||
private int stepTime = 20;
|
|
||||||
|
|
||||||
// Show time
|
|
||||||
private int displayTime = 3000;
|
|
||||||
|
|
||||||
// Current number of toaster...
|
|
||||||
private int currentNumberOfToaster = 0;
|
|
||||||
|
|
||||||
// Last opened toaster
|
|
||||||
private int maxToaster = 0;
|
|
||||||
|
|
||||||
// Max number of toasters for the sceen
|
|
||||||
private int maxToasterInSceen;
|
|
||||||
|
|
||||||
// Background image
|
|
||||||
private Image backgroundImage;
|
|
||||||
|
|
||||||
// Font used to display message
|
|
||||||
private Font font;
|
|
||||||
|
|
||||||
// Color for border
|
|
||||||
private Color borderColor;
|
|
||||||
|
|
||||||
// Color for toaster
|
|
||||||
private Color toasterColor;
|
|
||||||
|
|
||||||
// Set message color
|
|
||||||
private Color messageColor;
|
|
||||||
|
|
||||||
// Set the margin
|
// Set the margin
|
||||||
int margin;
|
int margin;
|
||||||
|
|
||||||
// Flag that indicate if use alwaysOnTop or not.
|
// Flag that indicate if use alwaysOnTop or not.
|
||||||
// method always on top start only SINCE JDK 5 !
|
// method always on top start only SINCE JDK 5 !
|
||||||
boolean useAlwaysOnTop = true;
|
boolean useAlwaysOnTop = true;
|
||||||
|
// Width of the toster
|
||||||
private static final long serialVersionUID = 1L;
|
private int toasterWidth = 300;
|
||||||
|
// Height of the toster
|
||||||
|
private int toasterHeight = 80;
|
||||||
|
// Step for the toaster
|
||||||
|
private int step = 20;
|
||||||
|
// Step time
|
||||||
|
private int stepTime = 20;
|
||||||
|
// Show time
|
||||||
|
private int displayTime = 3000;
|
||||||
|
// Current number of toaster...
|
||||||
|
private int currentNumberOfToaster = 0;
|
||||||
|
// Last opened toaster
|
||||||
|
private int maxToaster = 0;
|
||||||
|
// Max number of toasters for the sceen
|
||||||
|
private int maxToasterInSceen;
|
||||||
|
// Background image
|
||||||
|
private Image backgroundImage;
|
||||||
|
// Font used to display message
|
||||||
|
private Font font;
|
||||||
|
// Color for border
|
||||||
|
private Color borderColor;
|
||||||
|
// Color for toaster
|
||||||
|
private Color toasterColor;
|
||||||
|
// Set message color
|
||||||
|
private Color messageColor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to initialized toaster component...
|
* Constructor to initialized toaster component...
|
||||||
@ -97,8 +91,7 @@ public class Toaster
|
|||||||
* @author daniele piras
|
* @author daniele piras
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Toaster()
|
public Toaster() {
|
||||||
{
|
|
||||||
// Set default font...
|
// Set default font...
|
||||||
font = new Font("Arial", Font.BOLD, 12);
|
font = new Font("Arial", Font.BOLD, 12);
|
||||||
// Border color
|
// Border color
|
||||||
@ -107,25 +100,193 @@ public class Toaster
|
|||||||
messageColor = Color.BLACK;
|
messageColor = Color.BLACK;
|
||||||
useAlwaysOnTop = true;
|
useAlwaysOnTop = true;
|
||||||
// Verify AlwaysOnTop Flag...
|
// Verify AlwaysOnTop Flag...
|
||||||
try
|
try {
|
||||||
{
|
JWindow.class
|
||||||
JWindow.class.getMethod( "setAlwaysOnTop", new Class[] { Boolean.class } );
|
.getMethod("setAlwaysOnTop", new Class[] {Boolean.class});
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch( Exception e )
|
|
||||||
{
|
|
||||||
useAlwaysOnTop = false;
|
useAlwaysOnTop = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a toaster with the specified message and the associated icon.
|
||||||
|
*/
|
||||||
|
public void showToaster(Icon icon, String msg) {
|
||||||
|
SingleToaster singleToaster = new SingleToaster();
|
||||||
|
if (icon != null) {
|
||||||
|
singleToaster.iconLabel.setIcon(icon);
|
||||||
|
}
|
||||||
|
singleToaster.message.setText(msg);
|
||||||
|
|
||||||
|
singleToaster.toFront();
|
||||||
|
singleToaster.setAlwaysOnTop(true);
|
||||||
|
singleToaster.animate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a toaster with the specified message.
|
||||||
|
*/
|
||||||
|
public void showToaster(String msg) {
|
||||||
|
showToaster(null, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the font
|
||||||
|
*/
|
||||||
|
public Font getToasterMessageFont() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the font for the message
|
||||||
|
*/
|
||||||
|
public void setToasterMessageFont(Font f) {
|
||||||
|
font = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the borderColor.
|
||||||
|
*/
|
||||||
|
public Color getBorderColor() {
|
||||||
|
return borderColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param borderColor The borderColor to set.
|
||||||
|
*/
|
||||||
|
public void setBorderColor(Color borderColor) {
|
||||||
|
this.borderColor = borderColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the displayTime.
|
||||||
|
*/
|
||||||
|
public int getDisplayTime() {
|
||||||
|
return displayTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param displayTime The displayTime to set.
|
||||||
|
*/
|
||||||
|
public void setDisplayTime(int displayTime) {
|
||||||
|
this.displayTime = displayTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the margin.
|
||||||
|
*/
|
||||||
|
public int getMargin() {
|
||||||
|
return margin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param margin The margin to set.
|
||||||
|
*/
|
||||||
|
public void setMargin(int margin) {
|
||||||
|
this.margin = margin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the messageColor.
|
||||||
|
*/
|
||||||
|
public Color getMessageColor() {
|
||||||
|
return messageColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param messageColor The messageColor to set.
|
||||||
|
*/
|
||||||
|
public void setMessageColor(Color messageColor) {
|
||||||
|
this.messageColor = messageColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the step.
|
||||||
|
*/
|
||||||
|
public int getStep() {
|
||||||
|
return step;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param step The step to set.
|
||||||
|
*/
|
||||||
|
public void setStep(int step) {
|
||||||
|
this.step = step;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the stepTime.
|
||||||
|
*/
|
||||||
|
public int getStepTime() {
|
||||||
|
return stepTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param stepTime The stepTime to set.
|
||||||
|
*/
|
||||||
|
public void setStepTime(int stepTime) {
|
||||||
|
this.stepTime = stepTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the toasterColor.
|
||||||
|
*/
|
||||||
|
public Color getToasterColor() {
|
||||||
|
return toasterColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param toasterColor The toasterColor to set.
|
||||||
|
*/
|
||||||
|
public void setToasterColor(Color toasterColor) {
|
||||||
|
this.toasterColor = toasterColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the toasterHeight.
|
||||||
|
*/
|
||||||
|
public int getToasterHeight() {
|
||||||
|
return toasterHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param toasterHeight The toasterHeight to set.
|
||||||
|
*/
|
||||||
|
public void setToasterHeight(int toasterHeight) {
|
||||||
|
this.toasterHeight = toasterHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the toasterWidth.
|
||||||
|
*/
|
||||||
|
public int getToasterWidth() {
|
||||||
|
return toasterWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param toasterWidth The toasterWidth to set.
|
||||||
|
*/
|
||||||
|
public void setToasterWidth(int toasterWidth) {
|
||||||
|
this.toasterWidth = toasterWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image getBackgroundImage() {
|
||||||
|
return backgroundImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBackgroundImage(Image backgroundImage) {
|
||||||
|
this.backgroundImage = backgroundImage;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that rappresent a single toaster
|
* Class that rappresent a single toaster
|
||||||
*
|
*
|
||||||
* @author daniele piras
|
* @author daniele piras
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class SingleToaster extends JWindow
|
class SingleToaster extends JWindow {
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
// Label to store Icon
|
// Label to store Icon
|
||||||
@ -134,41 +295,33 @@ public class Toaster
|
|||||||
// Text area for the message
|
// Text area for the message
|
||||||
private JTextArea message = new JTextArea();
|
private JTextArea message = new JTextArea();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Simple costructor that initialized components...
|
* Simple costructor that initialized components...
|
||||||
*/
|
*/
|
||||||
public SingleToaster()
|
public SingleToaster() {
|
||||||
{
|
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Function to initialized components
|
* Function to initialized components
|
||||||
*/
|
*/
|
||||||
private void initComponents()
|
private void initComponents() {
|
||||||
{
|
|
||||||
|
|
||||||
setSize(toasterWidth, toasterHeight);
|
setSize(toasterWidth, toasterHeight);
|
||||||
message.setFont(getToasterMessageFont());
|
message.setFont(getToasterMessageFont());
|
||||||
JPanel externalPanel = new JPanel(new BorderLayout(1, 1));
|
JPanel externalPanel = new JPanel(new BorderLayout(1, 1));
|
||||||
externalPanel.setBackground(getBorderColor());
|
externalPanel.setBackground(getBorderColor());
|
||||||
JPanel innerPanel = new JPanel(new BorderLayout( getMargin(), getMargin() ))
|
JPanel innerPanel =
|
||||||
|
new JPanel(new BorderLayout(getMargin(), getMargin())) {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
if ( getBackgroundImage() != null )
|
if (getBackgroundImage() != null) {
|
||||||
{
|
|
||||||
g.drawImage(getBackgroundImage(), 0, 0, null);
|
g.drawImage(getBackgroundImage(), 0, 0, null);
|
||||||
}
|
}
|
||||||
super.paint(g);
|
super.paint(g);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if ( getBackgroundImage() != null )
|
if (getBackgroundImage() != null) {
|
||||||
{
|
|
||||||
innerPanel.setOpaque(false);
|
innerPanel.setOpaque(false);
|
||||||
message.setOpaque(false);
|
message.setOpaque(false);
|
||||||
iconLabel.setOpaque(false);
|
iconLabel.setOpaque(false);
|
||||||
@ -189,15 +342,16 @@ public class Toaster
|
|||||||
JButton closeButton = new JButton("Close");
|
JButton closeButton = new JButton("Close");
|
||||||
closeButton.setBounds(480, 10, 100, 40);
|
closeButton.setBounds(480, 10, 100, 40);
|
||||||
innerPanel.add(closeButton, BorderLayout.BEFORE_FIRST_LINE);
|
innerPanel.add(closeButton, BorderLayout.BEFORE_FIRST_LINE);
|
||||||
closeButton.addActionListener(e -> {setVisible(false); dispose();});
|
closeButton.addActionListener(e -> {
|
||||||
|
setVisible(false);
|
||||||
|
dispose();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Start toaster animation...
|
* Start toaster animation...
|
||||||
*/
|
*/
|
||||||
public void animate()
|
public void animate() {
|
||||||
{
|
|
||||||
(new Animation(this)).start();
|
(new Animation(this)).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,16 +360,13 @@ public class Toaster
|
|||||||
/***
|
/***
|
||||||
* Class that manage the animation
|
* Class that manage the animation
|
||||||
*/
|
*/
|
||||||
class Animation extends Thread
|
class Animation extends Thread {
|
||||||
{
|
|
||||||
SingleToaster toaster;
|
SingleToaster toaster;
|
||||||
|
|
||||||
public Animation( SingleToaster toaster )
|
public Animation(SingleToaster toaster) {
|
||||||
{
|
|
||||||
this.toaster = toaster;
|
this.toaster = toaster;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animate vertically the toaster. The toaster could be moved from bottom
|
* Animate vertically the toaster. The toaster could be moved from bottom
|
||||||
* to upper or to upper to bottom
|
* to upper or to upper to bottom
|
||||||
@ -224,22 +375,17 @@ public class Toaster
|
|||||||
* @param toY
|
* @param toY
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
protected void animateVertically( int posx, int fromY, int toY ) throws InterruptedException
|
protected void animateVertically(int posx, int fromY, int toY)
|
||||||
{
|
throws InterruptedException {
|
||||||
|
|
||||||
toaster.setLocation(posx, fromY);
|
toaster.setLocation(posx, fromY);
|
||||||
if ( toY < fromY )
|
if (toY < fromY) {
|
||||||
{
|
for (int i = fromY; i > toY; i -= step) {
|
||||||
for (int i = fromY; i > toY; i -= step)
|
|
||||||
{
|
|
||||||
toaster.setLocation(posx, i);
|
toaster.setLocation(posx, i);
|
||||||
Thread.sleep(stepTime);
|
Thread.sleep(stepTime);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
for (int i = fromY; i < toY; i += step) {
|
||||||
{
|
|
||||||
for (int i = fromY; i < toY; i += step)
|
|
||||||
{
|
|
||||||
toaster.setLocation(posx, i);
|
toaster.setLocation(posx, i);
|
||||||
Thread.sleep(stepTime);
|
Thread.sleep(stepTime);
|
||||||
}
|
}
|
||||||
@ -247,10 +393,8 @@ public class Toaster
|
|||||||
toaster.setLocation(posx, toY);
|
toaster.setLocation(posx, toY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
boolean animateFromBottom = true;
|
boolean animateFromBottom = true;
|
||||||
GraphicsEnvironment ge = GraphicsEnvironment
|
GraphicsEnvironment ge = GraphicsEnvironment
|
||||||
.getLocalGraphicsEnvironment();
|
.getLocalGraphicsEnvironment();
|
||||||
@ -261,47 +405,39 @@ public class Toaster
|
|||||||
int startYPosition;
|
int startYPosition;
|
||||||
int stopYPosition;
|
int stopYPosition;
|
||||||
|
|
||||||
if ( screenRect.y > 0 )
|
if (screenRect.y > 0) {
|
||||||
{
|
|
||||||
animateFromBottom = false; // Animate from top!
|
animateFromBottom = false; // Animate from top!
|
||||||
}
|
}
|
||||||
|
|
||||||
maxToasterInSceen = screenHeight / toasterHeight;
|
maxToasterInSceen = screenHeight / toasterHeight;
|
||||||
|
|
||||||
|
|
||||||
int posx = (int) screenRect.width - toasterWidth - 1;
|
int posx = (int) screenRect.width - toasterWidth - 1;
|
||||||
|
|
||||||
toaster.setLocation(posx, screenHeight);
|
toaster.setLocation(posx, screenHeight);
|
||||||
toaster.setVisible(true);
|
toaster.setVisible(true);
|
||||||
if ( useAlwaysOnTop )
|
if (useAlwaysOnTop) {
|
||||||
{
|
|
||||||
toaster.setAlwaysOnTop(true);
|
toaster.setAlwaysOnTop(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( animateFromBottom )
|
if (animateFromBottom) {
|
||||||
{
|
|
||||||
startYPosition = screenHeight;
|
startYPosition = screenHeight;
|
||||||
stopYPosition = startYPosition - toasterHeight - 1;
|
stopYPosition = startYPosition - toasterHeight - 1;
|
||||||
if ( currentNumberOfToaster > 0 )
|
if (currentNumberOfToaster > 0) {
|
||||||
{
|
stopYPosition =
|
||||||
stopYPosition = stopYPosition - ( maxToaster % maxToasterInSceen * toasterHeight );
|
stopYPosition - (maxToaster % maxToasterInSceen
|
||||||
}
|
* toasterHeight);
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
maxToaster = 0;
|
maxToaster = 0;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
startYPosition = screenRect.y - toasterHeight;
|
startYPosition = screenRect.y - toasterHeight;
|
||||||
stopYPosition = screenRect.y;
|
stopYPosition = screenRect.y;
|
||||||
|
|
||||||
if ( currentNumberOfToaster > 0 )
|
if (currentNumberOfToaster > 0) {
|
||||||
{
|
stopYPosition =
|
||||||
stopYPosition = stopYPosition + ( maxToaster % maxToasterInSceen * toasterHeight );
|
stopYPosition + (maxToaster % maxToasterInSceen
|
||||||
}
|
* toasterHeight);
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
maxToaster = 0;
|
maxToaster = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,7 +445,6 @@ public class Toaster
|
|||||||
currentNumberOfToaster++;
|
currentNumberOfToaster++;
|
||||||
maxToaster++;
|
maxToaster++;
|
||||||
|
|
||||||
|
|
||||||
animateVertically(posx, startYPosition, stopYPosition);
|
animateVertically(posx, startYPosition, stopYPosition);
|
||||||
Thread.sleep(displayTime);
|
Thread.sleep(displayTime);
|
||||||
animateVertically(posx, stopYPosition, startYPosition);
|
animateVertically(posx, stopYPosition, startYPosition);
|
||||||
@ -317,245 +452,10 @@ public class Toaster
|
|||||||
currentNumberOfToaster--;
|
currentNumberOfToaster--;
|
||||||
toaster.setVisible(false);
|
toaster.setVisible(false);
|
||||||
toaster.dispose();
|
toaster.dispose();
|
||||||
} catch (Exception e)
|
} catch (Exception e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show a toaster with the specified message and the associated icon.
|
|
||||||
*/
|
|
||||||
public void showToaster(Icon icon, String msg)
|
|
||||||
{
|
|
||||||
SingleToaster singleToaster = new SingleToaster();
|
|
||||||
if ( icon != null )
|
|
||||||
{
|
|
||||||
singleToaster.iconLabel.setIcon( icon );
|
|
||||||
}
|
|
||||||
singleToaster.message.setText( msg );
|
|
||||||
|
|
||||||
singleToaster.toFront( );
|
|
||||||
singleToaster.setAlwaysOnTop(true);
|
|
||||||
singleToaster.animate();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show a toaster with the specified message.
|
|
||||||
*/
|
|
||||||
public void showToaster( String msg )
|
|
||||||
{
|
|
||||||
showToaster( null, msg );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Returns the font
|
|
||||||
*/
|
|
||||||
public Font getToasterMessageFont()
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return font;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the font for the message
|
|
||||||
*/
|
|
||||||
public void setToasterMessageFont( Font f)
|
|
||||||
{
|
|
||||||
font = f;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Returns the borderColor.
|
|
||||||
*/
|
|
||||||
public Color getBorderColor()
|
|
||||||
{
|
|
||||||
return borderColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param borderColor The borderColor to set.
|
|
||||||
*/
|
|
||||||
public void setBorderColor(Color borderColor)
|
|
||||||
{
|
|
||||||
this.borderColor = borderColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Returns the displayTime.
|
|
||||||
*/
|
|
||||||
public int getDisplayTime()
|
|
||||||
{
|
|
||||||
return displayTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param displayTime The displayTime to set.
|
|
||||||
*/
|
|
||||||
public void setDisplayTime(int displayTime)
|
|
||||||
{
|
|
||||||
this.displayTime = displayTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Returns the margin.
|
|
||||||
*/
|
|
||||||
public int getMargin()
|
|
||||||
{
|
|
||||||
return margin;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param margin The margin to set.
|
|
||||||
*/
|
|
||||||
public void setMargin(int margin)
|
|
||||||
{
|
|
||||||
this.margin = margin;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Returns the messageColor.
|
|
||||||
*/
|
|
||||||
public Color getMessageColor()
|
|
||||||
{
|
|
||||||
return messageColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param messageColor The messageColor to set.
|
|
||||||
*/
|
|
||||||
public void setMessageColor(Color messageColor)
|
|
||||||
{
|
|
||||||
this.messageColor = messageColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Returns the step.
|
|
||||||
*/
|
|
||||||
public int getStep()
|
|
||||||
{
|
|
||||||
return step;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param step The step to set.
|
|
||||||
*/
|
|
||||||
public void setStep(int step)
|
|
||||||
{
|
|
||||||
this.step = step;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Returns the stepTime.
|
|
||||||
*/
|
|
||||||
public int getStepTime()
|
|
||||||
{
|
|
||||||
return stepTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param stepTime The stepTime to set.
|
|
||||||
*/
|
|
||||||
public void setStepTime(int stepTime)
|
|
||||||
{
|
|
||||||
this.stepTime = stepTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Returns the toasterColor.
|
|
||||||
*/
|
|
||||||
public Color getToasterColor()
|
|
||||||
{
|
|
||||||
return toasterColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param toasterColor The toasterColor to set.
|
|
||||||
*/
|
|
||||||
public void setToasterColor(Color toasterColor)
|
|
||||||
{
|
|
||||||
this.toasterColor = toasterColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Returns the toasterHeight.
|
|
||||||
*/
|
|
||||||
public int getToasterHeight()
|
|
||||||
{
|
|
||||||
return toasterHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param toasterHeight The toasterHeight to set.
|
|
||||||
*/
|
|
||||||
public void setToasterHeight(int toasterHeight)
|
|
||||||
{
|
|
||||||
this.toasterHeight = toasterHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Returns the toasterWidth.
|
|
||||||
*/
|
|
||||||
public int getToasterWidth()
|
|
||||||
{
|
|
||||||
return toasterWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param toasterWidth The toasterWidth to set.
|
|
||||||
*/
|
|
||||||
public void setToasterWidth(int toasterWidth)
|
|
||||||
{
|
|
||||||
this.toasterWidth = toasterWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Image getBackgroundImage() {
|
|
||||||
return backgroundImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBackgroundImage(Image backgroundImage) {
|
|
||||||
this.backgroundImage = backgroundImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<assembly
|
<assembly
|
||||||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
||||||
<id>jar-with-all-dependencies</id>
|
<id>jar-with-all-dependencies</id>
|
||||||
<formats>
|
<formats>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user