public AreaCodeMapTest()
        {
            SortedMap <Integer, String> sortedMapForUS = new TreeMap <Integer, String>();

            sortedMapForUS.put(1212, "New York");
            sortedMapForUS.put(1480, "Arizona");
            sortedMapForUS.put(1650, "California");
            sortedMapForUS.put(1907, "Alaska");
            sortedMapForUS.put(1201664, "Westwood, NJ");
            sortedMapForUS.put(1480893, "Phoenix, AZ");
            sortedMapForUS.put(1501372, "Little Rock, AR");
            sortedMapForUS.put(1626308, "Alhambra, CA");
            sortedMapForUS.put(1650345, "San Mateo, CA");
            sortedMapForUS.put(1867993, "Dawson, YT");
            sortedMapForUS.put(1972480, "Richardson, TX");

            areaCodeMapForUS.readAreaCodeMap(sortedMapForUS);

            SortedMap <Integer, String> sortedMapForIT = new TreeMap <Integer, String>();

            sortedMapForIT.put(3902, "Milan");
            sortedMapForIT.put(3906, "Rome");
            sortedMapForIT.put(39010, "Genoa");
            sortedMapForIT.put(390131, "Alessandria");
            sortedMapForIT.put(390321, "Novara");
            sortedMapForIT.put(390975, "Potenza");

            areaCodeMapForIT.readAreaCodeMap(sortedMapForIT);
        }
Exemple #2
0
 static SyllableMatcher()
 {
     map = new TreeMap <String, String>()
     {
         { "ニャン", "nyan" }, { "ビャ", "bya" }, { "ビェ", "bye" }, { "ビョ", "byo" }, { "ビュ", "byu" },
         { "チ", "chi" }, { "チャ", "cya" }, { "チェ", "cye" }, { "チョ", "cyo" }, { "チュ", "cyu" },
         { "ディ", "dhi" }, { "デュ", "dhu" }, { "ドゥ", "dwu" }, { "ギャ", "gya" }, { "ギェ", "gye" },
         { "ギョ", "gyo" }, { "ギュ", "gyu" }, { "ヒャ", "hya" }, { "ヒェ", "hye" }, { "ヒョ", "hyo" },
         { "ヒュ", "hyu" }, { "キャ", "kya" }, { "キェ", "kye" }, { "キョ", "kyo" }, { "キュ", "kyu" },
         { "ミャ", "mya" }, { "ミェ", "mye" }, { "ミョ", "myo" }, { "ミュ", "myu" }, { "ニャ", "nya" },
         { "ニェ", "nye" }, { "ニョ", "nyo" }, { "ニュ", "nyu" }, { "リャ", "rya" }, { "リェ", "rye" },
         { "リョ", "ryo" }, { "リュ", "ryu" }, { "スィ", "swi" }, { "シャ", "sya" }, { "シェ", "sye" },
         { "ショ", "syo" }, { "シュ", "syu" }, { "ティ", "thi" }, { "テュ", "thu" }, { "ツァ", "tsa" },
         { "ツェ", "tse" }, { "ツィ", "tsi" }, { "ツォ", "tso" }, { "トゥ", "twu" }, { "ズィ", "zwi" },
         { "バ", "ba" }, { "ベ", "be" }, { "ビ", "bi" }, { "ボ", "bo" }, { "ブ", "bu" }, { "ダ", "da" },
         { "デ", "de" }, { "ド", "do" }, { "ファ", "fa" }, { "フェ", "fe" }, { "フィ", "fi" }, { "フォ", "fo" },
         { "フ", "fu" }, { "ガ", "ga" }, { "ゲ", "ge" }, { "ギ", "gi" }, { "ゴ", "go" }, { "グ", "gu" },
         { "ハ", "ha" }, { "ヘ", "he" }, { "ヒ", "hi" }, { "ホ", "ho" }, { "ジャ", "ja" }, { "ジェ", "je" },
         { "ジ", "ji" }, { "ジョ", "jo" }, { "ジュ", "ju" }, { "カ", "ka" }, { "ケ", "ke" }, { "キ", "ki" },
         { "コ", "ko" }, { "ク", "ku" }, { "マ", "ma" }, { "メ", "me" }, { "ミ", "mi" }, { "モ", "mo" },
         { "ム", "mu" }, { "ナ", "na" }, { "ネ", "ne" }, { "ニ", "ni" }, { "ノ", "no" }, { "ヌ", "nu" },
         { "パ", "pa" }, { "ペ", "pe" }, { "ピ", "pi" }, { "ポ", "po" }, { "プ", "pu" }, { "ラ", "ra" },
         { "レ", "re" }, { "リ", "ri" }, { "ロ", "ro" }, { "ル", "ru" }, { "サ", "sa" }, { "セ", "se" },
         { "シ", "si" }, { "ソ", "so" }, { "ス", "su" }, { "タ", "ta" }, { "テ", "te" }, { "ト", "to" },
         { "ツ", "tu" }, { "ヴァ", "va" }, { "ヴェ", "ve" }, { "ヴィ", "vi" }, { "ヴォ", "vo" }, { "ヴ", "vu" },
         { "ワ", "wa" }, { "ヱ", "we" }, { "ヰ", "wi" }, { "ヲ", "wo" }, { "ヤ", "ya" }, { "イェ", "ye" },
         { "ヨ", "yo" }, { "ユ", "yu" }, { "ザ", "za" }, { "ゼ", "ze" }, { "ゾ", "zo" }, { "ズ", "zu" },
         { "ア", "a" }, { "エ", "e" }, { "イ", "i" }, { "ン", "n" }, { "オ", "o" }, { "ウ", "u" },
     };
 }
        public void ChangingContentsOfNestedObservableCollectionUpdatesTreeMap()
        {
            TreeMap treeMap = new TreeMap();
            TreeMapItemDefinition itemDefinition = new TreeMapItemDefinition
            {
                ValueBinding = new Binding(),
                ItemsSource  = new Binding("Value"),
            };

            itemDefinition.ItemTemplate = (DataTemplate)XamlReader.Load(SimpleItemTemplate);
            treeMap.ItemDefinition      = itemDefinition;
            ObservableCollection <int> nestedItemsSourceA = new ObservableCollection <int>();
            ObservableCollection <int> nestedItemsSourceB = new ObservableCollection <int>();

            treeMap.ItemsSource = new KeyValuePair <int, ObservableCollection <int> >[]
            {
                new KeyValuePair <int, ObservableCollection <int> >(0, nestedItemsSourceA),
                new KeyValuePair <int, ObservableCollection <int> >(0, nestedItemsSourceB),
            };
            TestAsync(
                treeMap,
                // +1 because of the Border in default template
                () => Assert.AreEqual(0 + 2 + 1, treeMap.GetVisualDescendents().OfType <Border>().Count()),
                () => nestedItemsSourceA.Add(1),
                () => Assert.AreEqual(1 + 2 + 1, treeMap.GetVisualDescendents().OfType <Border>().Count()),
                () => nestedItemsSourceB.Add(2),
                () => Assert.AreEqual(2 + 2 + 1, treeMap.GetVisualDescendents().OfType <Border>().Count()),
                () => nestedItemsSourceA.Add(3),
                () => Assert.AreEqual(3 + 2 + 1, treeMap.GetVisualDescendents().OfType <Border>().Count()),
                () => nestedItemsSourceB.Clear(),
                () => Assert.AreEqual(2 + 2 + 1, treeMap.GetVisualDescendents().OfType <Border>().Count()),
                () => nestedItemsSourceA.Clear(),
                () => Assert.AreEqual(0 + 2 + 1, treeMap.GetVisualDescendents().OfType <Border>().Count()));
        }
Exemple #4
0
    public void DrawMapInEditor()
    {
        textureData.ApplyToMaterial(terrainMaterial);
        textureData.UpdateMeshHeights(terrainMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);
        HeightMap heightMap = HeightMapGenerator.GenerateHeightMap(meshSettings.numVertsPerLine, meshSettings.numVertsPerLine, heightMapSettings, Vector2.zero);
        HeatMap   heatMap   = HeatMapGenerator.GenerateHeatMap(meshSettings.numVertsPerLine, meshSettings.numVertsPerLine, heightMap, heatMapSettings, Vector2.zero);
        TreeMap   treeMap   = TreeMapGenerator.generateVegetationMap(meshSettings.numVertsPerLine, meshSettings.numVertsPerLine, heightMap, heatMap, treeMapSettings, Vector2.zero);

        DestroyTrees();          //temporary fix

        if (drawMode == DrawMode.HeightMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(heightMap));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            DrawMesh(MeshGenerator.GenerateTerrainMesh2(heightMap.values, meshSettings, editorPreviewLOD, heatMap.values));
            DrawTrees(heightMap.values, meshSettings, treeMap.values);
        }
        else if (drawMode == DrawMode.FalloffMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(new HeightMap(FalloffGenerator.GenerateFalloffMap(meshSettings.numVertsPerLine), 0, 1)));
        }
        else if (drawMode == DrawMode.HeatMap)
        {
            DrawTexture(TextureGenerator.TextureColorizedFromHeatMap(heatMap));
        }
        else if (drawMode == DrawMode.TreeMap)
        {
            DrawTexture(TextureGenerator.TextureFromTreeMap(treeMap));
        }
    }
Exemple #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            var clickedButton = (sender as Button);

            panelMain.Controls.Clear();
            Control newControl;
            var     str = clickedButton.Text;

            switch (str)
            {
            case "BASIC DRILLDOWN": newControl = new BasicDrillDownDemo(); break;

            case "ASYNC DRILLDOWN": newControl = new AsyncDrillDownDemo(); break;

            case "SUNBURST": newControl = new Sunburst(); break;

            case "TREEMAP": newControl = new TreeMap(); break;

            default: newControl = new BasicDrillDownDemo(); break;
            }

            newControl.Dock = DockStyle.Fill;
            panelMain.Controls.Add(newControl);

            //Paint selection button color
            foreach (Button item in panelLinks.Controls)
            {
                item.Image = null;
            }

            clickedButton.Image = _menuButtonImage;
        }
