|
|
@ -85,6 +85,26 @@ public class CB_Controller { |
|
|
myCb.deleteRecipe(name); |
|
|
myCb.deleteRecipe(name); |
|
|
myCb.closeConnection(); |
|
|
myCb.closeConnection(); |
|
|
} |
|
|
} |
|
|
|
|
|
public ImageIcon resizeImage(File f) { |
|
|
|
|
|
//File file = f; |
|
|
|
|
|
ImageIcon iconLogo=null; |
|
|
|
|
|
try { |
|
|
|
|
|
BufferedImage srcImg = ImageIO.read(f); |
|
|
|
|
|
int w = (int)Math.ceil(srcImg.getWidth()/(double)srcImg.getHeight()*theView.getImgRecipe().getHeight()); |
|
|
|
|
|
|
|
|
|
|
|
BufferedImage resizedImg = new BufferedImage(w, theView.getImgRecipe().getHeight(), BufferedImage.TYPE_INT_ARGB); |
|
|
|
|
|
Graphics2D g2 = resizedImg.createGraphics(); |
|
|
|
|
|
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
|
|
|
|
|
g2.drawImage(srcImg, 0, 0, w, theView.getImgRecipe().getHeight(), null); |
|
|
|
|
|
g2.dispose(); |
|
|
|
|
|
iconLogo = new ImageIcon(resizedImg); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e1) { |
|
|
|
|
|
e1.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
return iconLogo; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
class AddListener implements ActionListener{ |
|
|
class AddListener implements ActionListener{ |
|
|
|
|
|
|
|
|
@ -143,23 +163,7 @@ public class CB_Controller { |
|
|
JFileChooser fcImg = theView.getFileChooser(); |
|
|
JFileChooser fcImg = theView.getFileChooser(); |
|
|
int returnVal = fcImg.showOpenDialog(theView); |
|
|
int returnVal = fcImg.showOpenDialog(theView); |
|
|
if (returnVal == JFileChooser.APPROVE_OPTION) { |
|
|
if (returnVal == JFileChooser.APPROVE_OPTION) { |
|
|
File file = fcImg.getSelectedFile(); |
|
|
|
|
|
try { |
|
|
|
|
|
BufferedImage srcImg = ImageIO.read(file); |
|
|
|
|
|
JLabel imgRecipe = theView.getImgRecipe(); |
|
|
|
|
|
int w = (int)Math.ceil(srcImg.getWidth()/(double)srcImg.getHeight()*imgRecipe.getHeight()); |
|
|
|
|
|
|
|
|
|
|
|
BufferedImage resizedImg = new BufferedImage(w, imgRecipe.getHeight(), BufferedImage.TYPE_INT_ARGB); |
|
|
|
|
|
Graphics2D g2 = resizedImg.createGraphics(); |
|
|
|
|
|
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
|
|
|
|
|
g2.drawImage(srcImg, 0, 0, w, imgRecipe.getHeight(), null); |
|
|
|
|
|
g2.dispose(); |
|
|
|
|
|
ImageIcon iconLogo = new ImageIcon(resizedImg); |
|
|
|
|
|
imgRecipe.setIcon(iconLogo); |
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e1) { |
|
|
|
|
|
e1.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
theView.getImgRecipe().setIcon(resizeImage(fcImg.getSelectedFile())); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
catch(NumberFormatException ex){ |
|
|
catch(NumberFormatException ex){ |
|
|
|