Category Archives: Phil

Phil 12.24.12

8:00 – 5:00 SR

  • DB backups
  • Tested scatterplot on target clients – good performance!
  • Discovered the JavaScript blog Performance Kills. Yow.
  • Angular
    • Need to make sure that the array of panels is cleared out on new loads.
    • Instrumenting directives is tricky! I wound up adding a debugText property to the panelObj object that I’m passing to the PanelManager directive. I can write into that object inside a directive’s controller and see the results that way.
    • Changed the panelArray to a panelMap. Add and delete now the appropriate-sized map. However, extra selects and hovers slip through, Need to make more robust.
    • Turning the stage div into a directive. Done. Much nicer. Isolates all the mouse interaction and matrix math too.

Phil 12.23.14

8:00 – 5:30 SR

  • DB Backups
  • Angular
    • Keeping scatterplotTest1 intact in case I break things
    • Adding a controller at the panel organization level. This should closely mimic how tabs should work – selecting a tab causes the others to go to the ‘unselected’ state. the getCssClass() call should still work though, which is nice.
    • Help from StackOverflow: http://stackoverflow.com/questions/15672709/how-to-require-a-controller-in-an-angularjs-directive
    • To make this work, the directives need to communicate, which requires a controller. To manage the instances, we must use the ‘requires’ tag. Here’s what I did:

First, excerpts from the javascript directives

sp.directive('floatingPanelManager', [function() {
   return {
      restrict: 'AE',
      scope: {
         panelObj: '='
      },
      templateUrl: 'directives/floatingPanelManager.html',
      controller: function($scope) {
         var currentId = -1;
         var hideAllPanels = false;
         $scope.panels = [];
         this.registerPanel = function(panelScope){
            $scope.panels.push(panelScope);
         }
         this.selectPanel = function(panelId) {
            currentId = panelId;
            var ps;
            for (var i = 0; i < $scope.panels.length; i++) {
               ps = $scope.panels[i];
               if(ps.$id === panelId){
                  ps.selected = !ps.selected;
                  hideAllPanels = ps.selected; // hide all the other panels if one is selected
               }else{
                  ps.selected = false;
               }
            }
         };
         this.getHideAllPanels = function(){
            return hideAllPanels;
         }
      }
   }
}]);
sp.directive('floatingPanel', ['$sce', function(sce) {
   return {
      restrict: 'AE',
      require: '^floatingPanelManager',
      scope: {
         panelObj: '=',
         stageObj: '='
      },
      templateUrl: 'directives/floatingPanel.html',
      link: function(scope, element, attr, panelMgr) {
         panelMgr.registerPanel(scope);
         scope.getCssClass = function(){
            if(scope.selected){
               return 'selectedClass';
            }
            if(panelMgr.getHideAllPanels()){
               return 'hiddenClass';
            }
            if(scope.hover){
               return 'hoverClass';
            }
            return '';
         }
         scope.selectPanel = function(){
            var sid = scope.$id;
            panelMgr.selectPanel(sid);
         }
      }
   };
}])

And here’s the directive html:

<div class="floatingPanelStyle" ng-class="getCssClass()"
     ng-click="selectPanel()"
     ng-mouseenter="hover = true"
     ng-mouseleave="hover = false"
     ng-style="{'transform':getTransformString()}" ng-bind-html="getHtml()"></div>
  • In this case, I have a ‘floatingPanel’ directive that requires (watch the spelling!!!)  ‘floatingPanelManager’. The use of ‘require’ means that angular will inject the required instance as the fourth argument to the link function.
  • It’s important to remember that we have to have a single instance here. In this case, that instance has an array of all the floating panels that are being managed. And that array needs to be attached to the $scope passed into the controller. As I understand it, that means that it is attached to the DOM.

Phil 12.22.14

8:00 – 4:30 SR

  • DB Backups
  • Angular
    • After spending most of the day puzzling out how come my transforms weren’t working correctly, I came to the realization that it’s impractical to unproject a CSS shape into screen space. It’s obvious in hindsight, but I’m used to working with projection and model matricies, and CSS3 only gives you the MODEL matrix. Perspective is determined using the perspective CSS property, which gives the distance to the z=0 plane. Short distances give wide perspectives, large distances give a telephoto effect. The problem is that there is not enough information to calculate the view frustum from this, at least in the way that xGL would do it (using 8 points, or two rectangles forming a prism).
    • Ok, after looking at the Wikipedia entry, this may not be so tough after all. http://en.wikipedia.org/wiki/3D_projection. Still tricky since this may or may not be the same matrix that the browser is using…
    • It does strike me that the way that CSS is doing things is effectively a pinhole camera, so it should be possible to work out the perspective matrix from that, but I’m not up to it today. I think instead, I’ll work on hiding/dimming items that are not selected while an item is selected. I think this calls for using controllers inside directives (pg. 216 Angular JS Up and Running)

Phil 12.19.14

8:00 – 4:00 SR

  • DB backups
  • Angular
    • Starting a page on useful javascript libraries
    • Got the inverse transforms working. It really slows things down though. As a compromise, I only apply the inverse transform to the hovered item
    • And now I cannot get the href in the hovered item to work. Ah. It’s because that to make the jquery tooltip work I have to wrap the dix in an <a> element, which you can’t nest. Something to work on next week
    • Last odd thing. When running on my home server, the hover transition is more abrupt, with the same code. No console errors.

Phil 12.18.2014

8:00 – 12:30 4:00 – 6:00 SR

  • DB backups
  • Meeting with Agenia
  • Angular
    • Working on changing states on floatingPanel
    • Got some easy ng-class changes running
    • Changed the transform call so that they use matrix3d. This way I can unproject the individual floating panels.

Phil 12.16.14

7:30 – 4:00 SR

  • DB backups
  • More mysterious paperwork. Ronda and Angine have been pinged, and I told them how our truststore was set up.
  • Cool thing for the morning: https://github.com/Automattic/atd-jquery
  • Angular
    • Add mouse tracking for more intuitive interaction. This looks like a good place that covers events
    • The mousewheel require more work, and an additional library. Monospaced labs has their hamster.js library and an angular directive that uses it. After remembering to include the name in my module’s dependencies, everything worked fine.
    • Figure out tooltips. As usual, stack overflow to the rescue. Now I need to build a lightweight directive that I can wrap in the <a href> element. Bonus points for seeing how to use the ui-jq directive that allows access to the (at least) jquery in the angular distro.
    • Set content in the divs and see if they can be brought to the front of the display. Tomorrow.

Progress for today.

  • Checked out the interaction on my touchscreen laptop and found that though the sliders are touch enabled, the mouse move events are not. It looks like I need to add ngTouch to the module. This would be easier if the laptop that I requested back in August would ever show up, but I kinda doubt if Novetta ever actually ordered it, even though they’ve been saying “it’ll be here in two weeks” for the last 5 months. Sigh.
  • Drag events work in FF but not Chrome. pinch-to-zoom needs to be trapped and used to handle the Z-axis.

Phil 12.11.14

8:00 – 2:30 SR

  • DB backups
  • Got an annotated set of screenshots for the FMP problem. Left on Dong’s desk.
  • Meeting with Agenia. Progress? There is confusion about what our landlord actually is.
  • Scatterplots
    • Got 3D transforms working. It’s important to have the root (origin) div have the perspective property set, and then the child (stage) div have the transform-style: preserve-3d set. As before, this intro to CSS 3D is most helpful.
    • The points for the pointcloud need to fit inside the dimensions (width/height) defined in the CSS for the rotations to work correctly

Phil 12.10.2014

8:00 – 10:00, 12:00 – 5:30SR

  • DB backups
  • Meeting with Agenia – nope, tomorrow.
  • Going to try to start the cluster chart in Angular/CSS today
    • Dynamically modifying the css with ng-style
    • 3D rendering in ng-repeat seems to require the parent and child divs to have position:absolute.
    • Setting up an origin with perspective, a stage with global changes and the individual items positioned on the stage. The origin has no transforms, the stage gets viewer transforms and the items get their own. Got to the point where I’m positioning the items in 3D space and moving the stage on the X-axis.

Phil 12.9.2014

8:00 – 6:00 SR

  • DB backups
  • Set up the new script to dynamically produce chart data – now I need to fix the charts
  • Angular
    • AngularJS Custom Directives Animations with Transclusion. Note that this cannot be an element. See StackOverflow for more background
    • Starting to try things outside of the book. One problem seems to be allowing time for the animation to clear, so everything goes where it’s supposed to. I had to add a delay in the controller between the list clean and the replacing of the data in a query to get rid of dumb loading artifacts. Animation delay didn’t work, and I’m not really sure what the right way to go is.
    • Had a long talk with Dong about how to organize code.

Phil 12.8.14

8:00 – 3:00 SR

  • DB backups
  • Realized that our old servers were probably still associated with the CP registry. Looked for a way to change that but couldn’t find one. Talked to Ronda, she’s looking into it.
  • Got another OMFG the server’s going to be turned off by the end of the year if we don’t do anything ASAP! Fortunately, I was able to point Agena at that. Whee!
  • Had a discussion with Dong about structuring projects. For the time being, we will continue doing the following:
    • Eclipse is for Java projects. They are assembled within the IDE (no maven!) so that we have nice jar packaging. Test deployment using Eclipse’s Tomcat server.
    • Client software runs in Webstorm/IntelleJ and deploys to the test tomcat directory, generally in wtwebapps
    • MySQL is developed using PHPMyAdmin and MySqlWorkbench
    • That being said, my dream of full cloud development appears to be near: koding.com
  • Angular.
    • Leaning how to use the animation function definition. Mentioned in the text, Greensock has some interesting stuff.
    • Javascript transition animation for ng-class DON’T FORGET – the name of the animation function uses css class naming convention of preceding the name with a period. E.g. angular.module(‘aniModule’. [‘ngAnimate’]).animation(‘.rememberThePeriod‘, [function (){}]);

