First Release and most Bugs eliminated
This commit is contained in:
parent
43aa49e419
commit
f9e1335a82
|
@ -10,6 +10,8 @@ import javax.swing.JCheckBox;
|
||||||
*/
|
*/
|
||||||
public class HtmlContext
|
public class HtmlContext
|
||||||
{
|
{
|
||||||
|
/** Base Points to start from, overrides max Points */
|
||||||
|
public BigDecimal basePoints = null;
|
||||||
/** Style for unchecked Boxes in CheckboxMultiSelect */
|
/** Style for unchecked Boxes in CheckboxMultiSelect */
|
||||||
public String cbmsFail = "";
|
public String cbmsFail = "";
|
||||||
/** Style for checked Boxes in CheckboxMultiSelect */
|
/** Style for checked Boxes in CheckboxMultiSelect */
|
||||||
|
@ -24,12 +26,12 @@ public class HtmlContext
|
||||||
public String noPtsStyle = "";
|
public String noPtsStyle = "";
|
||||||
/** Style for the Text, when the best case Points have been achieved */
|
/** Style for the Text, when the best case Points have been achieved */
|
||||||
public String noPtsTextStyle = "";
|
public String noPtsTextStyle = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Style for the Points, when neither best nor worst case Points have been
|
* Style for the Points, when neither best nor worst case Points have been
|
||||||
* achieved
|
* achieved
|
||||||
*/
|
*/
|
||||||
public String partialPtsStyle = "";
|
public String partialPtsStyle = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Style for the Text, when neither best nor worst case Points have been
|
* Style for the Text, when neither best nor worst case Points have been
|
||||||
* achieved
|
* achieved
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
package de.tuDortmund.cs.rvs.pingger.korrekturHelper;
|
package de.tuDortmund.cs.rvs.pingger.korrekturHelper;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.awt.BorderLayout;
|
||||||
import java.io.IOException;
|
import java.awt.Color;
|
||||||
import java.io.InputStreamReader;
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.datatransfer.Clipboard;
|
||||||
|
import java.awt.datatransfer.DataFlavor;
|
||||||
|
import java.awt.datatransfer.StringSelection;
|
||||||
|
import java.io.*;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.MathContext;
|
import java.math.MathContext;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
@ -11,10 +15,7 @@ import java.util.LinkedHashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import javax.swing.BoxLayout;
|
import javax.swing.*;
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
|
|
||||||
import de.tuDortmund.cs.rvs.pingger.korrekturHelper.nodes.*;
|
import de.tuDortmund.cs.rvs.pingger.korrekturHelper.nodes.*;
|
||||||
|
|
||||||
|
@ -51,33 +52,33 @@ public class KorrekturHelper
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) throws IOException
|
public static void main(String[] args) throws IOException
|
||||||
{
|
{
|
||||||
try (
|
LinkedHashSet<Node> x;
|
||||||
var in = KorrekturHelper.class.getClassLoader()
|
var hc = new HtmlContext();
|
||||||
.getResourceAsStream("de/tuDortmund/cs/rvs/pingger/korrekturHelper/Test.schema");
|
if (args.length == 0)
|
||||||
var isr = new InputStreamReader(in, StandardCharsets.UTF_8);
|
|
||||||
var br = new BufferedReader(isr, 1024 * 1024)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
var x = parseSchema(br);
|
try (
|
||||||
var frm = new JFrame("Test");
|
var in = KorrekturHelper.class.getClassLoader()
|
||||||
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
.getResourceAsStream("de/tuDortmund/cs/rvs/pingger/korrekturHelper/Test.schema");
|
||||||
var panel = new JPanel(true);
|
var isr = new InputStreamReader(in, StandardCharsets.UTF_8);
|
||||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
var br = new BufferedReader(isr, 1024 * 1024)
|
||||||
var jsp = new JScrollPane(panel);
|
)
|
||||||
Consumer<Node> c = n -> {
|
|
||||||
var sb = new StringBuilder();
|
|
||||||
recursiveToHtml(x, sb, new HtmlContext(), 0);
|
|
||||||
System.out.println(sb);
|
|
||||||
};
|
|
||||||
for (var n : x)
|
|
||||||
{
|
{
|
||||||
n.addChangeListener(c);
|
x = parseSchema(br, hc);
|
||||||
panel.add(n.getComponent());
|
|
||||||
}
|
}
|
||||||
frm.setContentPane(jsp);
|
|
||||||
frm.pack();
|
|
||||||
frm.setVisible(true);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try (
|
||||||
|
var in = new FileInputStream(new File(args[0]));
|
||||||
|
var isr = new InputStreamReader(in, StandardCharsets.UTF_8);
|
||||||
|
var br = new BufferedReader(isr, 1024 * 1024)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
x = parseSchema(br, hc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var kh = new KorrekturHelper(x, hc);
|
||||||
|
kh.frm.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LinkedHashSet<Node> parseNodes(String[] lines, int[] lineMap) throws IOException
|
private static LinkedHashSet<Node> parseNodes(String[] lines, int[] lineMap) throws IOException
|
||||||
|
@ -155,7 +156,15 @@ public class KorrekturHelper
|
||||||
return roots;
|
return roots;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LinkedHashSet<Node> parseSchema(BufferedReader br) throws IOException
|
/**
|
||||||
|
* Parses the Schema provided by the Buffered Reader
|
||||||
|
*
|
||||||
|
* @param br the Reader to read from
|
||||||
|
* @param hc the HtmlContext to apply the settings to
|
||||||
|
* @return the Found root-Nodes (containing their children recursively)
|
||||||
|
* @throws IOException in case reading fails
|
||||||
|
*/
|
||||||
|
public static LinkedHashSet<Node> parseSchema(BufferedReader br, HtmlContext hc) throws IOException
|
||||||
{
|
{
|
||||||
var lineMap = new ArrayList<Integer>();
|
var lineMap = new ArrayList<Integer>();
|
||||||
var nodeLines = new ArrayList<String>();
|
var nodeLines = new ArrayList<String>();
|
||||||
|
@ -170,8 +179,60 @@ public class KorrekturHelper
|
||||||
}
|
}
|
||||||
if (line.startsWith(":"))
|
if (line.startsWith(":"))
|
||||||
{
|
{
|
||||||
// TODO
|
var split = line.split("\t", -1);
|
||||||
|
switch (split[0])
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* :base 0.0
|
||||||
|
// Design für Punkte. Pts ist dabei für die Punkte, PtsText für den Text. die Punkte zählen als Teil des Textes (<li style=PtsText><span style=Pts>'Punkte'</span>Text</li>)
|
||||||
|
// full -> best-Case
|
||||||
|
:fullPts color: #0f0;
|
||||||
|
:fullPtsText
|
||||||
|
// no -> worst-case
|
||||||
|
:noPts color: #f00;
|
||||||
|
:noPtsText
|
||||||
|
// partial -> alle verbleibenden Fälle. Sonderfall: Elemente die 0 Punkte bringen (egal was ausgewählt ist) haben auch diesen Fall!
|
||||||
|
:partialPts color: #fb0;
|
||||||
|
:partialPtsText
|
||||||
|
:cbmsOk color: #080;
|
||||||
|
:cbmsFail color: #800;
|
||||||
|
*/
|
||||||
|
case ":base":
|
||||||
|
hc.basePoints = new BigDecimal(split[1]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ":fullPts":
|
||||||
|
hc.fullPtsStyle = split.length > 1 ? split[1] : "";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ":fullPtsText":
|
||||||
|
hc.fullPtsTextStyle = split.length > 1 ? split[1] : "";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ":noPts":
|
||||||
|
hc.noPtsStyle = split.length > 1 ? split[1] : "";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ":noPtsText":
|
||||||
|
hc.noPtsTextStyle = split.length > 1 ? split[1] : "";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ":partialPts":
|
||||||
|
hc.partialPtsStyle = split.length > 1 ? split[1] : "";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ":partialPtsText":
|
||||||
|
hc.partialPtsTextStyle = split.length > 1 ? split[1] : "";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ":cbmsOk":
|
||||||
|
hc.cbmsOk = split.length > 1 ? split[1] : "";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ":cbmsFail":
|
||||||
|
hc.cbmsFail = split.length > 1 ? split[1] : "";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -225,8 +286,115 @@ public class KorrekturHelper
|
||||||
}
|
}
|
||||||
if (depth == 0)
|
if (depth == 0)
|
||||||
{
|
{
|
||||||
sb.append("\n<p>").append(recursiveAchievedPoints(nodes, hc.mc)).append("/")
|
sb.append("\n<p>");
|
||||||
.append(recursiveMaxPoints(nodes, hc.mc)).append("</p>\n");
|
sb.append(hc.basePoints == null || hc.basePoints.equals(BigDecimal.ZERO) ? recursiveAchievedPoints(nodes, hc.mc)
|
||||||
|
: hc.basePoints.add(recursiveAchievedPoints(nodes, hc.mc), hc.mc));
|
||||||
|
sb.append("/");
|
||||||
|
sb.append(hc.basePoints == null || hc.basePoints.equals(BigDecimal.ZERO) ? recursiveMaxPoints(nodes, hc.mc)
|
||||||
|
: hc.basePoints);
|
||||||
|
sb.append("</p>\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final JButton btn_toClipboard;
|
||||||
|
private String currentHtml = "";
|
||||||
|
public final JFrame frm;
|
||||||
|
|
||||||
|
private final HtmlContext hc;
|
||||||
|
|
||||||
|
private final LinkedHashSet<Node> nodes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param nodes Nodes
|
||||||
|
* @param hc HtmlContext
|
||||||
|
*/
|
||||||
|
public KorrekturHelper(LinkedHashSet<Node> nodes, HtmlContext hc)
|
||||||
|
{
|
||||||
|
|
||||||
|
this.nodes = nodes;
|
||||||
|
this.hc = hc;
|
||||||
|
frm = new JFrame("Pinggers Korrektur Helper");
|
||||||
|
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
var contentPanel = new JPanel(new BorderLayout(), true);
|
||||||
|
/*
|
||||||
|
* Menu Panel
|
||||||
|
*/
|
||||||
|
var menuPanel = new JPanel(true);
|
||||||
|
menuPanel.setLayout(new BoxLayout(menuPanel, BoxLayout.X_AXIS));
|
||||||
|
|
||||||
|
var jtb_aot = new JToggleButton("Always on Top");
|
||||||
|
jtb_aot.addActionListener(l -> frm.setAlwaysOnTop(jtb_aot.isSelected()));
|
||||||
|
menuPanel.add(jtb_aot);
|
||||||
|
// SpinnerModel sm = new SpinnerNumberModel(100, 25, 100, 5);
|
||||||
|
// sm.addChangeListener(e -> AWTUtilities.setWindowOpacity((float) ((int)
|
||||||
|
// sm.getValue() / 100.0)));
|
||||||
|
// var spn_opacity = new JSpinner(sm);
|
||||||
|
// menuPanel.add(spn_opacity);
|
||||||
|
btn_toClipboard = new JButton("Copy to Clipboard");
|
||||||
|
btn_toClipboard.addActionListener(e -> copyToClipboard());
|
||||||
|
menuPanel.add(btn_toClipboard);
|
||||||
|
var btn_reset = new JButton("Reset");
|
||||||
|
btn_reset.addActionListener(e -> this.nodes.forEach(Node::reset));
|
||||||
|
menuPanel.add(btn_reset);
|
||||||
|
contentPanel.add(menuPanel, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Node-Panel with Scrollpane
|
||||||
|
*/
|
||||||
|
var panel = new JPanel(true);
|
||||||
|
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||||
|
var jsp = new JScrollPane(panel);
|
||||||
|
Consumer<Node> c = n -> lostOwnership();
|
||||||
|
for (var n : nodes)
|
||||||
|
{
|
||||||
|
n.addChangeListener(c);
|
||||||
|
panel.add(n.getComponent());
|
||||||
|
}
|
||||||
|
contentPanel.add(jsp, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
frm.setContentPane(contentPanel);
|
||||||
|
frm.pack();
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void copyToClipboard()
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
recursiveToHtml(nodes, sb, hc, 0);
|
||||||
|
currentHtml = sb.toString();
|
||||||
|
StringSelection s = new StringSelection(currentHtml)
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void lostOwnership(Clipboard clipboard, java.awt.datatransfer.Transferable contents)
|
||||||
|
{
|
||||||
|
KorrekturHelper.this.lostOwnership();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||||
|
clipboard.setContents(s, s);
|
||||||
|
btn_toClipboard.setBackground(Color.GREEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void lostOwnership()
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
recursiveToHtml(nodes, sb, hc, 0);
|
||||||
|
currentHtml = sb.toString();
|
||||||
|
var clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var contents = clipboard.getData(DataFlavor.stringFlavor);
|
||||||
|
if (!currentHtml.equals(contents))
|
||||||
|
{
|
||||||
|
btn_toClipboard.setBackground(Color.ORANGE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
btn_toClipboard.setBackground(Color.GREEN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
btn_toClipboard.setBackground(Color.ORANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,11 @@ import java.math.BigDecimal;
|
||||||
public class Utils
|
public class Utils
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public static String formatPoints(BigDecimal bd)
|
||||||
|
{
|
||||||
|
return String.format("%.1f", bd.doubleValue());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param p the {@link BigDecimal} to format
|
* @param p the {@link BigDecimal} to format
|
||||||
* @return a String for the given {@link BigDecimal}
|
* @return a String for the given {@link BigDecimal}
|
||||||
|
|
|
@ -58,7 +58,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.ptsToString(points[i - 1]) + "P - " + text[i - 1]);
|
rbs[i - 1] = new JCheckBox(Utils.formatPoints(points[i - 1]) + "P - " + text[i - 1]);
|
||||||
rbs[i - 1].addActionListener(cl);
|
rbs[i - 1].addActionListener(cl);
|
||||||
content.add(rbs[i - 1]);
|
content.add(rbs[i - 1]);
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ public class CheckboxMultiSelectNode extends AbstractNode
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
sb.append("<li").append(hc.styleText(achievedPoints(hc.mc), maxPoints)).append(">");
|
sb.append("<li").append(hc.styleText(achievedPoints(hc.mc), maxPoints)).append(">");
|
||||||
sb.append("<span").append(hc.stylePts(achievedPoints(hc.mc), maxPoints)).append(">");
|
sb.append("<span").append(hc.stylePts(achievedPoints(hc.mc), maxPoints)).append(">");
|
||||||
sb.append(achievedPoints(hc.mc)).append(" / ").append(maxPoints.toPlainString());
|
sb.append(Utils.formatPoints(achievedPoints(hc.mc))).append(" / ").append(Utils.formatPoints(maxPoints));
|
||||||
sb.append("P</span> ");
|
sb.append("P</span> ");
|
||||||
sb.append(baseMsg);
|
sb.append(baseMsg);
|
||||||
sb.append("\n\t<ul style=\"list-style-type: none;margin-top: 0px;margin-bottom:0px\">\n");
|
sb.append("\n\t<ul style=\"list-style-type: none;margin-top: 0px;margin-bottom:0px\">\n");
|
||||||
|
@ -132,7 +132,7 @@ public class CheckboxMultiSelectNode extends AbstractNode
|
||||||
{
|
{
|
||||||
sb.append("\t\t<li").append(hc.cbx(rbs[i])).append(">");
|
sb.append("\t\t<li").append(hc.cbx(rbs[i])).append(">");
|
||||||
sb.append(rbs[i].isSelected() ? "✓ " : "✗ ");
|
sb.append(rbs[i].isSelected() ? "✓ " : "✗ ");
|
||||||
sb.append("(").append(points[i].toPlainString()).append("P) ");
|
sb.append("(").append(Utils.formatPoints(points[i])).append("P) ");
|
||||||
sb.append(text[i]);
|
sb.append(text[i]);
|
||||||
sb.append("</li>\n");
|
sb.append("</li>\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,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.ptsToString(points) + "P " + message);
|
cbx = new JCheckBox(Utils.formatPoints(points) + "P " + message);
|
||||||
cbx.addActionListener(e -> onChange(this));
|
cbx.addActionListener(e -> onChange(this));
|
||||||
content.add(cbx);
|
content.add(cbx);
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ public class CheckboxNode extends AbstractNode
|
||||||
public String toResultHtml(HtmlContext hc)
|
public String toResultHtml(HtmlContext hc)
|
||||||
{
|
{
|
||||||
return "<li" + hc.styleText(points.signum()) + "><span" + hc.stylePts(points.signum()) + ">"
|
return "<li" + hc.styleText(points.signum()) + "><span" + hc.stylePts(points.signum()) + ">"
|
||||||
+ Utils.ptsToString(achievedPoints(hc.mc)) + "P</span> " + message + "</li>";
|
+ Utils.formatPoints(achievedPoints(hc.mc)) + "P</span> " + message + "</li>";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,14 +42,14 @@ 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.ptsToString(points) + "P " + messageOK);
|
btn_ok = new JRadioButton(Utils.formatPoints(points) + "P " + messageOK);
|
||||||
btn_fail = new JRadioButton(
|
btn_fail = new JRadioButton(
|
||||||
Utils.ptsToString(BigDecimal.ZERO) + "P " + (messageFail == null ? messageOK : messageFail));
|
Utils.ptsToString(BigDecimal.ZERO) + "P " + (messageFail == null ? messageOK : messageFail));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
btn_ok = new JRadioButton(Utils.ptsToString(BigDecimal.ZERO) + "P " + messageOK);
|
btn_ok = new JRadioButton(Utils.formatPoints(BigDecimal.ZERO) + "P " + messageOK);
|
||||||
btn_fail = new JRadioButton(Utils.ptsToString(points) + "P " + (messageFail == null ? messageOK : messageFail));
|
btn_fail = new JRadioButton(Utils.formatPoints(points) + "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));
|
||||||
|
@ -125,8 +125,8 @@ public class EitherNode extends AbstractNode
|
||||||
}
|
}
|
||||||
return "<li" + hc.styleText(signum) + ">" + //
|
return "<li" + hc.styleText(signum) + ">" + //
|
||||||
"<span" + hc.stylePts(signum) + ">" + //
|
"<span" + hc.stylePts(signum) + ">" + //
|
||||||
Utils.ptsToString(achievedPoints(hc.mc)) + //
|
Utils.formatPoints(achievedPoints(hc.mc)) + //
|
||||||
(points.signum() < 0 ? "" : " / " + maximumPoints()) + "P" + //
|
(points.signum() < 0 ? "" : " / " + Utils.formatPoints(maximumPoints())) + "P" + //
|
||||||
"</span> " + //
|
"</span> " + //
|
||||||
(btn_fail.isSelected() ? btn_fail.getText() : btn_ok.getText()) + //
|
(btn_fail.isSelected() ? btn_fail.getText() : btn_ok.getText()) + //
|
||||||
"</li>";
|
"</li>";
|
||||||
|
|
|
@ -15,6 +15,8 @@ import de.tuDortmund.cs.rvs.pingger.korrekturHelper.HtmlContext;
|
||||||
public class HeaderNode extends AbstractNode
|
public class HeaderNode extends AbstractNode
|
||||||
{
|
{
|
||||||
private static final String[] configStyles = { "", "#", "##", "###", "####", "#####", "######", "*", "_" };
|
private static final String[] configStyles = { "", "#", "##", "###", "####", "#####", "######", "*", "_" };
|
||||||
|
private static final int[] fontSizes = { 0, 24, 20, 18, 16, 14, 12 };
|
||||||
|
|
||||||
private static final String[] htmlStyles = { "", "h1", "h2", "h3", "h4", "h5", "h6", "b", "i" };
|
private static final String[] htmlStyles = { "", "h1", "h2", "h3", "h4", "h5", "h6", "b", "i" };
|
||||||
|
|
||||||
private static int indexOf(String[] array, String elem)
|
private static int indexOf(String[] array, String elem)
|
||||||
|
@ -74,8 +76,7 @@ public class HeaderNode extends AbstractNode
|
||||||
case 4:
|
case 4:
|
||||||
case 5:
|
case 5:
|
||||||
case 6:
|
case 6:
|
||||||
lbl.setFont(new Font(lbl.getFont().getFontName(), Font.PLAIN,
|
lbl.setFont(new Font(lbl.getFont().getFontName(), Font.PLAIN, fontSizes[style]));
|
||||||
(int) (lbl.getFont().getSize() * (1.0 + (6 - style) / 6))));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class RadioMultiSelectNode extends AbstractNode
|
||||||
System.out.println(s[0] + "\t" + s[1]);
|
System.out.println(s[0] + "\t" + s[1]);
|
||||||
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.ptsToString(points[i - 1]) + "P - " + text[i - 1]);
|
rbs[i - 1] = new JRadioButton(Utils.formatPoints(points[i - 1]) + "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]);
|
||||||
|
@ -125,7 +125,7 @@ public class RadioMultiSelectNode extends AbstractNode
|
||||||
{
|
{
|
||||||
return "<li" + hc.styleText(achievedPoints(hc.mc), maxPoints) + ">" + //
|
return "<li" + hc.styleText(achievedPoints(hc.mc), maxPoints) + ">" + //
|
||||||
"<span" + hc.stylePts(achievedPoints(hc.mc), maxPoints) + "> " + //
|
"<span" + hc.stylePts(achievedPoints(hc.mc), maxPoints) + "> " + //
|
||||||
achievedPoints(hc.mc) + " / " + maxPoints.toPlainString() + "P</span> " + //
|
Utils.formatPoints(achievedPoints(hc.mc)) + " / " + Utils.formatPoints(maxPoints) + "P</span> " + //
|
||||||
(baseMsg == null ? text[getSelected()] : baseMsg + " (" + text[getSelected()] + ")") + "</li>";
|
(baseMsg == null ? text[getSelected()] : baseMsg + " (" + text[getSelected()] + ")") + "</li>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue