001/** 002 * 003 */ 004package icy.painter; 005 006import icy.canvas.IcyCanvas; 007import icy.sequence.Sequence; 008import icy.type.point.Point5D; 009 010import java.awt.Graphics2D; 011import java.awt.event.KeyEvent; 012import java.awt.event.MouseEvent; 013 014/** 015 * This class is used to provide backward compatibility with the {@link Painter} interface. 016 * 017 * @author Stephane 018 */ 019@SuppressWarnings({"deprecation", "javadoc"}) 020public class OverlayWrapper extends Overlay 021{ 022 private final Painter painter; 023 024 public OverlayWrapper(Painter painter, String name) 025 { 026 super(name); 027 028 this.painter = painter; 029 } 030 031 public Painter getPainter() 032 { 033 return painter; 034 } 035 036 @Override 037 public void paint(Graphics2D g, Sequence sequence, IcyCanvas canvas) 038 { 039 painter.paint(g, sequence, canvas); 040 } 041 042 @Override 043 public void mouseClick(MouseEvent e, Point5D.Double imagePoint, IcyCanvas canvas) 044 { 045 if (imagePoint != null) 046 painter.mouseClick(e, imagePoint.toPoint2D(), canvas); 047 else 048 painter.mouseClick(e, null, canvas); 049 } 050 051 @Override 052 public void mousePressed(MouseEvent e, Point5D.Double imagePoint, IcyCanvas canvas) 053 { 054 if (imagePoint != null) 055 painter.mousePressed(e, imagePoint.toPoint2D(), canvas); 056 else 057 painter.mousePressed(e, null, canvas); 058 } 059 060 @Override 061 public void mouseReleased(MouseEvent e, Point5D.Double imagePoint, IcyCanvas canvas) 062 { 063 if (imagePoint != null) 064 painter.mouseReleased(e, imagePoint.toPoint2D(), canvas); 065 else 066 painter.mouseReleased(e, null, canvas); 067 } 068 069 @Override 070 public void mouseMove(MouseEvent e, Point5D.Double imagePoint, IcyCanvas canvas) 071 { 072 if (imagePoint != null) 073 painter.mouseMove(e, imagePoint.toPoint2D(), canvas); 074 else 075 painter.mouseMove(e, null, canvas); 076 } 077 078 @Override 079 public void mouseDrag(MouseEvent e, Point5D.Double imagePoint, IcyCanvas canvas) 080 { 081 if (imagePoint != null) 082 painter.mouseDrag(e, imagePoint.toPoint2D(), canvas); 083 else 084 painter.mouseDrag(e, null, canvas); 085 } 086 087 @Override 088 public void keyPressed(KeyEvent e, Point5D.Double imagePoint, IcyCanvas canvas) 089 { 090 if (imagePoint != null) 091 painter.keyPressed(e, imagePoint.toPoint2D(), canvas); 092 else 093 painter.keyPressed(e, null, canvas); 094 } 095 096 @Override 097 public void keyReleased(KeyEvent e, Point5D.Double imagePoint, IcyCanvas canvas) 098 { 099 if (imagePoint != null) 100 painter.keyReleased(e, imagePoint.toPoint2D(), canvas); 101 else 102 painter.keyReleased(e, null, canvas); 103 } 104}