def _set_color(self, c): if c == 'red': color = pyHAttributeColor(141, 38, 38, 255) fill = pyHAttributeFillColor(232, 61, 61, 255) elif c == 'blue': color = pyHAttributeColor(0, 76, 153, 255) fill = pyHAttributeFillColor(0, 128, 255, 255) elif c == 'gray': color = pyHAttributeColor(170, 170, 170, 255) fill = pyHAttributeFillColor(220, 220, 220, 255) else: raise ValueError('bad color selected') self.handle_figure.setAttribute('COLOR', color) self.handle_figure.setAttribute('FILL', fill)
def onMouseDobleClick(self, e): if e.isLeftClick(): actual_value = self.getView() p = pyHPoint(e.getX(), e.getY()) try: figure = actual_value.findFigure(p) if isinstance(figure, NodeFigure): if figure.is_input(): container_figure = figure.figures[0] color = container_figure.getAttribute('COLOR') container_figure.setColor( pyHAttributeColor(90, 90, 90, 255)) node = figure.get_node() actual_value = node.getValue() if node else "" dialog = AssignValuesDialog(self.getView(), figure.get_text(), actual_value) pos = self.getView().cursor().pos() dialog.move(pos.x() + 30, pos.y() - 70) if dialog.exec(): actual_value = dialog.get_value() if actual_value: figure.setValue(actual_value) figure.set_text(dialog.get_name()) container_figure.setColor(color) except pyHFigureNotFound: pass
def _emphasis(self, figure, attribs_dict): self._normal(figure, attribs_dict) if attribs_dict.get('COLOR'): figure.setAttribute('COLOR', pyHAttributeColor(*SEMI_BLACK)) width = attribs_dict.get('WIDTH') + 1 if width: figure.setAttribute('WIDTH', pyHAttributeWidth(width))
def _normal(figure, attribs_dict): width = attribs_dict.get('WIDTH') color = attribs_dict.get('COLOR') fill = attribs_dict.get('FILL') if width: figure.setAttribute('WIDTH', pyHAttributeWidth(width)) if color: figure.setAttribute('COLOR', pyHAttributeColor(*color)) if fill: figure.setAttribute('FILL', pyHAttributeFillColor(*fill))
def __init__(self, conector, l=120): pyHAbstractFigure.__init__(self) self.setColor(pyHAttributeColor(150, 150, 150, 255)) self.setAttribute('WIDTH', pyHAttributeWidth(2)) self.connectorStart = None self.points = [None] * 2 self.lenline = l self.forwardText = pyHTextFigure(0, 0, 0, 0, "") self.forwardText.setColor(COLOR.get('BLUE')) self.backwardText = pyHTextFigure(0, 0, 0, 0, "") self.backwardText.setColor(COLOR.get('RED')) self._error_figure = MathTextFigure(0, 0, r'\varepsilon') self._error_figure.setColor(pyHAttributeColor(0, 0, 0, 0)) self.setConnectorStart(conector)
def makeNormal(self): #self.getDecoratedFigure().setAttribute('WIDTH', pyHAttributeWidth(1)) if self.getDecoratedFigure().getColor(): r, g, b, _ = self.getDecoratedFigure().getColor().values() self.getDecoratedFigure().setColor(pyHAttributeColor(r, g, b, 255)) if self.getDecoratedFigure().getFillColor(): r, g, b, _ = self.getDecoratedFigure().getFillColor() self.getDecoratedFigure().setFillColor(r, g, b, 255)
def makeSemitransparent(self): #self.getDecoratedFigure().setAttribute('WIDTH', pyHAttributeWidth(1)) if self.getDecoratedFigure().getColor(): r, g, b, _ = self.getDecoratedFigure().getColor().values() self.getDecoratedFigure().setColor(pyHAttributeColor(r, g, b, 100)) if self.getDecoratedFigure().getFillColor(): r, g, b, _ = self.getDecoratedFigure().getFillColor() self.getDecoratedFigure().setFillColor(r, g, b, 100)
def onMouseDown(self,e): self.getView().clearSelectedFigures() self.r=pyHRectangleFigure(e.getX(),e.getY(),0,0) # javi edit: self.r.setAttribute('FILL', pyHAttributeFillColor(185, 237, 255, 100)) self.r.setAttribute('COLOR', pyHAttributeColor(51, 139, 171, 255)) # end self.getView().getDrawing().addFigure(self.r)
def set_default_style(self): self.setColor(pyHAttributeColor(150, 150, 150, 255)) self.setAttribute('WIDTH', pyHAttributeWidth(2)) self.forwardText.setColor(COLOR.get('BLUE')) self.forwardText.setAttribute('FONT', pyHAttributeFontSize(12)) self.backwardText.setColor(COLOR.get('RED')) self.backwardText.setAttribute('FONT', pyHAttributeFontSize(12))
def __init__(self, owner, point): ''' Constructor ''' self.handle_figure = pyHRectangleFigure(point.getX() - 1, point.getY() - 1, 20, 20) self.handle_figure.setAttribute('COLOR', pyHAttributeColor(232, 61, 61, 255)) self.handle_figure.setAttribute( 'FILL', pyHAttributeFillColor(141, 38, 38, 255)) self.point = point self.owner = owner
def _semitransparent(self, figure, attribs_dict): self._normal(figure, attribs_dict) width = attribs_dict.get('WIDTH') - 1 color = attribs_dict.get('COLOR') fill = attribs_dict.get('FILL') if width: figure.setAttribute('WIDTH', pyHAttributeWidth(width)) if color: r, g, b, _ = color figure.setAttribute('COLOR', pyHAttributeColor(r, g, b, 100)) if fill: r, g, b, _ = fill figure.setAttribute('FILL', pyHAttributeFillColor(r, g, b, 100))
import math from MiniTensorFlow.data import operations as ops from pyHotDraw.Figures.pyHAttributes import pyHAttributeColor, pyHAttributeWidth, pyHAttributeFontSize from pyHotDraw.Figures.pyHConnectionFigure import pyHConnectionFigure from pyHotDraw.Figures.pyHTextFigure import pyHTextFigure from pyHotDraw.Geom.pyHPoint import pyHPoint COLOR = { 'RED': pyHAttributeColor(255, 0, 0), 'BLUE': pyHAttributeColor(0, 0, 255), 'GRAY': pyHAttributeColor(127, 127, 127) } class pyHADNodeConnectionFigure(pyHConnectionFigure): def __init__(self): pyHConnectionFigure.__init__(self) self.forwardText = pyHTextFigure(0, 0, 0, 0, "") self.backwardText = pyHTextFigure(0, 0, 0, 0, "") self.set_default_style() def set_default_style(self): self.setColor(pyHAttributeColor(150, 150, 150, 255)) self.setAttribute('WIDTH', pyHAttributeWidth(2)) self.forwardText.setColor(COLOR.get('BLUE')) self.forwardText.setAttribute('FONT', pyHAttributeFontSize(12))
def setColor(self,c,g=None,b=None,a=255): if g==None and b==None: self.setAttribute("COLOR",c) else: r=c self.setAttribute("COLOR",pyHAttributeColor(r,g,b,a))
def __init__(self): self.attributes = {} self.changedFigureObservers = [] c = pyHAttributeColor(0, 0, 0) self.setColor(c)
def __init__(self): self.attributes={} self.changedFigureObservers=[] c=pyHAttributeColor(0,0,0) self.setColor(c)