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
e381c215ff
commit
3b9b6ef07a
@ -34,7 +34,7 @@ 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;
|
public static final int MIN_CHART_WIDTH = 400;
|
||||||
private final boolean ma14Enabled;
|
private final boolean ma14Enabled;
|
||||||
private final boolean ma28Enabled;
|
private final boolean ma28Enabled;
|
||||||
private final boolean ma56Enabled;
|
private final boolean ma56Enabled;
|
||||||
@ -73,14 +73,16 @@ public class ArrivalChart extends JPanel {
|
|||||||
this.add(chartPanel);
|
this.add(chartPanel);
|
||||||
widthProperty.addListener(e-> {
|
widthProperty.addListener(e-> {
|
||||||
if (widthProperty.getValue() > MIN_CHART_WIDTH) {
|
if (widthProperty.getValue() > MIN_CHART_WIDTH) {
|
||||||
chartPanel.setBounds(10, 10, widthProperty.getValue(),
|
chartPanel.setBounds(10, 10, widthProperty.getValue() - 60,
|
||||||
heightProperty.getValue());
|
heightProperty.getValue());
|
||||||
} else {widthProperty.setValue(MIN_CHART_WIDTH);}
|
} else {widthProperty.setValue(MIN_CHART_WIDTH);}
|
||||||
});
|
});
|
||||||
heightProperty.addListener(e-> chartPanel.setBounds(10, 10, widthProperty.getValue(), heightProperty.getValue()));
|
heightProperty.addListener(e-> {
|
||||||
|
if (heightProperty.getValue() > MIN_CHART_WIDTH) {
|
||||||
|
chartPanel.setBounds(10, 10, chartPanel.getWidth(),
|
||||||
|
heightProperty.getValue() - 60);
|
||||||
|
} else {heightProperty.setValue(MIN_CHART_WIDTH);}
|
||||||
|
});
|
||||||
|
|
||||||
widthProperty.setValue(width);
|
widthProperty.setValue(width);
|
||||||
chartPanel.setBounds(10, 10, width, 400);
|
chartPanel.setBounds(10, 10, width, 400);
|
||||||
|
@ -25,7 +25,6 @@ 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
|
||||||
@ -48,12 +47,15 @@ public class WorkingDaysWindow extends TWindow {
|
|||||||
private final int chartWidth;
|
private final int chartWidth;
|
||||||
private final JButton decreaseStart;
|
private final JButton decreaseStart;
|
||||||
private final JButton decreaseEnd;
|
private final JButton decreaseEnd;
|
||||||
|
private final TTabbedPane tp;
|
||||||
|
private final JComboBox years;
|
||||||
private ArrivalChart arrivalChart;
|
private ArrivalChart arrivalChart;
|
||||||
|
|
||||||
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;
|
private InvalidationListener invalidationWidthListener;
|
||||||
|
private InvalidationListener invalidationHeightListener;
|
||||||
|
|
||||||
public WorkingDaysWindow(WorkingDayRepositoryApi workingDayRepository,
|
public WorkingDaysWindow(WorkingDayRepositoryApi workingDayRepository,
|
||||||
Time time, double target) {
|
Time time, double target) {
|
||||||
@ -73,7 +75,7 @@ public class WorkingDaysWindow extends TWindow {
|
|||||||
for (int i = 0; i < yearsList.size(); i++) {
|
for (int i = 0; i < yearsList.size(); i++) {
|
||||||
yearsArray[i] = yearsList.get(i);
|
yearsArray[i] = yearsList.get(i);
|
||||||
}
|
}
|
||||||
JComboBox years = new JComboBox(yearsArray);
|
this.years = new JComboBox(yearsArray);
|
||||||
years.setMaximumSize(new Dimension(150, 25));
|
years.setMaximumSize(new Dimension(150, 25));
|
||||||
|
|
||||||
years.setSelectedItem(String.valueOf(year));
|
years.setSelectedItem(String.valueOf(year));
|
||||||
@ -240,6 +242,8 @@ public class WorkingDaysWindow extends TWindow {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.tp = new TTabbedPane();
|
||||||
|
|
||||||
//
|
//
|
||||||
ArrivalChartData acd =
|
ArrivalChartData acd =
|
||||||
new ArrivalChartData(new String[] {}, new double[] {}, 7d,
|
new ArrivalChartData(new String[] {}, new double[] {}, 7d,
|
||||||
@ -249,26 +253,31 @@ public class WorkingDaysWindow extends TWindow {
|
|||||||
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
|
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
this.chartWidth = (int) screen.getWidth() - 60;
|
this.chartWidth = (int) screen.getWidth() - 60;
|
||||||
arrivalChart.setBounds(SwingUtils.MARGIN,
|
arrivalChart.setBounds(SwingUtils.MARGIN,
|
||||||
years.getY() + years.getHeight() + SwingUtils.MARGIN,
|
SwingUtils.MARGIN,
|
||||||
(int) (screen.getWidth() - 50),
|
(int) (screen.getWidth() - 50),
|
||||||
400);
|
400);
|
||||||
add(arrivalChart);
|
|
||||||
//
|
//
|
||||||
this.scrollPane
|
this.scrollPane
|
||||||
= new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
|
= new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
|
||||||
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
|
tp.setBounds(years.getX(), years.getY() + years.getHeight() + SwingUtils.MARGIN, (int) (screen.getWidth() - 50),
|
||||||
|
(int) (screen.getHeight() - 200));
|
||||||
|
tp.add(scrollPane, "Table");
|
||||||
|
tp.add(arrivalChart, "Chart");
|
||||||
|
add(tp);
|
||||||
|
|
||||||
scrollPane.setBounds(SwingUtils.MARGIN,
|
scrollPane.setBounds(SwingUtils.MARGIN,
|
||||||
arrivalChart.getY() + arrivalChart.getHeight()
|
SwingUtils.MARGIN,
|
||||||
+ SwingUtils.MARGIN,
|
|
||||||
(int) (screen.getWidth() - 50),
|
(int) (screen.getWidth() - 50),
|
||||||
300);
|
300);
|
||||||
add(scrollPane);
|
|
||||||
scrollPane.setViewportView(table);
|
scrollPane.setViewportView(table);
|
||||||
|
|
||||||
loadYear(year, time);
|
loadYear(year, time);
|
||||||
|
|
||||||
setSize(scrollPane.getWidth() + 3 * SwingUtils.MARGIN,
|
setSize(tp.getWidth() + 3 * SwingUtils.MARGIN,
|
||||||
scrollPane.getY() + scrollPane.getHeight()
|
tp.getY() + tp.getHeight()
|
||||||
+ 4 * SwingUtils.MARGIN);
|
+ 4 * SwingUtils.MARGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,12 +474,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-> {
|
this.widthProperty.addListener(e-> {
|
||||||
if(/*this.widthProperty.getValue() % 10 == 0 && */this.widthProperty.getValue() > 100) {
|
if(/*this.widthProperty.getValue() % 10 == 0 && */this.widthProperty.getValue() > 400) {
|
||||||
scrollPane.setBounds(SwingUtils.MARGIN,
|
tp.setBounds(years.getX(), years.getY() + years.getHeight() + SwingUtils.MARGIN, this.widthProperty.getValue() - 50,
|
||||||
arrivalChart.getY() + arrivalChart.getHeight()
|
tp.getHeight());
|
||||||
+ SwingUtils.MARGIN,
|
}
|
||||||
(this.widthProperty.getValue() - 50),
|
});
|
||||||
scrollPane.getHeight());
|
this.heightProperty.addListener(e-> {
|
||||||
|
if(/*this.widthProperty.getValue() % 10 == 0 && */this.heightProperty.getValue() > 400) {
|
||||||
|
tp.setBounds(years.getX(), years.getY() + years.getHeight() + SwingUtils.MARGIN, tp.getWidth(),
|
||||||
|
getHeight() - years.getHeight() * 4);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//table.setDefaultRenderer(Object.class, new ColorRenderer());
|
//table.setDefaultRenderer(Object.class, new ColorRenderer());
|
||||||
@ -485,22 +497,25 @@ public class WorkingDaysWindow extends TWindow {
|
|||||||
|
|
||||||
public void reloadChart(ArrivalChartData newArrivalChartData) {
|
public void reloadChart(ArrivalChartData newArrivalChartData) {
|
||||||
Rectangle bounds = this.arrivalChart.getBounds();
|
Rectangle bounds = this.arrivalChart.getBounds();
|
||||||
remove(this.arrivalChart);
|
String currentTitle = tp.getTitleAt(tp.getSelectedIndex());
|
||||||
|
this.tp.remove(this.arrivalChart);
|
||||||
this.arrivalChart = new ArrivalChart(newArrivalChartData, chartWidth);
|
this.arrivalChart = new ArrivalChart(newArrivalChartData, chartWidth);
|
||||||
if(this.invalidationChartWidthListener != null) {
|
if(this.invalidationWidthListener != null) {
|
||||||
this.widthProperty.removeListener(invalidationChartWidthListener);
|
this.widthProperty.removeListener(invalidationWidthListener);
|
||||||
this.invalidationChartWidthListener = null;
|
this.invalidationWidthListener = null;
|
||||||
}
|
}
|
||||||
this.invalidationChartWidthListener =
|
if(this.invalidationHeightListener != null) {
|
||||||
new InvalidationListener() {
|
this.heightProperty.removeListener(invalidationHeightListener);
|
||||||
@Override
|
this.invalidationHeightListener = null;
|
||||||
public void invalidated(Property property) {
|
}
|
||||||
arrivalChart.widthProperty.setValue(getWidth() - 30);
|
this.invalidationWidthListener = property -> arrivalChart.widthProperty.setValue(tp.getWidth() - 10);
|
||||||
}
|
this.invalidationHeightListener = property -> arrivalChart.heightProperty.setValue(tp.getHeight() - 10);
|
||||||
};
|
this.widthProperty.addListener(invalidationWidthListener);
|
||||||
this.widthProperty.addListener(invalidationChartWidthListener);
|
this.heightProperty.addListener(invalidationHeightListener);
|
||||||
add(arrivalChart);
|
|
||||||
arrivalChart.setBounds(bounds);
|
arrivalChart.setBounds(bounds);
|
||||||
add(arrivalChart);
|
tp.add(arrivalChart, "Chart");
|
||||||
|
tp.switchTo(currentTitle);
|
||||||
|
arrivalChart.widthProperty.setValue(tp.getWidth() - 30);
|
||||||
|
arrivalChart.heightProperty.setValue(tp.getHeight() - 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user