From 65bcb0ec8157357fff8880a466d09718b1e1a7b1 Mon Sep 17 00:00:00 2001 From: ckl67 Date: Tue, 10 Jan 2017 15:14:02 +0100 Subject: [PATCH] Background image working --- README.md | 9 ++--- src/pacp/Enthalpy.java | 13 +++---- ...nthalpyImage.java => EnthalpyBkgdImg.java} | 5 +-- src/pacp/WinConfEnthalpy.java | 30 +++++++-------- src/pacp/WinEnthalpy.java | 37 +++++++++++++------ 5 files changed, 52 insertions(+), 42 deletions(-) rename src/pacp/{EnthalpyImage.java => EnthalpyBkgdImg.java} (98%) diff --git a/README.md b/README.md index c6524ab..4df44b3 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,10 @@ Outil pour Pompe Définition ------------- -Outil qui permet de vérifier les données contructeur (COP) et de calculer le COP de votre pompe à  chaleur à  partir de vos mesures. -Programme écrit en Java. +Outil qui permet de vérifier les données contructeur (COP) et de calculer le COP de votre pompe à  chaleur à  partir de vos mesures. (Programme écrit en Java) - Chaine Développement ------------------------ + Chaine de Développement +-------------------------- La chaine d'outil pour le développement est la suivante: Environnement de développement intégré / (Integrated Development Environment) @@ -19,7 +18,7 @@ Environnement de d Langage de modélisation unifié, Unified Modeling Language (UML) intégré à  Eclipse ObjectAid http://www.objectaid.com/installation - Uniquement les modules ne nécessitant (pas de licences). + Installer uniquement les modules ne nécessitant pas de licences. Java http://www.oracle.com/technetwork/java/javase/downloads/index.html diff --git a/src/pacp/Enthalpy.java b/src/pacp/Enthalpy.java index 08b6f37..1c35215 100644 --- a/src/pacp/Enthalpy.java +++ b/src/pacp/Enthalpy.java @@ -25,7 +25,6 @@ import java.util.List; import java.util.Scanner; - public class Enthalpy { /* ---------------- @@ -56,7 +55,7 @@ public class Enthalpy { /* ----------------------------- Enthalpy Image * ----------------------------*/ - private EnthalpyImage enthalpyImage; + private EnthalpyBkgdImg enthalpyBkgdImg; // ------------------------------------------------------- // CONSTRUCTOR @@ -89,7 +88,7 @@ public Enthalpy() { /* ----------------------------- Enthalpy Image * ----------------------------*/ - enthalpyImage = new EnthalpyImage(); + enthalpyBkgdImg = new EnthalpyBkgdImg(); } @@ -460,12 +459,12 @@ public double gethSatMax() { return hSatMax; } - public EnthalpyImage getEnthalpyImage() { - return enthalpyImage; + public EnthalpyBkgdImg getEnthalpyImage() { + return enthalpyBkgdImg; } - public void setEnthalpyImage(EnthalpyImage enthalpyImage) { - this.enthalpyImage = enthalpyImage; + public void setEnthalpyImage(EnthalpyBkgdImg enthalpyBkgdImg) { + this.enthalpyBkgdImg = enthalpyBkgdImg; } diff --git a/src/pacp/EnthalpyImage.java b/src/pacp/EnthalpyBkgdImg.java similarity index 98% rename from src/pacp/EnthalpyImage.java rename to src/pacp/EnthalpyBkgdImg.java index d100b4e..d75d2b2 100644 --- a/src/pacp/EnthalpyImage.java +++ b/src/pacp/EnthalpyBkgdImg.java @@ -26,7 +26,7 @@ import javax.imageio.ImageIO; -public class EnthalpyImage { +public class EnthalpyBkgdImg { private String enthalpyImageFile; // Enthalpy image file (.png) @@ -44,7 +44,7 @@ public class EnthalpyImage { // CONSTRUCTOR // ------------------------------------------------------- - public EnthalpyImage() { + public EnthalpyBkgdImg() { // Image setEnthalpyImageFile("D:/Users/kluges1/workspace/pac-tool/ressources/R22/R22 couleur A4.png"); @@ -97,7 +97,6 @@ public void setEnthalpyImageFile(String enthalpyImageFile) { this.enthalpyImageFile = enthalpyImageFile; } - public double getmHOrigine() { return mOrigineH.x; } diff --git a/src/pacp/WinConfEnthalpy.java b/src/pacp/WinConfEnthalpy.java index c8f1790..7cf7366 100644 --- a/src/pacp/WinConfEnthalpy.java +++ b/src/pacp/WinConfEnthalpy.java @@ -48,7 +48,7 @@ public class WinConfEnthalpy { private JTextField textFieldPFinal; private JTextField txtFieldTemperaturePressionFile; - private EnthalpyImage enthalpyImage; + private EnthalpyBkgdImg enthalpyBkgdImg; // ------------------------------------------------------- // CONSTRUCTOR // ------------------------------------------------------- @@ -57,7 +57,7 @@ public class WinConfEnthalpy { */ public WinConfEnthalpy(Enthalpy vconfEnthalpy) { enthalpy = vconfEnthalpy; - enthalpyImage = enthalpy.getEnthalpyImage(); + enthalpyBkgdImg = enthalpy.getEnthalpyImage(); initialize(); } @@ -103,7 +103,7 @@ public void actionPerformed(ActionEvent arg0) { //System.out.println("You chose to open this file: " + chooser.getSelectedFile().getAbsolutePath()); String imagepath=chooser.getSelectedFile().getAbsolutePath(); textFieldEnthalpyFilePath.setText(imagepath); - enthalpyImage.setEnthalpyImageFile(textFieldEnthalpyFilePath.getText()); + enthalpyBkgdImg.setEnthalpyImageFile(textFieldEnthalpyFilePath.getText()); try { if (WinEnthalpy.panelEnthalpyDrawArea.isVisible() ) { WinEnthalpy.panelEnthalpyDrawArea.clean(); @@ -153,7 +153,7 @@ public void actionPerformed(ActionEvent e) { textFieldHOrigine = new JTextField(); textFieldHOrigine.setHorizontalAlignment(SwingConstants.RIGHT); - textFieldHOrigine.setText(String.valueOf(enthalpyImage.getiHOrigine())); + textFieldHOrigine.setText(String.valueOf(enthalpyBkgdImg.getiHOrigine())); textFieldHOrigine.setToolTipText(""); textFieldHOrigine.setBounds(104, 23, 86, 20); panel_1.add(textFieldHOrigine); @@ -162,8 +162,8 @@ public void actionPerformed(ActionEvent e) { JButton btnHOrigine = new JButton("Centrer"); btnHOrigine.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { - enthalpyImage.setlocateOrigineH(true); - enthalpyImage.setiHOrigine(Integer.valueOf(textFieldHOrigine.getText())); + enthalpyBkgdImg.setlocateOrigineH(true); + enthalpyBkgdImg.setiHOrigine(Integer.valueOf(textFieldHOrigine.getText())); } }); btnHOrigine.setBounds(104, 53, 89, 23); @@ -177,7 +177,7 @@ public void actionPerformed(ActionEvent arg0) { textFieldHFinal = new JTextField(); textFieldHFinal.setHorizontalAlignment(SwingConstants.RIGHT); - textFieldHFinal.setText(String.valueOf(enthalpyImage.getiHFinal())); + textFieldHFinal.setText(String.valueOf(enthalpyBkgdImg.getiHFinal())); textFieldHFinal.setBounds(368, 23, 86, 20); panel_1.add(textFieldHFinal); textFieldHFinal.setColumns(10); @@ -185,8 +185,8 @@ public void actionPerformed(ActionEvent arg0) { JButton btnHFinal = new JButton("Centrer"); btnHFinal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - enthalpyImage.setlocateFinalH(true); - enthalpyImage.setiHFinal(Integer.valueOf(textFieldHFinal.getText())); + enthalpyBkgdImg.setlocateFinalH(true); + enthalpyBkgdImg.setiHFinal(Integer.valueOf(textFieldHFinal.getText())); } }); btnHFinal.setBounds(365, 53, 89, 23); @@ -215,7 +215,7 @@ public void actionPerformed(ActionEvent e) { textFieldPOrigine = new JTextField(); textFieldPOrigine.setHorizontalAlignment(SwingConstants.RIGHT); - textFieldPOrigine.setText(String.valueOf(enthalpyImage.getiPOrigine())); + textFieldPOrigine.setText(String.valueOf(enthalpyBkgdImg.getiPOrigine())); textFieldPOrigine.setBounds(104, 21, 86, 20); panel_2.add(textFieldPOrigine); textFieldPOrigine.setColumns(10); @@ -223,8 +223,8 @@ public void actionPerformed(ActionEvent e) { JButton btnPOrigine = new JButton("Centrer"); btnPOrigine.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { - enthalpyImage.setlocateOrigineP(true); - enthalpyImage.setiPOrigine(Integer.valueOf(textFieldPOrigine.getText())); + enthalpyBkgdImg.setlocateOrigineP(true); + enthalpyBkgdImg.setiPOrigine(Integer.valueOf(textFieldPOrigine.getText())); } }); btnPOrigine.setBounds(104, 52, 89, 23); @@ -238,7 +238,7 @@ public void actionPerformed(ActionEvent arg0) { textFieldPFinal = new JTextField(); textFieldPFinal.setHorizontalAlignment(SwingConstants.RIGHT); - textFieldPFinal.setText(String.valueOf(enthalpyImage.getiPFinal())); + textFieldPFinal.setText(String.valueOf(enthalpyBkgdImg.getiPFinal())); textFieldPFinal.setBounds(370, 19, 86, 20); panel_2.add(textFieldPFinal); textFieldPFinal.setColumns(10); @@ -246,8 +246,8 @@ public void actionPerformed(ActionEvent arg0) { JButton btnPFinal = new JButton("Centrer"); btnPFinal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - enthalpyImage.setlocateFinalP(true); - enthalpyImage.setiPFinal(Integer.valueOf(textFieldPFinal.getText())); + enthalpyBkgdImg.setlocateFinalP(true); + enthalpyBkgdImg.setiPFinal(Integer.valueOf(textFieldPFinal.getText())); } }); btnPFinal.setBounds(367, 49, 89, 23); diff --git a/src/pacp/WinEnthalpy.java b/src/pacp/WinEnthalpy.java index 96ef401..e8ee71c 100644 --- a/src/pacp/WinEnthalpy.java +++ b/src/pacp/WinEnthalpy.java @@ -71,7 +71,7 @@ public class WinEnthalpy { * INSTANCE VAR */ private Enthalpy enthalpy; - private EnthalpyImage enthalpyImage; + private EnthalpyBkgdImg enthalpyBkgdImg; private JFrame frame; private JLabel lblMouseCoordinate; @@ -112,7 +112,7 @@ public void run() { */ public WinEnthalpy(Enthalpy vconfEnthalpy) { enthalpy = vconfEnthalpy; - enthalpyImage = enthalpy.getEnthalpyImage(); + enthalpyBkgdImg = enthalpy.getEnthalpyImage(); enthalpy.loadPTFile(); enthalpy.loadSatFile(); initialize(); @@ -350,7 +350,7 @@ public class PanelEnthalpie extends JPanel implements MouseWheelListener, MouseL * ----------------------------*/ private Enthalpy enthalpy; - private BufferedImage imgEnthBg; // Image Background + private BufferedImage enthBkgdImg; // Image Background private float imageAlphaBlure=0; private Point offset = new Point(0,0); // Supplementary Offset @@ -364,7 +364,7 @@ public class PanelEnthalpie extends JPanel implements MouseWheelListener, MouseL private double xmax = 520; // Maximum of the range of value displayed. // Pressure - private double ymin = 0.1; // Minimum of the range of Pressure value + private double ymin = 0.5; // Minimum of the range of Pressure value private double ymax = 60; // Maximum of the range of Pressure value. private double log10_ymin = Math.log10(ymin); // Minimum of the range of values displayed. --> Math.log10(0.01) = -1 private double log10_ymax = Math.log10(ymax); // Maximum of the range of value displayed. --> Math.log10(100) = 2 @@ -387,7 +387,7 @@ public class PanelEnthalpie extends JPanel implements MouseWheelListener, MouseL // ------------------------------------------------------- public PanelEnthalpie(Enthalpy vconfEnthalpy) { enthalpy = vconfEnthalpy; - imgEnthBg = enthalpy.getEnthalpyImage().openEnthalpyImageFile(); + enthBkgdImg = enthalpy.getEnthalpyImage().openEnthalpyImageFile(); setBackground(Color.WHITE); addMouseWheelListener(this); @@ -497,18 +497,32 @@ public void paintComponent(Graphics g) { // ----------------------------------- // Image + // Background --> Panel // ----------------------------------- - g2.drawImage(imgEnthBg, - 140,2,540,-4, - 140,0,imgEnthBg.getWidth(),imgEnthBg.getHeight(), + int refCurveH1x = 140; + int refCurveH2x = 520; + int refCurveP1y = 0; //Log(1) + int refCurveP2y = 2; //Log(100) + + //Zone to consider: Outside of the zone nothing --> be large !! + int iBgH1x = 153; + int iBgH2x = 2791; + int iBgP1y = 1472; + int iBgP2y = 83; + + g2.drawImage(enthBkgdImg, + refCurveH1x,refCurveP2y,refCurveH2x,-refCurveP1y, + iBgH1x, iBgP2y, iBgH2x, iBgP1y, null); - + + + float[] scales = { 1f, 1f, 1f, imageAlphaBlure }; float[] offsets = new float[4]; RescaleOp rop = new RescaleOp(scales, offsets, null); /* Draw the image, applying the filter */ - g2.drawImage(imgEnthBg, rop, -1, -10); + g2.drawImage(enthBkgdImg, rop, -1, -10); //g2.setTransform(origTransform); // Restore transform @@ -644,7 +658,6 @@ else if ((y>=30) && (y<50) ) } - // ------------------------------------------------------- // EVENT LISTNER // ------------------------------------------------------- @@ -654,7 +667,7 @@ public void mousePressed(MouseEvent evt) { int xMouse = evt.getX(); int yMouse = evt.getY(); - if (enthalpyImage.islocateOrigineH()) { + if (enthalpyBkgdImg.islocateOrigineH()) { } if ((evt.getModifiers() & InputEvent.BUTTON2_MASK) != 0) {