// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://kpdus.tripod.com/jad.html // Decompiler options: packimports(3) // Source File Name: GraphPanel.java import java.awt.*; import java.io.PrintStream; import javax.swing.JPanel; import javax.swing.border.LineBorder; public class GraphPanel extends JPanel implements Runnable { public GraphPanel() { paused = false; p1 = 1.0D; p2 = 1.0D; p3 = 1.0D; p4 = 1.0D; p5 = 1.0D; p6 = 0.0D; p7 = 0.0D; firstTime = true; initComponents(); delay = 10; frame = 0.0D; frameholder = 0.0D; timetodraw = false; addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { formMousePressed(evt); } public void mouseReleased(java.awt.event.MouseEvent evt) { formMouseReleased(evt); } }); } private void formMouseReleased(java.awt.event.MouseEvent evt) { if ((evt.getButton()==1)&&(evt.getClickCount()<2)&&(!evt.getPoint().equals(pressed))){ this.repaint(); pressed=null; } } private void formMousePressed(java.awt.event.MouseEvent evt) { this.repaint(); System.out.println(evt.getModifiers()); if (/*(evt.getButton()==1)&&*/(evt.getClickCount()>=2)) { if (evt.isControlDown()) {zoomXIn();System.out.println("Zooming x in");} else if (evt.isShiftDown()) {zoomYIn();System.out.println("Zooming y in");} else zoomIn(); } else if (evt.getButton()==3) { System.out.println(evt.getModifiers()); if (evt.isControlDown()) {zoomXOut();System.out.println("ZOOMING X OUT");} else if (evt.isShiftDown()) {zoomYOut();System.out.println("ZOOMING Y OUT");} else zoomOut(); } else if (evt.getButton()==2) {restoreDefaults();repaint();} //else {pressed=evt.getPoint();System.out.println("mouse pressed");} } public void restoreDefaults() { // offsets/scales width = getWidth(); height = getHeight(); xOffset = width / 2; xScale = -xOffset / xmin; yOffset = height/2.0; yScale = -yOffset / ymax; } public void GetDelay(int appdelay) { delay = appdelay; } public void GetParam() { tmin = 0.0D; tmax = 1000D; tstep = p5; frameholder = 0.0D; frame = frameholder; Drawer(); } public void SetParam(double Ip1, double Ip2, double Ip3, double Ip4, double Ip5, double Ip6, double Ip7) { p1 = Ip1; p2 = Ip2; p3 = Ip3; p4 = Ip4; p5 = Ip5; p6 = Ip6; p7 = Ip7; repaint(); } public void zoomIn(){ fromZoom=true; xmax=xmax/2; xmin=xmin/2; ymax=ymax/2; ymin=ymin/2; //finished applying transf repaint(); } public void zoomOut(){ fromZoom=true; xmax=xmax*2; xmin=xmin*2; ymax=ymax*2; ymin=ymin*2; repaint(); } public void zoomXIn(){ fromZoom=true; xmax=xmax/2; xmin=xmin/2; repaint(); } public void zoomXOut(){ fromZoom=true; xmax=xmax*2; xmin=xmin*2; repaint(); } public void zoomYIn(){ fromZoom=true; ymax=ymax/2; ymin=ymin/2; //finished applying transf repaint(); } public void zoomYOut(){ fromZoom=true; ymax=ymax*2; ymin=ymin*2; repaint(); } public void PauseMe(){ frameholder = frame; System.out.println("frame"+frame+"frameholder"+frameholder); animator.stop(); frame = 0; } public void StartMe(){ frame = frameholder; System.out.println("frame"+frame+"frameholder"+frameholder); animator = new Thread(this); animator.start(); } public void ClearMe() { getGraphics().clearRect(0, 0, getWidth(), getHeight()); frame = 0.0D; frameholder = 0.0D; animator.stop(); } public void start() { animator = new Thread(this); frame = 0.0D; } public void run() { if(firstTime) { ClearMe(); firstTime = false; } else { for(; Thread.currentThread() == animator; frame += tstep) { repaint(); try { Thread.sleep(delay); continue; } catch(InterruptedException e) { } break; } frame = tmin; } } public void stop() { animator = null; } private void initComponents() { setLayout(new BorderLayout()); setBackground(new Color(0, 255, 255)); setBorder(new LineBorder(new Color(0, 51, 204))); } public void paintComponent(Graphics gr) { if(timetodraw) { int width = getWidth(); int height = getHeight(); gr.setColor(Color.cyan); gr.fillRect(0, 0, width, height); gr.setColor(Color.black); xOffset = width / 2; xScale = -xOffset / xmin; yOffset = (double)height / 2D; yScale = -yOffset / ymax; gr.drawLine(width / 2, 0, width / 2, height); gr.drawLine(0, height / 2, width, height / 2); //x-axis lines for (int i=0; i<=10; i++) { if (i!=5){ gr.setColor(Color.yellow); gr.drawLine(i*width/10,0,i*width/10,height/2-3); gr.drawLine(i*width/10,height/2+3,i*width/10,height); gr.setColor(Color.black); gr.drawLine(i*width/10,height/2-3,i*width/10,height/2+3); } gr.drawString(Double.toString(xmin+(xmax-xmin)*i/10),i*width/10,height-3); } for (int i=1;i<=9;i++) { if (i!=5) { gr.setColor(Color.yellow); gr.drawLine(0,height/10*i+2,width/2-3,height/10*i+2); gr.drawLine(width/2+3,height/10*i+2,width,height/10*i+2); gr.setColor(Color.black); gr.drawLine(width/2-3,height/10*i+2,width/2+3,height/10*i+2); } if (ymax-(ymax-ymin)*4/10>=.5){ if (ymax-(ymax-ymin)*i/10<0) gr.drawString(Double.toString(ymax-(ymax-ymin)*i/10),width-22,height/10*i+5); else gr.drawString(Double.toString(ymax-(ymax-ymin)*i/10),width-18,height/10*i+5); } else { if (ymax-(ymax-ymin)*i/10<0) gr.drawString(Double.toString(ymax-(ymax-ymin)*i/10),width-28,height/10*i+5); else gr.drawString(Double.toString(ymax-(ymax-ymin)*i/10),width-24,height/10*i+5); } } Polygon grapher = new Polygon(); for(i = 0.0D; i < (double)width; i += di) { x = (i - xOffset) / xScale; double K = 6.2831853071795862D / p1; double omega = Math.sqrt(p4 * K * tanh(K * p3)); y = p2 * (Math.cos(K * x - omega * frame) + p6 * Math.cos((K * x + omega * frame) - p7)); j = yScale * y + yOffset; grapher.addPoint((int)i, (int)j); } gr.setColor(Color.red); gr.drawPolyline(grapher.xpoints, grapher.ypoints, grapher.npoints); grapher = new Polygon(); } } public static double sinh(double myAngle) { double sinh = (Math.exp(myAngle) - Math.exp(-myAngle)) / 2D; return sinh; } public static double cosh(double myAngle) { double cosh = (Math.exp(myAngle) + Math.exp(-myAngle)) / 2D; return cosh; } public static double tanh(double myAngle) { double tanh = sinh(myAngle) / cosh(myAngle); return tanh; } public void Drawer() { xmax = 10D; xmin = -10D; ymax = 5D; ymin = -ymax; frame = frameholder; node = xmin / 2D; crest = xmin; di = 0.10000000000000001D; grapher = new Polygon(); timetodraw = true; animator = new Thread(this); if(!paused) animator.start(); } protected double p1 = 1; protected double p2 = 1; protected double p3 = 1; protected double p4 = 1; protected double p5 = 1; protected double p6 = 0; protected double p7 = 0; private Point pressed; private int width, height; public boolean firstTime=true; public boolean fromZoom=false; private double w1; private double w2; private double A; private double tmin; private double tmax; private double tstep; private double xOffset; private double xScale; private double yOffset; private double yScale; private double i; private double j; private boolean timetodraw; public boolean paused; private double k1; private double k2; private double xmin; private double xmax; private double ymin; private double ymax; private double x; private double y; private double t; private double dx; private double di; private double espeed; private double pspeed; private double node; private double crest; private double frame; private double frameholder; private int delay; public Thread animator; Polygon grapher; }