1 package edu.berkeley.slipway.gui;
3 import com.atmel.fpslic.*;
4 import edu.berkeley.slipway.*;
5 import static com.atmel.fpslic.FpslicConstants.*;
6 import static com.atmel.fpslic.FpslicUtil.*;
7 import edu.berkeley.slipway.*;
9 import java.awt.geom.*;
10 import java.awt.event.*;
11 import java.awt.color.*;
12 import org.ibex.util.*;
16 import static edu.berkeley.slipway.gui.GuiConstants.*;
18 public class Gui3 extends Canvas implements MouseWheelListener, MouseMotionListener {
25 private int magnify = 0;
26 private GuiCell[][] ca = new GuiCell[128][];
27 private FtdiBoard ftdiboard;
28 public Gui3(Fpslic at40k, FtdiBoard drone) {
29 this(at40k, drone, 24, 24);
31 public Gui3(Fpslic at40k, FtdiBoard drone, int width, int height) {
36 for(int i=0; i<ca.length; i++)
37 ca[i] = new GuiCell[128];
38 for(int x=0; x<width; x++)
39 for(int y=0; y<height; y++)
40 ca[x][y] = new GuiCell(at40k.cell(x, y));
41 addMouseWheelListener(this);
42 addMouseMotionListener(this);
45 public void mouseWheelMoved(MouseWheelEvent e) {
46 magnify -= e.getWheelRotation();
50 public void _paint(Graphics2D g_) {
52 //g_.setStroke(new BasicStroke((float)1.0/SIZE));
53 g_.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
54 g_.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
56 AffineTransform at = new AffineTransform();
57 at.translate(getWidth()/2, getHeight()/2);
65 } else if (magnify < 0) {
69 at.scale(-1.0/mag, -1.0/mag);
71 at.translate(-(width*SIZE)/4, -(height*SIZE)/4);
73 for(int x=0; x<ca.length; x++)
74 for(int y=0; y<ca[x].length; y++) {
75 R r = new R(SIZE*x, SIZE*y,
76 SIZE*(x+1), SIZE*(y+1));
77 if (ca[x][y] != null) {
78 g.color(GuiCell.BORDER_COLOR);
83 P mouse = new P(mousex, mousey);
84 mouse = mouse.inverseTransform(at);
85 for(int x=0; x<ca.length; x++)
86 for(int y=0; y<ca[x].length; y++) {
87 R r = new R(SIZE*x, SIZE*y,
88 SIZE*(x+1), SIZE*(y+1));
90 ca[x][y].draw(g, r, r.contains(mouse));
94 public void paint(Graphics g) { _paint((Graphics2D)g); }
95 public void mouseDragged(MouseEvent e) { mouseMoved(e); }
96 public void mouseMoved(MouseEvent e) {