Exemple #1
0
        /**
         * This method removes all the Symbols, that overlap each other. So that the output is collision free.
         *
         * @param symbols
         *            symbols from the actual tile
         */
        void removeOverlappingSymbols(List <SymbolContainer> symbols)
        {
            int dis = SYMBOL_DISTANCE_TO_SYMBOL;

            for (int x = 0; x < symbols.Count; x++)
            {
                this.symbolContainer = symbols[x];
                this.rect1           = new Rect((int)this.symbolContainer.point.X - dis, (int)this.symbolContainer.point.Y - dis,
                                                (int)this.symbolContainer.point.X + this.symbolContainer.symbol.Width + dis,
                                                (int)this.symbolContainer.point.Y + this.symbolContainer.symbol.Height + dis);

                for (int y = x + 1; y < symbols.Count; y++)
                {
                    if (y != x)
                    {
                        this.symbolContainer = symbols[y];
                        this.rect2           = new Rect((int)this.symbolContainer.point.X, (int)this.symbolContainer.point.Y,
                                                        (int)this.symbolContainer.point.X + this.symbolContainer.symbol.Width,
                                                        (int)this.symbolContainer.point.Y + this.symbolContainer.symbol.Height);

                        if (Utils.Intersects(this.rect2, this.rect1))
                        {
                            symbols.Remove(this.symbolContainer);
                            y--;
                        }
                    }
                }
            }
        }
Exemple #2
0
        /**
         * This method removes the Symbols, that are not visible in the actual tile.
         *
         * @param symbols
         *            Symbols from the actual tile
         */
        private void removeOutOfTileSymbols(List <SymbolContainer> symbols)
        {
            for (int i = 0; i < symbols.Count;)
            {
                this.symbolContainer = symbols[i];

                if (this.symbolContainer.point.X > Tile.TileSize)
                {
                    symbols.Remove(this.symbolContainer);
                }
                else if (this.symbolContainer.point.Y > Tile.TileSize)
                {
                    symbols.Remove(this.symbolContainer);
                }
                else if (this.symbolContainer.point.X + this.symbolContainer.symbol.Width < 0.0f)
                {
                    symbols.Remove(this.symbolContainer);
                }
                else if (this.symbolContainer.point.Y + this.symbolContainer.symbol.Height < 0.0f)
                {
                    symbols.Remove(this.symbolContainer);
                }
                else
                {
                    i++;
                }
            }
        }
Exemple #3
0
        /**
         * Removes the the symbols that overlap with area labels.
         *
         * @param symbols
         *            list of symbols
         * @param pTC
         *            list of labels
         */
        private void removeOverlappingSymbolsWithAreaLabels(List <SymbolContainer> symbols, List <pointTextContainer> pTC)
        {
            int dis = LABEL_DISTANCE_TO_SYMBOL;

            for (int x = 0; x < pTC.Count; x++)
            {
                this.label = pTC[x];

                this.rect1 = new Rect((int)this.label.x - dis, (int)(this.label.y - this.label.boundary.Height) - dis,
                                      (int)(this.label.x + this.label.boundary.Width + dis), (int)(this.label.y + dis));

                for (int y = 0; y < symbols.Count; y++)
                {
                    this.symbolContainer = symbols[y];

                    this.rect2 = new Rect((int)this.symbolContainer.point.X, (int)this.symbolContainer.point.Y,
                                          (int)(this.symbolContainer.point.X + this.symbolContainer.symbol.Width),
                                          (int)(this.symbolContainer.point.Y + this.symbolContainer.symbol.Height));

                    if (Utils.Intersects(this.rect1, this.rect2))
                    {
                        symbols.Remove(this.symbolContainer);
                        y--;
                    }
                }
            }
        }
Exemple #4
0
        public void drawSymbols(List <SymbolContainer> symbolContainers)
        {
            for (int index = symbolContainers.Count - 1; index >= 0; --index)
            {
                SymbolContainer symbolContainer = symbolContainers[index];

                MapPoint point = symbolContainer.point;
                if (symbolContainer.alignCenter)
                {
                    double pivotX = symbolContainer.symbol.Width / 2;
                    double pivotY = symbolContainer.symbol.Height / 2;
                    this.symbolMatrix.Rotation = symbolContainer.rotation;
                    this.symbolMatrix.CenterX  = pivotX;
                    this.symbolMatrix.CenterY  = pivotY;

                    this.symbolMatrix.TranslateX = point.X - pivotX;
                    this.symbolMatrix.TranslateY = point.Y - pivotY;
                }
                else
                {
                    this.symbolMatrix.Rotation   = symbolContainer.rotation;
                    this.symbolMatrix.TranslateX = point.X;
                    this.symbolMatrix.TranslateY = point.Y;
                }

                BitmapImage androidBitmap = AndroidGraphics.getAndroidBitmap(symbolContainer.symbol);
                this.canvas.drawBitmap(androidBitmap, this.symbolMatrix, PAINT_BITMAP_FILTER);
            }
        }
