package Current.plot.Dyadic; import Current.gui.*; import Current.basic.*; import Current.plot.Plotters.XDyadicPlotter; import Current.manage.*; import java.awt.*; import java.awt.event.*; /** (Made by Pat, modified by Rich) This is the super class that handles Rich's plots.*/ public class PlottingDyadic extends DBCanvas implements MouseListener { Manager M; ListenSquare L; // show squares ListenSquare FILTER; // controls the filtering of vertices IntegerSelector I1; // level of detail /** this class now does the real work */ XDyadicPlotter xdp; public PlottingDyadic(Manager M, XDyadicPlotter xdp) { this.M=M; this.xdp=xdp; L=new ListenSquare(7,4,42,16,Color.white); // toggle show squares L.on=xdp.show_squares; FILTER=new ListenSquare(58,4,15,15,new Color(80,130,255)); // controls filtering of vertices FILTER.on=xdp.filter; I1=new IntegerSelector(7,23,32,16,xdp.detail,1,25,1); this.addMouseListener(this); } /** Returns true if the plot can be run. This is useful for example * if the plot relies on C code which may or may not be available */ public boolean canRun(){ return true; } /** draw the buttons etc. */ public void paint(Graphics gfx){ Graphics2D g=(Graphics2D) gfx; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Color C1=new Color(250,0,255); L.render(g,C1,C1,Color.black); Color[] FC=new Color[3]; FC[0]=Color.black; FC[1]=new Color(120,0,120); FC[2]=new Color(255,0,255); FILTER.render(g,FC[FILTER.on]); g.setColor(Color.black); if(L.on==0) g.drawString("solid",10,16); if(L.on==1) g.drawString("seams",10,16); if(L.on==2) g.drawString("local",10,16); I1.render(g,C1,Color.black,Color.white); } /** Return smallest area that the drawing will take up * @return an integer array of length 2 */ public Dimension getPreferredSize() { return new Dimension(80,32); } /** These are taken from MouseListener */ public void mouseClicked(MouseEvent e){ e.consume(); Point X=new Point(); X.x=e.getX(); X.y=e.getY(); I1.modify(X); xdp.detail=I1.val; repaint(); } public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mousePressed(MouseEvent e){ e.consume(); Point X=new Point(); X.x=e.getX(); X.y=e.getY(); if(L.inside(X)==1) { ++L.on; if(L.on==3) L.on=0; xdp.show_squares=L.on; } if(FILTER.inside(X)==1) FILTER.on=(FILTER.on+1)%3; xdp.filter=FILTER.on; repaint(); } public void mouseReleased(MouseEvent e){} }