home *** CD-ROM | disk | FTP | other *** search
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Frame;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.MediaTracker;
- import java.awt.Panel;
- import java.awt.Scrollbar;
- import java.util.Vector;
-
- class AnalyzerPanel extends Panel {
- static final int CHANNEL_HEIGHT = 50;
- static final int DISPLAY_OFFSET = 5;
- static final int CLOCK_WIDTH = 10;
- static final int LINE_OFFSET = 5;
- static final int BUTTON_X_OFFSET = 5;
- static final int BUTTON_Y_OFFSET = 22;
- static final int BUTTON_CLOCK_NONE = 48;
- static final int BUTTON_CLOCK_NONE_PRESSED = 24;
- static final int BUTTON_CLOCK_UP_PRESSED = 72;
- static final int BUTTON_CLOCK_UP_SELECTED = 96;
- static final int BUTTON_CLOCK_DN_PRESSED = 120;
- static final int BUTTON_CLOCK_DN_SELECTED = 144;
- static final Color TextColor;
- static final Color BackGroundColor;
- protected Scrollbar myVertical;
- DigSim applet;
- Image OffScreenImage;
- Image ImageBuffer;
- Image CopyImage;
- Graphics cig;
- int ButtonOffset;
- // $FF: renamed from: og java.awt.Graphics
- Graphics field_0;
- Dimension ImageSize;
- protected Font AnalyzerFont;
- protected FontMetrics AnalyzerFontMetrics;
- Vector probes;
- boolean ImageButtonsDisabled = false;
- Probe PressedProbe;
- Probe DragProbe;
- int CurrentCol;
- boolean ImageUpdated = false;
- Frame frame;
-
- public AnalyzerPanel(DigSim var1, Frame var2) {
- this.applet = var1;
- this.frame = var2;
- ((Container)this).setLayout(new BorderLayout());
- this.AnalyzerFont = new Font("TimesRoman", 0, 14);
- this.AnalyzerFontMetrics = ((Component)this).getFontMetrics(this.AnalyzerFont);
- super.setLayout(new BorderLayout());
- this.LoadButtonsImage();
- this.myVertical = new Scrollbar(1);
- ((Container)this).add("East", this.myVertical);
- this.ImageSize = new Dimension(400, 250);
- this.CheckOffScreenImage();
- ((Component)this).repaint();
- }
-
- public void AdjustScrollbar() {
- if (this.probes != null) {
- int var2 = 50 * this.probes.size();
- int var3 = ((Component)this).size().height;
- int var4 = var2 - var3;
- if (var4 < 0) {
- var4 = 0;
- }
-
- String var1 = System.getProperty("os.name");
- if (!var1.equals("Windows 95") && !var1.equals("Windows NT")) {
- this.myVertical.setValues(this.myVertical.getValue(), var3, 0, var4);
- } else {
- this.myVertical.setValues(this.myVertical.getValue(), var3, 0, var4 + var3);
- }
- }
- }
-
- public void CheckOffScreenImage() {
- if (this.OffScreenImage == null) {
- this.PrepareOffScreenImage();
- } else {
- if (((Component)this).size().width > this.ImageSize.width || ((Component)this).size().height > this.ImageSize.height) {
- this.ImageSize.width = ((Component)this).size().width;
- this.ImageSize.height = ((Component)this).size().height;
- this.PrepareOffScreenImage();
- }
-
- }
- }
-
- public void PrepareOffScreenImage() {
- this.OffScreenImage = this.applet.createImage(this.ImageSize.width, this.ImageSize.height);
- this.field_0 = this.OffScreenImage.getGraphics();
- this.field_0.setFont(this.AnalyzerFont);
- ((Component)this).repaint();
- }
-
- public void SelectButton(int var1) {
- this.cig.copyArea(0, var1, 24, 24, 0, -var1);
- }
-
- public void ButtonPressed(int var1) {
- Probe var2 = (Probe)this.probes.elementAt(var1);
- this.PressedProbe = var2;
- if (var2.clockup_probe) {
- var2.clockup_probe = false;
- var2.clockdn_probe = true;
- } else if (var2.clockdn_probe) {
- var2.clockup_probe = false;
- var2.clockdn_probe = false;
- } else {
- var2.clockup_probe = true;
- var2.clockdn_probe = false;
- }
-
- for(int var3 = 0; var3 < this.probes.size(); ++var3) {
- if (var1 != var3) {
- var2 = (Probe)this.probes.elementAt(var3);
- var2.clockup_probe = false;
- var2.clockdn_probe = false;
- }
- }
-
- ((Component)this).repaint();
- }
-
- public boolean mouseDown(Event var1, int var2, int var3) {
- this.PressedProbe = null;
- this.DragProbe = null;
-
- for(int var5 = 0; var5 < this.probes.size(); ++var5) {
- int var6 = var5 * 50 + 22 - this.myVertical.getValue();
- if (var2 >= 5 && var2 <= 29 && var3 >= var6 && var3 <= var6 + 24) {
- this.ButtonPressed(var5);
- }
- }
-
- for(int var7 = 0; var7 < this.probes.size(); ++var7) {
- Probe var4 = (Probe)this.probes.elementAt(var7);
- if (var2 >= var4.ChannelPos.x && var3 >= var4.ChannelPos.y && var2 <= var4.ChannelPos.x + var4.ChannelDim.width && var3 <= var4.ChannelPos.y + var4.ChannelDim.height) {
- this.DragProbe = var4;
- ((Component)this).repaint();
- return true;
- }
- }
-
- return true;
- }
-
- public boolean mouseUp(Event var1, int var2, int var3) {
- if (this.DragProbe != null) {
- this.DragProbe = null;
- ((Component)this).repaint();
- }
-
- if (this.PressedProbe != null) {
- this.PressedProbe = null;
- ((Component)this).repaint();
- }
-
- return true;
- }
-
- public boolean mouseDrag(Event var1, int var2, int var3) {
- if (this.DragProbe != null) {
- for(int var5 = 0; var5 < this.probes.size(); ++var5) {
- Probe var4 = (Probe)this.probes.elementAt(var5);
- if (var2 >= var4.ChannelPos.x && var3 >= var4.ChannelPos.y && var2 <= var4.ChannelPos.x + var4.ChannelDim.width && var3 <= var4.ChannelPos.y + var4.ChannelDim.height && var4 != this.DragProbe) {
- this.applet.MySchematic.SwapComponents(var4, this.DragProbe);
- ((Component)this).repaint();
- return true;
- }
- }
- }
-
- return true;
- }
-
- public void DrawProbeHistory(Graphics var1, Probe var2) {
- var1.setColor(Color.green);
-
- for(int var3 = 0; var3 < 100; ++var3) {
- if (var3 > 0 && var2.LevelHistory[var3 - 1] != var2.LevelHistory[var3]) {
- this.field_0.drawLine(var2.ChannelPos.x + var3 * 10, var2.ChannelPos.y + 5, var2.ChannelPos.x + var3 * 10, var2.ChannelPos.y + var2.ChannelDim.height - 5);
- }
-
- if (var2.LevelHistory[var3] == 5) {
- var1.setColor(Color.green);
- var1.drawLine(var2.ChannelPos.x + var3 * 10, var2.ChannelPos.y + 5, var2.ChannelPos.x + (var3 + 1) * 10, var2.ChannelPos.y + 5);
- } else {
- var1.setColor(Color.green);
- var1.drawLine(var2.ChannelPos.x + var3 * 10, var2.ChannelPos.y + var2.ChannelDim.height - 5, var2.ChannelPos.x + (var3 + 1) * 10, var2.ChannelPos.y + var2.ChannelDim.height - 5);
- }
- }
-
- }
-
- public void DrawNoProbes(Graphics var1) {
- String var2 = "There are no probes to display.";
- int var3 = this.AnalyzerFontMetrics.stringWidth(var2);
- int var4 = (((Component)this).size().width - var3) / 2;
- var1.setColor(Color.black);
- var1.drawString(var2, var4, ((Component)this).size().height / 2);
- }
-
- public void DrawEmptyProbes(Graphics var1) {
- this.probes = this.applet.MySchematic.getProbes();
- int var5 = 30;
- int var6 = this.myVertical.getValue();
- var1.setColor(Color.lightGray);
- var1.fillRect(0, 0, this.ImageSize.width, this.ImageSize.height);
- if (this.probes.size() == 0) {
- this.DrawNoProbes(var1);
- } else {
- for(int var7 = 0; var7 < this.probes.size(); ++var7) {
- Probe var2 = (Probe)this.probes.elementAt(var7);
- int var4 = this.AnalyzerFontMetrics.stringWidth(var2.IPin[0].getName());
- if (var4 > var5) {
- var5 = var4;
- }
- }
-
- for(int var8 = 0; var8 < this.probes.size(); ++var8) {
- Probe var10 = (Probe)this.probes.elementAt(var8);
- int var3 = var8 * 50 - var6;
- var1.setColor(TextColor);
- var1.drawString(var10.IPin[0].getName(), 5, var3 + 16);
- var1.setColor(Color.gray);
- var1.drawLine(0, var3 + 50 - 2, ((Component)this).size().width, var3 + 50 - 2);
- var1.setColor(Color.white);
- var1.drawLine(0, var3 + 50 - 1, ((Component)this).size().width, var3 + 50 - 1);
- var10.ChannelPos.x = 5 + var5 + 5;
- var10.ChannelPos.y = 5 + var3;
- var10.ChannelDim.width = ((Component)this).size().width - (5 + var5 + 20);
- var10.ChannelDim.height = 40;
- var1.setColor(BackGroundColor);
- var1.fillRect(var10.ChannelPos.x, var10.ChannelPos.y + 1, var10.ChannelDim.width, var10.ChannelDim.height - 1);
- if (var10.clockup_probe) {
- if (var10 == this.PressedProbe) {
- this.SelectButton(72);
- } else {
- this.SelectButton(96);
- }
- } else if (var10.clockdn_probe) {
- if (var10 == this.PressedProbe) {
- this.SelectButton(120);
- } else {
- this.SelectButton(144);
- }
- } else if (var10 == this.PressedProbe) {
- this.SelectButton(24);
- } else {
- this.SelectButton(48);
- }
-
- this.DrawProbeHistory(var1, var10);
- Graphics var9 = this.ImageBuffer.getGraphics();
- var9.drawImage(this.CopyImage, 0, 0, this);
- var1.drawImage(this.ImageBuffer, 5, 22 + var3, this);
- }
-
- if (this.DragProbe != null) {
- var1.setColor(Color.red);
- var1.drawRect(this.DragProbe.ChannelPos.x, this.DragProbe.ChannelPos.y, this.DragProbe.ChannelDim.width, this.DragProbe.ChannelDim.height);
- }
-
- }
- }
-
- public synchronized void paint(Graphics var1) {
- if (this.OffScreenImage != null) {
- this.AdjustScrollbar();
- if (this.probes != null && ((Component)this).size().height >= 50 * this.probes.size()) {
- this.update(var1);
- } else if (!this.ImageUpdated) {
- this.update(var1);
- } else {
- var1.drawImage(this.OffScreenImage, 0, 0, this);
- }
- }
- }
-
- public synchronized void update(Graphics var1) {
- this.AdjustScrollbar();
- this.CheckOffScreenImage();
- if (this.OffScreenImage != null) {
- this.DrawEmptyProbes(this.field_0);
- var1.drawImage(this.OffScreenImage, 0, 0, this);
- this.ImageUpdated = true;
- }
- }
-
- public boolean handleEvent(Event var1) {
- if (var1.target instanceof Scrollbar) {
- ((Component)this).repaint();
- return true;
- } else {
- return super.handleEvent(var1);
- }
- }
-
- public boolean action(Event var1, Object var2) {
- return false;
- }
-
- public void update(Probe var1) {
- int var2 = this.CurrentCol * 10;
- if (var2 >= var1.ChannelDim.width) {
- if (var1.clockup_probe && var1.OldLevel == 0 && var1.IPin[0].getLevel() == 5) {
- this.CurrentCol = 0;
- return;
- }
-
- if (var1.clockdn_probe && var1.OldLevel == 5 && var1.IPin[0].getLevel() == 0) {
- this.CurrentCol = 0;
- }
- }
-
- }
-
- public void drawLevel(Probe var1) {
- int var2 = this.CurrentCol * 10;
- if (var2 < var1.ChannelDim.width) {
- if (this.CurrentCol == 0) {
- this.field_0.setColor(BackGroundColor);
- this.field_0.fillRect(var1.ChannelPos.x + var2, var1.ChannelPos.y + 1, 11, var1.ChannelDim.height - 1);
- }
-
- this.field_0.setColor(BackGroundColor);
- this.field_0.fillRect(var1.ChannelPos.x + var2 + 1, var1.ChannelPos.y + 1, 10, var1.ChannelDim.height - 1);
- if (this.CurrentCol > 0 && var1.IPin[0].getLevel() != var1.OldLevel) {
- this.field_0.setColor(Color.green);
- this.field_0.drawLine(var1.ChannelPos.x + var2, var1.ChannelPos.y + 5, var1.ChannelPos.x + var2, var1.ChannelPos.y + var1.ChannelDim.height - 5);
- }
-
- if (this.CurrentCol < 100) {
- var1.LevelHistory[this.CurrentCol] = var1.IPin[0].getLevel();
- }
-
- if (var1.IPin[0].getLevel() == 5) {
- this.field_0.setColor(Color.green);
- this.field_0.drawLine(var1.ChannelPos.x + var2, var1.ChannelPos.y + 5, var1.ChannelPos.x + var2 + 10, var1.ChannelPos.y + 5);
- } else {
- this.field_0.setColor(Color.green);
- this.field_0.drawLine(var1.ChannelPos.x + var2, var1.ChannelPos.y + var1.ChannelDim.height - 5, var1.ChannelPos.x + var2 + 10, var1.ChannelPos.y + var1.ChannelDim.height - 5);
- }
-
- this.paint(((Component)this).getGraphics());
- }
- }
-
- public void update() {
- if (this.probes != null) {
- for(int var2 = 0; var2 < this.probes.size(); ++var2) {
- Probe var1 = (Probe)this.probes.elementAt(var2);
- this.update(var1);
- }
-
- for(int var4 = 0; var4 < this.probes.size(); ++var4) {
- Probe var3 = (Probe)this.probes.elementAt(var4);
- this.drawLevel(var3);
- var3.OldLevel = var3.IPin[0].getLevel();
- }
-
- this.paint(((Component)this).getGraphics());
- ++this.CurrentCol;
- }
- }
-
- public void LoadButtonsImage() {
- MediaTracker var2 = new MediaTracker(this);
- Image var1 = this.applet.getImage(this.applet.getDocumentBase(), "images/all_analyzer.gif");
- var2.addImage(var1, 0);
-
- try {
- Thread.currentThread().setPriority(1);
- var2.waitForAll();
- } catch (Exception var6) {
- String var4 = ((Throwable)var6).toString();
- String[] var5 = new String[]{"OK"};
- new SimpleDialog((DigSimFrame)null, "Reading imagebuttons", var4, var5, 1, 0, 0, 1);
- return;
- }
-
- if (var2.isErrorAny()) {
- this.ImageButtonsDisabled = true;
- String var3 = "Can't read images/all_analyzer.gif ImageButtons will be disabled";
- String[] var7 = new String[]{"OK"};
- new SimpleDialog((DigSimFrame)null, "Error while reading imagebuttons", var3, var7, 1, 0, 0, 1);
- } else {
- this.ImageBuffer = this.applet.createImage(var1.getWidth(this), 24);
- this.CopyImage = this.applet.createImage(var1.getWidth(this), var1.getHeight(this));
- this.cig = this.CopyImage.getGraphics();
- this.cig.drawImage(var1, 0, 0, this);
- }
- }
-
- static {
- TextColor = Color.black;
- BackGroundColor = Color.black;
- }
- }
-