mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-13 14:56:29 -04:00
Merge branch 'master' into tutorial
This commit is contained in:
commit
2c1cd35a0d
@ -164,11 +164,11 @@ public class DataPlotter implements Drawable {
|
|||||||
if (width == 0) width = 1;
|
if (width == 0) width = 1;
|
||||||
long value = s.getValue(i).getValue();
|
long value = s.getValue(i).getValue();
|
||||||
int ry;
|
int ry;
|
||||||
if (Math.abs(width >>> 1) < Integer.MAX_VALUE) {
|
long sWidth = (width >>> 32);
|
||||||
|
if (sWidth == 0) {
|
||||||
ry = (int) (SIZE - (SIZE * value) / width);
|
ry = (int) (SIZE - (SIZE * value) / width);
|
||||||
} else {
|
} else {
|
||||||
width = (width >>> 32);
|
ry = (int) (SIZE - (SIZE * (value >>> 32)) / sWidth);
|
||||||
ry = (int) (SIZE - (SIZE * (value >>> 32)) / width);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value != last[i].value)
|
if (value != last[i].value)
|
||||||
|
@ -180,9 +180,9 @@ public class GraphicSVG implements Graphic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rotateText)
|
if (rotateText)
|
||||||
w.write("<text text-anchor=\"" + getAchor(orientation.getX()) + "\" x=\"" + p.getXFloat() + "\" y=\"" + p.getYFloat() + "\" fill=\"" + getColor(style) + "\" style=\"font-size:" + style.getFontSize() + "\" transform=\"rotate(-90," + str(p1) + ")\" >" + text + "</text>\n");
|
w.write("<text text-anchor=\"" + getAchor(orientation.getX()) + "\" x=\"" + p.getXFloat() + "\" y=\"" + p.getYFloat() + "\" fill=\"" + getColor(style) + "\" style=\"font-size:" + style.getFontSize() + "px\" transform=\"rotate(-90," + str(p1) + ")\" >" + text + "</text>\n");
|
||||||
else
|
else
|
||||||
w.write("<text text-anchor=\"" + getAchor(orientation.getX()) + "\" x=\"" + p.getXFloat() + "\" y=\"" + p.getYFloat() + "\" fill=\"" + getColor(style) + "\" style=\"font-size:" + style.getFontSize() + "\">" + text + "</text>\n");
|
w.write("<text text-anchor=\"" + getAchor(orientation.getX()) + "\" x=\"" + p.getXFloat() + "\" y=\"" + p.getYFloat() + "\" fill=\"" + getColor(style) + "\" style=\"font-size:" + style.getFontSize() + "px\">" + text + "</text>\n");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -40,9 +40,9 @@ public final class SVGFormatter {
|
|||||||
if (mathMode)
|
if (mathMode)
|
||||||
return format(d.getContent(), true);
|
return format(d.getContent(), true);
|
||||||
else
|
else
|
||||||
return "<tspan style=\"font-style:italic\">" + format(d.getContent(), true) + "</tspan>";
|
return "<tspan style=\"font-style:italic;\">" + format(d.getContent(), true) + "</tspan>";
|
||||||
case OVERLINE:
|
case OVERLINE:
|
||||||
return '\u00AC' + format(d.getContent(), mathMode);
|
return "<tspan style=\"text-decoration:overline;\">" + format(d.getContent(), mathMode) + "</tspan>";
|
||||||
default:
|
default:
|
||||||
return format(d.getContent(), mathMode);
|
return format(d.getContent(), mathMode);
|
||||||
}
|
}
|
||||||
@ -50,9 +50,9 @@ public final class SVGFormatter {
|
|||||||
Index i = (Index) text;
|
Index i = (Index) text;
|
||||||
String str = format(i.getVar(), true);
|
String str = format(i.getVar(), true);
|
||||||
if (i.getSubScript() != null)
|
if (i.getSubScript() != null)
|
||||||
str += "<tspan style=\"font-size:80%;baseline-shift:sub\">" + format(i.getSubScript(), mathMode) + "</tspan>";
|
str += "<tspan style=\"font-size:80%;baseline-shift:sub;\">" + format(i.getSubScript(), mathMode) + "</tspan>";
|
||||||
if (i.getSuperScript() != null)
|
if (i.getSuperScript() != null)
|
||||||
str += "<tspan style=\"font-size:80%;baseline-shift:super\">" + format(i.getSuperScript(), mathMode) + "</tspan>";
|
str += "<tspan style=\"font-size:80%;baseline-shift:super;\">" + format(i.getSuperScript(), mathMode) + "</tspan>";
|
||||||
return str;
|
return str;
|
||||||
} else if (text instanceof Sentence) {
|
} else if (text instanceof Sentence) {
|
||||||
Sentence s = (Sentence) text;
|
Sentence s = (Sentence) text;
|
||||||
|
@ -135,6 +135,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
private ToolTipAction runToBreakAction;
|
private ToolTipAction runToBreakAction;
|
||||||
private ToolTipAction showMeasurementDialog;
|
private ToolTipAction showMeasurementDialog;
|
||||||
private ToolTipAction showMeasurementGraph;
|
private ToolTipAction showMeasurementGraph;
|
||||||
|
private ToolTipAction runTests;
|
||||||
|
|
||||||
private File baseFilename;
|
private File baseFilename;
|
||||||
private File filename;
|
private File filename;
|
||||||
@ -979,7 +980,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
.setToolTip(Lang.get("menu_element_tt"))
|
.setToolTip(Lang.get("menu_element_tt"))
|
||||||
.setEnabledChain(false);
|
.setEnabledChain(false);
|
||||||
|
|
||||||
ToolTipAction runTests = new ToolTipAction(Lang.get("menu_runTests"), ICON_TEST) {
|
runTests = new ToolTipAction(Lang.get("menu_runTests"), ICON_TEST) {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
startTests();
|
startTests();
|
||||||
@ -1231,6 +1232,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
showMeasurementDialog.setEnabled(false);
|
showMeasurementDialog.setEnabled(false);
|
||||||
showMeasurementGraph.setEnabled(false);
|
showMeasurementGraph.setEnabled(false);
|
||||||
runToBreakAction.setEnabled(false);
|
runToBreakAction.setEnabled(false);
|
||||||
|
runTests.setEnabled(true);
|
||||||
// keep errors
|
// keep errors
|
||||||
if (circuitComponent.getHighLightStyle() != Style.ERROR)
|
if (circuitComponent.getHighLightStyle() != Style.ERROR)
|
||||||
circuitComponent.removeHighLighted();
|
circuitComponent.removeHighLighted();
|
||||||
@ -1245,6 +1247,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
showMeasurementDialog.setEnabled(true);
|
showMeasurementDialog.setEnabled(true);
|
||||||
showMeasurementGraph.setEnabled(true);
|
showMeasurementGraph.setEnabled(true);
|
||||||
stoppedState.getAction().setEnabled(true);
|
stoppedState.getAction().setEnabled(true);
|
||||||
|
runTests.setEnabled(false);
|
||||||
if (createAndStartModel(false, ModelEvent.MICROSTEP, null))
|
if (createAndStartModel(false, ModelEvent.MICROSTEP, null))
|
||||||
circuitComponent.setManualChangeObserver(new MicroStepObserver(model));
|
circuitComponent.setManualChangeObserver(new MicroStepObserver(model));
|
||||||
}
|
}
|
||||||
@ -1252,6 +1255,23 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
stateManager.setActualState(stoppedState);
|
stateManager.setActualState(stoppedState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class RunModelState extends State {
|
||||||
|
@Override
|
||||||
|
public void enter() {
|
||||||
|
enter(true, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
void enter(boolean runRealTime, ModelModifier modelModifier) {
|
||||||
|
super.enter();
|
||||||
|
stoppedState.getAction().setEnabled(true);
|
||||||
|
showMeasurementDialog.setEnabled(true);
|
||||||
|
showMeasurementGraph.setEnabled(true);
|
||||||
|
runTests.setEnabled(false);
|
||||||
|
if (createAndStartModel(runRealTime, ModelEvent.STEP, modelModifier))
|
||||||
|
circuitComponent.setManualChangeObserver(new FullStepObserver(model));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void clearModelDescription() {
|
private void clearModelDescription() {
|
||||||
if (model != null)
|
if (model != null)
|
||||||
model.access(() -> model.close());
|
model.access(() -> model.close());
|
||||||
@ -1672,23 +1692,6 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class RunModelState extends State {
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
enter(true, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
void enter(boolean runRealTime, ModelModifier modelModifier) {
|
|
||||||
super.enter();
|
|
||||||
stoppedState.getAction().setEnabled(true);
|
|
||||||
showMeasurementDialog.setEnabled(true);
|
|
||||||
showMeasurementGraph.setEnabled(true);
|
|
||||||
if (createAndStartModel(runRealTime, ModelEvent.STEP, modelModifier))
|
|
||||||
circuitComponent.setManualChangeObserver(new FullStepObserver(model));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//***********************
|
//***********************
|
||||||
// remote interface start
|
// remote interface start
|
||||||
//***********************
|
//***********************
|
||||||
|
@ -1174,11 +1174,12 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
|||||||
}
|
}
|
||||||
|
|
||||||
private VisualElement getActualVisualElement() {
|
private VisualElement getActualVisualElement() {
|
||||||
|
if (activeMouseController instanceof MouseControllerMoveElement)
|
||||||
|
mouseNormal.activate();
|
||||||
|
|
||||||
VisualElement ve = null;
|
VisualElement ve = null;
|
||||||
if (activeMouseController instanceof MouseControllerNormal)
|
if (activeMouseController instanceof MouseControllerNormal)
|
||||||
ve = getCircuit().getElementAt(getPosVector(lastMousePos.x, lastMousePos.y));
|
ve = getCircuit().getElementAt(getPosVector(lastMousePos.x, lastMousePos.y));
|
||||||
// if (activeMouseController instanceof MouseControllerMoveElement)
|
|
||||||
// ve = ((MouseControllerMoveElement) activeMouseController).getVisualElement();
|
|
||||||
return ve;
|
return ve;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +62,8 @@ import java.util.List;
|
|||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
|
import static de.neemann.digital.draw.graphics.GraphicSVG.escapeXML;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -811,6 +813,7 @@ public class TableDialog extends JDialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String identifier(String ident) {
|
public String identifier(String ident) {
|
||||||
|
ident = escapeXML(ident);
|
||||||
int p = ident.indexOf("_");
|
int p = ident.indexOf("_");
|
||||||
if (p < 0)
|
if (p < 0)
|
||||||
return ident;
|
return ident;
|
||||||
|
@ -14,9 +14,9 @@ public class GraphicSVGIndexTest extends TestCase {
|
|||||||
GraphicSVGIndex gs = new GraphicSVGIndex(System.out, null, 30);
|
GraphicSVGIndex gs = new GraphicSVGIndex(System.out, null, 30);
|
||||||
gs.setBoundingBox(new Vector(0, 0), new Vector(30, 30));
|
gs.setBoundingBox(new Vector(0, 0), new Vector(30, 30));
|
||||||
|
|
||||||
assertEquals("Z<tspan style=\"font-size:80%;baseline-shift:sub\">0</tspan>", gs.formatText("Z_0", Style.NORMAL));
|
assertEquals("Z<tspan style=\"font-size:80%;baseline-shift:sub;\">0</tspan>", gs.formatText("Z_0", Style.NORMAL));
|
||||||
assertEquals("<a>", gs.formatText("<a>", Style.NORMAL));
|
assertEquals("<a>", gs.formatText("<a>", Style.NORMAL));
|
||||||
assertEquals("\u00ACZ", gs.formatText("~Z", Style.NORMAL));
|
assertEquals("<tspan style=\"text-decoration:overline;\">Z</tspan>", gs.formatText("~Z", Style.NORMAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user