Ejemplo n.º 1
0
        private void selectGeoCellFlat(GeoCell cell, bool append)
        {
            GeoBlock                block    = cell.getBlock();
            GeoBlockEntry           entry    = getEntry(block);
            FastArrayList <GeoCell> selected = entry.getValue();

            //
            if (append)
            {
                if (selected != null)
                {
                    cell.setSelectionState(SelectionState.NORMAL);
                    entry.remove();
                    return;
                }
            }
            else
            {
                unselectAll();
                selected = null;
            }
            //
            cell.setSelectionState(SelectionState.SELECTED);
            selected = new FastArrayList <GeoCell>(block.getCells());
            entry.setKey(block);
            entry.setValue(selected);
            entry.addBefore(getTail());
        }
Ejemplo n.º 2
0
 private static void setStateOf(FastArrayList <GeoCell> cells, SelectionState state)
 {
     for (int i = cells.size(); i-- > 0;)
     {
         cells.getUnsafe(i).setSelectionState(state);
     }
 }
Ejemplo n.º 3
0
 public GeoBlockSelector()
 {
     _selected = new GeoBlockEntry[GeoEngine.GEO_REGION_SIZE * GeoEngine.GEO_REGION_SIZE];
     for (int i = _selected.Length; i-- > 0;)
     {
         _selected[i] = new GeoBlockEntry();
     }
     _head = new GeoBlockEntry();
     _tail = new GeoBlockEntry();
     getHead().setPrev(getHead());
     getHead().setNext(getTail());
     getTail().setPrev(getHead());
     getTail().setNext(getTail());
     _temp = new FastArrayList <GeoCell>();
 }
