Changeset 3681:a065b9f51a45 in orange


Ignore:
Timestamp:
05/21/07 19:02:44 (7 years ago)
Author:
martinm <martinm@…>
Branch:
default
Convert:
2f72341c7719a68bccb4c90678301af6c0e7b3ae
Message:

Rules are now written in several lines

Location:
orange/OrangeWidgets/Classify
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Classify/OWNomogram.py

    r3658 r3681  
    127127 
    128128        self.verticalSpacingLabel = OWGUI.spin(NomogramStyleTab, self, 'verticalSpacing', 15, 100, box = 'Vertical spacing:',  tooltip='Define space (pixels) between adjacent attributes.', callback = self.showNomogram) 
    129         self.verticalSpacingLabel.setDisabled(True) 
     129        self.verticalSpacingContLabel = OWGUI.spin(NomogramStyleTab, self, 'verticalSpacingContinuous', 15, 100, box = 'Vertical spacing 2d.:',  tooltip='Define space (pixels) between adjacent 2d presentation of attributes.', callback = self.showNomogram) 
     130##        self.verticalSpacingLabel.setDisabled(True) 
    130131        self.fontSizeLabel = OWGUI.spin(NomogramStyleTab, self, 'fontSize', 4, 14, box = 'Font size:', tooltip='Font size of nomogram labels.') 
    131132        self.fontSizeLabel.setDisabled(True) 
     
    470471        self.bnomogram.show() 
    471472 
    472     # Input channel: the rule classifier (from ABCN2 only) 
     473    # Input channel: the rule classifier (from CN2-EVC only) 
    473474    def ruleClassifier(self, cl): 
    474475        def selectSign(oper): 
     
    486487            conds = rule.filter.conditions 
    487488            domain = rule.filter.domain 
    488             ret = "" 
     489            ret = [] 
    489490            if len(conds)==0: 
    490                 ret = ret + "TRUE" 
     491                ret = ret + ["TRUE"] 
    491492            for i,c in enumerate(conds): 
    492493                if i > 0: 
    493                     ret += " & " 
     494                    ret[-1] += " & " 
    494495                if type(c) == orange.ValueFilter_discrete: 
    495                     ret += domain[c.position].name[:2] + "=" + str(domain[c.position].values[int(c.values[0])]) 
     496                    ret += [domain[c.position].name + "=" + str(domain[c.position].values[int(c.values[0])])] 
    496497                elif type(c) == orange.ValueFilter_continuous: 
    497                     ret += domain[c.position].name[:2] + selectSign(c.oper) + "%.1f"%c.ref 
     498                    ret += [domain[c.position].name + selectSign(c.oper) + "%.3f"%c.ref] 
    498499            return ret 
    499500 
  • orange/OrangeWidgets/Classify/OWNomogramGraph.py

    r3657 r3681  
    469469 
    470470    def initialize(self, canvas): 
    471         self.label = QCanvasText(canvas) 
    472         self.label.setText(self.name) 
    473         font = QFont(self.label.font()) 
    474         font.setBold(True) 
    475         self.label.setFont(font)         # draw label in bold 
     471        def createText(name): 
     472            label = QCanvasText(canvas) 
     473            label.setText(name) 
     474            font = QFont(label.font()) 
     475            font.setBold(True) 
     476            label.setFont(font) # draw label in bold 
     477            return label 
     478             
     479        if type(self.name) == str: 
     480            self.label = [createText(self.name)] 
     481        else: 
     482            self.label = [createText(n) for n in self.name] 
    476483        self.line = QCanvasLine(canvas) 
    477484 
     
    481488    def drawAttributeLine(self, canvas, rect, mapper): 
    482489        atValues_mapped, atErrors_mapped, min_mapped, max_mapped = mapper(self, error_factor = norm_factor(1-((1-float(canvas.parent.confidence_percent)/100.)/2.))) # return mapped values, errors, min, max --> mapper(self) 
    483         self.label.setX(1) 
    484         self.label.setY(rect.bottom()-canvas.fontSize) 
     490        for l_i,l in enumerate(self.label): 
     491            l.setX(1) 
     492            l.setY(rect.bottom()-(1-l_i)*canvas.fontSize+l_i*canvas.fontSize/3) 
     493            l.show() 
    485494 
    486495        # draw attribute line 
     
    498507         
    499508    def paint(self, canvas, rect, mapper): 
    500         self.label.setText(self.name) 
     509##        self.label.setText(self.name) 
    501510        atValues_mapped, atErrors_mapped, min_mapped, max_mapped = mapper(self, error_factor = norm_factor(1-((1-float(canvas.parent.confidence_percent)/100.)/2.))) # return mapped values, errors, min, max --> mapper(self) 
    502511 
     
    548557        if max_mapped - min_mapped > 5.0: 
    549558            self.line.show() 
    550         self.label.show() 
     559        [l.show() for l in self.label] 
    551560 
    552561    # some supplementary methods for 2d presentation 
     
    559568 
    560569        # show att. name 
    561         self.label.setText(self.name) 
    562         self.label.setX(min_mapped) 
    563         self.label.setY(rect.top()+rect.height()/8) 
     570##        self.label.setText(self.name) 
     571        for l_i,l in enumerate(self.label): 
     572            l.setX(min_mapped) 
     573            l.setY(rect.top()+(l_i+1)*rect.height()/8) 
    564574 
    565575    # draws a vertical legend on the left side of the bounding box 
     
    652662         
    653663    def paint(self, canvas, rect, mapper): 
    654         self.label.setText(self.name) 
     664##        self.label.setText(self.name) 
    655665        atValues_mapped, atErrors_mapped, min_mapped, max_mapped = mapper(self, error_factor = norm_factor(1-((1-float(canvas.parent.confidence_percent)/100.)/2.))) # return mapped values, errors, min, max --> mapper(self) 
    656666 
     
    686696        self.updateValue() 
    687697        self.line.show() 
    688         self.label.show() 
     698        [l.show() for l in self.label] 
    689699 
    690700 
     
    736746    def paint2d(self, canvas, rect, mapper): 
    737747        self.initializeBeforePaint(canvas) 
    738         self.label.setText(self.name) 
     748##        self.label.setText(self.name) 
    739749 
    740750        # get all values tranfsormed with current mapper  
     
    795805        self.updateValue() 
    796806        self.box.show() 
    797         self.label.show() 
     807        [l.show() for l in self.label] 
    798808 
    799809 
     
    907917        self.updateValue() 
    908918        self.box.show() 
    909         self.label.show() 
     919        [l.show() for l in self.label] 
    910920 
    911921 
     
    12891299        self.gleft = 0 
    12901300        for at in self.attributes: 
    1291             if not (self.parent.contType == 1 and isinstance(at, AttrLineCont)) and at.label.boundingRect().width()>self.gleft: 
    1292                 self.gleft = at.label.boundingRect().width() 
     1301            if not (self.parent.contType == 1 and isinstance(at, AttrLineCont)) and max([l.boundingRect().width() for l in at.label])>self.gleft: 
     1302                self.gleft = max([l.boundingRect().width() for l in at.label]) 
    12931303        if QCanvasText(self.footerCanvas.footerPercentName, self.footerCanvas).boundingRect().width()>self.gleft: 
    12941304            self.gleft = QCanvasText(self.footerCanvas.footerPercentName, self.footerCanvas).boundingRect().width() 
     
    13301340                self.mapper = Mapper_Linear_Center(self.minBeta, self.maxBeta, self.gleft, self.gright, maxLinearValue = self.maxBeta, minLinearValue = self.minBeta) 
    13311341        # draw HEADER and vertical line 
    1332         topRect=QRect(self.gleft, self.gtop, self.gwidth, self.parent.verticalSpacing-20) 
     1342        topRect=QRect(self.gleft, self.gtop, self.gwidth, 40) 
    13331343        self.header.paintHeader(topRect, self.mapper)  
    13341344        # draw nomogram 
     
    13361346        self.paint(middleRect, self.mapper) 
    13371347        # draw final line 
    1338         bottomRect=QRect(self.gleft, self.gtop, self.gwidth, 2*self.parent.verticalSpacing-30) 
     1348        bottomRect=QRect(self.gleft, self.gtop, self.gwidth, 90) 
    13391349        self.footerCanvas.paintFooter(bottomRect, self.parent.alignType, self.parent.yAxis, self.mapper)         
    13401350        self.footerCanvas.updateMarkers() 
Note: See TracChangeset for help on using the changeset viewer.