import java.awt.event.*; public class P88rdskaalagaIndikaator extends IndikaatoriKomponent implements MouseMotionListener{ double amplituud=3.14; public P88rdskaalagaIndikaator(double protsent){ super(protsent); addMouseMotionListener(this); } public void paintComponent(java.awt.Graphics g){ super.paintComponent(g); double nurk=(protsent)/100*amplituud-3.14; double r=Math.min(getHeight(), getWidth())/3; double keskx=getWidth()/2; double kesky=getHeight()/2; g.drawLine((int)keskx, (int)kesky, (int)(keskx+r*Math.cos(nurk)), (int)(kesky+r*Math.sin(nurk))); } public void mouseDragged(MouseEvent e){ double keskx=getWidth()/2; double kesky=getHeight()/2; double dx=e.getX()-keskx; double dy=e.getY()-kesky; double nurk=Math.atan2(dy, dx); int abiProtsent=(int)((nurk+3.14)/amplituud*100); if(abiProtsent<=100){ muudaProtsent(abiProtsent); } } public void mouseMoved(MouseEvent e){} }