Changeset 43:d6288aa6ccea for source
- Timestamp:
- Jan 15, 2008, 7:19:03 PM (17 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/class/pf/Application.js
r42 r43 517 517 fav.entity = leaf.getUserData("entity"); 518 518 fav.species = leaf.getUserData("species"); 519 fav.color = this.nextColor(); 519 520 this.favorites.push(fav); 520 521 … … 523 524 // ... and update the list of favorites 524 525 this.updateFavoritesListView(); 526 this.updateLegendListView(); 525 527 } 526 528 … … 551 553 // ... and update the list of favorites 552 554 this.updateFavoritesListView(); 555 this.updateLegendListView(); 553 556 } 554 557 … … 642 645 // Update the list of favorites 643 646 this.updateFavoritesListView(); 647 this.updateLegendListView(); 644 648 }, 645 649 … … 1031 1035 }, 1032 1036 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 1033 1076 1034 1077 renderTabPage : function(label, icon, checked) … … 1453 1496 this.gui_compare_units.update(dimension); 1454 1497 this.updateFavoritesListView(); 1498 this.updateLegendListView(); 1455 1499 }, this); 1456 1500 rc.add(l, e); … … 1617 1661 set.y = ydata; 1618 1662 set.legend = vname; 1663 set.color = fav.color; 1619 1664 sets.push(set); 1620 1665 } … … 1678 1723 1679 1724 // Draw sets 1680 canvas.setColor("red");1681 1725 for (var i = 0; i < sets.length; i++) { 1682 1726 var set = sets[i]; 1727 canvas.setColor(set.color); 1683 1728 canvas.drawPolyLineW(set.x, set.y); 1684 1729 … … 1716 1761 1717 1762 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 }); 1721 1770 left_pane.add(canvas); 1722 1771 this.canvas = canvas; 1723 1772 1724 1773 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 1725 1786 var gl = new qx.ui.layout.GridLayout; 1726 gl.set(1727 {1728 left: 4,1729 right: 4,1730 top: 41731 });1732 1787 1733 1788 gl.setVerticalSpacing(4); … … 1742 1797 gl.setRowHeight(3, 30); 1743 1798 gl.setRowHeight(4, 30); 1744 right_pane.add(gl); 1799 gl.setHeight("auto"); 1800 vbl.add(gl); 1745 1801 1746 1802 var l, e; … … 1748 1804 var btn = new qx.ui.form.Button("Redraw", "pf/image/tab-plot.png"); 1749 1805 btn.addEventListener("execute", this.drawCB, this); 1750 btn.setTop(20);1751 btn.setLeft(20);1752 1806 gl.add(btn, 0, 0); 1753 1807 … … 1782 1836 gl.add(l, 0, 4); 1783 1837 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 1784 1921 }, 1785 1922 … … 1924 2061 menubar.add(btn); 1925 2062 }, 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 }, 1926 2074 1927 2075 /** … … 1961 2109 // Favorites 1962 2110 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; 1963 2115 1964 2116 // Top-level container
Note: See TracChangeset
for help on using the changeset viewer.