import java.applet.Applet; import java.awt.*; import java.awt.event.*; import javax.swing.*; /* */ public class ExeInput extends Applet implements MouseListener ,MouseMotionListener { private int width = 300; private int height = 300; private Point before; private boolean checkPressed = false; private ArrayImage img; Mametan mame = null; private Label edgeL; public void init() { img =new ArrayImage( createImage(280,280),280,280); addMouseListener(this); addMouseMotionListener(this); before = null; // setLayout(null); edgeL = new Label("端の数:"); edgeL.setLocation(0,0); add(edgeL); } public void mouseDragged(MouseEvent e) { int x= 0; int y = 0; int xx = 0; int yy = 0; int width=280; int height=280; if(checkPressed == true && before != null) { if(e.getX()<280 && e.getY()<280 && e.getX()>0 && e.getY() >0) { img.drawLine((int)before.getX(),(int)before.getY(),e.getX(),e.getY()); img.baseXY(e.getX(),e.getY(),true); img.imageXY(e.getX(),e.getY()); x = (int)before.getX(); y = (int)before.getY(); xx = (int)e.getX(); yy = (int)e.getX(); before = e.getPoint(); if(x >xx){int temp = x;x =xx; xx= temp;} if(y >yy){int temp = y;y =yy; yy= temp;} repaint(x-5,y-5,xx-x+10,yy-y+10); } } } public void mouseMoved(MouseEvent e) { } public void update(Graphics g) { paint(g); } public void paint(Graphics g) { g.drawImage(img.createImage(),0,0,this); if(mame ==null){return;} for(int i= 0;null != mame.getRoot(i+1);i++) { // System.out.println("sdf"); g.setColor(new Color(100,10,200)); g.drawLine( (int)mame.getRoot(i).getX(), (int)mame.getRoot(i).getY(), (int)mame.getRoot(i+1).getX(), (int)mame.getRoot(i+1).getY()); } } public void mouseClicked(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mousePressed(MouseEvent e){checkPressed = true; before = e.getPoint();} public void mouseReleased(MouseEvent e) { checkPressed = false;before = null; Pattern pat = new Pattern(img.getArray(),img.Width(),img.Height()); int a = pat.searchEdge(); edgeL.setText("端の数:"+a); mame = new Mametan(img,pat.putEdge()); mame.startDeconvolution(); repaint(); } }