Exemple #6
0
        /// <summary>
        /// Возвращает родительскую TreeView-ветку для заданного пути.
        /// Фолдер или берется из кэша, или создается (и добавляется в кэш).
        /// </summary>
        /// <param name="typeNode">Ветка типа (корневая ветка иерархии)</param>
        /// <param name="treeMap">Кэш (мап путей/веток)</param>
        /// <param name="dir">Путь для которого нужно найти ветку</param>
        /// <returns></returns>
        private static TreeNode GetParentFolder(
            TreeNode typeNode,
            TreeMap treeMap,
            string dir)
        {
            TreeNode folder;

            if (treeMap.ContainsKey(dir))
            {
                folder = treeMap[dir];
            }
            else
            {
                if (dir.Length == 0)
                {
                    folder = typeNode;
                }
                else
                {
                    string[] dirs = dir.Split('\\', '/');
                    if (dirs.Length == 0)
                    {
                        folder = typeNode;
                    }
                    else
                    {
                        folder = GetFolderNode(typeNode, treeMap,
                                               dirs, dirs.Length);
                    }
                }
            }
            return(folder);
        }
        public void InterpolatorsMinMaxBindingTreeMapTest()
        {
            DoubleInterpolator testInterpolator = new DoubleInterpolator
            {
                From             = 11,
                To               = 20,
                DataRangeBinding = new Binding("Points"),
                TargetName       = "textB",
                TargetProperty   = "FontSize"
            };

            testInterpolator.SetBinding(DoubleInterpolator.DataMinimumProperty, new Binding("Key"));
            testInterpolator.SetBinding(DoubleInterpolator.DataMaximumProperty, new Binding("Value"));

            TreeMap testTreeMap = InterpolatedTreeMapToTest;

            testTreeMap.Interpolators.Clear();

            // Tuple can't be used as it is internal
            testTreeMap.DataContext = new KeyValuePair <double, double>(15.0, 20.0);

            testTreeMap.Interpolators.Add(testInterpolator);

            TestAsync(
                testTreeMap,
                () => testTreeMap.ItemsSource = InterpolatedTreeMapItemsSource,
                () => Assert.AreEqual(20, testInterpolator.ActualDataMaximum),
                () => Assert.AreEqual(15, testInterpolator.ActualDataMinimum));
        }
        /// <summary>  Generate automata using Tabakov and Vardi's approach
        ///
        /// </summary>
        /// <param name="num">
        /// </param>
        /// <returns> a random finite automaton
        /// </returns>
        /// <author>  Yu-Fang Chen
        /// </author>
        public static FiniteAutomaton genRandomTV(int size, float td, float fd, int alphabetSize)
        {
            FiniteAutomaton result = new FiniteAutomaton();
            //UPGRADE_ISSUE: The following fragment of code could not be parsed and was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1156'"
            TreeMap <Integer, FAState> st = new TreeMap <Integer, FAState>();

            td = td / size;
            System.Random r = new System.Random();

            for (int i = 0; i < size; i++)
            {
                st.put(i, result.createState());
                float rm = (float)r.NextDouble();
                if (fd > rm)
                {
                    result.F.add(st.get_Renamed(i));
                }
            }
            result.setInitialState(st.get_Renamed(0));
            result.F.add(st.get_Renamed(0));
            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    for (int k = 0; k < alphabetSize; k++)
                    {
                        if (td > (float)r.NextDouble())
                        {
                            result.addTransition(st.get_Renamed(i), st.get_Renamed(j), ("a" + k));
                        }
                    }
                }
            }
            return(result);
        }
Exemple #9
0
        public void GenerateMap()
        {
            _treeMap = new TreeMap(Vector2.zero, _width, _height);

            for (int i = 0; i < bspIteration; i++)
            {
                _treeMap.rootNode.Divide();
            }

            _treeMap.UpdateMapDatasetFromTree();
            _treeMap.GenerateCorridor();

            _treeComponents = GetAllMapComponent();
            //FindDoors(_treeComponents);

            var corridors = _treeComponents.FindAll(x => x.GetType() == typeof(BSPCorridor));
            var rooms     = _treeComponents.FindAll(x => x.GetType() == typeof(BSPRoom));

            AssignExistStartRoom(rooms, (_width + _height) / 2f);

            if (OnMapBuild != null)
            {
                OnMapBuild(dungeonSize, _treeComponents);
            }
        }
Exemple #10
0
 static SyllableMatcher()
 {
     map = new TreeMap<String, String>() {
         { "ニャン", "nyan" }, { "ビャ", "bya" },  { "ビェ", "bye" },  { "ビョ", "byo" },  { "ビュ", "byu" },
         { "チ", "chi" }, { "チャ", "cya" }, { "チェ", "cye" }, { "チョ", "cyo" }, { "チュ", "cyu" },
         { "ディ", "dhi" }, { "デュ", "dhu" }, { "ドゥ", "dwu" }, { "ギャ", "gya" }, { "ギェ", "gye" },
         { "ギョ", "gyo" }, { "ギュ", "gyu" }, { "ヒャ", "hya" }, { "ヒェ", "hye" }, { "ヒョ", "hyo" },
         { "ヒュ", "hyu" }, { "キャ", "kya" }, { "キェ", "kye" }, { "キョ", "kyo" }, { "キュ", "kyu" },
         { "ミャ", "mya" }, { "ミェ", "mye" }, { "ミョ", "myo" }, { "ミュ", "myu" }, { "ニャ", "nya" },
         { "ニェ", "nye" }, { "ニョ", "nyo" }, { "ニュ", "nyu" }, { "リャ", "rya" }, { "リェ", "rye" },
         { "リョ", "ryo" }, { "リュ", "ryu" }, { "スィ", "swi" }, { "シャ", "sya" }, { "シェ", "sye" },
         { "ショ", "syo" }, { "シュ", "syu" }, { "ティ", "thi" }, { "テュ", "thu" }, { "ツァ", "tsa" },
         { "ツェ", "tse" }, { "ツィ", "tsi" }, { "ツォ", "tso" }, { "トゥ", "twu" }, { "ズィ", "zwi" },
         { "バ", "ba" }, { "ベ", "be" }, { "ビ", "bi" }, { "ボ", "bo" }, { "ブ", "bu" }, { "ダ", "da" },
         { "デ", "de" }, { "ド", "do" }, { "ファ", "fa" }, { "フェ", "fe" }, { "フィ", "fi" }, { "フォ", "fo" },
         { "フ", "fu" }, { "ガ", "ga" }, { "ゲ", "ge" }, { "ギ", "gi" }, { "ゴ", "go" }, { "グ", "gu" },
         { "ハ", "ha" }, { "ヘ", "he" }, { "ヒ", "hi" }, { "ホ", "ho" }, { "ジャ", "ja" }, { "ジェ", "je" },
         { "ジ", "ji" }, { "ジョ", "jo" }, { "ジュ", "ju" }, { "カ", "ka" }, { "ケ", "ke" }, { "キ", "ki" },
         { "コ", "ko" }, { "ク", "ku" }, { "マ", "ma" }, { "メ", "me" }, { "ミ", "mi" }, { "モ", "mo" },
         { "ム", "mu" }, { "ナ", "na" }, { "ネ", "ne" }, { "ニ", "ni" }, { "ノ", "no" }, { "ヌ", "nu" },
         { "パ", "pa" }, { "ペ", "pe" }, { "ピ", "pi" }, { "ポ", "po" }, { "プ", "pu" }, { "ラ", "ra" },
         { "レ", "re" }, { "リ", "ri" }, { "ロ", "ro" }, { "ル", "ru" }, { "サ", "sa" }, { "セ", "se" },
         { "シ", "si" }, { "ソ", "so" }, { "ス", "su" }, { "タ", "ta" }, { "テ", "te" }, { "ト", "to" },
         { "ツ", "tu" }, { "ヴァ", "va" }, { "ヴェ", "ve" }, { "ヴィ", "vi" }, { "ヴォ", "vo" }, { "ヴ", "vu" },
         { "ワ", "wa" }, { "ヱ", "we" }, { "ヰ", "wi" }, { "ヲ", "wo" }, { "ヤ", "ya" }, { "イェ", "ye" },
         { "ヨ", "yo" }, { "ユ", "yu" }, { "ザ", "za" }, { "ゼ", "ze" }, { "ゾ", "zo" }, { "ズ", "zu" },
         { "ア", "a" }, { "エ", "e" }, { "イ", "i" }, { "ン", "n" }, { "オ", "o" }, { "ウ", "u" },
     };
 }
Exemple #11
0
        public Map <String, Object> getAllProperties()
        {
            TreeMap <String, Object> map = new TreeMap <String, Object>(_indexedProperties);

            map.putAll(_unindexedProperties);
            return(map);
        }
Exemple #12
0
        public void refresh(MyList <T?> _order, Map <T?, String> _tr)
        {
            order.Clear();
            order.AddRange(_order);
            Items.Clear();
            Map <T?, String> m_ = new Map <T?, String>(_tr);

            //		elements = new TreeMap<T,String>(new Comparator<T>(){
            //			@Override
            //			public int compare(T _o1, T _o2) {
            //				return order.indexOfObj(_o1) - order.indexOfObj(_o2);
            //			}
            //		});
            elements = new TreeMap <T?, String>(new ComparatorIndexes <T>(order));
            if (withDefaultValue)
            {
                m_.put(null, "");
            }
            elements.putAllMap(m_);
            foreach (T?e in elements.getKeys())
            {
                if (_tr.contains(e))
                {
                    Items.Add(_tr.getVal(e));
                }
                else
                {
                    Items.Add("");
                }
            }
        }
Exemple #13
0
    void GenerateTreeTexture()
    {
        treeHeightMapPreview            = new Texture2D(300, 300);
        treeHeightMapPreview.filterMode = FilterMode.Point;
        treeHeightMapPreview.wrapMode   = TextureWrapMode.Clamp;

        TreeMap treeMap = Utility.GetTargetObjectOfProperty(treeMapProperty) as TreeMap;

        var nbXPixel = treeHeightMapPreview.width / (Chunk.ChunkSize * 5);
        var nbYPixel = treeHeightMapPreview.height / (Chunk.ChunkSize * 5);

        for (int j = 0; j < Chunk.ChunkSize * 5; j++)
        {
            for (int i = 0; i < Chunk.ChunkSize * 5; i++)
            {
                var height = treeMap.GetHeight(i - Chunk.ChunkRadius, j - Chunk.ChunkRadius);
                var color  = (height > treeMap.probability) ? Color.Lerp(Color.black, Color.white, height) : Color.green;

                var colors = Enumerable.Repeat <Color>(color, nbXPixel * nbYPixel).ToArray();
                treeHeightMapPreview.SetPixels(i * nbXPixel, j * nbYPixel, nbXPixel, nbYPixel, colors);
            }
        }

        treeHeightMapPreview.Apply();
    }
