mirror of
https://github.com/DanilaFe/abacus
synced 2024-12-23 16:00:09 -08:00
Add comments and clean some code.
This commit is contained in:
parent
4c8dff6623
commit
ce484cfd43
|
@ -3,25 +3,52 @@ package org.nwapw.abacus.fx;
|
||||||
import javafx.beans.property.BooleanProperty;
|
import javafx.beans.property.BooleanProperty;
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class that represents an entry in the plugin check box list.
|
||||||
|
* The changes from this property are written to the config on application.
|
||||||
|
*/
|
||||||
public class ToggleablePlugin {
|
public class ToggleablePlugin {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The property that determines whether the plugin will be enabled.
|
||||||
|
*/
|
||||||
private final BooleanProperty enabled;
|
private final BooleanProperty enabled;
|
||||||
|
/**
|
||||||
|
* The name of the class this entry toggles.
|
||||||
|
*/
|
||||||
private final String className;
|
private final String className;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new toggleable plugin with the given properties.
|
||||||
|
* @param enabled the enabled / disabled state at the beginning.
|
||||||
|
* @param className the name of the class this plugin toggles.
|
||||||
|
*/
|
||||||
public ToggleablePlugin(boolean enabled, String className){
|
public ToggleablePlugin(boolean enabled, String className){
|
||||||
this.enabled = new SimpleBooleanProperty();
|
this.enabled = new SimpleBooleanProperty();
|
||||||
this.enabled.setValue(enabled);
|
this.enabled.setValue(enabled);
|
||||||
this.className = className;
|
this.className = className;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the enabled property of this plugin.
|
||||||
|
* @return the enabled property.
|
||||||
|
*/
|
||||||
public BooleanProperty enabledProperty() {
|
public BooleanProperty enabledProperty() {
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if this plugin entry should be enabled.
|
||||||
|
* @return whether this plugin will be enabled.
|
||||||
|
*/
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return enabled.get();
|
return enabled.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the class name this plugin toggles.
|
||||||
|
* @return the class name that should be disabled.
|
||||||
|
*/
|
||||||
public String getClassName() {
|
public String getClassName() {
|
||||||
return className;
|
return className;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import java.util.function.BiFunction;
|
||||||
*/
|
*/
|
||||||
public class StandardPlugin extends Plugin {
|
public class StandardPlugin extends Plugin {
|
||||||
|
|
||||||
private static HashMap<Class<? extends NumberInterface>, ArrayList<NumberInterface>> factorialLists = new HashMap<Class<? extends NumberInterface>, ArrayList<NumberInterface>>();
|
private static final HashMap<Class<? extends NumberInterface>, ArrayList<NumberInterface>> FACTORIAL_LISTS = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The addition operator, +
|
* The addition operator, +
|
||||||
|
@ -318,6 +318,9 @@ public class StandardPlugin extends Plugin {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The cosine function (the argument is in radians).
|
||||||
|
*/
|
||||||
public final Function functionCos = new Function() {
|
public final Function functionCos = new Function() {
|
||||||
@Override
|
@Override
|
||||||
protected boolean matchesParams(NumberInterface[] params) {
|
protected boolean matchesParams(NumberInterface[] params) {
|
||||||
|
@ -331,6 +334,9 @@ public class StandardPlugin extends Plugin {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The tangent function (the argument is in radians).
|
||||||
|
*/
|
||||||
public final Function functionTan = new Function() {
|
public final Function functionTan = new Function() {
|
||||||
@Override
|
@Override
|
||||||
protected boolean matchesParams(NumberInterface[] params) {
|
protected boolean matchesParams(NumberInterface[] params) {
|
||||||
|
@ -343,6 +349,9 @@ public class StandardPlugin extends Plugin {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The secant function (the argument is in radians).
|
||||||
|
*/
|
||||||
public final Function functionSec = new Function() {
|
public final Function functionSec = new Function() {
|
||||||
@Override
|
@Override
|
||||||
protected boolean matchesParams(NumberInterface[] params) {
|
protected boolean matchesParams(NumberInterface[] params) {
|
||||||
|
@ -355,6 +364,9 @@ public class StandardPlugin extends Plugin {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The cosecant function (the argument is in radians).
|
||||||
|
*/
|
||||||
public final Function functionCsc = new Function() {
|
public final Function functionCsc = new Function() {
|
||||||
@Override
|
@Override
|
||||||
protected boolean matchesParams(NumberInterface[] params) {
|
protected boolean matchesParams(NumberInterface[] params) {
|
||||||
|
@ -367,6 +379,9 @@ public class StandardPlugin extends Plugin {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The cotangent function (the argument is in radians).
|
||||||
|
*/
|
||||||
public final Function functionCot = new Function() {
|
public final Function functionCot = new Function() {
|
||||||
@Override
|
@Override
|
||||||
protected boolean matchesParams(NumberInterface[] params) {
|
protected boolean matchesParams(NumberInterface[] params) {
|
||||||
|
@ -499,12 +514,12 @@ public class StandardPlugin extends Plugin {
|
||||||
* @return a number of numClass with value n factorial.
|
* @return a number of numClass with value n factorial.
|
||||||
*/
|
*/
|
||||||
public static NumberInterface factorial(Class<? extends NumberInterface> numberClass, int n){
|
public static NumberInterface factorial(Class<? extends NumberInterface> numberClass, int n){
|
||||||
if(!factorialLists.containsKey(numberClass)){
|
if(!FACTORIAL_LISTS.containsKey(numberClass)){
|
||||||
factorialLists.put(numberClass, new ArrayList<>());
|
FACTORIAL_LISTS.put(numberClass, new ArrayList<>());
|
||||||
factorialLists.get(numberClass).add(NaiveNumber.ONE.promoteTo(numberClass));
|
FACTORIAL_LISTS.get(numberClass).add(NaiveNumber.ONE.promoteTo(numberClass));
|
||||||
factorialLists.get(numberClass).add(NaiveNumber.ONE.promoteTo(numberClass));
|
FACTORIAL_LISTS.get(numberClass).add(NaiveNumber.ONE.promoteTo(numberClass));
|
||||||
}
|
}
|
||||||
ArrayList<NumberInterface> list = factorialLists.get(numberClass);
|
ArrayList<NumberInterface> list = FACTORIAL_LISTS.get(numberClass);
|
||||||
if(n >= list.size()){
|
if(n >= list.size()){
|
||||||
while(list.size() < n + 16){
|
while(list.size() < n + 16){
|
||||||
list.add(list.get(list.size()-1).multiply(new NaiveNumber(list.size()).promoteTo(numberClass)));
|
list.add(list.get(list.size()-1).multiply(new NaiveNumber(list.size()).promoteTo(numberClass)));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user