Phil 12.4.14

8:00 – 6:00 SR

Directive Supported animations
ngRepeat Enter, leave, and move
ngView Enter and leave
ngInclude Enter and leave
ngSwitch Enter and leave
ngIf Enter and leave
ngClass Add and remove
ngShow and ngHide Add and remove
form and ngModel Add and remove
ngMessages Add and remove
ngMessage Enter and leave

A better ng-class example (here in plunker):
The CSS classes. Note that the ‘base-class’ contains the animation timings:
.base-class {
width: 200px;
height: 50px;
text-align: center;
margin: 10px;
padding: 10px;
-webkit-transition: background-color 1s, color 1s, border-color 1s;
transition: background-color 1s, color 1s, border-color 1s;
}

.base-class.whiteBackground {
background-color: white;
color: black;
border: 3px solid black;
}
.base-class.blackBackground {
background-color: black;
color: white;
border: 3px solid white;
}
.base-class.greenBackground {
background-color: green;
color: yellow;
border: 3px solid yellow;
}
.base-class.blueBackground {
background-color: blue;
color: magenta;
border: 3px solid magenta;
}
.base-class.redBackground {
background-color: red;
color: cyan;
border: 3px solid cyan;
}

The Angular code that cycles through the classes:

<body>
    <link href="ngClassSample.css" rel="stylesheet" />
    <div ng-controller="MyApp as ma">
        <h1>ngClass Animation</h1>
        <div>
            <button ng-click="ma.doToggle()">Next !</button>
            <div class="base-class" ng-class="ma.getAnimationClass()">
                This is the 'ugly sweater' of css animations
            </div>
        </div>
    </div>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular-animate.min.js"></script>
    <script>
        var app = angular.module('myApp', ['ngAnimate']);
        app.controller('MyApp', [function(){
            var self = this;
            var classArray = ['', 'blackBackground', 'whiteBackground', 'greenBackground', 'blueBackground', 'redBackground'];
            self.toggle = 0;
            self.doToggle = function(){
                self.toggle++;
            }
            self.getAnimationClass = function(){
                var index = self.toggle%classArray.length;
                return classArray[index];
            }
        }]);
    </script>
</body>

Phil 12.3.14

8:00 – 1:00, 3:00 – 7:00

  • DB backups
  • Status Report
  • Rolled back the JavaUtils jar file to the working version (compiled on 9/4/14)
  • Discussed the whole direct cite vs. reimbursable with Chris and Lenny. A scatter plot with 0% for DC, R and allocation time at one corner and 100% at the other should give them what they want. Dong’s going to work on the query to produce the data and I’m going to try to render the report in angular and 3D css.
  • More angular. Learning the lifecycle of animations. It looks like if you use straight transitions, then there is a lot of state watching, but if you use keyframe abnimations, everything is much simpler. For example, the two following CSS examples give the fade in/out results:

Using Transitions

/* ngIf animation */
 .animIf.ng-enter {
 /* if the value is true */
 -webkit-transition: opacity linear 0.1s;
 -moz-transition: opacity linear 5.0s;
 -ms-transition: opacity linear 5.0s;
 -o-transition: opacity linear 5.0s;
 transition: opacity linear 5.0s;
 }

 .animIf.ng-leave {
 /* if the value is false */
 -webkit-transition: opacity linear 5s;
 -moz-transition: opacity linear 5s;
 -ms-transition: opacity linear 5s;
 -o-transition: opacity linear 5s;
 transition: opacity linear 5s;
 }
 .animIf.ng-enter,
 .animIf.ng-leave.ng-leave-active {
 opacity: 0.0;
 }

 .animIf.ng-leave,
 .animIf.ng-enter.ng-enter-active {
 opacity: 1;
 }

Using keyframes:

  .listStyle.ng-enter {
 -webkit-animation: 5s enterKeyframes;
 -moz-animation: 5s enterKeyframes;
 -ms-animation: 5s enterKeyframes;
 -o-animation: 5s enterKeyframes;
 animation: 5s enterKeyframes;
 }
 @keyframes enterKeyframes {
 from {
 opacity: 0;
 }
 to {
 opacity: 1;
 }
 }

 .listStyle.ng-leave {
 -webkit-animation: 5s leaveKeyframes;
 -moz-animation: 5s leaveKeyframes;
 -ms-animation: 5s leaveKeyframes;
 -o-animation: 5s leaveKeyframes;
 animation: 5s leaveKeyframes;
 }
 @keyframes leaveKeyframes {
 from {
 opacity: 1;
 }
 to {
 opacity: 0;
 }
 }

I don’t know about you, but to me, the second seems much clearer.