Exemple #14
0
        public void TestDefaultComparer()
        {
            var map = new TreeMap <Employee, int>();

            map.DictionaryOperations(x => new Employee {
                Id = x, Mark = x * 5
            }, y => y, EqualityComparer <int> .Default.Equals);
        }
        public void toXmlString10Test()
        {
            TreeMap <String, CarOptions> opts2_ = new TreeMap <String, CarOptions>(new ReverseComparer());

            opts2_.put("1", CarOptions.SunRoof);
            opts2_.put("2", CarOptions.FogLights);
            Assert.AreEqual("<Util.Util.TreeMap types=\"`2[[System.String, mscorlib], [Util.CarOptions, Util]]\"><StreamTests.StreamTests.ReverseComparer class=\"Util.Util.ListableKey\" Comparer=\"\"/><mscorlib.System.String class=\"Util.Util.ListableKey\" key=\"\" value=\"2\"/><Util.Util.CarOptions class=\"Util.Util.ListableKey\" value=\"FogLights\"/><mscorlib.System.String class=\"Util.Util.ListableKey\" key=\"\" value=\"1\"/><Util.Util.CarOptions class=\"Util.Util.ListableKey\" value=\"SunRoof\"/></Util.Util.TreeMap>", SerializeXmlObject.toXmlString(opts2_));
        }
        public TreeMap_Series()
        {
            InitializeComponent();

            tChart1.Aspect.View3D = false;
            treeMap = new TreeMap(tChart1.Chart);
            treeMap.FillSampleValues();
        }
        public void EdgeAreaValuesTreeMapTest()
        {
            TreeMap           treeMapControl = InterpolatedTreeMapToTest;
            List <SimpleNode> itemList       = new List <SimpleNode>
            {
                new SimpleNode
                {
                    Name     = "A",
                    Points   = 0.0,
                    Wins     = 100,
                    Children = new SimpleNode[0],
                },
                new SimpleNode
                {
                    Name     = "B",
                    Children = new SimpleNode[]
                    {
                        new SimpleNode
                        {
                            Name     = "C",
                            Points   = 80.0,
                            Wins     = 20,
                            Children = null,
                        },
                        new SimpleNode
                        {
                            Name     = "D",
                            Points   = 20.0,
                            Wins     = 0,
                            Children = new SimpleNode[0],
                        },
                    }
                },
            };

            treeMapControl.ItemsSource = itemList;

            TestAsync(
                treeMapControl,
                () => Assert.IsNull(FindElementWithTag(treeMapControl, "A")),
                () => AssertSize(treeMapControl, "B", 1),
                () => AssertSize(treeMapControl, "C", 0.8),
                () => AssertSize(treeMapControl, "D", 0.2),
                () => itemList[0].Points         = -100,
                () => treeMapControl.ItemsSource = null,
                () => treeMapControl.ItemsSource = itemList,
                () => Assert.IsNull(FindElementWithTag(treeMapControl, "A")),
                () => AssertSize(treeMapControl, "B", 1),
                () => AssertSize(treeMapControl, "C", 0.8),
                () => AssertSize(treeMapControl, "D", 0.2),
                () => itemList[0].Points         = 0.01,
                () => treeMapControl.ItemsSource = null,
                () => treeMapControl.ItemsSource = itemList,
                () => Assert.IsNotNull(FindElementWithTag(treeMapControl, "A")),
                () => AssertSize(treeMapControl, "B", 1),
                () => AssertSize(treeMapControl, "C", 0.8),
                () => AssertSize(treeMapControl, "D", 0.2));
        }
        static void Main(string[] args)
        {
            TreeMap<string, string> map = new TreeMap<string, string>();

            foreach(KeyValuePair<string,string> pair in map)
            {
                Console.WriteLine("{0}, {1}", pair.Key, pair.Value);
            }
        }
        private static SortedMap <Integer, String> createDefaultStorageMapCandidate()
        {
            SortedMap <Integer, String> sortedMap = new TreeMap <Integer, String>();

            // Make the area codes bigger to store them using integer.
            sortedMap.put(121212345, "New York");
            sortedMap.put(148034434, "Arizona");
            return(sortedMap);
        }
Exemple #20
0
        static void Main(string[] args)
        {
            TreeMap <string, string> map = new TreeMap <string, string>();


            foreach (KeyValuePair <string, string> pair in map)
            {
                Console.WriteLine("{0}, {1}", pair.Key, pair.Value);
            }
        }
        private void dumpCommands()
        {
            Iterator iterator = new TreeMap(this.commandList).entrySet().iterator();

            while (iterator.hasNext())
            {
                Map.Entry entry = (Map.Entry)iterator.next();
                this.putResponse(new StringBuilder().append((string)entry.getKey()).append(" - ").append(((CommandInterface)entry.getValue()).getHelp()).toString());
            }
        }
        public void TreeMapRendersSimpleData()
        {
            TreeMap treeMap = new TreeMap();

            treeMap.ItemsSource = new int[] { 1, 2, 3 };
            TestAsync(
                treeMap,
                // +1 because of the Border in default template
                () => Assert.AreEqual(3 + 1, treeMap.GetVisualDescendents().OfType <Border>().Count()));
        }
        public void fromXmlString10Test()
        {
            TreeMap <string, CarOptions> obj_ = (TreeMap <string, CarOptions>)SerializeXmlObject.fromXmlStringObject("<Util.Util.TreeMap types=\"`2[[System.String, mscorlib], [Util.CarOptions, Util]]\"><StreamTests.StreamTests.ReverseComparer class=\"Util.Util.ListableKey\" Comparer=\"\" /><mscorlib.System.String class=\"Util.Util.ListableKey\" key=\"\" value=\"2\" /><Util.Util.CarOptions class=\"Util.Util.ListableKey\" value=\"FogLights\" /><mscorlib.System.String class=\"Util.Util.ListableKey\" key=\"\" value=\"1\" /><Util.Util.CarOptions class=\"Util.Util.ListableKey\" value=\"SunRoof\" /></Util.Util.TreeMap>");

            Assert.AreEqual(2, obj_.size());
            Assert.AreEqual("2", obj_.getKey(0));
            Assert.AreEqual(CarOptions.FogLights, obj_.getValue(0));
            Assert.AreEqual("1", obj_.getKey(1));
            Assert.AreEqual(CarOptions.SunRoof, obj_.getValue(1));
        }
        private static SortedMap <Integer, String> createFlyweightStorageMapCandidate()
        {
            SortedMap <Integer, String> sortedMap = new TreeMap <Integer, String>();

            sortedMap.put(1212, "New York");
            sortedMap.put(1213, "New York");
            sortedMap.put(1214, "New York");
            sortedMap.put(1480, "Arizona");
            return(sortedMap);
        }
Exemple #25
0
        public void TestTreeMapDictionaryOperations()
        {
            var map = new TreeMap <Order, Bill>(new OrderComparer());

            map.DictionaryOperations(x => new Order {
                Id = x
            }, y => new Bill {
                Id = y
            }, new BillEqualityComparer().Equals);
        }
Exemple #26
0
        public Form1()
        {
            InitializeComponent();
            this.MetroColor = Color.White;
            this.BackColor  = Color.White;

            #region Sample Header

            Label sampleHeader = new Label();
            sampleHeader.Text      = "This sample represents TreeMap showing Olympic Medals won by United States in various events.";
            sampleHeader.Font      = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            sampleHeader.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(150)))), ((int)(((byte)(205)))));
            sampleHeader.ForeColor = System.Drawing.Color.White;
            sampleHeader.Size      = new System.Drawing.Size(970, (int)DpiAware.LogicalToDeviceUnits(35));
            sampleHeader.Margin    = new System.Windows.Forms.Padding(0);
            sampleHeader.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            sampleHeader.Dock      = DockStyle.Top;
            this.Controls.Add(sampleHeader);

            #endregion

            #region TreeMap

            Panel sampleLayoutPanel = new Panel();
            sampleLayoutPanel.Dock    = DockStyle.Fill;
            sampleLayoutPanel.Padding = new System.Windows.Forms.Padding(10, (int)DpiAware.LogicalToDeviceUnits(35), 0, 0);

            OlymicMedalsViewModel olymicMedalsViewModel = new OlymicMedalsViewModel();

            TreeMap treeMap = new TreeMap();
            treeMap.Dock             = DockStyle.Fill;
            treeMap.Margin           = new System.Windows.Forms.Padding(0, 0, 10, 10);
            treeMap.ItemsSource      = olymicMedalsViewModel.OlympicMedalsDetails;
            treeMap.WeightValuePath  = "TotalMedals";
            treeMap.ColorValuePath   = "GoldMedals";
            treeMap.ItemsLayoutMode  = ItemsLayoutModes.Squarified;
            treeMap.LeafItemDrawing += treeMap_LeafItemDrawing;
            ToolTipInfo itemInfo = new ToolTipInfo();
            itemInfo.ToolTipHeaderPattern      = "<b>{Country} - {GameName}</b>";
            itemInfo.ToolTipContentPattern     = "GoldMedals \t {GoldMedals}  \nSilverMedals \t {SilverMedals}  \nBronzeMedals \t {BronzeMedals}";
            treeMap.ItemToolTipInfo            = itemInfo;
            treeMap.LeafItemSettings.LabelPath = "GameName";
            #region Range ColorMapping

            UniColorMapping uniColorMapping = new UniColorMapping();
            uniColorMapping.Color    = Color.FromArgb(215, 48, 40);
            treeMap.LeafColorMapping = uniColorMapping;

            #endregion

            sampleLayoutPanel.Controls.Add(treeMap);
            this.Controls.Add(sampleLayoutPanel);

            #endregion
        }
Exemple #27
0
        private static long GetProductOfTreesEncountered(TreeMap map, Slope[] slopes)
        {
            var treesEncountered = slopes.Select(slope =>
            {
                map.Slope  = slope;
                long count = map.CountTreesEncountered();
                return(count);
            });

            return(treesEncountered.Aggregate(1L, (product, i) => product * i));
        }
