/************************************************************** * You can modify the template of this file in the * directory ..\JCreator\Templates\Template_2\Project_Name.java * * You can also create your own project template by making a new * folder in the directory ..\JCreator\Template\. Use the other * templates as examples. * */ import java.awt.*; import java.applet.*; import java.awt.event.*; public class BDD extends Applet implements MouseListener, ActionListener, MouseMotionListener { Arbore Arb = new Arbore(); int coordX; int coordY; int transX; int transY; boolean apas,att; TextField nodeInput = new TextField("", 15) ; Button but1 = new Button("Calculeaza"); Button but2 = new Button("Centreaza"); Button but3 = new Button("Reset"); Label label = new Label("Expresia Logica : "); ExprLogic e; Panel p = new Panel(); public void init() { Graphics g; addMouseMotionListener(this); addMouseListener(this); add(label); add(nodeInput); add(but1); add(but2); add(but3); //this.add(p); // label.show(10,10); // p.show(10,10); but1.addActionListener(this); but2.addActionListener(this); but3.addActionListener(this); att = false; transX = 0; transY = 0; apas = false; int nrNod[] = new int[30]; Nod n; } public void paint(Graphics g) { setBackground(Color.black); //g.setColor(new Color(0,0,100)); //g.fillRect(0,0,getSize().width,getSize().height); if (Arb.getParinte()!=null) Arb.DesenArbore(g,Arb,15,transX,transY); g.setColor(new Color(200,200,100)); g.fillRect(0,0,getSize().width,50); } public void repaint(Graphics g) { } public void mouseDragged (MouseEvent e) { int pozX,pozY; pozX = e.getX(); pozY = e.getY(); if (apas == false) { coordX = e.getX(); coordY = e.getY(); apas =true; pozX = coordX; pozY = coordY; } else if (pozX !=coordX || pozY != coordY) {transX += pozX - coordX; transY += pozY - coordY; coordX = pozX; coordY = pozY; repaint(); } } public void mouseClicked(MouseEvent e) { } public void mouseMoved(MouseEvent e) {} public void mouseReleased(MouseEvent e) {apas = false;} public void mousePressed(MouseEvent e) {} public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) {} public void actionPerformed(ActionEvent ev) { String com = ev.getActionCommand(); String ex; if (com.equals("Calculeaza")) { ex = nodeInput.getText(); if (ex != "" ) { ExprLogic e = new ExprLogic(ex); Arb = new Arbore(); Arb=Arb.Creare(0,ex,1,Arb,e); Arb.desenBinar(Arb.getParinte(),Arb.nrNivel(Arb.getParinte()), getSize().width/2,getSize().height/4,6,12,80,1); // att = true; repaint(); } } if (com.equals("Centreaza")) { transX = 0; transY = 0; repaint(); } if (com.equals("Reset")) { Arb = new Arbore(); nodeInput.setText(""); repaint(); } } }