Custom Decimals Moar
This commit is contained in:
parent
b1133e0aee
commit
522899eb1e
|
@ -81,7 +81,7 @@ public class KorrekturHelper
|
||||||
kh.frm.setVisible(true);
|
kh.frm.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LinkedHashSet<Node> parseNodes(String[] lines, int[] lineMap) throws IOException
|
private static LinkedHashSet<Node> parseNodes(String[] lines, int[] lineMap, HtmlContext hc) throws IOException
|
||||||
{
|
{
|
||||||
var roots = new LinkedHashSet<Node>();
|
var roots = new LinkedHashSet<Node>();
|
||||||
var path = new LinkedList<Node>();
|
var path = new LinkedList<Node>();
|
||||||
|
@ -97,10 +97,10 @@ public class KorrekturHelper
|
||||||
yield new HeaderNode(line.substring(path.size()));
|
yield new HeaderNode(line.substring(path.size()));
|
||||||
|
|
||||||
case "[]": // [] -0.5 Punktabzug
|
case "[]": // [] -0.5 Punktabzug
|
||||||
yield new CheckboxNode(line.substring(path.size()));
|
yield new CheckboxNode(line.substring(path.size()), hc);
|
||||||
|
|
||||||
case "\\": // \ 1.0 Element existiert | Element existiert nicht
|
case "\\": // \ 1.0 Element existiert | Element existiert nicht
|
||||||
yield new EitherNode(line.substring(path.size()));
|
yield new EitherNode(line.substring(path.size()), hc);
|
||||||
|
|
||||||
case "\\\\": // \\ MultiSelects
|
case "\\\\": // \\ MultiSelects
|
||||||
if (lines.length <= li)
|
if (lines.length <= li)
|
||||||
|
@ -118,12 +118,12 @@ public class KorrekturHelper
|
||||||
if (lines[li + 1].trim().startsWith("[]"))
|
if (lines[li + 1].trim().startsWith("[]"))
|
||||||
{
|
{
|
||||||
li = i - 1;
|
li = i - 1;
|
||||||
yield new CheckboxMultiSelectNode(sb.toString());
|
yield new CheckboxMultiSelectNode(sb.toString(), hc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
li = i - 1;
|
li = i - 1;
|
||||||
yield new RadioMultiSelectNode(sb.toString());
|
yield new RadioMultiSelectNode(sb.toString(), hc);
|
||||||
}
|
}
|
||||||
|
|
||||||
case "":
|
case "":
|
||||||
|
@ -243,7 +243,7 @@ public class KorrekturHelper
|
||||||
lineMap.add(lineNumber);
|
lineMap.add(lineNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return parseNodes(nodeLines.toArray(String[]::new), lineMap.stream().mapToInt(i -> i).toArray());
|
return parseNodes(nodeLines.toArray(String[]::new), lineMap.stream().mapToInt(i -> i).toArray(), hc);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BigDecimal recursiveAchievedPoints(LinkedHashSet<Node> nodes, MathContext mc)
|
private static BigDecimal recursiveAchievedPoints(LinkedHashSet<Node> nodes, MathContext mc)
|
||||||
|
|
|
@ -25,8 +25,9 @@ public class CheckboxMultiSelectNode extends AbstractNode
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param config the config string to parse
|
* @param config the config string to parse
|
||||||
|
* @param hc {@link HtmlContext}
|
||||||
*/
|
*/
|
||||||
public CheckboxMultiSelectNode(String config)
|
public CheckboxMultiSelectNode(String config, HtmlContext hc)
|
||||||
{
|
{
|
||||||
var lines = config.split("\n");
|
var lines = config.split("\n");
|
||||||
if (lines.length <= 1)
|
if (lines.length <= 1)
|
||||||
|
@ -58,7 +59,7 @@ public class CheckboxMultiSelectNode extends AbstractNode
|
||||||
{ throw new IllegalArgumentException("Expected []"); }
|
{ throw new IllegalArgumentException("Expected []"); }
|
||||||
points[i - 1] = new BigDecimal(s[1]);
|
points[i - 1] = new BigDecimal(s[1]);
|
||||||
text[i - 1] = s[2];
|
text[i - 1] = s[2];
|
||||||
rbs[i - 1] = new JCheckBox(Utils.formatPoints(points[i - 1], 2) + "P - " + text[i - 1]);
|
rbs[i - 1] = new JCheckBox(Utils.formatPoints(points[i - 1], hc.decimals) + "P - " + text[i - 1]);
|
||||||
rbs[i - 1].addActionListener(cl);
|
rbs[i - 1].addActionListener(cl);
|
||||||
content.add(rbs[i - 1]);
|
content.add(rbs[i - 1]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,9 @@ public class CheckboxNode extends AbstractNode
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param configString config String to parse
|
* @param configString config String to parse
|
||||||
|
* @param hc {@link HtmlContext}
|
||||||
*/
|
*/
|
||||||
public CheckboxNode(String configString)
|
public CheckboxNode(String configString, HtmlContext hc)
|
||||||
{
|
{
|
||||||
if (configString.contains("\n"))
|
if (configString.contains("\n"))
|
||||||
{ throw new IllegalArgumentException("Bad config! Found line feed!"); }
|
{ throw new IllegalArgumentException("Bad config! Found line feed!"); }
|
||||||
|
@ -33,7 +34,7 @@ public class CheckboxNode extends AbstractNode
|
||||||
{ throw new IllegalArgumentException("Not a [] Node"); }
|
{ throw new IllegalArgumentException("Not a [] Node"); }
|
||||||
points = new BigDecimal(spl[1]);
|
points = new BigDecimal(spl[1]);
|
||||||
message = spl[2];
|
message = spl[2];
|
||||||
cbx = new JCheckBox(Utils.formatPoints(points, 2) + "P " + message);
|
cbx = new JCheckBox(Utils.formatPoints(points, hc.decimals) + "P " + message);
|
||||||
cbx.addActionListener(e -> onChange(this));
|
cbx.addActionListener(e -> onChange(this));
|
||||||
content.add(cbx);
|
content.add(cbx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,9 @@ public class EitherNode extends AbstractNode
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param config the config String
|
* @param config the config String
|
||||||
|
* @param hc {@link HtmlContext}
|
||||||
*/
|
*/
|
||||||
public EitherNode(String config)
|
public EitherNode(String config, HtmlContext hc)
|
||||||
{
|
{
|
||||||
if (config.contains("\n"))
|
if (config.contains("\n"))
|
||||||
{ throw new IllegalArgumentException("Bad config! Found line feed!"); }
|
{ throw new IllegalArgumentException("Bad config! Found line feed!"); }
|
||||||
|
@ -42,15 +43,15 @@ public class EitherNode extends AbstractNode
|
||||||
messageFail = spl.length == 3 ? null : spl.length == 4 ? spl[3].substring(1).trim() : spl[4];
|
messageFail = spl.length == 3 ? null : spl.length == 4 ? spl[3].substring(1).trim() : spl[4];
|
||||||
if (points.signum() > 0)
|
if (points.signum() > 0)
|
||||||
{
|
{
|
||||||
btn_ok = new JRadioButton(Utils.formatPoints(points, 2) + "P " + messageOK);
|
btn_ok = new JRadioButton(Utils.formatPoints(points, hc.decimals) + "P " + messageOK);
|
||||||
btn_fail = new JRadioButton(
|
btn_fail = new JRadioButton(
|
||||||
Utils.ptsToString(BigDecimal.ZERO) + "P " + (messageFail == null ? messageOK : messageFail));
|
Utils.formatPoints(BigDecimal.ZERO, hc.decimals) + "P " + (messageFail == null ? messageOK : messageFail));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
btn_ok = new JRadioButton(Utils.formatPoints(BigDecimal.ZERO, 2) + "P " + messageOK);
|
btn_ok = new JRadioButton(Utils.formatPoints(BigDecimal.ZERO, hc.decimals) + "P " + messageOK);
|
||||||
btn_fail = new JRadioButton(
|
btn_fail = new JRadioButton(
|
||||||
Utils.formatPoints(points, 2) + "P " + (messageFail == null ? messageOK : messageFail));
|
Utils.formatPoints(points, hc.decimals) + "P " + (messageFail == null ? messageOK : messageFail));
|
||||||
}
|
}
|
||||||
btn_ok.addActionListener(e -> onChange(this));
|
btn_ok.addActionListener(e -> onChange(this));
|
||||||
btn_fail.addActionListener(e -> onChange(this));
|
btn_fail.addActionListener(e -> onChange(this));
|
||||||
|
|
|
@ -28,8 +28,9 @@ public class RadioMultiSelectNode extends AbstractNode
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param config the config string to parse
|
* @param config the config string to parse
|
||||||
|
* @param hc htmlContext
|
||||||
*/
|
*/
|
||||||
public RadioMultiSelectNode(String config)
|
public RadioMultiSelectNode(String config, HtmlContext hc)
|
||||||
{
|
{
|
||||||
var lines = config.split("\n");
|
var lines = config.split("\n");
|
||||||
if (lines.length <= 1)
|
if (lines.length <= 1)
|
||||||
|
@ -60,7 +61,7 @@ public class RadioMultiSelectNode extends AbstractNode
|
||||||
{ throw new IllegalArgumentException("Expected exactly 1 \\t"); }
|
{ throw new IllegalArgumentException("Expected exactly 1 \\t"); }
|
||||||
points[i - 1] = new BigDecimal(s[0]);
|
points[i - 1] = new BigDecimal(s[0]);
|
||||||
text[i - 1] = s[1];
|
text[i - 1] = s[1];
|
||||||
rbs[i - 1] = new JRadioButton(Utils.formatPoints(points[i - 1], 2) + "P - " + text[i - 1]);
|
rbs[i - 1] = new JRadioButton(Utils.formatPoints(points[i - 1], hc.decimals) + "P - " + text[i - 1]);
|
||||||
rbs[i - 1].addActionListener(cl);
|
rbs[i - 1].addActionListener(cl);
|
||||||
content.add(rbs[i - 1]);
|
content.add(rbs[i - 1]);
|
||||||
bg.add(rbs[i - 1]);
|
bg.add(rbs[i - 1]);
|
||||||
|
|
Loading…
Reference in New Issue