mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
Added several improvements, changes and bug fixes
This commit is contained in:
parent
abc622290c
commit
e381c215ff
@ -12,6 +12,7 @@ import org.jfree.data.time.Day;
|
|||||||
import org.jfree.data.time.TimeSeries;
|
import org.jfree.data.time.TimeSeries;
|
||||||
import org.jfree.data.time.TimeSeriesCollection;
|
import org.jfree.data.time.TimeSeriesCollection;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.property.IntegerProperty;
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
@ -33,10 +34,14 @@ public class ArrivalChart extends JPanel {
|
|||||||
private static final Color BROWN = new Color(128, 0, 64);
|
private static final Color BROWN = new Color(128, 0, 64);
|
||||||
private static final Color PURPLE = new Color(128, 0, 255);
|
private static final Color PURPLE = new Color(128, 0, 255);
|
||||||
public static final Rectangle EMPTY_RECTANGLE = new Rectangle();
|
public static final Rectangle EMPTY_RECTANGLE = new Rectangle();
|
||||||
|
public static final int MIN_CHART_WIDTH = 600;
|
||||||
private final boolean ma14Enabled;
|
private final boolean ma14Enabled;
|
||||||
private final boolean ma28Enabled;
|
private final boolean ma28Enabled;
|
||||||
private final boolean ma56Enabled;
|
private final boolean ma56Enabled;
|
||||||
|
|
||||||
|
public IntegerProperty widthProperty = new IntegerProperty("widthProperty", 600);
|
||||||
|
public IntegerProperty heightProperty = new IntegerProperty("heightProperty", 400);
|
||||||
|
|
||||||
public ArrivalChart(ArrivalChartData data, int width) {
|
public ArrivalChart(ArrivalChartData data, int width) {
|
||||||
this(data.getDays(), data.getArrival(), data.getTarget(), data.getMa7(),
|
this(data.getDays(), data.getArrival(), data.getTarget(), data.getMa7(),
|
||||||
data.getMa14(), data.getMa28(), data.getMa56(),
|
data.getMa14(), data.getMa28(), data.getMa56(),
|
||||||
@ -66,10 +71,23 @@ public class ArrivalChart extends JPanel {
|
|||||||
chartPanel.setDomainZoomable(true);
|
chartPanel.setDomainZoomable(true);
|
||||||
chartPanel.setMouseZoomable(true);
|
chartPanel.setMouseZoomable(true);
|
||||||
this.add(chartPanel);
|
this.add(chartPanel);
|
||||||
|
widthProperty.addListener(e-> {
|
||||||
|
if (widthProperty.getValue() > MIN_CHART_WIDTH) {
|
||||||
|
chartPanel.setBounds(10, 10, widthProperty.getValue(),
|
||||||
|
heightProperty.getValue());
|
||||||
|
} else {widthProperty.setValue(MIN_CHART_WIDTH);}
|
||||||
|
});
|
||||||
|
heightProperty.addListener(e-> chartPanel.setBounds(10, 10, widthProperty.getValue(), heightProperty.getValue()));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
widthProperty.setValue(width);
|
||||||
chartPanel.setBounds(10, 10, width, 400);
|
chartPanel.setBounds(10, 10, width, 400);
|
||||||
this.ma14Enabled = ma14Enabled;
|
this.ma14Enabled = ma14Enabled;
|
||||||
this.ma28Enabled = ma28Enabled;
|
this.ma28Enabled = ma28Enabled;
|
||||||
this.ma56Enabled = ma56Enabled;
|
this.ma56Enabled = ma56Enabled;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private JFreeChart createChart(List<TimeSeries> timeSeries,
|
private JFreeChart createChart(List<TimeSeries> timeSeries,
|
||||||
|
@ -703,6 +703,7 @@ public class MainWindow extends TWindow {
|
|||||||
System.out.println(wd);
|
System.out.println(wd);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
if (updateWindow(timeCalcApp, time, clock, minuteBattery, hourBattery,
|
if (updateWindow(timeCalcApp, time, clock, minuteBattery, hourBattery,
|
||||||
dayBattery,
|
dayBattery,
|
||||||
weekBattery, monthBattery, yearBattery,
|
weekBattery, monthBattery, yearBattery,
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
package org.nanoboot.utils.timecalc.swing.common;
|
package org.nanoboot.utils.timecalc.swing.common;
|
||||||
|
|
||||||
|
import org.nanoboot.utils.timecalc.utils.property.IntegerProperty;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.Timer;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.HeadlessException;
|
import java.awt.HeadlessException;
|
||||||
|
import java.awt.event.ComponentAdapter;
|
||||||
|
import java.awt.event.ComponentEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
@ -10,8 +15,25 @@ import java.awt.HeadlessException;
|
|||||||
*/
|
*/
|
||||||
public class TWindow extends JFrame {
|
public class TWindow extends JFrame {
|
||||||
|
|
||||||
|
public IntegerProperty widthProperty = new IntegerProperty("widthProperty");
|
||||||
|
public IntegerProperty heightProperty = new IntegerProperty("heightProperty");
|
||||||
public TWindow() throws HeadlessException {
|
public TWindow() throws HeadlessException {
|
||||||
|
addComponentListener(new ComponentAdapter() {
|
||||||
|
public void componentResized(ComponentEvent e) {
|
||||||
|
widthProperty.setValue(getWidth());
|
||||||
|
heightProperty.setValue(getHeight());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
widthProperty.addListener(e -> {
|
||||||
|
if (widthProperty.getValue() > 100 /*&& widthProperty.getValue() % 10 == 0*/) {
|
||||||
|
setSize(widthProperty.getValue(), getHeight());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
heightProperty.addListener(e -> {
|
||||||
|
if (heightProperty.getValue() > 100 /*&& widthProperty.getValue() % 10 == 0*/) {
|
||||||
|
setSize(getWidth(), heightProperty.getValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component[] addAll(Component... comp) {
|
public Component[] addAll(Component... comp) {
|
||||||
|
@ -8,6 +8,8 @@ import org.nanoboot.utils.timecalc.utils.common.DateFormats;
|
|||||||
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.TTime;
|
import org.nanoboot.utils.timecalc.utils.common.TTime;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.property.InvalidationListener;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.property.Property;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
@ -23,6 +25,7 @@ import java.awt.event.KeyListener;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
@ -50,6 +53,7 @@ public class WorkingDaysWindow extends TWindow {
|
|||||||
private JTable table = null;
|
private JTable table = null;
|
||||||
private final JScrollPane scrollPane;
|
private final JScrollPane scrollPane;
|
||||||
private int loadedYear;
|
private int loadedYear;
|
||||||
|
private InvalidationListener invalidationChartWidthListener;
|
||||||
|
|
||||||
public WorkingDaysWindow(WorkingDayRepositoryApi workingDayRepository,
|
public WorkingDaysWindow(WorkingDayRepositoryApi workingDayRepository,
|
||||||
Time time, double target) {
|
Time time, double target) {
|
||||||
@ -460,6 +464,15 @@ public class WorkingDaysWindow extends TWindow {
|
|||||||
|
|
||||||
scrollPane.setViewportView(table);
|
scrollPane.setViewportView(table);
|
||||||
table.setBounds(30, 30, 750, 600);
|
table.setBounds(30, 30, 750, 600);
|
||||||
|
this.widthProperty.addListener(e-> {
|
||||||
|
if(/*this.widthProperty.getValue() % 10 == 0 && */this.widthProperty.getValue() > 100) {
|
||||||
|
scrollPane.setBounds(SwingUtils.MARGIN,
|
||||||
|
arrivalChart.getY() + arrivalChart.getHeight()
|
||||||
|
+ SwingUtils.MARGIN,
|
||||||
|
(this.widthProperty.getValue() - 50),
|
||||||
|
scrollPane.getHeight());
|
||||||
|
}
|
||||||
|
});
|
||||||
//table.setDefaultRenderer(Object.class, new ColorRenderer());
|
//table.setDefaultRenderer(Object.class, new ColorRenderer());
|
||||||
ArrivalChartData acd = WorkingDayForStats
|
ArrivalChartData acd = WorkingDayForStats
|
||||||
.toArrivalChartData(wdfsList, 7d, startTextField.getText(),
|
.toArrivalChartData(wdfsList, 7d, startTextField.getText(),
|
||||||
@ -474,6 +487,18 @@ public class WorkingDaysWindow extends TWindow {
|
|||||||
Rectangle bounds = this.arrivalChart.getBounds();
|
Rectangle bounds = this.arrivalChart.getBounds();
|
||||||
remove(this.arrivalChart);
|
remove(this.arrivalChart);
|
||||||
this.arrivalChart = new ArrivalChart(newArrivalChartData, chartWidth);
|
this.arrivalChart = new ArrivalChart(newArrivalChartData, chartWidth);
|
||||||
|
if(this.invalidationChartWidthListener != null) {
|
||||||
|
this.widthProperty.removeListener(invalidationChartWidthListener);
|
||||||
|
this.invalidationChartWidthListener = null;
|
||||||
|
}
|
||||||
|
this.invalidationChartWidthListener =
|
||||||
|
new InvalidationListener() {
|
||||||
|
@Override
|
||||||
|
public void invalidated(Property property) {
|
||||||
|
arrivalChart.widthProperty.setValue(getWidth() - 30);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.widthProperty.addListener(invalidationChartWidthListener);
|
||||||
add(arrivalChart);
|
add(arrivalChart);
|
||||||
arrivalChart.setBounds(bounds);
|
arrivalChart.setBounds(bounds);
|
||||||
add(arrivalChart);
|
add(arrivalChart);
|
||||||
|
@ -117,7 +117,9 @@ public class Property<T> {
|
|||||||
public void addListener(ChangeListener<T> listener) {
|
public void addListener(ChangeListener<T> listener) {
|
||||||
this.changeListeners.add(listener);
|
this.changeListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
public void removeListener(InvalidationListener listener) {
|
||||||
|
this.invalidationListeners.remove(listener);
|
||||||
|
}
|
||||||
public void removeListener(ChangeListener<T> listener) {
|
public void removeListener(ChangeListener<T> listener) {
|
||||||
this.changeListeners.remove(listener);
|
this.changeListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user