Skip to content

Commit

Permalink
Background image working
Browse files Browse the repository at this point in the history
  • Loading branch information
ckl67 committed Jan 10, 2017
1 parent 2d0e71f commit 65bcb0e
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 42 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
13 changes: 6 additions & 7 deletions src/pacp/Enthalpy.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.List;
import java.util.Scanner;


public class Enthalpy {

/* ----------------
Expand Down Expand Up @@ -56,7 +55,7 @@ public class Enthalpy {
/* -----------------------------
Enthalpy Image
* ----------------------------*/
private EnthalpyImage enthalpyImage;
private EnthalpyBkgdImg enthalpyBkgdImg;

// -------------------------------------------------------
// CONSTRUCTOR
Expand Down Expand Up @@ -89,7 +88,7 @@ public Enthalpy() {
/* -----------------------------
Enthalpy Image
* ----------------------------*/
enthalpyImage = new EnthalpyImage();
enthalpyBkgdImg = new EnthalpyBkgdImg();

}

Expand Down Expand Up @@ -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;
}


Expand Down
5 changes: 2 additions & 3 deletions src/pacp/EnthalpyImage.java → src/pacp/EnthalpyBkgdImg.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import javax.imageio.ImageIO;

public class EnthalpyImage {
public class EnthalpyBkgdImg {

private String enthalpyImageFile; // Enthalpy image file (.png)

Expand All @@ -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");
Expand Down Expand Up @@ -97,7 +97,6 @@ public void setEnthalpyImageFile(String enthalpyImageFile) {
this.enthalpyImageFile = enthalpyImageFile;
}


public double getmHOrigine() {
return mOrigineH.x;
}
Expand Down
30 changes: 15 additions & 15 deletions src/pacp/WinConfEnthalpy.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class WinConfEnthalpy {
private JTextField textFieldPFinal;
private JTextField txtFieldTemperaturePressionFile;

private EnthalpyImage enthalpyImage;
private EnthalpyBkgdImg enthalpyBkgdImg;
// -------------------------------------------------------
// CONSTRUCTOR
// -------------------------------------------------------
Expand All @@ -57,7 +57,7 @@ public class WinConfEnthalpy {
*/
public WinConfEnthalpy(Enthalpy vconfEnthalpy) {
enthalpy = vconfEnthalpy;
enthalpyImage = enthalpy.getEnthalpyImage();
enthalpyBkgdImg = enthalpy.getEnthalpyImage();
initialize();
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -177,16 +177,16 @@ 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);

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);
Expand Down Expand Up @@ -215,16 +215,16 @@ 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);

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);
Expand All @@ -238,16 +238,16 @@ 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);

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);
Expand Down
37 changes: 25 additions & 12 deletions src/pacp/WinEnthalpy.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class WinEnthalpy {
* INSTANCE VAR
*/
private Enthalpy enthalpy;
private EnthalpyImage enthalpyImage;
private EnthalpyBkgdImg enthalpyBkgdImg;

private JFrame frame;
private JLabel lblMouseCoordinate;
Expand Down Expand Up @@ -112,7 +112,7 @@ public void run() {
*/
public WinEnthalpy(Enthalpy vconfEnthalpy) {
enthalpy = vconfEnthalpy;
enthalpyImage = enthalpy.getEnthalpyImage();
enthalpyBkgdImg = enthalpy.getEnthalpyImage();
enthalpy.loadPTFile();
enthalpy.loadSatFile();
initialize();
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -644,7 +658,6 @@ else if ((y>=30) && (y<50) )

}


// -------------------------------------------------------
// EVENT LISTNER
// -------------------------------------------------------
Expand All @@ -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) {
Expand Down

0 comments on commit 65bcb0e

Please sign in to comment.