⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wire.java

📁 java 写的几个图型程序
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   Wire.java

package bfield;

import java.awt.*;
import sTools.Format;
import Pix3D;

// Referenced classes of package bfield:
//            FieldPanel

public class Wire
{

    String label;
    Font f;
    boolean noDrag;
    boolean noOptionDrag;
    boolean hideWire;
    boolean showInfo;
    protected boolean showF;
    FieldPanel p;
    int s;
    double current;
    Color color;
    double x;
    double y;
    double radius;
    int xPix;
    int yPix;
    int id;
    Format format;
    int angle;

    public Wire(FieldPanel fieldpanel, double d, double d1, double d2)
    {
    	angle=45;
        label = null;
        f = new Font("Helvetica", 1, 14);
        noDrag = true;
        noOptionDrag = true;
        hideWire = false;
        showInfo = false;
        showF = true;
        s = 5;
        current = 1.0D;
        color = Color.black;
        x = 0.0D;
        y = 0.0D;
        radius = 0.0D;
        xPix = 0;
        yPix = 0;
        id = 0;
        format = new Format("%-+6.2g");
        p = fieldpanel;
        x = d;
        y = d1;
        current = d2;
        if(d2 < 0.0D)
            color = Color.blue;
        else
        if(d2 > 0.0D)
            color = Color.red;
    }

    double[] getB(double ad[])
    {
        double d = (x - ad[0]) * (x - ad[0]) + (y - ad[1]) * (y - ad[1]);
        double d1 = (-current * (ad[1] - y)) / d;
        double d2 = (current * (ad[0] - x)) / d;
        ad[0] = d1;
        ad[1] = d2;
        return ad;
    }

    double getBx(double d, double d1)
    {
        return (-current * (d1 - y)) / ((x - d) * (x - d) + (y - d1) * (y - d1));
    }

    double getBy(double d, double d1)
    {
        return (current * (d - x)) / ((x - d) * (x - d) + (y - d1) * (y - d1));
    }

    final Color getColor()
    {
        return color;
    }

    final double getCurrent()
    {
        return current;
    }

    int getHotSpot(int i, int j)
    {
        return 0;
    }

    final int getID()
    {
        return id;
    }

    final String getLabel()
    {
        return label;
    }

    final double getMaxB()
    {
        double d = p.xFromPix(0);
        double d1 = p.xFromPix(s);
        double d2 = d - d1;
        if(d2 != 0.0D)
            return Math.abs(current / d2);
        else
            return 0.0D;
    }

    final double getRadius()
    {
        return radius;
    }

    final int getSize()
    {
        return s;
    }

    boolean isInsidePix(int i, int j)
    {
        if(noDrag)
            return false;
        else
            return Math.abs(xPix - i) < s + 1 && Math.abs(yPix - j) < s + 1;
    }

    final boolean isInsideWire(double d, double d1)
    {
        return isInsidePix(p.pixFromX(d), p.pixFromY(d1));
    }

    boolean isInsideWire(double d, double d1, int i)
    {
        if(i != 0)
            return false;
        else
            return isInsidePix(p.pixFromX(d), p.pixFromY(d1));
    }

    final boolean isShowF()
    {
        return showF;
    }

    public void paint(Graphics g)
    {
        if(hideWire)
            return;
       
        xPix = p.pixFromX(x);
        yPix = p.pixFromY(y);
        int x1;
        int y1;
        int r;
        x1 = Pix3D.changex(xPix,yPix,0,angle);
        y1 = Pix3D.changey(xPix,yPix,0,angle);
        r=Pix3D.changeR(2*s,angle);
        
        g.setColor(color);

        g.fillOval(x1 - s, y1 - (int)(s*1/2), 2 * s,r);
        int x2;
        int y2;
        int x3;
        int y3;
       
        
        x2=Pix3D.changex(xPix,yPix,50,angle);
       	y2=Pix3D.changey(xPix,yPix,50,angle);
       	x3=Pix3D.changex(xPix,yPix,-50,angle);
       	y3=Pix3D.changey(xPix,yPix,-50,angle);

       	g.drawLine(x2,y2,x3,y3);

        if(color==Color.blue)
        {

        	x2=Pix3D.changex(xPix-5,yPix,-15,angle);
        	y2=Pix3D.changey(xPix-5,yPix,-15,angle);
        	x3=Pix3D.changex(xPix+5,yPix,-15,angle);
        	y3=Pix3D.changey(xPix+5,yPix,-15,angle);
        	g.drawLine(x1,y1,x2,y2);
        	g.drawLine(x1,y1,x3,y3);
        }
        else
        {

        	x2=Pix3D.changex(xPix-5,yPix,15,angle);
        	y2=Pix3D.changey(xPix-5,yPix,15,angle);
        	x3=Pix3D.changex(xPix+5,yPix,15,angle);
        	y3=Pix3D.changey(xPix+5,yPix,15,angle);
        	g.drawLine(x1,y1,x2,y2);
        	g.drawLine(x1,y1,x3,y3);
        }
        
        if(label != null)
        {
            Font font = g.getFont();
            g.setFont(f);
            g.setColor(Color.white);
            g.drawString(label, xPix - 4, yPix + 5);
            g.setColor(Color.black);
            g.setFont(font);
        }
    }

    public void paintInfo(Graphics g, int i)
    {
        if(!showInfo && i == 0)
            return;
        g.setColor(Color.yellow);
        g.fillRect(xPix + 15, yPix - 8, 60, 15);
        g.setColor(Color.black);
        if(!noOptionDrag && Math.abs(i) == 1)
            g.drawString("R =" + format.form(radius), xPix + 20, yPix + 5);
        if(Math.abs(i) == 0)
            g.drawString("I =" + format.form(current), xPix + 20, yPix + 5);
    }

    final void setColor(Color color1)
    {
        color = color1;
    }

    final void setCurrent(double d)
    {
        current = d;
    }

    final void setID(int i)
    {
        id = i;
    }

    final void setLabel(String s1)
    {
        if(s1 == null || s1.trim().equals(""))
            label = null;
        else
            label = new String(new char[] {
                s1.charAt(0)
            });
    }

    final void setRadius(double d)
    {
        radius = d;
    }

    void setShowF(boolean flag)
    {
        showF = flag;
    }

    final void setSize(int i)
    {
        s = i;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -