import edu.berkeley.qfat.geom.*;
import edu.berkeley.qfat.geom.Point;
-public class InteractiveMeshViewer extends MeshViewer {
+public class InteractiveMeshViewer extends JPanel {
public Mesh tile;
public Mesh goal;
+
+ private MeshViewer mv;
+
public InteractiveMeshViewer(JFrame f) {
- super(f);
+ mv = new MeshViewer();
+ setLayout(new BorderLayout());
+ this.add(mv, BorderLayout.CENTER);
setTile(new Mesh(false));
setGoal(new Mesh(false));
}
+ public void repaint() {
+ if (mv != null) mv.repaint();
+ }
+
public void setTile(Mesh tile) {
- removeMesh(this.tile);
+ mv.removeMesh(this.tile);
this.tile = tile;
- addMesh(this.tile);
+ mv.addMesh(this.tile);
}
public void setGoal(Mesh goal) {
- removeMesh(this.goal);
+ mv.removeMesh(this.goal);
this.goal = goal;
goal.option_selectable = false;
goal.option_wireframe = true;
- addMesh(this.goal);
+ mv.addMesh(this.goal);
}
public synchronized void dump() {
public int vertss;
public void keyPressed(KeyEvent e) {
- super.keyPressed(e);
+ //super.keyPressed(e);
switch(e.getKeyCode()) {
case KeyEvent.VK_SPACE: breaks++; force = true; break;
case KeyEvent.VK_UP: temp = temp * 2; break;
import edu.berkeley.qfat.geom.*;
import edu.berkeley.qfat.geom.Point;
-public class MeshViewer implements GLEventListener, MouseListener, MouseMotionListener, KeyListener, MouseWheelListener {
+public class MeshViewer extends JPanel implements GLEventListener, MouseListener, MouseMotionListener, KeyListener, MouseWheelListener {
- Mesh.Vertex closest = null;
+ private float tz = 0;
+ private float anglex = 0;
+ private float angley = 0;
- private int mousex;
- private int mousey;
- private Matrix projection = null;
- private Point clickPoint = null;
- private GLCanvas glcanvas;
- private boolean updateVisibilities = false;
+ private Mesh.Vertex closest = null;
+ private int mousex;
+ private int mousey;
+ private Matrix projection = null;
+ private Point clickPoint = null;
+ private GLCanvas glcanvas;
+ private boolean updateVisibilities = false;
private HashSet<Mesh> meshes = new HashSet<Mesh>();
public synchronized void addMesh(Mesh m) { meshes.add(m); }
public synchronized void removeMesh(Mesh m) { meshes.remove(m); }
- float tz = 0;
- float anglex = 0;
- float angley = 0;
-
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { }
}
public synchronized final void display(GLAutoDrawable drawable) {
- glcanvas.setSize(glcanvas.getParent().getWidth(), glcanvas.getParent().getHeight() - 100);
+ glcanvas.setSize(glcanvas.getParent().getWidth(), glcanvas.getParent().getHeight());
GL gl = glcanvas.getGL();//drawable.getGL();
GLU glu = new GLU();
mousey = e.getY();
}
- public MeshViewer(JFrame f) {
+ public MeshViewer() {
glcanvas = new GLCanvas();
glcanvas.addGLEventListener(this);
- f.add(glcanvas, BorderLayout.CENTER);
+ setLayout(new BorderLayout());
+ this.add(glcanvas, BorderLayout.CENTER);
glcanvas.addMouseListener(this);
glcanvas.addMouseMotionListener(this);
glcanvas.addMouseWheelListener(this);
}
public void repaint() {
- glcanvas.repaint();
+ if (glcanvas != null) glcanvas.repaint();
}
}
\ No newline at end of file