Exemple #5
0
 public ReferencePosition(double x, double y, int nodeNumber, double width, double height, SymbolContainer symbol)
 {
     this.x          = x;
     this.y          = y;
     this.nodeNumber = nodeNumber;
     this.width      = width;
     this.height     = height;
     this.symbol     = symbol;
 }
Exemple #6
0
        /**
         * The greedy algorithms need possible label positions, to choose the best among them. This method removes the
         * reference points, that are not validate. Not validate means, that the Reference overlap with another symbol or
         * label or is outside of the tile.
         *
         * @param refPos
         *            list of the potential positions
         * @param symbols
         *            actual list of the symbols
         * @param areaLabels
         *            actual list of the area labels
         */
        private void removeNonValidateReferencePosition(ReferencePosition[] refPos, List <SymbolContainer> symbols,
                                                        List <pointTextContainer> areaLabels)
        {
            int distance = LABEL_DISTANCE_TO_SYMBOL;

            for (int i = 0; i < symbols.Count; i++)
            {
                this.symbolContainer = symbols[i];
                this.rect1           = new Rect((int)this.symbolContainer.point.X - distance, (int)this.symbolContainer.point.Y
                                                - distance, (int)this.symbolContainer.point.X + this.symbolContainer.symbol.Width + distance,
                                                (int)this.symbolContainer.point.Y + this.symbolContainer.symbol.Height + distance);

                for (int y = 0; y < refPos.Length; y++)
                {
                    if (refPos[y] != null)
                    {
                        this.rect2 = new Rect((int)refPos[y].x, (int)(refPos[y].y - refPos[y].height),
                                              (int)(refPos[y].x + refPos[y].width), (int)(refPos[y].y));

                        if (Utils.Intersects(this.rect2, this.rect1))
                        {
                            refPos[y] = null;
                        }
                    }
                }
            }

            distance = LABEL_DISTANCE_TO_LABEL;

            foreach (pointTextContainer areaLabel in areaLabels)
            {
                this.rect1 = new Rect((int)areaLabel.x - distance, (int)areaLabel.y - areaLabel.boundary.Height
                                      - distance, (int)areaLabel.x + areaLabel.boundary.Width + distance, (int)areaLabel.y + distance);

                for (int y = 0; y < refPos.Length; y++)
                {
                    if (refPos[y] != null)
                    {
                        this.rect2 = new Rect((int)refPos[y].x, (int)(refPos[y].y - refPos[y].height),
                                              (int)(refPos[y].x + refPos[y].width), (int)(refPos[y].y));

                        if (Utils.Intersects(this.rect2, this.rect1))
                        {
                            refPos[y] = null;
                        }
                    }
                }
            }

            this.dependencyCache.removeReferencepointsFromDependencyCache(refPos);
        }
        /**
         * Create a new Point container, that holds the x-y coordinates of a point, a text variable, two paint objects, and
         * a reference on a symbol, if the text is connected with a NODE.
         *
         * @param text
         *            the text of the point.
         * @param x
         *            the x coordinate of the point.
         * @param y
         *            the y coordinate of the point.
         * @param paintFront
         *            the paintFront for the point.
         * @param paintBack
         *            the paintBack for the point.
         * @param symbol
         *            the connected Symbol.
         */
        public PointTextContainer(string text, double x, double y, Paint paintFront, Paint paintBack, SymbolContainer symbol)
        {
            this.text       = text;
            this.x          = x;
            this.y          = y;
            this.paintFront = paintFront;
            this.paintBack  = paintBack;
            this.symbol     = symbol;

            if (paintBack != null)
            {
                this.boundary = new Rect(0, 0, paintBack.getTextWidth(text), paintBack.getTextHeight(text));
            }
            else
            {
                this.boundary = new Rect(0, 0, paintFront.getTextWidth(text), paintFront.getTextHeight(text));
            }
        }
        private void removeOverlappingSymbolsWithDependencyLabels(List <SymbolContainer> symbols)
        {
            for (int i = 0; i < this.currentDependencyOnTile.labels.Count; i++)
            {
                this.depLabel = this.currentDependencyOnTile.labels[i];
                this.rect1    = new Rect((int)(this.depLabel.point.X),
                                         (int)(this.depLabel.point.Y - this.depLabel.value.boundary.Height),
                                         (int)(this.depLabel.point.X + this.depLabel.value.boundary.Width), (int)(this.depLabel.point.Y));

                for (int x = 0; x < symbols.Count; x++)
                {
                    this.smb = symbols[x];

                    this.rect2 = new Rect((int)this.smb.point.X, (int)this.smb.point.Y, (int)this.smb.point.X
                                          + this.smb.symbol.Width, (int)this.smb.point.Y + this.smb.symbol.Height);

                    if (Utils.Intersects(this.rect2, this.rect1))
                    {
                        symbols.Remove(x);
                        x--;
                    }
                }
            }
        }