From e61cfdca4638152f5219d5c92cb072031388658a Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Mon, 7 Aug 2017 22:30:32 -0700 Subject: [PATCH 01/13] Create a documentation object class. --- .../org/nwapw/abacus/function/Documentation.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/main/kotlin/org/nwapw/abacus/function/Documentation.kt diff --git a/src/main/kotlin/org/nwapw/abacus/function/Documentation.kt b/src/main/kotlin/org/nwapw/abacus/function/Documentation.kt new file mode 100644 index 0000000..b1c384b --- /dev/null +++ b/src/main/kotlin/org/nwapw/abacus/function/Documentation.kt @@ -0,0 +1,15 @@ +package org.nwapw.abacus.function + +/** + * A data class used for storing information about a function. + * + * The Documentation class holds the information necessary to display the information + * about a function to the user. + * + * @param codeName the name of the function as it occurs in code. + * @param name the name of the function in English. + * @param description the short description of this function. + * @param longDescription the full description of this function. + */ +data class Documentation(val codeName: String, val name: String, + val description: String, val longDescription: String) \ No newline at end of file From 5f80c0bf143c429940962129e2c8148a4ce5d9e0 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 8 Aug 2017 10:50:30 -0700 Subject: [PATCH 02/13] Add a documentation class. --- .../nwapw/abacus/fx/DocumentationCell.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/main/java/org/nwapw/abacus/fx/DocumentationCell.java diff --git a/src/main/java/org/nwapw/abacus/fx/DocumentationCell.java b/src/main/java/org/nwapw/abacus/fx/DocumentationCell.java new file mode 100644 index 0000000..73bdbd7 --- /dev/null +++ b/src/main/java/org/nwapw/abacus/fx/DocumentationCell.java @@ -0,0 +1,36 @@ +package org.nwapw.abacus.fx; + +import javafx.scene.control.Label; +import javafx.scene.control.ListCell; +import org.nwapw.abacus.function.Documentation; + +public class DocumentationCell extends ListCell { + + private Label codeNameLabel; + private Label nameLabel; + private Label description; + private Label longDescription; + + public DocumentationCell(){ + codeNameLabel = new Label(); + nameLabel = new Label(); + description = new Label(); + longDescription = new Label(); + } + + @Override + protected void updateItem(Documentation item, boolean empty) { + super.updateItem(item, empty); + if(empty){ + codeNameLabel.setText(""); + nameLabel.setText(""); + description.setText(""); + longDescription.setText(""); + } else { + codeNameLabel.setText(item.getCodeName()); + nameLabel.setText(item.getName()); + description.setText(item.getDescription()); + longDescription.setText(item.getLongDescription()); + } + } +} From ea5ff08c09d9ebf20b5065c94907f1dbf7425c7c Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 8 Aug 2017 10:54:36 -0700 Subject: [PATCH 03/13] Add documentation type for a documentation entry. --- .../java/org/nwapw/abacus/function/DocumentationType.java | 7 +++++++ src/main/kotlin/org/nwapw/abacus/function/Documentation.kt | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/nwapw/abacus/function/DocumentationType.java diff --git a/src/main/java/org/nwapw/abacus/function/DocumentationType.java b/src/main/java/org/nwapw/abacus/function/DocumentationType.java new file mode 100644 index 0000000..0084657 --- /dev/null +++ b/src/main/java/org/nwapw/abacus/function/DocumentationType.java @@ -0,0 +1,7 @@ +package org.nwapw.abacus.function; + +public enum DocumentationType { + + FUNCTION + +} diff --git a/src/main/kotlin/org/nwapw/abacus/function/Documentation.kt b/src/main/kotlin/org/nwapw/abacus/function/Documentation.kt index b1c384b..fc9205b 100644 --- a/src/main/kotlin/org/nwapw/abacus/function/Documentation.kt +++ b/src/main/kotlin/org/nwapw/abacus/function/Documentation.kt @@ -10,6 +10,8 @@ package org.nwapw.abacus.function * @param name the name of the function in English. * @param description the short description of this function. * @param longDescription the full description of this function. + * @param type the things this documentation maps to. */ data class Documentation(val codeName: String, val name: String, - val description: String, val longDescription: String) \ No newline at end of file + val description: String, val longDescription: String, + val type: DocumentationType) \ No newline at end of file From 61f40c72aa7823591ba5660e71002fd0972e88ad Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 8 Aug 2017 11:09:46 -0700 Subject: [PATCH 04/13] Add a registered documentation set. --- .../nwapw/abacus/plugin/PluginManager.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/main/java/org/nwapw/abacus/plugin/PluginManager.java b/src/main/java/org/nwapw/abacus/plugin/PluginManager.java index 9ec48b4..e6d4953 100644 --- a/src/main/java/org/nwapw/abacus/plugin/PluginManager.java +++ b/src/main/java/org/nwapw/abacus/plugin/PluginManager.java @@ -1,6 +1,8 @@ package org.nwapw.abacus.plugin; import org.nwapw.abacus.Abacus; +import org.nwapw.abacus.function.Documentation; +import org.nwapw.abacus.function.DocumentationType; import org.nwapw.abacus.function.Function; import org.nwapw.abacus.function.Operator; import org.nwapw.abacus.number.NumberInterface; @@ -34,6 +36,10 @@ public class PluginManager { * The map of number implementations registered by the plugins. */ private Map registeredNumberImplementations; + /** + * The map of documentation for functions registered by the plugins. + */ + private Set registeredDocumentation; /** * The list of number implementations that have been * found by their implementation class. @@ -65,6 +71,7 @@ public class PluginManager { registeredFunctions = new HashMap<>(); registeredOperators = new HashMap<>(); registeredNumberImplementations = new HashMap<>(); + registeredDocumentation = new HashSet<>(); cachedInterfaceImplementations = new HashMap<>(); cachedPi = new HashMap<>(); listeners = new HashSet<>(); @@ -97,6 +104,15 @@ public class PluginManager { registeredNumberImplementations.put(name, implementation); } + /** + * Registers the given documentation with the plugin manager, + * making it accessible to the plugin manager etc. + * @param documentation the documentation to register. + */ + public void registerDocumentation(Documentation documentation){ + registeredDocumentation.add(documentation); + } + /** * Gets the function registered under the given name. * @param name the name of the function. @@ -124,6 +140,19 @@ public class PluginManager { return registeredNumberImplementations.get(name); } + /** + * Gets the documentation for the given entity of the given type. + * @param name the name of the entity to search for. + * @param type the type that this entity is, to filter out similarly named documentation. + * @return the documentation object. + */ + public Documentation documentationFor(String name, DocumentationType type){ + for(Documentation entry : registeredDocumentation){ + if(entry.getCodeName().equals(name) && entry.getType() == type) return entry; + } + return null; + } + /** * Gets the number implementation for the given implementation class. * @@ -212,6 +241,7 @@ public class PluginManager { registeredFunctions.clear(); registeredOperators.clear(); registeredNumberImplementations.clear(); + registeredDocumentation.clear(); cachedInterfaceImplementations.clear(); cachedPi.clear(); listeners.forEach(e -> e.onUnload(this)); From 5a57544067f1cdc15bcdcc675cf2feaefbb63bc4 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 8 Aug 2017 11:27:59 -0700 Subject: [PATCH 05/13] Add a plugin registration function to Plugins. --- .../java/org/nwapw/abacus/plugin/StandardPlugin.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java b/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java index 4d8aea2..08e849f 100755 --- a/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java +++ b/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java @@ -1,9 +1,6 @@ package org.nwapw.abacus.plugin; -import org.nwapw.abacus.function.Function; -import org.nwapw.abacus.function.Operator; -import org.nwapw.abacus.function.OperatorAssociativity; -import org.nwapw.abacus.function.OperatorType; +import org.nwapw.abacus.function.*; import org.nwapw.abacus.number.NaiveNumber; import org.nwapw.abacus.number.NumberInterface; import org.nwapw.abacus.number.PreciseNumber; @@ -583,6 +580,10 @@ public class StandardPlugin extends Plugin { registerFunction("sec", functionSec); registerFunction("csc", functionCsc); registerFunction("cot", functionCot); + + registerDocumentation(new Documentation("abs", "Absolute Value", "Finds the distance " + + "from zero of a number.", "Given a number, this function finds the distance form " + + "zero of a number, effectively turning negative numbers into positive ones.", DocumentationType.FUNCTION)); } @Override From 8c3de54d0cf57dbbb3a04f93fb2bdfe2ccbd6fbe Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 8 Aug 2017 13:46:54 -0700 Subject: [PATCH 06/13] Add a matches function. --- .../kotlin/org/nwapw/abacus/function/Documentation.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/org/nwapw/abacus/function/Documentation.kt b/src/main/kotlin/org/nwapw/abacus/function/Documentation.kt index fc9205b..3b94845 100644 --- a/src/main/kotlin/org/nwapw/abacus/function/Documentation.kt +++ b/src/main/kotlin/org/nwapw/abacus/function/Documentation.kt @@ -14,4 +14,13 @@ package org.nwapw.abacus.function */ data class Documentation(val codeName: String, val name: String, val description: String, val longDescription: String, - val type: DocumentationType) \ No newline at end of file + val type: DocumentationType) { + + fun matches(other: String): Boolean { + return codeName.toLowerCase().contains(other.toLowerCase()) || + name.toLowerCase().contains(other.toLowerCase()) || + description.toLowerCase().contains(other.toLowerCase()) || + longDescription.toLowerCase().contains(other.toLowerCase()) + } + +} \ No newline at end of file From fdcf2b5c6d371f973a9ee4df850d3440f27fff65 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 8 Aug 2017 13:47:03 -0700 Subject: [PATCH 07/13] Fix documentation loading code. --- .../java/org/nwapw/abacus/plugin/PluginManager.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/nwapw/abacus/plugin/PluginManager.java b/src/main/java/org/nwapw/abacus/plugin/PluginManager.java index e6d4953..390b9e8 100644 --- a/src/main/java/org/nwapw/abacus/plugin/PluginManager.java +++ b/src/main/java/org/nwapw/abacus/plugin/PluginManager.java @@ -147,10 +147,18 @@ public class PluginManager { * @return the documentation object. */ public Documentation documentationFor(String name, DocumentationType type){ + Documentation toReturn = null; for(Documentation entry : registeredDocumentation){ - if(entry.getCodeName().equals(name) && entry.getType() == type) return entry; + if(entry.getCodeName().equals(name) && entry.getType() == type) { + toReturn = entry; + break; + } } - return null; + if(toReturn == null){ + toReturn = new Documentation(name, "", "", "", type); + registerDocumentation(toReturn); + } + return toReturn; } /** From 9d92d0eebb1f6ff233ccb7753cfe197ea11e7f85 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 8 Aug 2017 13:49:04 -0700 Subject: [PATCH 08/13] Add registering documentation to plugins. --- .../java/org/nwapw/abacus/plugin/Plugin.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/java/org/nwapw/abacus/plugin/Plugin.java b/src/main/java/org/nwapw/abacus/plugin/Plugin.java index 7a78764..b92a9f4 100644 --- a/src/main/java/org/nwapw/abacus/plugin/Plugin.java +++ b/src/main/java/org/nwapw/abacus/plugin/Plugin.java @@ -1,5 +1,7 @@ package org.nwapw.abacus.plugin; +import org.nwapw.abacus.function.Documentation; +import org.nwapw.abacus.function.DocumentationType; import org.nwapw.abacus.function.Function; import org.nwapw.abacus.function.Operator; import org.nwapw.abacus.number.NumberInterface; @@ -94,6 +96,15 @@ public abstract class Plugin { manager.registerNumberImplementation(name, implementation); } + /** + * To be used in load(). Registers a documentation instance + * used to explain some element of the plugin to the user. + * @param documentation the documentation instance. + */ + protected final void registerDocumentation(Documentation documentation){ + manager.registerDocumentation(documentation); + } + /** * Searches the PluginManager for the given function name. * This can be used by the plugins internally in order to call functions @@ -130,6 +141,17 @@ public abstract class Plugin { return manager.numberImplementationFor(name); } + /** + * Searches the PluginManager for the given documentation name and type. + * + * @param name the name for which to search. + * @param type the type of documentation to search for. + * @return the found documentation, or null if none was found. + */ + protected final Documentation documentationFor(String name, DocumentationType type){ + return manager.documentationFor(name, type); + } + /** * Searches the plugin manager for a Pi value for the given number implementation. * This is done so that number implementations with various degrees of precision From 400e4578a008a2c3abc3def4c723d3608a18070b Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 8 Aug 2017 13:49:19 -0700 Subject: [PATCH 09/13] Add documentation browsing to the abacus controller. --- .../org/nwapw/abacus/fx/AbacusController.java | 25 +++++++++++++------ .../nwapw/abacus/fx/DocumentationCell.java | 22 ++++++++++++++++ 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/nwapw/abacus/fx/AbacusController.java b/src/main/java/org/nwapw/abacus/fx/AbacusController.java index 976f8c7..96f155e 100644 --- a/src/main/java/org/nwapw/abacus/fx/AbacusController.java +++ b/src/main/java/org/nwapw/abacus/fx/AbacusController.java @@ -14,6 +14,8 @@ import javafx.util.Callback; import javafx.util.StringConverter; import org.nwapw.abacus.Abacus; import org.nwapw.abacus.config.Configuration; +import org.nwapw.abacus.function.Documentation; +import org.nwapw.abacus.function.DocumentationType; import org.nwapw.abacus.number.ComputationInterruptedException; import org.nwapw.abacus.number.NumberInterface; import org.nwapw.abacus.plugin.ClassFinder; @@ -24,7 +26,9 @@ import org.nwapw.abacus.tree.TreeNode; import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.Set; +import java.util.stream.Collectors; /** @@ -97,7 +101,7 @@ public class AbacusController implements PluginListener { @FXML private TextField computationLimitField; @FXML - private ListView functionListView; + private ListView functionListView; @FXML private TextField functionListSearchField; @@ -120,11 +124,11 @@ public class AbacusController implements PluginListener { /** * The list of functions that are registered in the calculator. */ - private ObservableList functionList; + private ObservableList functionList; /** * The filtered list displayed to the user. */ - private FilteredList functionFilter; + private FilteredList functionFilter; /** * The abacus instance used for changing the plugin configuration. @@ -227,12 +231,12 @@ public class AbacusController implements PluginListener { return new ToggleablePlugin(true, string); } }); - functionList = FXCollections.observableArrayList(); functionFilter = new FilteredList<>(functionList, (s) -> true); functionListView.setItems(functionFilter); functionListSearchField.textProperty().addListener((observable, oldValue, newValue) -> - functionFilter.setPredicate((newValue.length() == 0) ? ((s) -> true) : ((s) -> s.contains(newValue)))); + functionFilter.setPredicate((newValue.length() == 0) ? ((s) -> true) : ((s) -> s.matches(newValue)))); + functionListView.setCellFactory(param -> new DocumentationCell()); historyData = FXCollections.observableArrayList(); historyTable.setItems(historyData); numberImplementationOptions = FXCollections.observableArrayList(); @@ -347,8 +351,15 @@ public class AbacusController implements PluginListener { plugin.enabledProperty().addListener(e -> changesMade = true); enabledPlugins.add(plugin); } - functionList.addAll(manager.getAllFunctions()); - functionList.sort(String::compareTo); + PluginManager pluginManager = abacus.getPluginManager(); + functionList.addAll(manager.getAllFunctions().stream().map(name -> pluginManager.documentationFor(name, DocumentationType.FUNCTION)) + .collect(Collectors.toCollection(ArrayList::new))); + functionList.sort((a, b) -> { + if(a == null && b == null) return 0; + else if(a == null) return -1; + else if(b == null) return 1; + else return a.getCodeName().compareTo(b.getCodeName()); + }); } @Override diff --git a/src/main/java/org/nwapw/abacus/fx/DocumentationCell.java b/src/main/java/org/nwapw/abacus/fx/DocumentationCell.java index 73bdbd7..bc68fb7 100644 --- a/src/main/java/org/nwapw/abacus/fx/DocumentationCell.java +++ b/src/main/java/org/nwapw/abacus/fx/DocumentationCell.java @@ -2,6 +2,8 @@ package org.nwapw.abacus.fx; import javafx.scene.control.Label; import javafx.scene.control.ListCell; +import javafx.scene.control.TitledPane; +import javafx.scene.layout.VBox; import org.nwapw.abacus.function.Documentation; public class DocumentationCell extends ListCell { @@ -10,12 +12,30 @@ public class DocumentationCell extends ListCell { private Label nameLabel; private Label description; private Label longDescription; + private TitledPane titledPane; public DocumentationCell(){ + VBox vbox = new VBox(); + vbox.setSpacing(10); + titledPane = new TitledPane(); codeNameLabel = new Label(); nameLabel = new Label(); description = new Label(); longDescription = new Label(); + codeNameLabel.setWrapText(true); + nameLabel.setWrapText(true); + description.setWrapText(true); + longDescription.setWrapText(true); + vbox.getChildren().add(codeNameLabel); + vbox.getChildren().add(nameLabel); + vbox.getChildren().add(description); + vbox.getChildren().add(longDescription); + titledPane.textProperty().bindBidirectional(codeNameLabel.textProperty()); + titledPane.setContent(vbox); + titledPane.setExpanded(false); + titledPane.maxWidthProperty().bind(widthProperty()); + + visibleProperty().addListener((a, b, c) -> titledPane.setExpanded(false)); } @Override @@ -26,11 +46,13 @@ public class DocumentationCell extends ListCell { nameLabel.setText(""); description.setText(""); longDescription.setText(""); + setGraphic(null); } else { codeNameLabel.setText(item.getCodeName()); nameLabel.setText(item.getName()); description.setText(item.getDescription()); longDescription.setText(item.getLongDescription()); + setGraphic(titledPane); } } } From 6767a0e4aa8fed15bd95052057261b67350b7e0b Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 8 Aug 2017 14:18:08 -0700 Subject: [PATCH 10/13] Change the width property bound to the width. --- src/main/java/org/nwapw/abacus/fx/DocumentationCell.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/nwapw/abacus/fx/DocumentationCell.java b/src/main/java/org/nwapw/abacus/fx/DocumentationCell.java index bc68fb7..fbb5c0f 100644 --- a/src/main/java/org/nwapw/abacus/fx/DocumentationCell.java +++ b/src/main/java/org/nwapw/abacus/fx/DocumentationCell.java @@ -33,7 +33,7 @@ public class DocumentationCell extends ListCell { titledPane.textProperty().bindBidirectional(codeNameLabel.textProperty()); titledPane.setContent(vbox); titledPane.setExpanded(false); - titledPane.maxWidthProperty().bind(widthProperty()); + titledPane.prefWidthProperty().bind(widthProperty()); visibleProperty().addListener((a, b, c) -> titledPane.setExpanded(false)); } From 3316f02e2b71386975f3bfbb1e3e20c7dff4eaed Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 8 Aug 2017 14:18:14 -0700 Subject: [PATCH 11/13] Add documentation. --- .../nwapw/abacus/plugin/StandardPlugin.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java b/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java index 08e849f..5cd7669 100755 --- a/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java +++ b/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java @@ -1,12 +1,18 @@ package org.nwapw.abacus.plugin; import org.nwapw.abacus.function.*; +import org.nwapw.abacus.lexing.pattern.Match; import org.nwapw.abacus.number.NaiveNumber; import org.nwapw.abacus.number.NumberInterface; import org.nwapw.abacus.number.PreciseNumber; +import org.nwapw.abacus.parsing.Parser; +import org.nwapw.abacus.parsing.ShuntingYardParser; +import org.nwapw.abacus.tree.TokenType; +import org.nwapw.abacus.tree.TreeNode; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.function.BiFunction; /** @@ -583,7 +589,32 @@ public class StandardPlugin extends Plugin { registerDocumentation(new Documentation("abs", "Absolute Value", "Finds the distance " + "from zero of a number.", "Given a number, this function finds the distance form " + - "zero of a number, effectively turning negative numbers into positive ones.", DocumentationType.FUNCTION)); + "zero of a number, effectively turning negative numbers into positive ones.\n\n" + + "Example: abs(-2) -> 2", DocumentationType.FUNCTION)); + registerDocumentation(new Documentation("exp", "Exponentiate", "Brings e to the given power.", + "This function evaluates e to the power of the given value, and is the inverse " + + "of the natural logarithm.\n\n" + + "Example: exp(1) -> 2.718...", DocumentationType.FUNCTION)); + registerDocumentation(new Documentation("ln", "Natural Logarithm", "Gets the natural " + + "logarithm of the given value.", "The natural logarithm of a number is essentially " + + "the power that e has to be brought to to be equal to the number.\n\n" + + "Example: ln(2.718) -> 1", DocumentationType.FUNCTION)); + registerDocumentation(new Documentation("sqrt", "Square Root", "Finds the square root " + + "of the number.", "A square root a of a number is defined such that a times a is equal " + + "to that number.\n\n" + + "Example: sqrt(4) -> 2", DocumentationType.FUNCTION)); + registerDocumentation(new Documentation("sin", "Sine", "Computes the sine of the given angle," + + "in radians.", "", DocumentationType.FUNCTION)); + registerDocumentation(new Documentation("cos", "Cosine", "Computes the cosine of the given angle," + + "in radians.", "", DocumentationType.FUNCTION)); + registerDocumentation(new Documentation("tan", "Tangent", "Computes the tangent of the given angle," + + "in radians.", "", DocumentationType.FUNCTION)); + registerDocumentation(new Documentation("sec", "Secant", "Computes the sec of the given angle," + + "in radians.", "", DocumentationType.FUNCTION)); + registerDocumentation(new Documentation("csc", "Cosecant", "Computes the cosecant of the given angle," + + "in radians.", "", DocumentationType.FUNCTION)); + registerDocumentation(new Documentation("cot", "Cotangent", "Computes the cotangent of the given angle," + + "in radians.", "", DocumentationType.FUNCTION)); } @Override From c95a6df304aa93393af25b62cbb8770fc8244405 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 8 Aug 2017 14:26:04 -0700 Subject: [PATCH 12/13] Change the sorting order. --- src/main/java/org/nwapw/abacus/fx/AbacusController.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/nwapw/abacus/fx/AbacusController.java b/src/main/java/org/nwapw/abacus/fx/AbacusController.java index 96f155e..ddd877a 100644 --- a/src/main/java/org/nwapw/abacus/fx/AbacusController.java +++ b/src/main/java/org/nwapw/abacus/fx/AbacusController.java @@ -7,6 +7,7 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.collections.transformation.FilteredList; import javafx.fxml.FXML; +import javafx.scene.Node; import javafx.scene.control.*; import javafx.scene.control.cell.CheckBoxListCell; import javafx.scene.text.Text; @@ -27,6 +28,7 @@ import org.nwapw.abacus.tree.TreeNode; import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Comparator; import java.util.Set; import java.util.stream.Collectors; @@ -354,12 +356,7 @@ public class AbacusController implements PluginListener { PluginManager pluginManager = abacus.getPluginManager(); functionList.addAll(manager.getAllFunctions().stream().map(name -> pluginManager.documentationFor(name, DocumentationType.FUNCTION)) .collect(Collectors.toCollection(ArrayList::new))); - functionList.sort((a, b) -> { - if(a == null && b == null) return 0; - else if(a == null) return -1; - else if(b == null) return 1; - else return a.getCodeName().compareTo(b.getCodeName()); - }); + functionList.sort(Comparator.comparing(Documentation::getCodeName)); } @Override From 33b175a3c6ca880ebc1dc70741856baa4080002e Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 8 Aug 2017 14:39:41 -0700 Subject: [PATCH 13/13] Fix some documentation glitches. --- .../org/nwapw/abacus/plugin/StandardPlugin.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java b/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java index 5cd7669..68c1b43 100755 --- a/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java +++ b/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java @@ -596,24 +596,24 @@ public class StandardPlugin extends Plugin { "of the natural logarithm.\n\n" + "Example: exp(1) -> 2.718...", DocumentationType.FUNCTION)); registerDocumentation(new Documentation("ln", "Natural Logarithm", "Gets the natural " + - "logarithm of the given value.", "The natural logarithm of a number is essentially " + + "logarithm of the given value.", "The natural logarithm of a number is " + "the power that e has to be brought to to be equal to the number.\n\n" + "Example: ln(2.718) -> 1", DocumentationType.FUNCTION)); registerDocumentation(new Documentation("sqrt", "Square Root", "Finds the square root " + "of the number.", "A square root a of a number is defined such that a times a is equal " + "to that number.\n\n" + "Example: sqrt(4) -> 2", DocumentationType.FUNCTION)); - registerDocumentation(new Documentation("sin", "Sine", "Computes the sine of the given angle," + + registerDocumentation(new Documentation("sin", "Sine", "Computes the sine of the given angle, " + "in radians.", "", DocumentationType.FUNCTION)); - registerDocumentation(new Documentation("cos", "Cosine", "Computes the cosine of the given angle," + + registerDocumentation(new Documentation("cos", "Cosine", "Computes the cosine of the given angle, " + "in radians.", "", DocumentationType.FUNCTION)); - registerDocumentation(new Documentation("tan", "Tangent", "Computes the tangent of the given angle," + + registerDocumentation(new Documentation("tan", "Tangent", "Computes the tangent of the given angle, " + "in radians.", "", DocumentationType.FUNCTION)); - registerDocumentation(new Documentation("sec", "Secant", "Computes the sec of the given angle," + + registerDocumentation(new Documentation("sec", "Secant", "Computes the secant of the given angle, " + "in radians.", "", DocumentationType.FUNCTION)); - registerDocumentation(new Documentation("csc", "Cosecant", "Computes the cosecant of the given angle," + + registerDocumentation(new Documentation("csc", "Cosecant", "Computes the cosecant of the given angle, " + "in radians.", "", DocumentationType.FUNCTION)); - registerDocumentation(new Documentation("cot", "Cotangent", "Computes the cotangent of the given angle," + + registerDocumentation(new Documentation("cot", "Cotangent", "Computes the cotangent of the given angle, " + "in radians.", "", DocumentationType.FUNCTION)); }