Ejemplo n.º 4
0
        //public bool isInside(GeoCell cell) {
        //    if (_geoX == int.MinValue) return false;
        //    if (cell.getBlock().getGeoX() != _geoX) return false;
        //    if (cell.getBlock().getGeoY() != _geoY) return false;
        //    if (_infHeight) return true;
        //    //
        //    int height = cell.getHeight();
        //    if (height < _geoZ - _height || height > _geoZ + _height) return false;
        //    return true;
        //}

        public void getAllCellsInside(GeoCell reference, GeoCell[] cells, FastArrayList <GeoCell> store)
        {
            if (_infHeight)
            {
                store.addAll(cells);
            }
            else
            {
                int height;
                int geoZ = reference.getHeight();
                foreach (GeoCell cell in cells)
                {
                    height = cell.getHeight();
                    if (height >= geoZ - _height && height <= geoZ + _height)
                    {
                        store.add(cell);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public void unselectGeoCell(GeoCell cell)
        {
            GeoBlock                block    = cell.getBlock();
            GeoBlockEntry           entry    = getEntry(block);
            FastArrayList <GeoCell> selected = entry.getValue();

            if (selected != null && selected.remove(cell))
            {
                if (selected.isEmpty())
                {
                    setStateOf(block.getCells(), SelectionState.NORMAL);
                    entry.remove();
                    updateGUI(null);
                }
                else
                {
                    cell.setSelectionState(SelectionState.HIGHLIGHTED);
                    updateGUI(selected.getLastUnsafe());
                }
            }
        }
Ejemplo n.º 6
0
        public void IsWriteTest()
        {
            var arr = new FastArrayList <int>(5);

            Assert.IsTrue(arr.IsEmpty);
            Assert.AreEqual(5, arr.Size);

            Assert.IsTrue(arr.IsAvailableWrite);
            arr.Append(1);
            arr.Prepend(2);
            arr.Append(3);
            arr.Append(4);
            Assert.IsTrue(arr.IsAvailableWrite);
            arr.Append(5);

            Assert.IsFalse(arr.IsAvailableWrite);
            arr.Append(5);
            arr.Append(5);
            arr.RemoveLast();
            Assert.IsTrue(arr.IsAvailableWrite);
        }
Ejemplo n.º 7
0
 private void updateGUI(GeoCell cell)
 {
     if (!hasSelected())
     {
         FrameMain.getInstance().setSelectedGeoCell(null);
     }
     else
     {
         FastArrayList <GeoCell> selected = cell == null ? null : getEntry(cell.getBlock()).getValue();
         if (selected == null)
         {
             selected = getTail().getPrev().getValue();
         }
         //
         if (cell != null && selected.contains(cell))
         {
             FrameMain.getInstance().setSelectedGeoCell(cell);
         }
         else
         {
             FrameMain.getInstance().setSelectedGeoCell(selected.getLastUnsafe());
         }
     }
 }
Ejemplo n.º 8
0
        private void selectGeoCellMultiLayer(GeoCell cell, bool fullBlock, bool append)
        {
            GeoBlock      block = cell.getBlock();
            GeoBlockEntry entry = getEntry(block);

            GeoCell[]               cells        = block.getCells();
            GLSelectionBox          selectionBox = GLDisplay.getInstance().getSelectionBox();
            FastArrayList <GeoCell> selected     = entry.getValue();

            //
            if (append)
            {
                if (selected != null)
                {
                    if (fullBlock)
                    {
                        if (selectionBox.isInfHeight())
                        {
                            if (selected.size() == cells.Length)
                            {
                                setStateOf(cells, SelectionState.NORMAL);
                                entry.remove();
                            }
                            else
                            {
                                selected.clear();
                                selected.addAll(cells);
                                setStateOf(cells, SelectionState.SELECTED);
                            }
                        }
                        else
                        {
                            _temp.clear();
                            selectionBox.getAllCellsInside(cell, cells, _temp);
                            //
                            if (selected.containsAll(_temp))
                            {
                                if (selected.size() == _temp.size())
                                {
                                    setStateOf(cells, SelectionState.NORMAL);
                                    entry.remove();
                                }
                                else
                                {
                                    setStateOf(_temp, SelectionState.NORMAL);
                                    selected.removeAll(_temp);
                                }
                            }
                            else
                            {
                                setStateOf(_temp, SelectionState.SELECTED);
                                selected.addAllIfAbsent(_temp);
                            }
                        }
                    }
                    else
                    {
                        if (selected.remove(cell))
                        {
                            if (selected.isEmpty())
                            {
                                setStateOf(cells, SelectionState.NORMAL);
                                entry.remove();
                            }
                            else
                            {
                                cell.setSelectionState(SelectionState.HIGHLIGHTED);
                            }
                        }
                        else
                        {
                            selected.addLast(cell);
                            cell.setSelectionState(SelectionState.SELECTED);
                        }
                    }
                }
                else
                {
                    if (fullBlock)
                    {
                        if (selectionBox.isInfHeight())
                        {
                            selected = new FastArrayList <GeoCell>(cells);
                        }
                        else
                        {
                            selected = new FastArrayList <GeoCell>();
                            selectionBox.getAllCellsInside(cell, cells, selected);
                            if (!selected.isEmpty())
                            {
                                setStateOf(cells, SelectionState.HIGHLIGHTED);
                            }
                        }
                    }
                    else
                    {
                        selected = new FastArrayList <GeoCell>(8);
                        selected.addLastUnsafe(cell);
                        setStateOf(cells, SelectionState.HIGHLIGHTED);
                    }
                    //
                    if (!selected.isEmpty())
                    {
                        setStateOf(selected, SelectionState.SELECTED);
                        entry.setKey(block);
                        entry.setValue(selected);
                        entry.addBefore(getTail());
                    }
                }
            }
            else
            {
                unselectAll();
                //
                if (fullBlock)
                {
                    if (selectionBox.isInfHeight())
                    {
                        selected = new FastArrayList <GeoCell>(cells);
                    }
                    else
                    {
                        selected = new FastArrayList <GeoCell>();
                        selectionBox.getAllCellsInside(cell, cells, selected);
                    }
                }
                else
                {
                    selected = new FastArrayList <GeoCell>(8);
                    selected.addLastUnsafe(cell);
                    setStateOf(cells, SelectionState.HIGHLIGHTED);
                }
                //
                if (!selected.isEmpty())
                {
                    setStateOf(selected, SelectionState.SELECTED);
                    entry.setKey(block);
                    entry.setValue(selected);
                    entry.addBefore(getTail());
                }
            }
        }
Ejemplo n.º 9
0
        private void selectGeoCellComplex(GeoCell cell, bool fullBlock, bool append)
        {
            GeoBlock      block = cell.getBlock();
            GeoBlockEntry entry = getEntry(block);

            GeoCell[] cells = block.getCells();
            FastArrayList <GeoCell> selected = entry.getValue();

            //
            if (append)
            {
                if (selected != null)
                {
                    if (selected.size() == cells.Length)
                    {
                        if (fullBlock)
                        {
                            setStateOf(cells, SelectionState.NORMAL);
                            entry.remove();
                        }
                        else
                        {
                            if (selected.remove(cell))
                            {
                                cell.setSelectionState(SelectionState.HIGHLIGHTED);
                            }
                        }
                    }
                    else
                    {
                        if (fullBlock)
                        {
                            selected.clear();
                            selected.addAll(cells);
                            setStateOf(cells, SelectionState.SELECTED);
                        }
                        else
                        {
                            if (selected.remove(cell))
                            {
                                if (selected.isEmpty())
                                {
                                    setStateOf(cells, SelectionState.NORMAL);
                                    entry.remove();
                                }
                                else
                                {
                                    cell.setSelectionState(SelectionState.HIGHLIGHTED);
                                }
                            }
                            else
                            {
                                selected.addLast(cell);
                                cell.setSelectionState(SelectionState.SELECTED);
                            }
                        }
                    }
                }
                else
                {
                    if (fullBlock)
                    {
                        selected = new FastArrayList <GeoCell>(cells);
                    }
                    else
                    {
                        selected = new FastArrayList <GeoCell>(8);
                        selected.addLastUnsafe(cell);
                        setStateOf(cells, SelectionState.HIGHLIGHTED);
                    }
                    //
                    setStateOf(selected, SelectionState.SELECTED);
                    entry.setKey(block);
                    entry.setValue(selected);
                    entry.addBefore(getTail());
                }
            }
            else
            {
                unselectAll();
                //
                if (fullBlock)
                {
                    selected = new FastArrayList <GeoCell>(cells);
                }
                else
                {
                    selected = new FastArrayList <GeoCell>(8);
                    selected.addLastUnsafe(cell);
                    setStateOf(cells, SelectionState.HIGHLIGHTED);
                }
                //
                setStateOf(selected, SelectionState.SELECTED);
                entry.setKey(block);
                entry.setValue(selected);
                entry.addBefore(getTail());
            }
        }
Ejemplo n.º 10
0
        public bool isGeoCellSelected(GeoCell cell)
        {
            FastArrayList <GeoCell> selected = getEntry(cell.getBlock()).getValue();

            return(selected != null && selected.contains(cell));
        }
Ejemplo n.º 11
0
 public void setValue(FastArrayList <GeoCell> value)
 {
     _value = value;
 }