Exemple #28
0
        /// <summary>
        /// Trim the current set of strike prices to the given set.
        /// </summary>
        /// <param name="strikeSet"></param>
        public void trimStrikes(SortedSet strikeSet)
        {
            double lowStrike  = (double)strikeSet.first();
            double highStrike = (double)strikeSet.last();

            highStrike = highStrike + 0.0001;
            TreeMap trimmedStrikes = new TreeMap(subMap(lowStrike, highStrike));

            clear();
            putAll(trimmedStrikes);
        }
    public void createTerrainObject()
    {
        this.BaseTerrainObj = new GameObject("TerrainIsle");
        this.BaseTerrainObj.transform.parent   = terr.transform;
        terr.BaseTerrainData.baseMapResolution = 1024;
        int baseResolution = (int)Math.Pow(2, 8 + terr.terrainScalingFactor) + 1;

        terr.BaseTerrainData.SetDetailResolution(baseResolution, 16);
        terr.BaseTerrainData.heightmapResolution = baseResolution;
        terr.BaseTerrainData.alphamapResolution  = baseResolution;

        terr.BaseTerrainData.size = new Vector3(baseResolution, 600, baseResolution);

        this.BaseTerrainCollider             = this.BaseTerrainObj.AddComponent <TerrainCollider>();
        this.BaseTerrainCollider.terrainData = terr.BaseTerrainData;

        this.terrain             = BaseTerrainObj.AddComponent <Terrain>();
        this.terrain.terrainData = terr.BaseTerrainData;

        // get the terrain component
        //this.terrain = BaseTerrain;

        // get the generated standard data
        this.tData = terrain.terrainData;

        // get the terrain resolution
        this.xTerrainRes        = tData.heightmapWidth;
        this.yTerrainRes        = tData.heightmapHeight;
        this.terrainWidthScale  = tData.size.x;
        this.terrainLengthScale = tData.size.z;
        this.terrainHeightScale = tData.size.y;

        // transform terrain to middle point of global coordinates system
        this.terrain.transform.position = new Vector3(-terrainWidthScale / 2, 0, -terrainLengthScale / 2);

        // get the texture resolution
        this.xTextureRes = tData.alphamapWidth;
        this.yTextureRes = tData.alphamapHeight;

        this.alphaMap   = new AlphaMap(new float[this.xTextureRes, this.yTextureRes, 6]);
        this.biomeMap   = new int[this.xTextureRes, this.yTextureRes];
        this.MountMap   = new MountMap(this);
        this.DetailsMap = new DetailsMap(this);
        this.TreeMap    = new TreeMap(this);


        tData.SetAlphamaps(0, 0, this.alphaMap.aMap);
        tData.SetDetailLayer(0, 0, 0, this.DetailsMap.dMap);
        tData.SetHeights(0, 0, this.MountMap.heightMap);
        tData.treeInstances = new List <TreeInstance>().ToArray();

        //print("Width: " + xTerrainRes + " / " + xTextureRes + " / " + terrainWidthScale + " / " + tData.alphamapResolution);
        //print("Length: " + yTerrainRes + " / " + yTextureRes + " / " + terrainLengthScale + " / " + tData.detailResolution);
    }
