Overriding the Methods from the interface
This section describes the purpose of the methods you override and what you should do with them
public boolean buildAndShowGui()
This is the first method that is called after the user has selected this algorithm and has pressed the 'Start' button to commence it. The purpose of this method is to enable you, the developer, to present an options panel to the user where he can set up some values used by your algorithm if you want him to.
The rest of the application blocks unless you return the thread from this method.
If you want to provide a GUI (a Graphical User Interface), then your algorithm should assemble and display your options at this point, using Swing components for that. You can create your own dialog frame to display your panel or you can use MembraneAlgorithmGUI. popUpGUI() (see Essential Methods and Objects) for that.
The boolean that you have to return from this method indicates whether or not your membrane algorithm should proceed or if it should be cancelled already:
Return true if the user confirmed his settings or if you don't provide a GUI at all.
Return false not to start the algorithm e.g. if the user chose to cancel it.
public void fillWithLipids() throws Exception
This method is the entry point of your algorithm. All further operations are invoked here. As soon as this method returns, the algorithm is finished and will terminate.
There is no general pattern for how you have implement your algorithm inside this method. But here's a good proposal of how it could be done:
Write a loop that performs the following steps:
- Create a new lipid (all molecules are represented by referring objects) that you want to place. To maintain a proper ratio of lipid types, use the createExtracellularLipid() or createIntracellularLipid() methods (see Essential Methods and Objects) for that.
- Choose a position for your lipid and rotate it to its desired alignment
- Test your lipid for intersections with the borders and for intersections with other molecules
- If an intersection occurs correct your position and/or alignment and continue at step 3.
- If no intersection occurs, add your lipid to the appropriate side of the membrane, using addExtracellularLipid() or addIntracellularLipid().
- If you want to end the algorithm you could break the loop here, so that the method returns. Otherwise you may continue at step 1 and focus on the other membrane side now.
Alternatively, you could pick an existing lipid and just change its alignment (only if you do not want to add new ones), or you could mix up both approaches.
public String getFullInformation()
Use this method to return a String that contains a full description of your algorithm. This is the text that gets displayed in the large text area that the user sees when he selects an algorithm.
Make sure to insert line breaks for a proper style.
May return "null" if you want.
public String getName()
This method returns the name that you want use for this algorithm.
It gets displayed in the table.
The name also serves as an identifier, that's why it has to be unique and not empty to get this algorithm to be accepted
public String getShortInformation()
Here you can return a description that is a than the complete information. It will be written into the output file later on if the membrane has been generated with this algorithm.
May also return "null".
public String getStringRepresentationOfSetupParameters()
Allows you to return a String that is meant to contain the setup parameters of your algorithm GUI. This String will also be written into the output file later on. It is up to you how you style this String and what contents you put into it.
May return "null".
public Component getRuntimeControlPanel()
Enables you to provide a panel that contains options that can be accessed during the runtime of the algorithm. It will be placed beneath the 3D view, so try to keep it small.
This method may also return "null" if there is no need for a panel.
public void stopAlgorithm()
This method is called when the user presses the 'Stop' button while the algorithm is running. It is up to you to recognize this call and to terminate the algorithm at the next appropriate point.
It is very important to handle this case, otherwise the user will not have the opportunity to abort the algorithm.
The easiest way to handle this is to use a flag that gets toggled inside this method. The algorithm then uses this flag for each loop to decide whether to break or to continue.
public boolean overrideExistingLipids()
Here you have to decide if your algorithm needs to remove all existing lipids first or if they may remain. If you return true, then all lipids will be automatically removed before this algorithm starts, if you return false, they will be remained.
public boolean supportsMicrodomains()
Forces you to provide information as to whether your algorithm supports microdomains or not. Return false if you don't want or need to implement microdomain support. This value will be presented in the table of available algorithms.
- Written by bjoern
- Category: Cm2dev
- Published: 14 September 2013
- Hits: 2073