fix for @oleting

This commit is contained in:
weckyy702
2021-02-09 15:07:12 +01:00
parent cbad444743
commit 9e505e512f
3 changed files with 42 additions and 39 deletions

View File

@@ -25,7 +25,7 @@ class Iinstruction(metaclass=ABCMeta):
pass
def _getblkheight(self) -> float:
return cti.get_text_size(self.instruction_text)[1]
return cti.get_text_size(self.instruction_text)[1] + 5#padding
def _getblkwidth(self) -> float:
return cti.get_text_size(self.instruction_text)[0]+50 #padding
@@ -92,7 +92,7 @@ class if_instruction(Iinstruction):
return w
def getblkheight(self) -> float:
return max(self.get_trueheight(), self.get_falseheight())
return self._getblkheight() + max(self.get_trueheight(), self.get_falseheight())
def getblkwidth(self) -> float:
return max(self._getblkwidth(), self.get_truewidth() + self.get_falsewidth())
@@ -101,7 +101,7 @@ class if_instruction(Iinstruction):
def to_image(self, x:int, y:int, x_sz: int) -> Iterable[float]:
true_w = self.get_truewidth()
false_w = self.get_falsewidth()
true_x, true_y, _, _, false_x, false_y, _, _ = cti.draw_if_statement(
true_x, true_y, false_x, false_y = cti.draw_if_statement(
self.instruction_text, x, y, true_w, false_w, self.getblkheight()
)
self.draw_true_case(true_x, true_y, true_w)
@@ -130,7 +130,6 @@ class if_instruction(Iinstruction):
res += "}"
return res
#TODO
# class switch_instruction(Iinstruction):
# """Switch structure"""

View File

@@ -1,5 +1,3 @@
from os import stat
from interpreter.interpret_source import Function_scope
from typing import Dict, List, Optional
from PySimpleGUI import one_line_progress_meter
import logging
@@ -8,6 +6,7 @@ import os.path
import secrets
from interpreter.interpret_source import JavaInterpreter
from interpreter.function_scope import Function_scope
from draw.code_to_image_wrapper import NSD_writer
import draw.code_to_image as cti
@@ -50,7 +49,7 @@ class NassiShneidermanDiagram:
return filepath
else:
while os.path.exists(filepath+".png"):
filepath = filepath + str(secrets.token_hex(1))
filepath += str(secrets.token_hex(1))
return filepath
return filepath

View File

@@ -329,6 +329,9 @@
// final int value;
// };
// }
class Testing {
public void test_function() {
int rot = getRotation();
@@ -348,28 +351,30 @@ public void test_function() {
}
}
if (richtung=="vorne" && rot==90 || richtung=="rechts" && rot==0 || richtung=="links" && rot==180)
{
if(getOneObjectAtOffset(0,1,Huegel.class)!=null && ((Huegel)getOneObjectAtOffset(0,1,Huegel.class)).getSteigung() >30)
{
return true;
// if (richtung=="vorne" && rot==90 || richtung=="rechts" && rot==0 || richtung=="links" && rot==180)
// {
// if(getOneObjectAtOffset(0,1,Huegel.class)!=null && ((Huegel)getOneObjectAtOffset(0,1,Huegel.class)).getSteigung() >30)
// {
// return true;
// }
// }
// if (richtung=="vorne" && rot==270 || richtung=="rechts" && rot==180 || richtung=="links" && rot==0)
// {
// if(getOneObjectAtOffset(0,-1,Huegel.class)!=null && ((Huegel)getOneObjectAtOffset(0,-1,Huegel.class)).getSteigung() >30)
// {
// return true;
// }
// }
// if(richtung!="vorne" && richtung!="links" && richtung!="rechts")
// {
// nachricht("Befehl nicht korrekt!");
// }
// return false;
}
}
if (richtung=="vorne" && rot==270 || richtung=="rechts" && rot==180 || richtung=="links" && rot==0)
{
if(getOneObjectAtOffset(0,-1,Huegel.class)!=null && ((Huegel)getOneObjectAtOffset(0,-1,Huegel.class)).getSteigung() >30)
{
return true;
}
}
if(richtung!="vorne" && richtung!="links" && richtung!="rechts")
{
nachricht("Befehl nicht korrekt!");
}
return false;
}