From 50b93f87a37e7f44b0db626bb370e574c5f9f47a Mon Sep 17 00:00:00 2001 From: Nikola-Mircic Date: Fri, 26 Jan 2024 18:37:22 +0100 Subject: [PATCH 1/6] Stats button --- src/efakturaplus/gui/MainPanel.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/efakturaplus/gui/MainPanel.java b/src/efakturaplus/gui/MainPanel.java index ee96f85..535049a 100644 --- a/src/efakturaplus/gui/MainPanel.java +++ b/src/efakturaplus/gui/MainPanel.java @@ -37,6 +37,7 @@ public class MainPanel extends JPanel { private JPanel navigator; private JButton purchaseBtn; private JButton salesBtn; + private JButton statsBtn; private InvoiceList purchaseIl; private InvoiceList salesIl; @@ -68,10 +69,12 @@ public MainPanel(Window parent) { private void createNavigator() { Image purchaseBtnImg = null; Image salesBtnImg = null; + Image statsButtonImg = null; Image logoutImg = null; try { purchaseBtnImg = ImageIO.read(new File("icons/invoice-purchase.png")); salesBtnImg = ImageIO.read(new File("icons/invoice-sales.png")); + statsButtonImg = ImageIO.read(new File("icons/stats.png")); logoutImg = ImageIO.read(new File("icons/logout.png")); //this.purchaseBtn.add(new JLabel("Sales")); @@ -99,9 +102,8 @@ public void actionPerformed(ActionEvent e) { navigator.add(purchaseBtn, gbc); - gbc.gridy = 1; - + gbc.gridy = 1; this.salesBtn = makeButton(salesBtnImg, "Sales", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -111,6 +113,16 @@ public void actionPerformed(ActionEvent e) { navigator.add(salesBtn, gbc); + gbc.gridy = 2; + this.statsBtn = makeButton(statsButtonImg, "Statistics", new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dataPanelLayout.show(dataPanel, "PURCHASE"); + } + }); + + navigator.add(statsBtn, gbc); + JButton logout = makeButton(logoutImg, "Log out", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -118,7 +130,7 @@ public void actionPerformed(ActionEvent e) { } }); - gbc.gridy = 2; + gbc.gridy = 3; gbc.anchor = GridBagConstraints.LAST_LINE_END; gbc.weighty = 1; From d5f7041df8821dadca1857c0d29cf9e0c92fc8ec Mon Sep 17 00:00:00 2001 From: Nikola-Mircic Date: Fri, 26 Jan 2024 18:48:11 +0100 Subject: [PATCH 2/6] Moved API key reading to KeyPanel class --- src/efakturaplus/App.java | 27 ----------------- src/efakturaplus/gui/KeyPanel.java | 47 ++++++++++++++++++------------ 2 files changed, 29 insertions(+), 45 deletions(-) diff --git a/src/efakturaplus/App.java b/src/efakturaplus/App.java index 6ac6551..8a839c6 100644 --- a/src/efakturaplus/App.java +++ b/src/efakturaplus/App.java @@ -1,37 +1,10 @@ package efakturaplus; -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileReader; -import java.io.InputStreamReader; - import efakturaplus.gui.Window; -import efakturaplus.models.User; public class App { public static void main(String[] args) { - try { - File f = new File("user.enc"); - - if(f.exists()) { - FileInputStream fis = new FileInputStream(f); - BufferedReader br = new BufferedReader(new FileReader(f)); - StringBuilder sb = new StringBuilder(); - String line; - while((line = br.readLine()) == null) { - sb.append(line); - } - - User.API_KEY = sb.toString(); - } - - }catch(Exception e){ - System.out.println("Error reading a file!"); - }; - @SuppressWarnings("unused") Window w = new Window(); } diff --git a/src/efakturaplus/gui/KeyPanel.java b/src/efakturaplus/gui/KeyPanel.java index 0bd122f..03ba5fb 100644 --- a/src/efakturaplus/gui/KeyPanel.java +++ b/src/efakturaplus/gui/KeyPanel.java @@ -4,9 +4,6 @@ import java.awt.event.*; import java.io.*; import java.security.AlgorithmParameters; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.security.spec.InvalidKeySpecException; @@ -15,47 +12,57 @@ import javax.crypto.*; import javax.crypto.spec.*; -import sun.misc.*; - -import java.util.Arrays; -import java.util.Base64; - import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JLabel; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JTextField; -import javax.swing.border.Border; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import ch.randelshofer.util.ArrayUtil; import efakturaplus.models.User; public class KeyPanel extends JPanel { private static final long serialVersionUID = 1L; - private String password; - private byte[] iv; - JLabel keyLabel, passLabel, passLabel2; JTextField keyInput; JPasswordField passInput, passInput2; private Window parent; - private boolean registeredUser; - public KeyPanel(Window parent, int width, int height) { this.parent = parent; this.setSize(width, height); this.setLayout(null); + loadAPIKey(); addComponents(width, height); } + + private void loadAPIKey() { + try { + File f = new File("user.enc"); + + if(f.exists()) { + FileInputStream fis = new FileInputStream(f); + BufferedReader br = new BufferedReader(new FileReader(f)); + StringBuilder sb = new StringBuilder(); + String line; + while((line = br.readLine()) == null) { + sb.append(line); + } + + User.API_KEY = sb.toString(); + + br.close(); + fis.close(); + } + + }catch(Exception e){ + System.out.println("Error reading a file!"); + }; + } private void addComponents(int width, int height) { @@ -200,6 +207,8 @@ private void encryptData() throws NoSuchAlgorithmException, InvalidKeySpecExcept fos.write(iv); fos.write(salt); fos.write(ciphertext); + + fos.close(); } catch (Exception e) { e.printStackTrace(); } @@ -230,6 +239,8 @@ private String decryptData() { String plaintext = new String(cis.readAllBytes()); content = plaintext; + + cis.close(); }catch(Exception e) { e.printStackTrace(); From 840fbc6aaaf14d85f0ba47f656654869d9a81d1a Mon Sep 17 00:00:00 2001 From: Nikola-Mircic Date: Fri, 26 Jan 2024 19:15:37 +0100 Subject: [PATCH 3/6] Plot --- src/efakturaplus/gui/MainPanel.java | 7 +- src/efakturaplus/gui/StatisticsPanel.java | 97 +++++++++++++++++++++++ 2 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 src/efakturaplus/gui/StatisticsPanel.java diff --git a/src/efakturaplus/gui/MainPanel.java b/src/efakturaplus/gui/MainPanel.java index 535049a..a233a59 100644 --- a/src/efakturaplus/gui/MainPanel.java +++ b/src/efakturaplus/gui/MainPanel.java @@ -41,6 +41,8 @@ public class MainPanel extends JPanel { private InvoiceList purchaseIl; private InvoiceList salesIl; + + private StatisticsPanel statsPanel; public MainPanel(Window parent) { this.parent = parent; @@ -58,6 +60,9 @@ public MainPanel(Window parent) { salesIl = new InvoiceList(); dataPanel.add(salesIl, "SALES"); + statsPanel = new StatisticsPanel(); + dataPanel.add(statsPanel, "STATS"); + dataPanelLayout.show(dataPanel, "PURCHASE"); this.add(dataPanel, BorderLayout.CENTER); @@ -117,7 +122,7 @@ public void actionPerformed(ActionEvent e) { this.statsBtn = makeButton(statsButtonImg, "Statistics", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - dataPanelLayout.show(dataPanel, "PURCHASE"); + dataPanelLayout.show(dataPanel, "STATS"); } }); diff --git a/src/efakturaplus/gui/StatisticsPanel.java b/src/efakturaplus/gui/StatisticsPanel.java new file mode 100644 index 0000000..99d0596 --- /dev/null +++ b/src/efakturaplus/gui/StatisticsPanel.java @@ -0,0 +1,97 @@ +package efakturaplus.gui; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Random; + +import javax.swing.JPanel; + +public class StatisticsPanel extends JPanel { + + private static final int MAX_SCORE = 20; + private static final int PREF_W = 800; + private static final int PREF_H = 650; + private static final int BORDER_GAP = 30; + private static final Color GRAPH_COLOR = Color.green; + private static final Color GRAPH_POINT_COLOR = new Color(150, 50, 50, 180); + private static final Stroke GRAPH_STROKE = new BasicStroke(3f); + private static final int GRAPH_POINT_WIDTH = 12; + private static final int Y_HATCH_CNT = 10; + + private ArrayList scores; + + public StatisticsPanel() { + scores = new ArrayList(); + + Random rand = new Random(); + + for(int i=0;i<20;++i) { + scores.add(Math.sqrt(i)*3); + } + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + Graphics2D g2 = (Graphics2D)g; + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + double xScale = ((double) getWidth() - 2 * BORDER_GAP) / (scores.size()); + double yScale = ((double) getHeight() - 2 * BORDER_GAP) / (MAX_SCORE); + + ArrayList graphPoints = new ArrayList(); + for (int i = 0; i < scores.size(); i++) { + int x1 = (int) (i * xScale + BORDER_GAP); + int y1 = (int) ((MAX_SCORE - scores.get(i)) * yScale + BORDER_GAP); + graphPoints.add(new Point(x1, y1)); + } + + // create x and y axes + g2.drawLine(BORDER_GAP, getHeight() - BORDER_GAP, BORDER_GAP, BORDER_GAP); + g2.drawLine(BORDER_GAP, getHeight() - BORDER_GAP, getWidth() - BORDER_GAP, getHeight() - BORDER_GAP); + + // create hatch marks for y axis. + for (int i = 0; i < Y_HATCH_CNT; i++) { + int x0 = BORDER_GAP; + int x1 = GRAPH_POINT_WIDTH + BORDER_GAP; + int y0 = getHeight() - (((i + 1) * (getHeight() - BORDER_GAP * 2)) / Y_HATCH_CNT + BORDER_GAP); + int y1 = y0; + g2.drawLine(x0, y0, x1, y1); + } + + // and for x axis + for (int i = 0; i < scores.size() - 1; i++) { + int x0 = (i + 1) * (getWidth() - BORDER_GAP * 2) / (scores.size() - 1) + BORDER_GAP; + int x1 = x0; + int y0 = getHeight() - BORDER_GAP; + int y1 = y0 - GRAPH_POINT_WIDTH; + g2.drawLine(x0, y0, x1, y1); + } + + Stroke oldStroke = g2.getStroke(); + g2.setColor(GRAPH_COLOR); + g2.setStroke(GRAPH_STROKE); + for (int i = 0; i < graphPoints.size() - 1; i++) { + int x1 = graphPoints.get(i).x; + int y1 = graphPoints.get(i).y; + int x2 = graphPoints.get(i + 1).x; + int y2 = graphPoints.get(i + 1).y; + g2.drawLine(x1, y1, x2, y2); + } + + g2.setStroke(oldStroke); + g2.setColor(GRAPH_POINT_COLOR); + for (int i = 0; i < graphPoints.size(); i++) { + int x = graphPoints.get(i).x - GRAPH_POINT_WIDTH / 2; + int y = graphPoints.get(i).y - GRAPH_POINT_WIDTH / 2;; + int ovalW = GRAPH_POINT_WIDTH; + int ovalH = GRAPH_POINT_WIDTH; + g2.fillOval(x, y, ovalW, ovalH); + } + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(PREF_W, PREF_H); + } +} From d776999ce1837a5fbecb5141687c038541778077 Mon Sep 17 00:00:00 2001 From: Nikola-Mircic Date: Thu, 1 Feb 2024 23:49:05 +0100 Subject: [PATCH 4/6] Scalin plot data --- src/efakturaplus/gui/InvoiceList.java | 4 +++ src/efakturaplus/gui/StatisticsPanel.java | 32 +++++++++++++++++++++-- src/efakturaplus/util/EFakturaUtil.java | 2 +- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/efakturaplus/gui/InvoiceList.java b/src/efakturaplus/gui/InvoiceList.java index 5bc3f81..7c471a8 100644 --- a/src/efakturaplus/gui/InvoiceList.java +++ b/src/efakturaplus/gui/InvoiceList.java @@ -26,6 +26,7 @@ import javax.swing.border.Border; import efakturaplus.models.Invoice; +import efakturaplus.models.InvoiceStatus; import efakturaplus.models.InvoiceType; import efakturaplus.util.EFakturaUtil; import efakturaplus.util.PrintColor; @@ -350,6 +351,9 @@ private void deselect(InvoiceListItem item) { } private void approveOrReject(boolean approve) { + if(approve) + this.invoice.status = InvoiceStatus.Approved; + EFakturaUtil util = EFakturaUtil.getInstance(); util.approveOrReject(this.invoice, approve); diff --git a/src/efakturaplus/gui/StatisticsPanel.java b/src/efakturaplus/gui/StatisticsPanel.java index 99d0596..e0aa3bd 100644 --- a/src/efakturaplus/gui/StatisticsPanel.java +++ b/src/efakturaplus/gui/StatisticsPanel.java @@ -2,10 +2,14 @@ import java.awt.*; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.Random; import javax.swing.JPanel; +import ch.randelshofer.util.ArrayUtil; + public class StatisticsPanel extends JPanel { private static final int MAX_SCORE = 20; @@ -25,9 +29,33 @@ public StatisticsPanel() { Random rand = new Random(); - for(int i=0;i<20;++i) { - scores.add(Math.sqrt(i)*3); + for(int i=1;i<20;++i) { + scores.add(1.0*i*i); + } + + scaleValues(scores); + } + + private void scaleValues(ArrayList values) { + double minimum = Collections.min(values); + double maximum = Collections.max(values); + + // TODO: Scaling + + if(minimum == maximum) { + minimum = 1.0; + maximum = 1.0; + } + + for(int i = 0; i Date: Fri, 2 Feb 2024 01:37:04 +0100 Subject: [PATCH 5/6] Ploting invoice data --- src/efakturaplus/gui/StatisticsPanel.java | 257 +++++++++++++--------- src/efakturaplus/models/Invoice.java | 6 + src/efakturaplus/util/Pair.java | 16 ++ 3 files changed, 181 insertions(+), 98 deletions(-) create mode 100644 src/efakturaplus/util/Pair.java diff --git a/src/efakturaplus/gui/StatisticsPanel.java b/src/efakturaplus/gui/StatisticsPanel.java index e0aa3bd..7c29a15 100644 --- a/src/efakturaplus/gui/StatisticsPanel.java +++ b/src/efakturaplus/gui/StatisticsPanel.java @@ -3,123 +3,184 @@ import java.awt.*; import java.util.ArrayList; import java.util.Arrays; +import java.util.Calendar; import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.List; import java.util.Random; +import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import javax.swing.JPanel; import ch.randelshofer.util.ArrayUtil; +import efakturaplus.models.Invoice; +import efakturaplus.util.Pair; public class StatisticsPanel extends JPanel { - private static final int MAX_SCORE = 20; - private static final int PREF_W = 800; - private static final int PREF_H = 650; - private static final int BORDER_GAP = 30; - private static final Color GRAPH_COLOR = Color.green; - private static final Color GRAPH_POINT_COLOR = new Color(150, 50, 50, 180); - private static final Stroke GRAPH_STROKE = new BasicStroke(3f); - private static final int GRAPH_POINT_WIDTH = 12; - private static final int Y_HATCH_CNT = 10; - - private ArrayList scores; + private static final int PREF_W = 800; + private static final int PREF_H = 650; + private static final int BORDER_GAP = 30; + private static final Color GRAPH_COLOR = new Color(0.0f, 1.0f, 0.1f, 0.2f); + private static final Color GRAPH_POINT_COLOR = new Color(150, 50, 50, 180); + private static final Stroke GRAPH_STROKE = new BasicStroke(3f); + private static final int GRAPH_POINT_WIDTH = 5; + private ArrayList invoices; + + private Plot plot; + public StatisticsPanel() { - scores = new ArrayList(); - - Random rand = new Random(); + this.invoices = new ArrayList(); - for(int i=1;i<20;++i) { - scores.add(1.0*i*i); - } - - scaleValues(scores); + this.plot = new Plot(new ArrayList(), new ArrayList()); } - private void scaleValues(ArrayList values) { - double minimum = Collections.min(values); - double maximum = Collections.max(values); - - // TODO: Scaling + /*public StatisticsPanel(ArrayList invoices) { + this.invoices = invoices; + + ArrayList dates = (ArrayList) invoices.parallelStream().map(Invoice::getDate).toList(); + ArrayList values = (ArrayList) invoices.parallelStream().map(Invoice::getAmount).toList(); - if(minimum == maximum) { - minimum = 1.0; - maximum = 1.0; + this.plot = new Plot(dates, values); + }*/ + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + Graphics2D g2 = (Graphics2D) g; + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + double DATA_WIDTH = getWidth() - 2 * BORDER_GAP; + double DATA_HEIGHT = getHeight() - 2 * BORDER_GAP; + + ArrayList graphPoints = new ArrayList(); + for (int i = 0; i < plot.points.size(); i++) { + + int x1 = BORDER_GAP + (int)(plot.points.get(i).first * DATA_WIDTH); + int y1 = BORDER_GAP + (int)(DATA_HEIGHT - plot.points.get(i).second * DATA_HEIGHT); + + graphPoints.add(new Point(x1, y1)); } - - for(int i = 0; i graphPoints = new ArrayList(); - for (int i = 0; i < scores.size(); i++) { - int x1 = (int) (i * xScale + BORDER_GAP); - int y1 = (int) ((MAX_SCORE - scores.get(i)) * yScale + BORDER_GAP); - graphPoints.add(new Point(x1, y1)); - } - - // create x and y axes - g2.drawLine(BORDER_GAP, getHeight() - BORDER_GAP, BORDER_GAP, BORDER_GAP); - g2.drawLine(BORDER_GAP, getHeight() - BORDER_GAP, getWidth() - BORDER_GAP, getHeight() - BORDER_GAP); - - // create hatch marks for y axis. - for (int i = 0; i < Y_HATCH_CNT; i++) { - int x0 = BORDER_GAP; - int x1 = GRAPH_POINT_WIDTH + BORDER_GAP; - int y0 = getHeight() - (((i + 1) * (getHeight() - BORDER_GAP * 2)) / Y_HATCH_CNT + BORDER_GAP); - int y1 = y0; - g2.drawLine(x0, y0, x1, y1); - } - - // and for x axis - for (int i = 0; i < scores.size() - 1; i++) { - int x0 = (i + 1) * (getWidth() - BORDER_GAP * 2) / (scores.size() - 1) + BORDER_GAP; - int x1 = x0; - int y0 = getHeight() - BORDER_GAP; - int y1 = y0 - GRAPH_POINT_WIDTH; - g2.drawLine(x0, y0, x1, y1); - } - - Stroke oldStroke = g2.getStroke(); - g2.setColor(GRAPH_COLOR); - g2.setStroke(GRAPH_STROKE); - for (int i = 0; i < graphPoints.size() - 1; i++) { - int x1 = graphPoints.get(i).x; - int y1 = graphPoints.get(i).y; - int x2 = graphPoints.get(i + 1).x; - int y2 = graphPoints.get(i + 1).y; - g2.drawLine(x1, y1, x2, y2); - } - - g2.setStroke(oldStroke); - g2.setColor(GRAPH_POINT_COLOR); - for (int i = 0; i < graphPoints.size(); i++) { - int x = graphPoints.get(i).x - GRAPH_POINT_WIDTH / 2; - int y = graphPoints.get(i).y - GRAPH_POINT_WIDTH / 2;; - int ovalW = GRAPH_POINT_WIDTH; - int ovalH = GRAPH_POINT_WIDTH; - g2.fillOval(x, y, ovalW, ovalH); - } - } + public Dimension getPreferredSize() { + return new Dimension(PREF_W, PREF_H); + } + + public void addInvoice(Invoice invoice) { + this.invoices.add(invoice); + + this.plot.dates.add(invoice.deliveryDate); + this.plot.values.add(invoice.payableAmount); + } - @Override - public Dimension getPreferredSize() { - return new Dimension(PREF_W, PREF_H); - } + public void updatePlot() { + this.plot.makePoints(); + repaint(); + } +} + +class Plot { + public ArrayList dates; + public ArrayList values; + + public ArrayList> points; + + public Plot(ArrayList dates, ArrayList values) { + this.dates = dates; + this.values = values; + + makePoints(); + } + + public void makePoints() { + this.points = new ArrayList>(); + + if(dates.size() == 0) + return; + + Calendar c = Calendar.getInstance(); + + c.setTime(new Date()); + + c.add(Calendar.MONTH, -1); + + Date refDate = c.getTime(); + + double maxValue = Collections.max(values); + double minValue = Collections.min(values); + + long dateDiff = (new Date()).getTime() - refDate.getTime(); + dateDiff = TimeUnit.DAYS.convert(dateDiff, TimeUnit.MILLISECONDS); + + double valuesDiff = maxValue - minValue; + + for (int i = 0; i < dates.size(); ++i) { + long diff = dates.get(i).getTime() - refDate.getTime(); + diff = TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS); + + points.add(new Pair(1.0 * diff / dateDiff, values.get(i) / valuesDiff)); + } + + points.sort(new Comparator>() { + @Override + public int compare(Pair o1, Pair o2) { + return (int) (o1.first*1000 - o2.first*1000); + } + }); + + System.out.println(points.toString()); + } } diff --git a/src/efakturaplus/models/Invoice.java b/src/efakturaplus/models/Invoice.java index 7e84240..9171abd 100644 --- a/src/efakturaplus/models/Invoice.java +++ b/src/efakturaplus/models/Invoice.java @@ -227,5 +227,11 @@ public String getDateString() { return format.format(new Date()); } + public static Date getDate(Invoice inv) { + return inv.deliveryDate; + } + public static double getAmount(Invoice inv) { + return inv.payableAmount; + } } diff --git a/src/efakturaplus/util/Pair.java b/src/efakturaplus/util/Pair.java new file mode 100644 index 0000000..12b082f --- /dev/null +++ b/src/efakturaplus/util/Pair.java @@ -0,0 +1,16 @@ +package efakturaplus.util; + +public class Pair { + public T1 first; + public T2 second; + + public Pair(T1 first, T2 second) { + this.first = first; + this.second = second; + } + + @Override + public String toString() { + return "("+first+", "+second+")"; + } +} From a4e3441999e63caac81c3b63a7479b1299bda73e Mon Sep 17 00:00:00 2001 From: Nikola-Mircic Date: Sun, 4 Feb 2024 01:21:28 +0100 Subject: [PATCH 6/6] Total amount spent on purchases --- src/efakturaplus/gui/StatisticsPanel.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/efakturaplus/gui/StatisticsPanel.java b/src/efakturaplus/gui/StatisticsPanel.java index 7c29a15..d987ede 100644 --- a/src/efakturaplus/gui/StatisticsPanel.java +++ b/src/efakturaplus/gui/StatisticsPanel.java @@ -97,9 +97,9 @@ protected void paintComponent(Graphics g) { int y2 = graphPoints.get(i + 1).y; g2.drawLine(x1, y1, x2, y2); - g2.fillPolygon(new int[] {x1, x1, x2, x2}, + /*g2.fillPolygon(new int[] {x1, x1, x2, x2}, new int[] {y1, BORDER_GAP+(int)DATA_HEIGHT, BORDER_GAP+(int)DATA_HEIGHT, y2}, - 4); + 4);*/ } g2.setStroke(oldStroke); @@ -158,20 +158,25 @@ public void makePoints() { c.add(Calendar.MONTH, -1); Date refDate = c.getTime(); - + + Collections.reverse(dates); + Collections.reverse(values); + + for(int i=1; i(1.0 * diff / dateDiff, values.get(i) / valuesDiff)); + points.add(new Pair(1.0 * diff / dateDiff, values.get(i) / maxValue)); } points.sort(new Comparator>() {