Exemple #30
0
        public MappingFileProviderTest()
        {
            SortedMap <Integer, Set <String> > mapping = new TreeMap <Integer, Set <String> >();

            mapping.put(1, newHashSet("en"));
            mapping.put(86, newHashSet("zh", "en", "zh_Hant"));
            mapping.put(41, newHashSet("de", "fr", "it", "rm"));
            mapping.put(65, newHashSet("en", "zh_Hans", "ms", "ta"));

            mappingProvider.readFileConfigs(mapping);
        }
        public void ProvidingEmptyTreeMapItemDefinitionWorks()
        {
            TreeMap treeMap = new TreeMap();

            treeMap.ItemDefinition = new TreeMapItemDefinition();
            TestAsync(
                treeMap,
                // +1 because of the Border in default template
                () => treeMap.ItemsSource = new int[] { 1, 2, 3 },
                () => Assert.AreEqual(0 + 1, treeMap.GetVisualDescendents().OfType <Border>().Count()));
        }
        /// <summary>
        /// Calculate distance between two points
        /// Uses Manhattan distance
        /// </summary>
        /// <param name="z">Start Point Z</param>
        /// <param name="x">Start Point X</param>
        /// <param name="tZ">Target Point Z</param>
        /// <param name="tX">Target Point X</param>
        /// <param name="acceptableMap">Acceptable Map</param>
        /// <param name="waterMap">Water Map</param>
        /// <param name="treeMap">Tree Map</param>
        /// <returns>Distancce to Point</returns>
        public static float Metric(int z, int x, int tZ, int tX, bool[][] acceptableMap, int[][] waterMap, int[][] treeMap)
        {
            int   dz       = tZ - z;
            int   dx       = tX - x;
            float distance = (float)(Math.Abs(dz) + Math.Abs(dx));

            if (acceptableMap[z][x] || waterMap[z][x] == 1 || TreeMap.IsLeaf(z, x, treeMap) || TreeMap.IsExpanded(z, x, treeMap))
            {
                return(distance);
            }
            return(float.PositiveInfinity);
        }
 public List<Polyline> ComputeTreeMap(List<double> x, List<double> y)
 {
     double total = 0;
     for (int i = 0; i < x.Count; i++)
     {
         total += Math.Abs(x[i]);
     }
     List<double> output = new List<double>();
     for (int i = 0; i < x.Count; i++)
     {
         output.Add(Math.Abs(x[i]) * (Math.Abs(y[0]) * Math.Abs(y[1])) / total);
     }
     TreeMap treemap1 = new TreeMap(Math.Abs(y[0]), Math.Abs(y[1]));
     List<box> boxes = new List<box>();
     for (int i = 0; i < output.Count; i++)
     {
         boxes.Add(new box(output[i]));
     }
     __out.Add(treemap1.__Error);
     return treemap1.Run(boxes);
 }
 public EventQueueSequence()
 {
     sequence = new TreeMap<Integer, MidiEventQueue>();
 }
        //Resolves the battle at planet p, if there is one.
        //* Removes all fleets involved in the battle
        //* Sets the number of ships and owner of the planet according the outcome
        private void FightBattle(Planet p)
        {
            Map<int, int> participants = new TreeMap<int, int>();
            participants.put(p.Owner, p.NumShips);
            bool doBattle = false;
            //PORT: Deleting items from iterators is not allowed.
            //      converted to deletable for loop
            for (int fleetIndex = 0; fleetIndex < Fleets.Count; )
            {
                Fleet fl = Fleets[fleetIndex];
                if (fl.TurnsRemaining <= 0 && fl.DestinationPlanet == p.PlanetID)
                {
                    int attackForce;
                    doBattle = true;
                    if (participants.TryGetValue(fl.Owner, out attackForce))
                    {
                        participants[fl.Owner] = attackForce + fl.NumShips;
                    }
                    else
                    {
                        participants.Add(fl.Owner, fl.NumShips);
                    }
                    Fleets.Remove(fl);
                }
                else { fleetIndex++; }
            }

            if (doBattle)
            {
                Fleet winner = new Fleet(0, 0);
                Fleet second = new Fleet(0, 0);
                foreach (var f in participants)
                {
                    if (f.Value > second.NumShips)
                    {
                        if (f.Value > winner.NumShips)
                        {
                            second = winner;
                            winner = new Fleet(f.Key, f.Value);
                        }
                        else
                        {
                            second = new Fleet(f.Key, f.Value);
                        }
                    }
                }

                if (winner.NumShips > second.NumShips)
                {
                    p.SetNumShips(winner.NumShips - second.NumShips);
                    p.SetOwner(winner.Owner);
                }
                else
                {
                    p.SetNumShips(0);
                }
            }
        }
    public static ScriptReturnStatus Edit( VsqFileEx vsq )
    {
        // 選択状態のアイテムがなければ戻る
        if ( AppManager.itemSelection.getEventCount() <= 0 ) {
            return ScriptReturnStatus.NOT_EDITED;
        }

        // 現在のトラック
        int selected = AppManager.getSelected();
        VsqTrack vsq_track = vsq.Track.get( selected );
        vsq_track.sortEvent();

        // プラグイン情報の定義ファイル(plugin.txt)があるかどうかチェック
        string pluginTxtPath = s_plugin_txt_path;
        if ( pluginTxtPath == "" ) {
            AppManager.showMessageBox( "pluginTxtPath=" + pluginTxtPath );
            return ScriptReturnStatus.ERROR;
        }
        if ( !System.IO.File.Exists( pluginTxtPath ) ) {
            AppManager.showMessageBox( "'" + pluginTxtPath + "' does not exists" );
            return ScriptReturnStatus.ERROR;
        }

        // plugin.txtがあれば,プラグインの実行ファイルのパスを取得する
        System.Text.Encoding shift_jis = System.Text.Encoding.GetEncoding( "Shift_JIS" );
        string name = "";
        string exe_path = "";
        using ( StreamReader sr = new StreamReader( pluginTxtPath, shift_jis ) ) {
            string line = "";
            while ( (line = sr.ReadLine()) != null ) {
                string[] spl = line.Split( new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries );
                if ( line.StartsWith( "name=" ) ) {
                    name = spl[1];
                } else if ( line.StartsWith( "execute=" ) ) {
                    exe_path = Path.Combine( Path.GetDirectoryName( pluginTxtPath ), spl[1] );
                }
            }
        }
        if ( exe_path == "" ) {
            return ScriptReturnStatus.ERROR;
        }
        if ( !System.IO.File.Exists( exe_path ) ) {
            AppManager.showMessageBox( "'" + exe_path + "' does not exists" );
            return ScriptReturnStatus.ERROR;
        }

        // 選択状態のアイテムの最初と最後がどこか調べる
        // clock_start, clock_endは,最終的にはPREV, NEXTを含んだ範囲を表すことになる
        // sel_start, sel_endはPREV, NEXTを含まない選択範囲を表す
        int id_start = -1;
        int clock_start = int.MaxValue;
        int id_end = -1;
        int clock_end = int.MinValue;
        int sel_start = 0;
        int sel_end = 0;
        for ( Iterator<SelectedEventEntry> itr = AppManager.itemSelection.getEventIterator(); itr.hasNext(); ) {
            SelectedEventEntry item = itr.next();
            if ( item.original.ID.type != VsqIDType.Anote ) {
                continue;
            }
            int clock = item.original.Clock;
            if ( clock < clock_start ) {
                id_start = item.original.InternalID;
                clock_start = clock;
                sel_start = clock;
            }
            clock += item.original.ID.getLength();
            if ( clock_end < clock ) {
                id_end = item.original.InternalID;
                clock_end = clock;
                sel_end = clock;
            }
        }

        // 選択範囲の前後の音符を探す
        VsqEvent ve_prev = null;
        VsqEvent ve_next = null;
        VsqEvent l = null;
        for ( Iterator<VsqEvent> itr = vsq_track.getNoteEventIterator(); itr.hasNext(); ) {
            VsqEvent item = itr.next();
            if ( item.InternalID == id_start ) {
                if ( l != null ) {
                    ve_prev = l;
                }
            }
            if ( l != null ) {
                if ( l.InternalID == id_end ) {
                    ve_next = item;
                }
            }
            l = item;
            if ( ve_prev != null && ve_next != null ) {
                break;
            }
        }
        int next_rest_clock = -1;
        bool prev_is_rest = false;
        if ( ve_prev != null ) {
            // 直前の音符がある場合
            if ( ve_prev.Clock + ve_prev.ID.getLength() == clock_start ) {
                // 接続している
                clock_start = ve_prev.Clock;
            } else {
                // 接続していない
                int new_clock_start = ve_prev.Clock + ve_prev.ID.getLength();
                clock_start = new_clock_start;
            }
        } else {
            // 無い場合
            if ( vsq.getPreMeasureClocks() < clock_start ) {
                prev_is_rest = true;
            }
            int new_clock_start = vsq.getPreMeasureClocks();
            clock_start = new_clock_start;
        }
        if ( ve_next != null ) {
            // 直後の音符がある場合
            if ( ve_next.Clock == clock_end ) {
                // 接続している
                clock_end = ve_next.Clock + ve_next.ID.getLength();
            } else {
                // 接続していない
                next_rest_clock = clock_end;
                clock_end = ve_next.Clock;
            }
        }

        // 作業用のVSQに,選択範囲のアイテムを格納
        VsqFileEx v = (VsqFileEx)vsq.clone();// new VsqFile( "Miku", 1, 4, 4, 500000 );
        // 選択トラックだけ残して他を削る
        for ( int i = 1; i < selected; i++ ) {
            v.Track.removeElementAt( 1 );
        }
        for ( int i = selected + 1; i < v.Track.size(); i++ ) {
            v.Track.removeElementAt( selected + 1 );
        }
        // 選択トラックの音符を全消去する
        VsqTrack v_track = v.Track.get( 1 );
        v_track.MetaText.getEventList().clear();
        for ( Iterator<VsqEvent> itr = vsq_track.getNoteEventIterator(); itr.hasNext(); ) {
            VsqEvent item = itr.next();
            if ( clock_start <= item.Clock && item.Clock + item.ID.getLength() <= clock_end ) {
                v_track.addEvent( (VsqEvent)item.clone(), item.InternalID );
            }
        }
        // 最後のRを手動で追加.これは自動化できない
        if ( next_rest_clock != -1 ) {
            VsqEvent item = (VsqEvent)ve_next.clone();
            item.ID.LyricHandle.L0.Phrase = "R";
            item.Clock = next_rest_clock;
            item.ID.setLength( clock_end - next_rest_clock );
            v_track.addEvent( item );
        }
        // 0~選択範囲の開始位置までを削除する
        v.removePart( 0, clock_start );

        // vsq -> ustに変換
        // キーがustのIndex, 値がInternalID
        TreeMap<int, int> map = new TreeMap<int, int>();
        UstFile u = new UstFile( v, 1, map );

        u.write( Path.Combine( PortUtil.getApplicationStartupPath(), "u.ust" ) );

        // PREV, NEXTのIndex値を設定する
        if ( ve_prev != null || prev_is_rest ) {
            u.getTrack( 0 ).getEvent( 0 ).Index = UstFile.PREV_INDEX;
        }
        if ( ve_next != null ) {
            u.getTrack( 0 ).getEvent( u.getTrack( 0 ).getEventCount() - 1 ).Index = UstFile.NEXT_INDEX;
        }

        // ustファイルに出力
        UstFileWriteOptions option = new UstFileWriteOptions();
        option.settingCacheDir = false;
        option.settingOutFile = false;
        option.settingProjectName = false;
        option.settingTempo = true;
        option.settingTool1 = true;
        option.settingTool2 = true;
        option.settingTracks = false;
        option.settingVoiceDir = true;
        option.trackEnd = false;
        string temp = Path.GetTempFileName();
        u.write( temp, option );

        StringBuilder before = new StringBuilder();
        using ( StreamReader sr = new StreamReader( temp, System.Text.Encoding.GetEncoding( "Shift_JIS" ) ) ) {
            string line = "";
            while ( (line = sr.ReadLine()) != null ) {
                before.AppendLine( line );
            }
        }
        String md5_before = PortUtil.getMD5FromString( before.ToString() );
        // プラグインの実行ファイルを起動
        Utau_Plugin_Invoker dialog = new Utau_Plugin_Invoker( exe_path, temp );
        dialog.ShowDialog();
        StringBuilder after = new StringBuilder();
        using ( StreamReader sr = new StreamReader( temp, System.Text.Encoding.GetEncoding( "Shift_JIS" ) ) ) {
            string line = "";
            while ( (line = sr.ReadLine()) != null ) {
                after.AppendLine( line );
            }
        }
        String md5_after = PortUtil.getMD5FromString( after.ToString() );
        if ( md5_before == md5_after ) {
            // 編集されなかったようだ
            return ScriptReturnStatus.NOT_EDITED;
        }

        // プラグインの実行結果をustオブジェクトにロード
        UstFile r = new UstFile( temp );
        if ( r.getTrackCount() < 1 ) {
            return ScriptReturnStatus.ERROR;
        }

        // 変更のなかったものについてはプラグインは記録してこないので,
        // 最初の値を代入するようにする
        UstTrack utrack_src = u.getTrack( 0 );
        UstTrack utrack_dst = r.getTrack( 0 );
        for ( int i = 0; i < utrack_dst.getEventCount(); i++ ) {
            UstEvent ue_dst = utrack_dst.getEvent( i );
            int index = ue_dst.Index;
            UstEvent ue_src = utrack_src.findEventFromIndex( index );
            if ( ue_src == null ) {
                continue;
            }
            if ( !ue_dst.isEnvelopeSpecified() && ue_src.isEnvelopeSpecified() ) {
                ue_dst.setEnvelope( ue_src.getEnvelope() );
            }
            if ( !ue_dst.isIntensitySpecified() && ue_src.isIntensitySpecified() ) {
                ue_dst.setIntensity( ue_src.getIntensity() );
            }
            if ( !ue_dst.isLengthSpecified() && ue_src.isLengthSpecified() ) {
                ue_dst.setLength( ue_src.getLength() );
            }
            if ( !ue_dst.isLyricSpecified() && ue_src.isLyricSpecified() ) {
                ue_dst.setLyric( ue_src.getLyric() );
            }
            if ( !ue_dst.isModurationSpecified() && ue_src.isModurationSpecified() ) {
                ue_dst.setModuration( ue_src.getModuration() );
            }
            if ( !ue_dst.isNoteSpecified() && ue_src.isNoteSpecified() ) {
                ue_dst.setNote( ue_src.getNote() );
            }
            if ( !ue_dst.isPBTypeSpecified() && ue_src.isPBTypeSpecified() ) {
                ue_dst.setPBType( ue_src.getPBType() );
            }
            if ( !ue_dst.isPitchesSpecified() && ue_src.isPitchesSpecified() ) {
                ue_dst.setPitches( ue_src.getPitches() );
            }
            if ( !ue_dst.isPortamentoSpecified() && ue_src.isPortamentoSpecified() ) {
                ue_dst.setPortamento( ue_src.getPortamento() );
            }
            if ( !ue_dst.isPreUtteranceSpecified() && ue_src.isPreUtteranceSpecified() ) {
                ue_dst.setPreUtterance( ue_src.getPreUtterance() );
            }
            if ( !ue_dst.isStartPointSpecified() && ue_src.isStartPointSpecified() ) {
                ue_dst.setStartPoint( ue_src.getStartPoint() );
            }
            if ( !ue_dst.isTempoSpecified() && ue_src.isTempoSpecified() ) {
                ue_dst.setTempo( ue_src.getTempo() );
            }
            if ( !ue_dst.isVibratoSpecified() && ue_src.isVibratoSpecified() ) {
                ue_dst.setVibrato( ue_src.getVibrato() );
            }
            if ( !ue_dst.isVoiceOverlapSpecified() && ue_src.isVoiceOverlapSpecified() ) {
                ue_dst.setVoiceOverlap( ue_src.getVoiceOverlap() );
            }
        }

        // PREVとNEXT含めて,clock_startからclock_endまでプラグインに渡したけれど,
        // それが伸びて帰ってきたか縮んで帰ってきたか.
        int ret_length = 0;
        UstTrack r_track = r.getTrack( 0 );
        int size = r_track.getEventCount();
        for ( int i = 0; i < size; i++ ) {
            UstEvent ue = r_track.getEvent( i );
            // 戻りのustには,変更があったものしか記録されていない
            int ue_length = ue.getLength();
            if ( !ue.isLengthSpecified() && map.ContainsKey( ue.Index ) ) {
                int internal_id = map[ue.Index];
                VsqEvent found_item = vsq_track.findEventFromID( internal_id );
                if ( found_item != null ) {
                    ue_length = found_item.ID.getLength();
                }
            }
            // PREV, ENDの場合は長さに加えない
            if ( ue.Index != UstFile.NEXT_INDEX &&
                 ue.Index != UstFile.PREV_INDEX ) {
                ret_length += ue_length;
            }
        }

        // 伸び縮みがあった場合
        // 伸ばしたり縮めたりするよ
        int delta = ret_length - (sel_end - sel_start);
        if ( delta > 0 ) {
            // のびた
            vsq.insertBlank( selected, sel_end, delta );
        } else if ( delta < 0 ) {
            // 縮んだ
            vsq.removePart( selected, sel_end + delta, sel_end );
        }

        // r_trackの内容をvsq_trackに転写
        size = r_track.getEventCount();
        int c = clock_start;
        for ( int i = 0; i < size; i++ ) {
            UstEvent ue = r_track.getEvent( i );
            if ( ue.Index == UstFile.NEXT_INDEX || ue.Index == UstFile.PREV_INDEX ) {
                // PREVとNEXTは単に無視する
                continue;
            }
            int ue_length = ue.getLength();
            if ( map.containsKey( ue.Index ) ) {
                // 既存の音符の編集
                VsqEvent target = vsq_track.findEventFromID( map[ue.Index] );
                if ( target == null ) {
                    // そんなばかな・・・
                    continue;
                }
                if ( !ue.isLengthSpecified() ) {
                    ue_length = target.ID.getLength();
                }
                if ( target.UstEvent == null ) {
                    target.UstEvent = (UstEvent)ue.clone();
                }
                // utau固有のパラメータを転写
                // pitchは後でやるので無視していい
                // テンポもあとでやるので無視していい
                if ( ue.isEnvelopeSpecified() ) {
                    target.UstEvent.setEnvelope( ue.getEnvelope() );
                }
                if ( ue.isModurationSpecified() ) {
                    target.UstEvent.setModuration( ue.getModuration() );
                }
                if ( ue.isPBTypeSpecified() ) {
                    target.UstEvent.setPBType( ue.getPBType() );
                }
                if ( ue.isPortamentoSpecified() ) {
                    target.UstEvent.setPortamento( ue.getPortamento() );
                }
                if ( ue.isPreUtteranceSpecified() ) {
                    target.UstEvent.setPreUtterance( ue.getPreUtterance() );
                }
                if ( ue.isStartPointSpecified() ) {
                    target.UstEvent.setStartPoint( ue.getStartPoint() );
                }
                if ( ue.isVibratoSpecified() ) {
                    target.UstEvent.setVibrato( ue.getVibrato() );
                }
                if ( ue.isVoiceOverlapSpecified() ) {
                    target.UstEvent.setVoiceOverlap( ue.getVoiceOverlap() );
                }
                // vocaloid, utauで同じ意味のパラメータを転写
                if ( ue.isIntensitySpecified() ) {
                    target.UstEvent.setIntensity( ue.getIntensity() );
                    target.ID.Dynamics = ue.getIntensity();
                }
                if ( ue.isLengthSpecified() ) {
                    target.UstEvent.setLength( ue.getLength() );
                    target.ID.setLength( ue.getLength() );
                }
                if ( ue.isLyricSpecified() ) {
                    target.UstEvent.setLyric( ue.getLyric() );
                    target.ID.LyricHandle.L0.Phrase = ue.getLyric();
                }
                if ( ue.isNoteSpecified() ) {
                    target.UstEvent.setNote( ue.getNote() );
                    target.ID.Note = ue.getNote();
                }
            } else {
                // マップに入っていないので,新しい音符の追加だと思う
                if ( ue.getLyric() == "R" ) {
                    // 休符.なにもしない
                } else {
                    VsqEvent newe = new VsqEvent();
                    newe.Clock = c;
                    newe.UstEvent = (UstEvent)ue.clone();
                    newe.ID = new VsqID();
                    AppManager.editorConfig.applyDefaultSingerStyle( newe.ID );
                    if ( ue.isIntensitySpecified() ) {
                        newe.ID.Dynamics = ue.getIntensity();
                    }
                    newe.ID.LyricHandle = new LyricHandle( "あ", "a" );
                    if ( ue.isLyricSpecified() ) {
                        newe.ID.LyricHandle.L0.Phrase = ue.getLyric();
                    }
                    newe.ID.Note = ue.getNote();
                    newe.ID.setLength( ue.getLength() );
                    newe.ID.type = VsqIDType.Anote;
                    // internal id はaddEventメソッドで自動で割り振られる
                    vsq_track.addEvent( newe );
                }
            }

            // テンポの追加がないかチェック
            if ( ue.isTempoSpecified() ) {
                insertTempoInto( vsq, c, ue.getTempo() );
            }

            c += ue_length;
        }

        // ピッチを転写
        // pitのデータがほしいので,PREV, NEXTを削除して,VsqFileにコンバートする
        UstFile uf = (UstFile)r.clone();
        // prev, nextを削除
        UstTrack uf_track = uf.getTrack( 0 );
        for ( int i = 0; i < uf_track.getEventCount(); ) {
            UstEvent ue = uf_track.getEvent( i );
            if ( ue.Index == UstFile.NEXT_INDEX ||
                 ue.Index == UstFile.PREV_INDEX ) {
                uf_track.removeEventAt( i );
            } else {
                i++;
            }
        }
        uf.updateTempoInfo();
        // VsqFileにコンバート
        VsqFile uf_vsq = new VsqFile( uf );
        // uf_vsqの最初のトラックの0からret_lengthクロックまでが,
        // vsq_trackのsel_startからsel_start+ret_lengthクロックまでに対応する.
        // まずPBSをコピーする
        CurveType[] type = new CurveType[] { CurveType.PBS, CurveType.PIT };
        foreach ( CurveType ct in type ) {
            // コピー元を取得
            VsqBPList src = uf_vsq.Track[1].getCurve( ct.getName() );
            if ( src != null ) {
                // コピー先を取得
                VsqBPList dst = vsq_track.getCurve( ct.getName() );
                if ( dst == null ) {
                    // コピー先がnullだった場合は作成
                    dst = new VsqBPList( ct.getName(), ct.getDefault(), ct.getMinimum(), ct.getMaximum() );
                    vsq_track.setCurve( ct.getName(), dst );
                }
                // あとで復元するので,最終位置での値を保存しておく
                int value_at_end = dst.getValue( sel_start + ret_length );
                // 復元するかどうか.最終位置にそもそもデータ点があれば復帰の必要がないので.
                bool do_revert = (dst.findIndexFromClock( sel_start + ret_length ) < 0);
                // [sel_start, sel_start + ret_length)の範囲の値を削除しておく
                size = dst.size();
                for ( int i = size - 1; i >= 0; i-- ) {
                    int cl = dst.getKeyClock( i );
                    if ( sel_start <= cl && cl < sel_start + ret_length ) {
                        dst.removeElementAt( i );
                    }
                }
                // コピーを実行
                size = src.size();
                for ( int i = 0; i < size; i++ ) {
                    int cl = src.getKeyClock( i );
                    if ( ret_length <= cl ) {
                        break;
                    }
                    int value = src.getElementA( i );
                    dst.add( cl + sel_start, value );
                }
                // コピー後,最終位置での値が元と異なる場合,元に戻すようにする
                if ( do_revert && dst.getValue( sel_start + ret_length ) != value_at_end ) {
                    dst.add( sel_start + ret_length, value_at_end );
                }
            }
        }

        return ScriptReturnStatus.EDITED;
    }
        public void run()
        {
            bool successful = true;

            try {
                // replace illegal XML characters with corresponding entities:
                string plainText = noteContent.ToString();
                TreeMap<string,string> replacements = new TreeMap<string,string>();
                replacements.put( "&", "&amp;" ); replacements.put( "<", "&lt;" ); replacements.put( ">", "&gt;" );
                foreach( Map.Entry<string,string> entry in replacements.entrySet() ) {
                    for( int currPos=plainText.Length; currPos>=0; currPos-- ){
             				currPos = plainText.LastIndexOf(entry.getKey(), currPos);
             				if(currPos < 0)
             				    break;
             				noteContent.Replace( currPos, currPos+entry.getKey().Length, entry.getValue() );
                        TLog.d(TAG, "new xml content: {0}", noteContent.ToString());
                    }
                    plainText = noteContent.ToString(); // have to refresh!
                }

                // translate spans into XML elements:
                for( int prevPos=0, currPos=0, maxPos=noteContent.Length;
                        currPos!=-1 && currPos<=maxPos && prevPos<maxPos;
                        prevPos=currPos, currPos=noteContent.nextSpanTransition(currPos, maxPos, typeof(Object)) )
                {
                    TreeMap<Integer,LinkedList<string>> elemStartsByEnd = new TreeMap<Integer,LinkedList<string>>();
                    TreeMap<Integer,LinkedList<string>> elemEndsByStart = new TreeMap<Integer,LinkedList<string>>();
                    Object[] spans = noteContent.getSpans(currPos, currPos, typeof(Object));
                    int bulletStart = 0, bulletEnd = 0, currentMargin = 0;
                    foreach( Object span in spans )
                    {
                        int spanStart = noteContent.getSpanStart(span);
                        int spanEnd = noteContent.getSpanEnd(span);
                        string elementName = "";
                        if( spanStart==currPos || spanEnd==currPos )
                        {
                            if( span as StyleSpan )
                            {
                                StyleSpan style = (StyleSpan) span;
                                if( (style.getStyle()&Typeface.BOLD)>0 )
                                {
                                    elementName = "bold";
                                }
                                if( (style.getStyle()&Typeface.ITALIC)>0 )
                                {
                                    elementName = "italic";
                                }
                            }
                            else if( span as StrikethroughSpan )
                            {
                                elementName = "strikethrough";
                            }

                            else if( span as BackgroundColorSpan )
                            {
                                BackgroundColorSpan bgcolor = (BackgroundColorSpan) span;
                                if( bgcolor.BackgroundColor ==Note.NOTE_HIGHLIGHT_COLOR )
                                {
                                    elementName = "highlight";
                                }
                            }
                            else if( span as TypefaceSpan )
                            {
                                TypefaceSpan typeface = (TypefaceSpan) span;
                                if( typeface.Family ==Note.NOTE_MONOSPACE_TYPEFACE )
                                {
                                    elementName = "monospace";
                                }
                            }
                            else if( span as RelativeSizeSpan )
                            {
                                RelativeSizeSpan size = (RelativeSizeSpan) span;
                                if( size.SizeChange ==Note.NOTE_SIZE_SMALL_FACTOR )
                                {
                                    elementName = "size:small";
                                }
                                else if( size.SizeChange ==Note.NOTE_SIZE_LARGE_FACTOR )
                                {
                                    elementName = "size:large";
                                }
                                else if( size.SizeChange ==Note.NOTE_SIZE_HUGE_FACTOR )
                                {
                                    elementName = "size:huge";
                                }
                            }
                            else if( span as LeadingMarginSpan.Standard )
                            {
                                LeadingMarginSpan.Standard margin = (LeadingMarginSpan.Standard) span;
                                currentMargin = margin.getLeadingMargin(true);
                            }
                            else if( span as LinkInternalSpan )
                            {
                                elementName = "link:internal";
                            }
                            else if( span as BulletSpan )
                            {
                                elementName = "list-item";
                                bulletStart = spanStart;
                                bulletEnd = spanEnd;
                                int listLevelDiff = 0, marginFactor = 30;
                                int currentListLevel = currentMargin / marginFactor;
                                int prevListLevel = 0, nextListLevel = 0;
                                // compute indentation difference between current position and offset -1 for a starting transition
                                // or current position and offset +1 for an ending transition:
                                if( currPos==bulletStart )
                                {
                                    elementName += " dir=\"ltr\""; // add unsupported (and unused by Tomboy?), fixed orientation attribute
                                    prevListLevel = 0;
                                    if( currPos > 0 )
                                    {
                                        LeadingMarginSpan.Standard[] prevMargins = noteContent.getSpans( currPos-1, currPos-1, typeof(LeadingMarginSpan.Standard) );
                                        if( prevMargins.Length >1 ) throw new System.Exception("Multiple margins at "+new Integer(currPos-1).ToString() );
                                        foreach( LeadingMarginSpan.Standard prevMargin in prevMargins )
                                            prevListLevel = prevMargin.getLeadingMargin(true) / marginFactor;
                                    }
                                    listLevelDiff = currentListLevel - prevListLevel;
                                }
                                else if( currPos==bulletEnd )
                                {
                                    // most needed list tags are triggered by bullet start transitions, but we have
                                    // to trigger some list end tags on special bullet end transitions...
                                    nextListLevel = 0;
                                    if( currPos < noteContent.Length )
                                    {
                                        LeadingMarginSpan.Standard[] nextMargins = noteContent.getSpans( currPos+1, currPos+1, typeof(LeadingMarginSpan.Standard) );
                                        if( nextMargins.Length>1 ) throw new System.Exception("Multiple margins at "+new Integer(currPos+1).ToString() );;
                                        foreach( LeadingMarginSpan.Standard nextMargin in nextMargins )
                                            nextListLevel = nextMargin.getLeadingMargin(true) / marginFactor;
                                        // force writing of missing list end tags before non-list content:
                                        if( nextMargins.Length==0 ) listLevelDiff = -currentListLevel;
                                    }
                                    // force writing of missing list end tags at the end of the note:
                                    else listLevelDiff = -currentListLevel;
                                    // suppress list-item end tag, as it has to enclose the following list element:
                                    // FIXME: what happens if abs(listLevelDiff)>1?
                                    if( currentListLevel < nextListLevel ) elementName = "";
                                }
                                // add needed number of list start or list end and list-item end tags to represent the observed indentation
                                // difference at this position:
                                for( int i=0; i<System.Math.Abs(listLevelDiff); i++ )
                                {
                                    if( listLevelDiff<0)
                                    {
                                        // assume a growing negative fake start offset to force list and list-item end tags to appear behind all other end tags at this position:
                                        if( elemEndsByStart.get(-1-i*2) == null ) elemEndsByStart.put( -1-i*2, new LinkedList<string>() );
                                        elemEndsByStart.get(-1-i*2).add( "list" );
                                        int levelCorrector = Math.abs(listLevelDiff)-i-1;
                                        if( nextListLevel+levelCorrector>0 || prevListLevel+levelCorrector>1 )
                                        {
                                            // explicitly add a previously suppressed list-items end tag after enclosed list element,
                                            // but only if this was not the root list element of the list
                                            // (assume a fake start offset of -2 to force list-item end to appear behind list end)
                                            if( elemEndsByStart.get(-2-i*2) == null ) elemEndsByStart.put( -2-i*2, new LinkedList<string>() );
                                            elemEndsByStart.get(-2-i*2).add( "list-item" );
                                        }
                                    }
                                    else
                                    {
                                        // assume a fake end offset of maxPos to force list starts to appear in front of all other start tags at this position:
                                        if( elemStartsByEnd.get(maxPos) == null ) elemStartsByEnd.put( maxPos, new LinkedList<string>() );
                                        elemStartsByEnd.get(maxPos).add( "list" );
                                    }
                                }
                            }
                        }
                        // add generic start/end tags defined above
                        if( elementName.Length != 0 )
                        {
                            if( spanStart==currPos )
                            {
                                if( elemStartsByEnd.get(spanEnd)==null ) elemStartsByEnd.put( spanEnd, new LinkedList<string>() );
                                elemStartsByEnd.get(spanEnd).add(elementName);
                            }
                            else if( spanEnd==currPos )
                            {
                                if( elemEndsByStart.get(spanStart)==null ) elemEndsByStart.put( spanStart, new LinkedList<string>() );
                                elemEndsByStart.get(spanStart).add(elementName);
                            }
                        }
                    }
                    // write plain character content from previous to current (relevant) span transition:
                    noteXMLContent += noteContent.subSequence( prevPos, currPos );

                    // API 3 compat - is this reversal really necessary?  I think it should be reversed in the for(string elementName...)

                    ListIterator<Integer> iter = new List<Integer>(elemEndsByStart.keySet()).listIterator(elemEndsByStart.Count);

                    // write needed end tags for the current span transition in the correct order, depending on the corresponding span start positions:

                    while (iter.hasPrevious()) {
                        Integer key = iter.previous();
                        foreach( string elementName in elemEndsByStart.get(key) ) {
                            closeTags.Add(elementName); // add for comparing with later ones
                        }
                    }

                    iter = new List<Integer>(elemStartsByEnd.keySet()).listIterator(elemStartsByEnd.Count);

                    // write needed start tags for the current span transition in the correct order, depending on the corresponding span end positions:

                    while (iter.hasPrevious()) {
                        Integer key = iter.previous();
                        foreach( string elementName in elemStartsByEnd.get(key) ) {
                            tagsToOpen.Add(elementName); // add for comparing with later ones
                        }
                    }

                    noteXMLContent += addTags(currPos == maxPos);

                }
            } catch (System.Exception e) {
                e.PrintStackTrace();
                // TODO handle error in a more granular way
                TLog.e(TAG, "There was an error parsing the note.");
                successful = false;
            }
            if(!openTags.IsEmpty()) {
                for(int x = 0; x < openTags.Count; x++) {
                    string tag = openTags.get(openTags.Count-x-1);
                    TLog.d(TAG, "Closed readonly tag: {0}","</"+tag+">");
                    noteXMLContent += "</"+tag+">";
                }
            }

            warnHandler(successful);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="vsq"></param>
        /// <param name="track"></param>
        /// <param name="clock_start"></param>
        /// <param name="clock_end"></param>
        /// <returns></returns>
        private TreeMap<Integer, MidiEventQueue> generateMidiEvent( VsqFileEx vsq, int track, int clock_start, int clock_end )
        {
            TreeMap<Integer, MidiEventQueue> list = new TreeMap<Integer, MidiEventQueue>();
            VsqTrack t = vsq.Track.get( track );

            // 歌手変更
            for ( Iterator<VsqEvent> itr = t.getSingerEventIterator(); itr.hasNext(); ) {
                VsqEvent item = itr.next();
                if ( clock_start <= item.Clock && item.Clock <= clock_end ) {
                    if ( item.ID.IconHandle == null ) {
                        continue;
                    }
                    int program = item.ID.IconHandle.Program;
                    if ( 0 > program || program >= AquesToneDriver.SINGERS.Length ) {
                        program = 0;
                    }
                    ParameterEvent singer = new ParameterEvent();
                    singer.index = mDriver.phontParameterIndex;
                    singer.value = program + 0.01f;
                    if ( !list.containsKey( item.Clock ) ) {
                        list.put( item.Clock, new MidiEventQueue() );
                    }
                    MidiEventQueue queue = list.get( item.Clock );
                    if ( queue.param == null ) {
                        queue.param = new Vector<ParameterEvent>();
                    }
                    queue.param.add( singer );
                } else if ( clock_end < item.Clock ) {
                    break;
                }
            }

            // ノートon, off
            Vector<Point> pit_send = new Vector<Point>(); // PITが追加されたゲートタイム。音符先頭の分を重複して送信するのを回避するために必要。
            VsqBPList pit = t.getCurve( "pit" );
            VsqBPList pbs = t.getCurve( "pbs" );
            VsqBPList dyn = t.getCurve( "dyn" );
            VsqBPList bre = t.getCurve( "bre" );
            VsqBPList cle = t.getCurve( "cle" );
            VsqBPList por = t.getCurve( "por" );
            for ( Iterator<VsqEvent> itr = t.getNoteEventIterator(); itr.hasNext(); ) {
                VsqEvent item = itr.next();
                int endclock = item.Clock + item.ID.getLength();
                boolean contains_start = clock_start <= item.Clock && item.Clock <= clock_end;
                boolean contains_end = clock_start <= endclock && endclock <= clock_end;
                if ( contains_start || contains_end ) {
                    if ( contains_start ) {
                        #region contains_start
                        // noteonのゲートタイムが,範囲に入っている
                        // noteon MIDIイベントを作成
                        String lyric = item.ID.LyricHandle.L0.Phrase;
                        String katakana = KanaDeRomanization.hiragana2katakana( KanaDeRomanization.Attach( lyric ) );
                        int index = -1;
                        for ( int i = 0; i < AquesToneDriver.PHONES.Length; i++ ) {
                            if ( katakana.Equals( AquesToneDriver.PHONES[i] ) ) {
                                index = i;
                                break;
                            }
                        }
                        if ( index >= 0 ) {
                            if ( !list.containsKey( item.Clock ) ) {
                                list.put( item.Clock, new MidiEventQueue() );
                            }
                            MidiEventQueue queue = list.get( item.Clock );
                            if ( queue.noteon == null ) {
                                queue.noteon = new Vector<MidiEvent>();
                            }

                            // index行目に移動するコマンドを贈る
                            MidiEvent moveline = new MidiEvent();
                            moveline.firstByte = 0xb0;
                            moveline.data = new[] { 0x0a, index };
                            MidiEvent noteon = new MidiEvent();
                            noteon.firstByte = 0x90;
                            noteon.data = new int[] { item.ID.Note, item.ID.Dynamics };
                            Vector<MidiEvent> add = Arrays.asList( new MidiEvent[] { moveline, noteon } );
                            queue.noteon.addAll( add );
                            pit_send.add( new Point( item.Clock, item.Clock ) );
                        }

                        /* 音符頭で設定するパラメータ */
                        // Release
                        MidiEventQueue q = null;
                        if ( !list.containsKey( item.Clock ) ) {
                            q = new MidiEventQueue();
                        } else {
                            q = list.get( item.Clock );
                        }
                        if ( q.param == null ) {
                            q.param = new Vector<ParameterEvent>();
                        }

                        String strRelease = VsqFileEx.getEventTag( item, VsqFileEx.TAG_VSQEVENT_AQUESTONE_RELEASE );
                        int release = 64;
                        try {
                            release = str.toi( strRelease );
                        } catch ( Exception ex ) {
                            Logger.write( typeof( AquesToneWaveGenerator ) + ".generateMidiEvent; ex=" + ex + "\n" );
                            release = 64;
                        }
                        ParameterEvent pe = new ParameterEvent();
                        pe.index = mDriver.releaseParameterIndex;
                        pe.value = release / 127.0f;
                        q.param.add( pe );

                        // dyn
                        int dynAtStart = dyn.getValue( item.Clock );
                        ParameterEvent peDyn = new ParameterEvent();
                        peDyn.index = mDriver.volumeParameterIndex;
                        peDyn.value = (float)(dynAtStart - dyn.getMinimum()) / (float)(dyn.getMaximum() - dyn.getMinimum());
                        q.param.add( peDyn );

                        // bre
                        int breAtStart = bre.getValue( item.Clock );
                        ParameterEvent peBre = new ParameterEvent();
                        peBre.index = mDriver.haskyParameterIndex;
                        peBre.value = (float)(breAtStart - bre.getMinimum()) / (float)(bre.getMaximum() - bre.getMinimum());
                        q.param.add( peBre );

                        // cle
                        int cleAtStart = cle.getValue( item.Clock );
                        ParameterEvent peCle = new ParameterEvent();
                        peCle.index = mDriver.resonancParameterIndex;
                        peCle.value = (float)(cleAtStart - cle.getMinimum()) / (float)(cle.getMaximum() - cle.getMinimum());
                        q.param.add( peCle );

                        // por
                        int porAtStart = por.getValue( item.Clock );
                        ParameterEvent pePor = new ParameterEvent();
                        pePor.index = mDriver.portaTimeParameterIndex;
                        pePor.value = (float)(porAtStart - por.getMinimum()) / (float)(por.getMaximum() - por.getMinimum());
                        q.param.add( pePor );
                        #endregion
                    }

                    // ビブラート
                    // ビブラートが存在する場合、PBSは勝手に変更する。
                    if ( item.ID.VibratoHandle == null ) {
                        if ( contains_start ) {
                            // 音符頭のPIT, PBSを強制的に指定
                            int notehead_pit = pit.getValue( item.Clock );
                            MidiEvent pit0 = getPitMidiEvent( notehead_pit );
                            if ( !list.containsKey( item.Clock ) ) {
                                list.put( item.Clock, new MidiEventQueue() );
                            }
                            MidiEventQueue queue = list.get( item.Clock );
                            if ( queue.pit == null ) {
                                queue.pit = new Vector<MidiEvent>();
                            } else {
                                queue.pit.clear();
                            }
                            queue.pit.add( pit0 );
                            int notehead_pbs = pbs.getValue( item.Clock );
                            ParameterEvent pe = new ParameterEvent();
                            pe.index = mDriver.bendLblParameterIndex;
                            pe.value = notehead_pbs / 13.0f;
                            if ( queue.param == null ) {
                                queue.param = new Vector<ParameterEvent>();
                            }
                            queue.param.add( pe );
                        }
                    } else {
                        int delta_clock = 5;  //ピッチを取得するクロック間隔
                        int tempo = 120;
                        double sec_start_act = vsq.getSecFromClock( item.Clock );
                        double sec_end_act = vsq.getSecFromClock( item.Clock + item.ID.getLength() );
                        double delta_sec = delta_clock / (8.0 * tempo); //ピッチを取得する時間間隔
                        float pitmax = 0.0f;
                        int st = item.Clock;
                        if ( st < clock_start ) {
                            st = clock_start;
                        }
                        int end = item.Clock + item.ID.getLength();
                        if ( clock_end < end ) {
                            end = clock_end;
                        }
                        pit_send.add( new Point( st, end ) );
                        // ビブラートが始まるまでのピッチを取得
                        double sec_vibstart = vsq.getSecFromClock( item.Clock + item.ID.VibratoDelay );
                        int pit_count = (int)((sec_vibstart - sec_start_act) / delta_sec);
                        TreeMap<Integer, Float> pit_change = new TreeMap<Integer, Float>();
                        for ( int i = 0; i < pit_count; i++ ) {
                            double gtime = sec_start_act + delta_sec * i;
                            int clock = (int)vsq.getClockFromSec( gtime );
                            float pvalue = (float)t.getPitchAt( clock );
                            pitmax = Math.Max( pitmax, Math.Abs( pvalue ) );
                            pit_change.put( clock, pvalue );
                        }
                        // ビブラート部分のピッチを取得
                        Vector<PointD> ret = new Vector<PointD>();
                        Iterator<PointD> itr2 = new VibratoPointIteratorBySec(
                            vsq,
                            item.ID.VibratoHandle.getRateBP(),
                            item.ID.VibratoHandle.getStartRate(),
                            item.ID.VibratoHandle.getDepthBP(),
                            item.ID.VibratoHandle.getStartDepth(),
                            item.Clock + item.ID.VibratoDelay,
                            item.ID.getLength() - item.ID.VibratoDelay,
                            (float)delta_sec );
                        for ( ; itr2.hasNext(); ) {
                            PointD p = itr2.next();
                            float gtime = (float)p.getX();
                            int clock = (int)vsq.getClockFromSec( gtime );
                            float pvalue = (float)(t.getPitchAt( clock ) + p.getY() * 100.0);
                            pitmax = Math.Max( pitmax, Math.Abs( pvalue ) );
                            pit_change.put( clock, pvalue );
                        }

                        // ピッチベンドの最大値を実現するのに必要なPBS
                        int required_pbs = (int)Math.Ceiling( pitmax / 100.0 );
#if DEBUG
                        sout.println( "AquesToneRenderingRunner#generateMidiEvent; required_pbs=" + required_pbs );
#endif
                        if ( required_pbs > 13 ) {
                            required_pbs = 13;
                        }
                        if ( !list.containsKey( item.Clock ) ) {
                            list.put( item.Clock, new MidiEventQueue() );
                        }
                        MidiEventQueue queue = list.get( item.Clock );
                        ParameterEvent pe = new ParameterEvent();
                        pe.index = mDriver.bendLblParameterIndex;
                        pe.value = required_pbs / 13.0f;
                        if ( queue.param == null ) {
                            queue.param = new Vector<ParameterEvent>();
                        }
                        queue.param.add( pe );

                        // PITを順次追加
                        for ( Iterator<Integer> itr3 = pit_change.keySet().iterator(); itr3.hasNext(); ) {
                            Integer clock = itr3.next();
                            if ( clock_start <= clock && clock <= clock_end ) {
                                float pvalue = pit_change.get( clock );
                                int pit_value = (int)(8192.0 / (double)required_pbs * pvalue / 100.0);
                                if ( !list.containsKey( clock ) ) {
                                    list.put( clock, new MidiEventQueue() );
                                }
                                MidiEventQueue q = list.get( clock );
                                MidiEvent me = getPitMidiEvent( pit_value );
                                if ( q.pit == null ) {
                                    q.pit = new Vector<MidiEvent>();
                                } else {
                                    q.pit.clear();
                                }
                                q.pit.add( me );
                            } else if ( clock_end < clock ) {
                                break;
                            }
                        }
                    }

                    //pit_send.add( pit_send_p );

                    // noteoff MIDIイベントを作成
                    if ( contains_end ) {
                        MidiEvent noteoff = new MidiEvent();
                        noteoff.firstByte = 0x80;
                        noteoff.data = new int[] { item.ID.Note, 0x40 }; // ここのvel
                        Vector<MidiEvent> a_noteoff = Arrays.asList( new MidiEvent[] { noteoff } );
                        if ( !list.containsKey( endclock ) ) {
                            list.put( endclock, new MidiEventQueue() );
                        }
                        MidiEventQueue q = list.get( endclock );
                        if ( q.noteoff == null ) {
                            q.noteoff = new Vector<MidiEvent>();
                        }
                        q.noteoff.addAll( a_noteoff );
                        pit_send.add( new Point( endclock, endclock ) ); // PITの送信を抑制するために必要
                    }
                }

                if ( clock_end < item.Clock ) {
                    break;
                }
            }

            // pitch bend sensitivity
            // RPNで送信するのが上手くいかないので、parameterを直接いぢる
            if ( pbs != null ) {
                int keycount = pbs.size();
                for ( int i = 0; i < keycount; i++ ) {
                    int clock = pbs.getKeyClock( i );
                    if ( clock_start <= clock && clock <= clock_end ) {
                        int value = pbs.getElementA( i );
                        ParameterEvent pbse = new ParameterEvent();
                        pbse.index = mDriver.bendLblParameterIndex;
                        pbse.value = value / 13.0f;
                        MidiEventQueue queue = null;
                        if ( list.containsKey( clock ) ) {
                            queue = list.get( clock );
                        } else {
                            queue = new MidiEventQueue();
                        }
                        if ( queue.param == null ) {
                            queue.param = new Vector<ParameterEvent>();
                        }
                        queue.param.add( pbse );
                        list.put( clock, queue );
                    } else if ( clock_end < clock ) {
                        break;
                    }
                }
            }

            // pitch bend
            if ( pit != null ) {
                int keycount = pit.size();
                for ( int i = 0; i < keycount; i++ ) {
                    int clock = pit.getKeyClock( i );
                    if ( clock_start <= clock && clock <= clock_end ) {
                        boolean contains = false;
                        for ( Iterator<Point> itr = pit_send.iterator(); itr.hasNext(); ) {
                            Point p = itr.next();
                            if ( p.x <= clock && clock <= p.y ) {
                                contains = true;
                                break;
                            }
                        }
                        if ( contains ) {
                            continue;
                        }
                        int value = pit.getElementA( i );
                        MidiEvent pbs0 = getPitMidiEvent( value );
                        MidiEventQueue queue = null;
                        if ( list.containsKey( clock ) ) {
                            queue = list.get( clock );
                        } else {
                            queue = new MidiEventQueue();
                        }
                        if ( queue.pit == null ) {
                            queue.pit = new Vector<MidiEvent>();
                        } else {
                            queue.pit.clear();
                        }
                        queue.pit.add( pbs0 );
                        list.put( clock, queue );
                    } else if ( clock_end < clock ) {
                        break;
                    }
                }
            }

            appendParameterEvents( list, dyn, mDriver.volumeParameterIndex, clock_start, clock_end );
            appendParameterEvents( list, bre, mDriver.haskyParameterIndex, clock_start, clock_end );
            appendParameterEvents( list, cle, mDriver.resonancParameterIndex, clock_start, clock_end );
            appendParameterEvents( list, por, mDriver.portaTimeParameterIndex, clock_start, clock_end );

            return list;
        }
 private static void appendParameterEvents( TreeMap<Integer, MidiEventQueue> list, VsqBPList cle, int parameter_index, int clock_start, int clock_end )
 {
     int max = cle.getMaximum();
     int min = cle.getMinimum();
     float order = 1.0f / (float)(max - min);
     if ( cle != null ) {
         int keycount = cle.size();
         for ( int i = 0; i < keycount; i++ ) {
             int clock = cle.getKeyClock( i );
             if ( clock_start <= clock && clock <= clock_end ) {
                 int value = cle.getElementA( i );
                 MidiEventQueue queue = null;
                 if ( list.containsKey( clock ) ) {
                     queue = list.get( clock );
                 } else {
                     queue = new MidiEventQueue();
                 }
                 if ( queue.param == null ) {
                     queue.param = new Vector<ParameterEvent>();
                 }
                 ParameterEvent pe = new ParameterEvent();
                 pe.index = parameter_index;
                 pe.value = (value - min) * order;
                 queue.param.add( pe );
                 list.put( clock, queue );
             } else if ( clock_end < clock ) {
                 break;
             }
         }
     }
 }