Questions re Additional Java Files

User avatar
Posts: 64
Joined: Sat Nov 09, 2019 1:18 pm

Re: Questions re Additional Java Files

Post by honki-bobo » Sat May 23, 2020 9:05 pm

The preparation was this:

I have implemented an "adapter class" in Eclipse with interface, abstract class and a stub implementation as part of my library that basically implements all methods of a VoltageModule, but does not extend it. The library also includes voltage.jar in the classpath, since I need a lot of Voltage classes.

Then I have made a template project in VMD that already has a background image, lables, my company logo and name at the bottom, etc. This template project includes my library as external Jar file and has just a few lines of code that basically call all methods in my adapter class. For instance

Code: Select all

public boolean Notify( VoltageComponent component, ModuleNotifications notification, double doubleValue, long longValue, int x, int y, Object object )
	// add your own code here
	return this.moduleAdapter.Notify(component, notification, doubleValue, longValue, x, y, object);
When I create a new module, first thing I do is I save this template project in a new folder and give it the name of the module I want to create, let's say Sample Delay. In VMD I do the layout of all GUI components and also set their parameters, like min, max, default value, visibility and all that stuff.

Back in Eclipse I create a new project for Sample Delay and include my library and the voltage.jar in the classpath of that project. Then I create the same package that is used in VMD for Sample Delay in the src folder, in my case it's com.monkeybusinessaudio.sampledelay and create the class in this package (VMA for VoltageModuleAdapter). This class extends the abstract adapter class which in turn implements the adapter's interface, so Eclipse takes care of all the method creation for me. After the class is created I save it and add it as external Java file back in the VMD project.

I call the adapter class' constructor in the Initialize() method in the VMD project. My adapter class also has a addComponent method to which I pass all GUI components. It gets called for each component right after the constructor call. This method puts each component into a hashmap according to its class and uses the componentName attribute as a key for the object in the hashmap. I have taken care of this in the abstract class, so I only had to implement this once. This gives me a very convenient way to access all Voltage Components that I have added to the module in VMD. Finally, I call the Initialize() method of my adapter object and that's basically it.

From there on I almost only work in Eclipse for the GUI behaviour and all audio DSP code. When I want to compile my code, I save the java file, press CTRL+A and CTRL+C in Eclipse, go to VMD and select my VMA java file in the editor, press CTRL+A, wait a few seconds for VMD to digest this (yes, it somehow needs its time, haven't tested V2 yet), press CTRL+V and then hit CTRL+F5 to run and test it. Then I go back to Eclipse... hack, hack, hack... CTRL+A,CTRL+C, back to VMD, CTRL+A, wait, CTRL+V, CTRL+F5... check, check, check... back to Eclipse and so on and so forth.

That is basically my workflow. It might seem a bit complicated and over-engineered, but (at least with V1 of VMD) it is much less of a hazzle and way more comfortable to work in a fully featured IDE that has been developed by a lot of people over a very long time specifically for this purpose. No offense intended against CA! VMD is absolutely great for the GUI part of things, it's just that I am way more comfortable working in Eclipse. Also, I haven't tried V2 yet. It might as well be that VMD got more responsive with V2 and also offers some IDE features that I just don't want to miss. But since I still have a few projects that I'm working on I do not dare to upgrade just now.
Monkey Business Audio
Modules - Forum

Post Reply