~ubuntu-branches/ubuntu/utopic/python-chaco/utopic

« back to all changes in this revision

Viewing changes to chaco/axis.py

  • Committer: Package Import Robot
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2014-06-01 17:04:08 UTC
  • mfrom: (7.2.5 sid)
  • Revision ID: package-import@ubuntu.com-20140601170408-m86xvdjd83a4qon0
Tags: 4.4.1-1ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
 - Let the binary-predeb target work on the usr/lib/python* directory
   as we don't have usr/share/pyshared anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    # The mapper that drives this axis.
38
38
    mapper = Instance(AbstractMapper)
39
39
 
 
40
    # Keep an origin for plots that aren't attached to a component
 
41
    origin = Enum("bottom left", "top left", "bottom right", "top right")
 
42
 
40
43
    # The text of the axis title.
41
44
    title = Trait('', Str, Unicode) #May want to add PlotLabel option
42
45
 
61
64
    # The color of the tick labels.
62
65
    tick_label_color = ColorTrait("black")
63
66
 
64
 
    # The rotation of the tick labels.  (Only multiples of 90 are supported)
 
67
    # The rotation of the tick labels.
65
68
    tick_label_rotate_angle = Float(0)
66
69
 
67
70
    # Whether to align to corners or edges (corner is better for 45 degree rotation)
435
438
        screenlow = self.mapper.low_pos
436
439
        if overlay_component is not None:
437
440
            origin = getattr(overlay_component, 'origin', 'bottom left')
438
 
            if self.orientation in ("top", "bottom"):
439
 
                if "right" in origin:
440
 
                    flip_from_gc = True
441
 
                else:
442
 
                    flip_from_gc = False
443
 
            elif self.orientation in ("left", "right"):
444
 
                if "top" in origin:
445
 
                    flip_from_gc = True
446
 
                else:
447
 
                    flip_from_gc = False
448
 
 
449
 
            if flip_from_gc:
450
 
                screenlow, screenhigh = screenhigh, screenlow
 
441
        else:
 
442
            origin = self.origin
 
443
        if self.orientation in ("top", "bottom"):
 
444
            if "right" in origin:
 
445
                flip_from_gc = True
 
446
            else:
 
447
                flip_from_gc = False
 
448
        elif self.orientation in ("left", "right"):
 
449
            if "top" in origin:
 
450
                flip_from_gc = True
 
451
            else:
 
452
                flip_from_gc = False
 
453
        if flip_from_gc:
 
454
            screenlow, screenhigh = screenhigh, screenlow
451
455
 
452
456
        if (datalow == datahigh) or (screenlow == screenhigh) or \
453
457
           (datalow in [inf, -inf]) or (datahigh in [inf, -inf]):
522
526
 
523
527
 
524
528
    def _calculate_geometry(self):
 
529
        origin = self.origin
525
530
        screenhigh = self.mapper.high_pos
526
531
        screenlow = self.mapper.low_pos
527
532
 
532
537
            self._title_orientation = array([0.,1.])
533
538
            self.title_angle = 0.0
534
539
            if self.orientation == 'top':
535
 
                self._origin_point = array(self.position) + self._major_axis * screenlow
 
540
                self._origin_point = array(self.position)
536
541
                self._inside_vector = array([0.,-1.])
537
542
            else: #self.oriention == 'bottom'
538
 
                self._origin_point = array(self.position) + array([0., self.bounds[1]]) + self._major_axis*screenlow
 
543
                self._origin_point = array(self.position) + array([0., self.bounds[1]])
539
544
                self._inside_vector = array([0., 1.])
 
545
            if "right" in origin:
 
546
                screenlow, screenhigh = screenhigh, screenlow
540
547
 
541
548
        elif self.orientation in ('left', 'right'):
542
549
            self._major_axis_size = self.bounds[1]
544
551
            self._major_axis = array([0., 1.])
545
552
            self._title_orientation = array([-1., 0])
546
553
            if self.orientation == 'left':
547
 
                self._origin_point = array(self.position) + array([self.bounds[0], 0.]) + self._major_axis*screenlow
 
554
                self._origin_point = array(self.position) + array([self.bounds[0], 0.])
548
555
                self._inside_vector = array([1., 0.])
549
556
                self.title_angle = 90.0
550
557
            else: #self.orientation == 'right'
551
 
                self._origin_point = array(self.position) + self._major_axis * screenlow
 
558
                self._origin_point = array(self.position)
552
559
                self._inside_vector = array([-1., 0.])
553
560
                self.title_angle = 270.0
 
561
            if "top" in origin:
 
562
                screenlow, screenhigh = screenhigh, screenlow
554
563
 
555
564
        if self.ensure_ticks_bounded:
556
565
            self._origin_point -= self._inside_vector*self.tick_in
557
566
 
558
 
        self._end_axis_point = (screenhigh-screenlow)*self._major_axis + self._origin_point
 
567
        self._end_axis_point = abs(screenhigh-screenlow)*self._major_axis + self._origin_point
559
568
        self._axis_vector = self._end_axis_point - self._origin_point
560
569
        # This is the vector that represents one unit of data space in terms of screen space.
561
570
        self._axis_pixel_vector = self._axis_vector/sqrt(dot(self._axis_vector,self._axis_vector))
604
613
        if self.ensure_ticks_bounded:
605
614
            self._origin_point -= self._inside_vector*self.tick_in
606
615
 
607
 
        self._end_axis_point = (screenhigh-screenlow)*self._major_axis + self._origin_point
 
616
        self._end_axis_point = abs(screenhigh-screenlow)*self._major_axis + self._origin_point
608
617
        self._axis_vector = self._end_axis_point - self._origin_point
609
618
        # This is the vector that represents one unit of data space in terms of screen space.
610
619
        self._axis_pixel_vector = self._axis_vector/sqrt(dot(self._axis_vector,self._axis_vector))
693
702
            if hasattr(component, attr):
694
703
                self.mapper = getattr(component, attr)
695
704
                break
 
705
 
 
706
        # Keep our origin in sync with the component
 
707
        self.origin = getattr(component, 'origin', 'bottom left')
696
708
        return
697
709
 
698
710
 
732
744
            'tick_interval',
733
745
            'tick_generator',
734
746
            'orientation',
 
747
            'origin',
735
748
            'axis_line_visible',
736
749
            'axis_line_color',
737
750
            'axis_line_weight',