//AmplifierCircuit.java import java.awt.*; class AmplifierCircuit extends GraphicComposite { ResistorSymbol Rb, Rc; NPNTransistor trans; GroundSymbol grd; CapacitorSymbol Cb,Cc; // SineWave inputSW, outputSW; WireLine w1, w2, w3, w4, w5, w6, w7, w8, w9; Point baseP; DisplayParameters displayParameters; //CircuitBkg cBkg; //the two moving waveforms TheMovingWaveforms theMovingWaveforms; public AmplifierCircuit(/*int width, int height*/Dimension imgSize){ super(/*width, height*/imgSize); baseP = new Point(180, 100); Rb = new ResistorSymbol(baseP.x-30, baseP.y-40, 6, 20); Rb.setName("Rb"); Rb.setNameAt(new Point(baseP.x-50, baseP.y-30)); Rc = new ResistorSymbol(baseP.x+15, baseP.y-40, 6, 20); Rc.setName("Rc"); Rc.setNameAt(new Point(baseP.x+25, baseP.y-30)); trans = new NPNTransistor(baseP.x,baseP.y, Rc.getLocation().x+(int)(Rc.getSize().width/2.0)-baseP.x, (int)((Rc.getLocation().x-baseP.x)*4.0/5.0)); grd = new GroundSymbol(new Point(Rc.getLocation().x+(int)(Rc.getSize().width/2.0), baseP.y+(int)((Rc.getLocation().x-baseP.x)*4.0/5.0)), 20); Cb = new CapacitorSymbol(trans.getB().x-60, trans.getB().y); Cc = new CapacitorSymbol(trans.getC().x+30, trans.getC().y-5); w1 = new WireLine(new Point(Cb.getFirstPad().x-20, Cb.getFirstPad().y), Cb.getFirstPad(), true, 'p', 'n'); w1.setName("Vin"); w1.setNameAt(new Point(Cb.getFirstPad().x-28, Cb.getFirstPad().y+18)); w2 = new WireLine(Cb.getSecondPad(), trans.getB()); w3 = new WireLine(new Point(Rb.getLocation().x+(int)(Rb.getSize().width/2.0), Rb.getLocation().y+Rb.getSize().height), new Point(Rb.getLocation().x+(int)(Rb.getSize().width/2.0), trans.getB().y),false,'n','d'); w4 = new WireLine(new Point(Rb.getLocation().x+(int)(Rb.getSize().width/2.0), Rb.getLocation().y), new Point(Rb.getLocation().x+(int)(Rb.getSize().width/2.0), Rb.getLocation().y-20), false, 'n','n'); w5 = new WireLine(new Point(Rb.getLocation().x+(int)(Rb.getSize().width/2.0), Rb.getLocation().y-20), new Point(Rc.getLocation().x+(int)(Rc.getSize().width/2.0), Rb.getLocation().y-20), true, 'n', 'd'); w6 = new WireLine(new Point(Rc.getLocation().x+(int)(Rc.getSize().width/2.0), Rc.getLocation().y-40), new Point(Rc.getLocation().x+(int)(Rc.getSize().width/2.0), Rc.getLocation().y), false, 'p','n'); w6.setName("Vcc"); w6.setNameAt(new Point(Rc.getLocation().x+(int)(Rc.getSize().width/2.0)-5, Rc.getLocation().y-45)); w7 = new WireLine(new Point(Rc.getLocation().x+(int)(Rc.getSize().width/2.0), Rc.getLocation().y+Rc.getSize().height), trans.getC(), true); w8 = new WireLine(new Point(trans.getC().x, Cc.getFirstPad().y), Cc.getFirstPad(), false, 'd','n'); w9 = new WireLine(Cc.getSecondPad(), new Point(Cc.getSecondPad().x+20, Cc.getSecondPad().y), false, 'n','p'); w9.setName("Vout"); w9.setNameAt(new Point(Cc.getSecondPad().x+14, Cc.getSecondPad().y+18)); /* inputSW = new SineWave(10, 30); inputSW.translate(50,100); outputSW = new SineWave(-20,30); outputSW.translate(270, 83); */ // cBkg = new CircuitBkg(); // this.addGraphicComponent(cBkg); this.addGraphicComponent(Rb); this.addGraphicComponent(Rc); this.addGraphicComponent(trans); this.addGraphicComponent(grd); this.addGraphicComponent(Cb); this.addGraphicComponent(Cc); this.addGraphicComponent(w1); this.addGraphicComponent(w2); this.addGraphicComponent(w3); this.addGraphicComponent(w4); this.addGraphicComponent(w5); this.addGraphicComponent(w6); this.addGraphicComponent(w7); this.addGraphicComponent(w8); this.addGraphicComponent(w9); displayParameters = new DisplayParameters(this); this.addGraphicComponent(displayParameters); // this.addGraphicComponent(inputSW); // this.addGraphicComponent(outputSW); this.theMovingWaveforms = new TheMovingWaveforms(this); this.addGraphicComponent(theMovingWaveforms); } /* public void draw(Graphics g){ this.gBuffer.setColor(new Color(255,205,255)); this.gBuffer.fillRoundRect(0,0,360,150,10,10); this.gBuffer.setColor(Color.black); super.draw(g); } */ public void drawThisCompFixedImg(){ this.gFixed.setColor(new Color(255,205,255)); this.gFixed.fillRoundRect(0,0,360,150,10,10); this.gFixed.setColor(Color.black); } }