from graphEntity import * from GraphicalForm import * from ATOM3Constraint import * class graph_aTest(graphEntity): def __init__(self, x, y, semObject = None): self.semanticObject = semObject self.sizeX, self.sizeY = 73, 53 graphEntity.__init__(self, x, y) self.ChangesAtRunTime = 0 self.constraintList = [] if self.semanticObject: atribs = self.semanticObject.attributesToDraw() else: atribs = None constObj = ATOM3Constraint(atribs,"changeColor","self.semanticObject.", [], []) constObj.setValue(('changeColor', (['Python', 'OCL'], 0), (['PREcondition', 'POSTcondition'], 1), (['EDIT', 'SAVE', 'CREATE', 'CONNECT', 'DELETE', 'DISCONNECT', 'TRANSFORM', 'SELECT', 'DRAG', 'DROP', 'MOVE'], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]), 'number=self.semanticObject.aNumber.getValue()\012if number > 500:\012 self.gf0.setFill("red")\012else:\012 self.gf0.setFill("green")\012\012\012\012\012\012')) self.constraintList.append(constObj) self.graphForms = [] def DrawObject(self, drawing, showGG = 0): self.dc = drawing if showGG and self.semanticObject: self.drawGGLabel(drawing) h = drawing.create_rectangle(self.translate([1.0, 4.0, 72.0, 50.0]), tags = self.tag, fill= '', outline= 'black', width= '1.0', stipple= '') self.gf0 = GraphicalForm(drawing, h, "gf0") self.graphForms.append(self.gf0) h = drawing.create_oval(self.translate([33.0, 50.0, 33.0, 50.0]), tags = (self.tag, "connector"), fill= 'red', outline= 'black', width= '1.0', stipple= '') self.connectors.append(h) h = drawing.create_oval(self.translate([34.0, 3.0, 34.0, 3.0]), tags = (self.tag, "connector"), fill= 'red', outline= 'black', width= '1.0', stipple= '') self.connectors.append(h) if self.semanticObject: drawText = self.semanticObject.aString.toString(25,5) else: drawText = "" h = drawing.create_text(self.translate([36.0, 21.0]), tags = self.tag, text = drawText, fill= 'blue', anchor= 'center', font= '{MS Sans Serif} 8', justify= 'left', width= '0', stipple= '') self.attr_display["aString"] = h self.gf1 = GraphicalForm(drawing, h, "gf1") self.graphForms.append(self.gf1) def changeColor(self): number=self.semanticObject.aNumber.getValue() if number > 500: self.gf0.setFill("red") else: self.gf0.setFill("green") def postCondition (self, actionID, * params): if actionID == self.EDIT or actionID == self.CREATE: res = self.changeColor() if res: return res return None def preCondition (self, actionID, * params): return None new_class = graph_aTest