File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes To Rob , Manfred or Dirk.. I have a request.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "To Rob , Manfred or Dirk.. I have a request.." Watch "To Rob , Manfred or Dirk.. I have a request.." New topic
Author

To Rob , Manfred or Dirk.. I have a request..

Avin Sinanan
Ranch Hand

Joined: Nov 07, 2001
Posts: 109
Hello,
Am my name is Avin Sinanan. And I have posted a few questions on this forum. And well its usally one of you guys who help me. Thanks a million.
Am doing a project on simulation a GSM network. And all the questions I've posted on this forum were realted to helping me finish that project. I've combined all the code you all have helped me with and my own code. And I came up with 700 line of code. Now of course my project is about 10,000 lines. But the 700 lines is a condensed version of that 10,000 lines. I belive if I get this 700 lines of code to work I can complete my project.
So am asking if one of you guys can pleasse give the code a look. I'll post up the code below. And if possible ( if its more convenient) I could email you the code. I'll post it below anyway.
First of all the code below works. It complies and everything. So getting it to complile and exectute is not a problem. The problem is that the code doen't do exactly what it is suppse to do. It does most of what it is suppose to do.
So I'll explain now what the code does and what it doesn't do and what it is suppose to do ->
Ok the code is discrete event simulation techiniques again.
Ok in the code you'll notice two classes:
1) MobileStation
2)BTS
In the beginning of the code in the class DESMarch112002 two classes of MobileStation and BTS are made. These classes being
ms[1] , ms[2] , bts[1] and bts[2]
now ms[1] sends messages to bts[1] and
ms[2] sends messages to bts[2].
Hence ms[1] and bts[1] have no relation to ms[2] and bts[2]. ms[1] and bts[1] function together and are completely seperate from ms[2] and bts[2].
Now ms[1] and bts[2] are connected together by link[1] and ms[2] and bts[2] are connected together by link[2].
Now what is the purpose of this code. The end product of this simulation is a graph showing the amount of bytes Vs tine that flowed between ms[1] and bts[1] and between ms[2] and bts[2].
Hence two graphs are generated at the end,one for ms[1] and bts[1] and one for ms[2] and bts[2].
Now the simulation lasts 600 units of time. A sample for the graph is taken every 10 units of time. At each ten units of time a time value and a byte value is recored and used a point in the graph. The graph values are stored in dynamic array in the Link class.
When the end of the simulation is reached it plots the graphs.
So whats my problem?
Ok first of all two graphs are being generated as it is upoose to do. But one of the two graphs have no values (ie no points)
Also I had to implement a sleep in line 420 in the Link class becasue if I didn't the program would keep gererating new JFrame over and over. I think the reason for this beacsue the graphs are suppose to be printed when the sinulation is more than 600 time units. The smulation runs for 610 time units and for each number >600 it prints a new graph. ie for 600.00001 , 600.0001 , 600.0003 and so on. I tried using ==600 but that didn't work for some reason.
So when 3 graphs were created it goes into sleep mode so no more frames geberated.
And when the graphs are printed that are all jumbled up. They are all one on top the other and look distorted . You have to maximize the screen to get the distorsion to go away.
So can yoy all help me with this please. I know its long and I'll understand. Thanks..
yours respectuflly Avin Sinanan
heres the code

[ March 11, 2002: Message edited by: Avin Sinanan ]

yours respectfully<br />Avin Sinanan
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Avin,
After a few days of playing around with it. I have made the following changes that get pretty close (I think) to what you want.
I assumed the following: Once a Link was displayed it was done. Therefore I used an instance boolean value to make sure we only got one plot per instance.
I altered five of your classes: MobileStation, BTS, Link, Global, and Start. I also altered your main method. I will only show those because the others were unchanged.
The changes might not be what you wanted but they can at least give you a direction.

Enjoy,
Manfred.
Avin Sinanan
Ranch Hand

Joined: Nov 07, 2001
Posts: 109
Hey Manfred thanks a million. The code works like a charm. Thanks a lot.
Yours respectfully Avin Sinanan
Avin Sinanan
Ranch Hand

Joined: Nov 07, 2001
Posts: 109
Hey Manfred,
I tried to merge the code with my GUI. And I think I almost got it to work execept I ran into a little problem.
The code above in the class extend Simulator.
Is there anyway I can implements Simulator instead of extend Simulator?
You see my GUI already extends JButton and well as you know you cannot extend two things.
So can I bug you one more time please.
I tried all how to implement it. By chance can you implement JButton instead?
Am lost when it comes to interfaces..
bye
yours repectfully Avin Sinanan
[ March 13, 2002: Message edited by: Avin Sinanan ]
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Avin,
I am not going to be able to help you out much more. I don't understand your GUI design and without the understanding it would be a waste of my time to try and figure out what you are doing.
It would be MUCH easier to just stop extending JButton rather than take multiple classes that contain variables and try and make them into a single interface. Interface variables are static and public by default (i.e., one per class no matter how many instances exist).
You might be able to make the class just have a JButton inside of it, or maybe a new class to wrap the extends JButton class?
Sorry,
Manfred.
[ March 14, 2002: Message edited by: Manfred Leonhardt ]
Avin Sinanan
Ranch Hand

Joined: Nov 07, 2001
Posts: 109
Hey Manfred, thanks for all the help. And I understand. Its all cool.
But is it ok if I ask you one more question. You don't have to look at any code or anything. Its mostly based on the code above. I tried to combine it with my GUI. And I got some errors. here is the list of errors. I wanted to know if you could tell me what these errores mean in general. I know you don't undersatnd what am trying to build. But I assume when you get errors that have a general meaning. So if you have time could you let me know what you think. If you don't respond I understand and I wante dto let you know you have helped me a great deal and even if you don't reply thnak you very very much for everything.
here are the errors

at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:250
)
at javax.swing.AbstractButton.doClick(AbstractButton.java:279)
at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseRelease
d(BasicMenuItemUI.java:886)
at java.awt.Component.processMouseEvent(Component.java:3717)
at java.awt.Component.processEvent(Component.java:3546)
at java.awt.Container.processEvent(Container.java:1164)
at java.awt.Component.dispatchEventImpl(Component.java:2595)
at java.awt.Container.dispatchEventImpl(Container.java:1213)
at java.awt.Component.dispatchEvent(Component.java:2499)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451
)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2216)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
at java.awt.Container.dispatchEventImpl(Container.java:1200)
at java.awt.Window.dispatchEventImpl(Window.java:912)
at java.awt.Component.dispatchEvent(Component.java:2499)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:10
3)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Avin,
You are not showing me what the error was. You are only giving me the program trace which is meaningless to me. The error you should be interested in would have been above the lines you showed me. Something like:
NullPointerException:
or
IOException:
These are the errors that can be generalized and usually lead the programmer to figure out what the problem is.
Regards,
Manfred.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: To Rob , Manfred or Dirk.. I have a request..