Guest User

Untitled

a guest
Jul 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. import java.awt.Graphics;
  2. import java.awt.Graphics2D;
  3. import java.awt.RenderingHints;
  4. import java.awt.image.BufferedImage;
  5. import java.io.File;
  6. import java.io.IOException;
  7. import javax.imageio.ImageIO;
  8. import javax.swing.JPanel;
  9. import rektify.MathUtils.Sector;
  10.  
  11.  
  12. public class ImagePanel extends JPanel{
  13.  
  14. private BufferedImage image;
  15. private Sector sector;
  16. private boolean isBilinear = false;
  17.  
  18. public void loadFromFile(File file) {
  19. try {
  20. image = ImageIO.read(file);
  21. } catch (IOException ex) {
  22. // ...
  23. }
  24. }
  25.  
  26. public void setIsBilinear(boolean state) {
  27. this.isBilinear = state;
  28. }
  29.  
  30.  
  31. @Override
  32. public void paintComponent(Graphics g) {
  33. Graphics2D g2d = (Graphics2D)g;
  34. if (image != null) {
  35. // g.drawImage(image, 0, 0, null);
  36. if (this.isBilinear)
  37. g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
  38. g2d.drawImage(image, 0, 0, this.getWidth(), this.getHeight(), 0, 0, image.getWidth(), image.getHeight(), null);
  39. }
  40. if (sector != null) {
  41.  
  42. }
  43.  
  44. }
  45.  
  46. void setSector(Sector sector) {
  47. this.sector = sector;
  48. }
  49.  
  50. public BufferedImage getImage() {
  51. return image;
  52. }
  53.  
  54. public void setImage(BufferedImage im) {
  55. this.image = im;
  56. this.repaint();
  57. }
  58.  
  59.  
  60.  
  61. }
Add Comment
Please, Sign In to add comment