Skip to content

Commit

Permalink
Switch To Markdown
Browse files Browse the repository at this point in the history
Instead of long strings within the Java file the text is written within a markdown file, parsed into HTML, and then rendered by the JTextPane.
  • Loading branch information
AvocadoMoon committed Jan 30, 2024
1 parent 780e965 commit 9b53574
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 24 deletions.
6 changes: 6 additions & 0 deletions view-simulation-results/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@
<artifactId>jsoup</artifactId>
<version>1.16.1</version>
</dependency>

<dependency>
<groupId>org.commonmark</groupId>
<artifactId>commonmark</artifactId>
<version>0.20.0</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,41 +1,57 @@
package org.vcell.N5.UI;

import org.commonmark.node.Node;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;

import javax.swing.*;
import java.awt.*;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;

public class HelpExplanation {
private JDialog jDialog;

public HelpExplanation(){
JPanel helperPanel = new JPanel();
JTextArea textArea = new JTextArea();

String intro = "The VCell application can export the simulations it creates into multiple formats. The format type .N5 is stored remotely on VCell servers,"
+ "and allows for other applications such as ImageJ to access the results of these simulations, perform some type of analysis, and never have to save"
+ "the simulation results locally. \n\n\n";

String accessingSimulationResults = "There are three methods for accessing simulation results within this plugin. \n"
+ "1. Copy the export link from the VCell app, click the 'Remote Files' button, paste the link in the text box then open it. This method is best for"
+ "when you need to save a set of exports for the long term future. \n"
+ "2. Click the recent export button to open the most recent simulation you exported in the N5 format. \n"
+ "3. Open the export table and open any export within that table using the open button. The tables information is stored locally on your computer so"
+ "if your computers drive fails the table will be empty, but any links saved elsewhere can still be used. \n\n\n";
int height = 400;
int width = 700;

String n5AndDataSet = "N5 files are one to one with simulations within VCell in terms of grouping."
+"Data sets are the grouping category for different export variances. For example with simulation A, if you decide to export only 2 of 3 variables, that"
+ " would be one dataset. For that same simulation if you decide to 1 variable that would be a completely different dataset. "
+ "Now with simulation B, if you decide to export 2 of 3 variables that would be a different N5 file and a different dataset.";

textArea.setText("Intro: \n" + intro + "Accessing Simulation Results: \n" + accessingSimulationResults + "N5 and Datasets: \n" + n5AndDataSet);
JPanel helperPanel = new JPanel();
JTextPane textArea = new JTextPane();

Parser parser = Parser.builder().build();
String md;
URL mdPath = ClassLoader.getSystemClassLoader().getResource("Help.md");
try {
md = new String(Files.readAllBytes(Paths.get(mdPath.getPath())));
} catch (IOException e) {
throw new RuntimeException(e);
}
Node node = parser.parse(md);
HtmlRenderer renderer = HtmlRenderer.builder().build();
String text = renderer.render(node);
// textArea.setText("Intro: \n" + intro + "Accessing Simulation Results: \n" + accessingSimulationResults + "N5 and Datasets: \n" + n5AndDataSet);
textArea.setContentType("text/html");
textArea.setSize(width, height);
textArea.setPreferredSize(new Dimension(width, height));
textArea.setText(text);
textArea.setEditable(false);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
textArea.setSize(600, 600);
helperPanel.add(textArea);
// textArea.setLineWrap(true);
// textArea.setWrapStyleWord(true);
JScrollPane scrollPane = new JScrollPane(textArea);
scrollPane.setSize(width, height);
helperPanel.setSize(width, height);
helperPanel.add(scrollPane);


JOptionPane pane = new JOptionPane(helperPanel, JOptionPane.PLAIN_MESSAGE, 0, null, new Object[]{"Close"});
jDialog = pane.createDialog("Helper Menu");
jDialog.setModal(false);
jDialog.setResizable(true);
jDialog.setPreferredSize(new Dimension(width, height));
// jDialog.setResizable(true);
}

public void displayHelpMenu(){
Expand Down
28 changes: 28 additions & 0 deletions view-simulation-results/src/main/resources/Help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
### Intro
The VCell application can export the simulations it creates into multiple formats.
The .N5 format type is stored remotely on VCell servers, allowing other applications, such as ImageJ,
to access the results of these simulations, perform various types of analyses,
and avoid the need to save the simulation results locally.

### Accessing Simulation Results
There are three methods for accessing simulation results within this plugin:

1. Copy the export link from the VCell app, click the 'Remote Files' button, paste the link in the text box, and then open it.
This method is best when you need to save a set of exports for the long term future.

2. Click the recent export button to open the most recent simulation you exported in the N5 format.

3. Open the export table and access any export within that table using the open button. The table's information
is stored locally on your computer. If your computer's drive fails, the table will be empty, but any links
saved elsewhere can still be used.


### N5 and Datasets
N5 files correspond one-to-one with simulations within VCell in terms of grouping.
Data sets serve as the grouping category for different export variances.
For example, with simulation A, if you choose to export only 2 of 3 variables,
that constitutes one dataset. In the same simulation, if you decide to export just 1 variable,
that would be an entirely different dataset.

Now, considering simulation B, if you choose to export 2 of 3 variables, it results in a different N5 file and a distinct dataset.

0 comments on commit 9b53574

Please sign in to comment.