/** * Removes the are labels from the actual list, that would be rendered in a Tile that has already be drawn. * * @param areaLabels * current area Labels, that will be displayed */ public void removeAreaLabelsInAlreadyDrawnAreas(List <pointTextContainer> areaLabels) { Tile lefttmp = new Tile(this.currentTile.TileX - 1, this.currentTile.TileY, this.currentTile.ZoomFactor); Tile righttmp = new Tile(this.currentTile.TileX + 1, this.currentTile.TileY, this.currentTile.ZoomFactor); Tile uptmp = new Tile(this.currentTile.TileX, this.currentTile.TileY - 1, this.currentTile.ZoomFactor); Tile downtmp = new Tile(this.currentTile.TileX, this.currentTile.TileY + 1, this.currentTile.ZoomFactor); bool up; bool left; bool right; bool down; this.tmp = this.dependencyTable[lefttmp]; left = this.tmp == null ? false : this.tmp.drawn; this.tmp = this.dependencyTable[righttmp]; right = this.tmp == null ? false : this.tmp.drawn; this.tmp = this.dependencyTable[uptmp]; up = this.tmp == null ? false : this.tmp.drawn; this.tmp = this.dependencyTable[downtmp]; down = this.tmp == null ? false : this.tmp.drawn; pointTextContainer label; for (int i = 0; i < areaLabels.Count; i++) { label = areaLabels[i]; if (up && label.y - label.boundary.Height < 0.0f) { areaLabels.Remove(i); i--; continue; } if (down && label.y > Tile.TileSize) { areaLabels.Remove(i); i--; continue; } if (left && label.x < 0.0f) { areaLabels.Remove(i); i--; continue; } if (right && label.x + label.boundary.Width > Tile.TileSize) { areaLabels.Remove(i); i--; continue; } } }
public void removeSymbolsFromDrawnAreas(List <SymbolContainer> symbols) { Tile lefttmp = new Tile(this.currentTile.TileX - 1, this.currentTile.TileY, this.currentTile.ZoomFactor); Tile righttmp = new Tile(this.currentTile.TileX + 1, this.currentTile.TileY, this.currentTile.ZoomFactor); Tile uptmp = new Tile(this.currentTile.TileX, this.currentTile.TileY - 1, this.currentTile.ZoomFactor); Tile downtmp = new Tile(this.currentTile.TileX, this.currentTile.TileY + 1, this.currentTile.ZoomFactor); bool up; bool left; bool right; bool down; this.tmp = this.dependencyTable[lefttmp]; left = this.tmp == null ? false : this.tmp.drawn; this.tmp = this.dependencyTable[righttmp]; right = this.tmp == null ? false : this.tmp.drawn; this.tmp = this.dependencyTable[uptmp]; up = this.tmp == null ? false : this.tmp.drawn; this.tmp = this.dependencyTable[downtmp]; down = this.tmp == null ? false : this.tmp.drawn; SymbolContainer reference; for (int i = 0; i < symbols.Count; i++) { reference = symbols[i]; if (up && reference.point.Y < 0) { symbols.Remove(i); i--; continue; } if (down && reference.point.Y + reference.symbol.Height > Tile.TileSize) { symbols.Remove(i); i--; continue; } if (left && reference.point.X < 0) { symbols.Remove(i); i--; continue; } if (right && reference.point.X + reference.symbol.Width > Tile.TileSize) { symbols.Remove(i); i--; continue; } } }
/** * This method must be called, before the dependencies will be handled correctly. Because it sets the actual Tile * and looks if it has already dependencies. * * @param tile * the current Tile */ public void generateTileAndDependencyOnTile(Tile tile) { this.currentTile = new Tile(tile.TileX, tile.TileY, tile.ZoomFactor); this.currentDependencyOnTile = this.dependencyTable[this.currentTile]; if (this.currentDependencyOnTile == null) { this.dependencyTable[this.currentTile] = new DependencyOnTile(); this.currentDependencyOnTile = this.dependencyTable[this.currentTile]; } }
/** * When the LabelPlacement class generates potential label positions for an NODE, there should be no possible * positions, that collide with existing symbols or labels in the dependency Cache. This class : this * functionality. * * @param refPos * possible label positions form the two or four point Greedy */ public void removeReferencepointsFromDependencyCache(LabelPlacement.ReferencePosition[] refPos) { Tile lefttmp = new Tile(this.currentTile.TileX - 1, this.currentTile.TileY, this.currentTile.ZoomFactor); Tile righttmp = new Tile(this.currentTile.TileX + 1, this.currentTile.TileY, this.currentTile.ZoomFactor); Tile uptmp = new Tile(this.currentTile.TileX, this.currentTile.TileY - 1, this.currentTile.ZoomFactor); Tile downtmp = new Tile(this.currentTile.TileX, this.currentTile.TileY + 1, this.currentTile.ZoomFactor); bool up; bool left; bool right; bool down; this.tmp = this.dependencyTable[lefttmp]; left = this.tmp == null ? false : this.tmp.drawn; this.tmp = this.dependencyTable[righttmp]; right = this.tmp == null ? false : this.tmp.drawn; this.tmp = this.dependencyTable[uptmp]; up = this.tmp == null ? false : this.tmp.drawn; this.tmp = this.dependencyTable[downtmp]; down = this.tmp == null ? false : this.tmp.drawn; LabelPlacement.ReferencePosition reference; for (int i = 0; i < refPos.Length; i++) { reference = refPos[i]; if (reference == null) { continue; } if (up && reference.y - reference.height < 0) { refPos[i] = null; continue; } if (down && reference.y >= Tile.TileSize) { refPos[i] = null; continue; } if (left && reference.x < 0) { refPos[i] = null; continue; } if (right && reference.x + reference.width > Tile.TileSize) { refPos[i] = null; } } // removes all Reverence points that intersects with Labels from the Dependency Cache int dis = 2; if (this.currentDependencyOnTile != null) { if (this.currentDependencyOnTile.labels != null) { 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 - dis, (int)(this.depLabel.point.Y - this.depLabel.value.boundary.Height) - dis, (int)(this.depLabel.point.X + this.depLabel.value.boundary.Width + dis), (int)(this.depLabel.point.Y + dis)); 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; } } } } } if (this.currentDependencyOnTile.symbols != null) { foreach (Dependency <DependencySymbol> symbols2 in this.currentDependencyOnTile.symbols) { this.rect1 = new Rect((int)symbols2.point.X, (int)(symbols2.point.Y), (int)(symbols2.point.X + symbols2.value.symbol.Width), (int)(symbols2.point.Y + symbols2.value.symbol.Height)); 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; } } } } } } }