// 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: D:\Sergey\JavaPM\ver10\Plota\PanelA.java import java.awt.*; class PanelA extends Panel implements Runnable { public void start() { if(m_Runner == null) { m_Runner = new Thread(this); m_Runner.start(); } } public void stop() { if(m_Runner != null) { m_Runner.stop(); m_Runner = null; } } public void setInvalid() { m_bInvalid = true; } PanelA(Plota applet) { m_pszX = 500; m_pszY = 300; m_bInvalid = true; m_Font = new Font("Helvetica", 1, 12); m_FM = getFontMetrics(m_Font); m_Xmax = 400D; m_Ymax = 200D; m_strMessage = "my message"; m_Applet = applet; setFont(m_Font); m_bInvalid = true; } public Dimension preferredSize() { return new Dimension(m_pszX, m_pszY); } public void run() { do { if(m_bInvalid) { repaint(); m_bInvalid = true; } try { Thread.sleep(500L); } catch(InterruptedException interruptedexception) { } } while(true); } public float round (float x){ if (Math.abs((float)Math.round((double)10000*x)/10000-x)<=.001) x= (float)Math.round((double)10000*x)/10000; return x; } public void update(Graphics g) { Dimension d = size(); if(m_ImageOff == null || d.width != m_DimOff.width || d.height != m_DimOff.height) { m_ImageOff = createImage(d.width, d.height); m_DimOff = d; m_GraphOff = m_ImageOff.getGraphics(); } paint(m_GraphOff); g.drawImage(m_ImageOff, 0, 0, null); } public void paint(Graphics g) { Dimension d = size(); int border = Rect3D.drawRect(g, 0, 0, d.width - 1, d.height - 1); g.setColor(Color.red); m_strMessage = m_Applet.m_strMessage; m_NumPoints = m_Applet.m_NumPoints; m_Xmin = m_Applet.m_Xmin; m_Xmax = m_Applet.m_Xmax; m_Ymin = m_Applet.m_Ymin; m_Ymax = m_Applet.m_Ymax; m_X = m_Applet.m_X; m_Y = m_Applet.m_Y; String sy0 = Float.toString(round((float)m_Ymin)); String sy1 = Float.toString(round((float)m_Ymax)); String sx0 = Float.toString(round((float)m_Xmin)); String sx1 = Float.toString(round((float)m_Xmax)); int wsx0 = m_FM.stringWidth(sx0); int wsx1 = m_FM.stringWidth(sx1); int wsy0 = m_FM.stringWidth(sy0); int wsy1 = m_FM.stringWidth(sy1); int h = m_FM.getHeight(); int xl = border + Math.max(wsy0, wsy1) + 6; int xr = d.width - border - 3; int yt = border + 3; int yb = d.height - border - (3 * h) / 2; double coefX = (double)(xr - xl) / (m_Xmax - m_Xmin); double coefY = (double)(yt - yb) / (m_Ymax - m_Ymin); int i = 0; int x = 0; int y = 0; int x0 = 0; int y0 = 0; g.setColor(Color.black); g.drawLine(xl, yb, xl, yt); double del = (double)(yt - yb) / 5D; i = 1; if (!(xAxisImg.equals(null))) g.drawImage(xAxisImg,xr-xAxisImg.getWidth(this),yb,this); if (!(yAxisImg.equals(null))) g.drawImage(yAxisImg,5,5,this); g.setColor(Color.yellow); do { y = yb + (int)((double)i * del); // g.drawLine(xl, y, xl + 10, y); g.drawLine(xl, y, 640, y); } while(++i <= 10); g.drawLine(xl, yb, xr, yb); del = (double)(xr - xl) / 10D; i = 1; g.setColor(Color.yellow); do { x = xl + (int)((double)i * del); // g.drawLine(x, yb, x, yb - 7); g.drawLine(x, yb, x, 0); } while(++i <= 10); g.setFont(m_Font); g.setColor(Color.black); g.drawString(sy0, xl - wsy0 - 3, yb); g.drawString(sy1, xl - wsy1 - 3, yt + h); g.drawString(sx0, xl, yb + h); g.drawString(sx1, xr - wsx1, yb + h); for(i = 0; i < m_NumPoints; i++) { x = xl + (int)(coefX * (m_X[i] - m_Xmin)); y = yb + (int)(coefY * (m_Y[i] - m_Ymin)); if(x < xl) x = xl; else if(x > xr) x = xr; if(y > yb) y = yb; else if(y < yt) y = yt; if(i != 0) g.drawLine(x0, y0, x, y); x0 = x; y0 = y; } } private Plota m_Applet; private Thread m_Runner; private int m_pszX; private int m_pszY; private boolean m_bInvalid; private Image m_ImageOff; private Dimension m_DimOff; private Graphics m_GraphOff; private Font m_Font; private FontMetrics m_FM; private int m_NumPoints; private double m_X[]; private double m_Y[]; private double m_Xmin; private double m_Xmax; private double m_Ymin; private double m_Ymax; public Image xAxisImg, yAxisImg; private String m_strMessage; }