Changeset 43:d6288aa6ccea for source


Ignore:
Timestamp:
Jan 15, 2008, 7:19:03 PM (17 years ago)
Author:
fnevgeny
Branch:
default
Phase:
public
Message:

Added different (changeable) colors to the curves.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/class/pf/Application.js

    r42 r43  
    517517    fav.entity  = leaf.getUserData("entity");
    518518    fav.species = leaf.getUserData("species");
     519    fav.color   = this.nextColor();
    519520    this.favorites.push(fav);
    520521   
     
    523524    // ... and update the list of favorites
    524525    this.updateFavoritesListView();
     526    this.updateLegendListView();
    525527}
    526528
     
    551553    // ... and update the list of favorites
    552554    this.updateFavoritesListView();
     555    this.updateLegendListView();
    553556}
    554557
     
    642645            // Update the list of favorites
    643646            this.updateFavoritesListView();
     647            this.updateLegendListView();
    644648        },
    645649       
     
    10311035        },
    10321036
     1037        updateLegendListView : function()
     1038        {
     1039            var lv = this.legendListView;
     1040            var rowData = lv.getData();
     1041            rowData.length = 0;
     1042           
     1043            var dimension = this.gui_compare_dim.getSelectedValue();
     1044           
     1045            for (var i = 0; i < this.favorites.length; i++) {
     1046                var fav = this.favorites[i];
     1047                var entity = fav.entity;
     1048               
     1049                if (entity.dimension != dimension) {
     1050                    continue;
     1051                }
     1052               
     1053                var species = fav.species;
     1054
     1055                var icon;
     1056                if (species) {
     1057                    icon = "pf/image/" + species.id + "_small.png";
     1058                } else {
     1059                    icon = "pf/image/all_small.png";
     1060                }
     1061                var name  = this.getEntityFullName(entity, species);
     1062                var color = fav.color;
     1063
     1064                rowData.push({ s_icon   : {icon       : icon,
     1065                                           iconWidth  : 16,
     1066                                           iconHeight : 16    },
     1067                               name     : {text       : name  },
     1068                               color    : {text       : color,
     1069                                           textColor  : color },
     1070                               favorite : fav
     1071                             });
     1072            }
     1073            lv.update();
     1074        },
     1075
    10331076
    10341077        renderTabPage : function(label, icon, checked)
     
    14531496                    this.gui_compare_units.update(dimension);
    14541497                    this.updateFavoritesListView();
     1498                    this.updateLegendListView();
    14551499                }, this);
    14561500            rc.add(l, e);
     
    16171661                set.y = ydata;
    16181662                set.legend = vname;
     1663                set.color = fav.color;
    16191664                sets.push(set);
    16201665            }
     
    16781723           
    16791724            // Draw sets
    1680             canvas.setColor("red");
    16811725            for (var i = 0; i < sets.length; i++) {
    16821726                var set = sets[i];
     1727                canvas.setColor(set.color);
    16831728                canvas.drawPolyLineW(set.x, set.y);
    16841729               
     
    17161761
    17171762            var canvas = new pf.ui.canvas.Plotter();
    1718             canvas.setBackgroundColor("white");
    1719             canvas.setWidth("100%");
    1720             canvas.setHeight("100%");
     1763            canvas.set(
     1764            {
     1765                height          : "100%",
     1766                width           : "100%",
     1767                border          : "inset-thin",
     1768                backgroundColor : "white"
     1769            });
    17211770            left_pane.add(canvas);
    17221771            this.canvas = canvas;
    17231772
    17241773
     1774            var vbl = new qx.ui.layout.VerticalBoxLayout("vertical");
     1775            vbl.set(
     1776            {
     1777                height          : "100%",
     1778                width           : "100%",
     1779                border          : "inset-thin",
     1780                padding         : 4,
     1781                spacing         : 10,
     1782                backgroundColor : "white"
     1783            });
     1784            right_pane.add(vbl);
     1785
    17251786            var gl = new qx.ui.layout.GridLayout;
    1726             gl.set(
    1727             {
    1728                 left:   4,
    1729                 right:  4,
    1730                 top:    4
    1731             });
    17321787           
    17331788            gl.setVerticalSpacing(4);
     
    17421797            gl.setRowHeight(3, 30);
    17431798            gl.setRowHeight(4, 30);
    1744             right_pane.add(gl);
     1799            gl.setHeight("auto");
     1800            vbl.add(gl);
    17451801
    17461802            var l, e;
     
    17481804            var btn = new qx.ui.form.Button("Redraw", "pf/image/tab-plot.png");
    17491805            btn.addEventListener("execute", this.drawCB, this);
    1750             btn.setTop(20);
    1751             btn.setLeft(20);
    17521806            gl.add(btn, 0, 0);
    17531807
     
    17821836            gl.add(l, 0, 4);
    17831837            gl.add(e, 1, 4);
     1838
     1839
     1840            var lc =
     1841            {
     1842                s_icon   : { label      : "",
     1843                             width      : 24,
     1844                             type       : "iconHtml",
     1845                             align      : "center",                   
     1846                             sortable   : false                         },
     1847                name     : { label      : "Name",
     1848                             width      : 185,
     1849                             type       : "text",
     1850                             align      : "left",
     1851                             sortable   : true,
     1852                             sortProp   : "text"                        },
     1853                color    : { label      : "Color",
     1854                             width      : 55,
     1855                             type       : "text",
     1856                             align      : "left",
     1857                             sortable   : false                         }
     1858            };
     1859
     1860            var lv = new qx.ui.listview.ListView(new Array, lc);
     1861
     1862            lv.setWidth("100%");
     1863            lv.setHeight("2*");
     1864            // lv.setBackgroundColor("white");
     1865            lv.setBorder("dark-shadow");
     1866           
     1867            lv.addEventListener("dblclick", function(ev) {
     1868                    ev.setPropagationStopped(true);
     1869                    var pane = this.getPane();
     1870                    var item = pane.getSelectedItem();
     1871                    if (!item) {
     1872                        return;
     1873                    }
     1874                    var favorite = item.favorite;
     1875                    if (!favorite) {
     1876                        return;
     1877                    }
     1878                    mypop.setUserData("favorite", null); // avoid loop call
     1879                    mypop.setValue(favorite.color);
     1880                    mypop.setUserData("favorite", favorite);
     1881                    var el = this.getElement();
     1882                    mypop.setTop(qx.html.Location.getPageBoxTop(el));
     1883                    mypop.setLeft(qx.html.Location.getPageBoxLeft(el) -
     1884                        this.getWidthValue());
     1885                    mypop.show();
     1886                });
     1887
     1888            vbl.add(lv);
     1889            this.legendListView = lv;
     1890           
     1891            var mytables =
     1892            {
     1893              core : {
     1894                label : "Basic Colors",
     1895                values : this.colorMap
     1896              },
     1897
     1898              recent : {
     1899                label : "Recent Colors",
     1900                values : [ ]
     1901              }
     1902            }
     1903
     1904            var mypop = new qx.ui.component.ColorPopup(mytables);
     1905            // A hack
     1906            mypop._layout.remove(mypop._automaticBtn);
     1907
     1908            mypop.addToDocument();
     1909
     1910            mypop.addEventListener("changeValue", function(ev) {
     1911                var color = ev.getValue();
     1912                var mypop = ev.getTarget();
     1913                var favorite = mypop.getUserData("favorite");
     1914                if (!favorite || !color) {
     1915                    return;
     1916                }
     1917                favorite.color = color;
     1918                this.updateLegendListView();
     1919            }, this);
     1920   
    17841921        },
    17851922
     
    19242061            menubar.add(btn);
    19252062        },
     2063       
     2064        nextColor : function()
     2065        {
     2066            var color = this.colorMap[this.ncolor];
     2067            this.ncolor++;
     2068            if (this.ncolor == this.colorMap.length) {
     2069                this.ncolor = 0;
     2070            }
     2071           
     2072            return color;
     2073        },
    19262074
    19272075        /**
     
    19612109            // Favorites
    19622110            this.favorites = new Array;
     2111           
     2112            this.colorMap = new Array("red", "blue", "green", "orange",
     2113                "brown", "olive", "teal", "magenta", "grey", "black");
     2114            this.ncolor = 0;
    19632115
    19642116            // Top-level container
Note: See TracChangeset for help on using the changeset viewer.