phpDocumentor SMap
Objects
[ class tree: SMap ] [ index: SMap ] [ all elements ]

Class: SMap_Object_Area_Label

Source Location: /SMap/Object.php

Class SMap_Object_Area_Label

Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From SMap_Object_Area_Rec

SMap_Object_Area_Rec::$overlaps
SMap_Object_Area_Rec::$rectBounds

Inherited From SMap_Object_Area

SMap_Object_Area::$borderColor

Inherited From SMap_Object

SMap_Object::$alt
SMap_Object::$color
SMap_Object::$layer
SMap_Object::$map
SMap_Object::$tile
SMap_Object::$url
SMap_Object::$view

Inherited From SMap_Object_Area_Rec

SMap_Object_Area_Rec::__construct()
Give the object a context
SMap_Object_Area_Rec::applyTile()
SMap_Object_Area_Rec::draw()
Draw this rectangle on an image
SMap_Object_Area_Rec::drawBox()
Draw this rectangle
SMap_Object_Area_Rec::drawShadow()
Draw a shadow around an area, prepare for the main rect to be drawn
SMap_Object_Area_Rec::findOverlap()
Finds if and how a viewport falls on an rectangle
SMap_Object_Area_Rec::getInnerBounds()
SMap_Object_Area_Rec::handleWrap()
Handle wrapping of an rectangle in a viewport
SMap_Object_Area_Rec::label()
Place the label on the rectangle
SMap_Object_Area_Rec::map()
Retrn the appropriate image map for this rectangle

Inherited From SMap_Object_Area

SMap_Object_Area::setBrdrColor()
Set the border color for this image

Inherited From SMap_Object

SMap_Object::__construct()
Give the object a context
SMap_Object::applyTile()
Apply a tile to this object
SMap_Object::draw()
Draw this object on a canvas
SMap_Object::getInnerBounds()
Get the rough inner rectangular bounds for this object.
SMap_Object::label()
Are we drawing a label for this object?
SMap_Object::map()
Return a map of this object
SMap_Object::setColor()
Set the color for this object
SMap_Object::setLink()
Set this to link to something

[ Top ]
Property Summary
static array   $avoid   Labels should avoid these places.
static mixed   $cached   What have we cached in the DB?
static object   $data   Store a reference to the data object
static mixed   $drawn  
static array   $labels   Label's text should be drawn last so it isn't covered
static mixed   $notCached  
mixed   $alignX  
mixed   $alignY  
array   $col   Define the colors of the label
integer   $copyDir   The label was copied in this direction
mixed   $font   Define the string
string   $label   The label's string
object   $labeledObj   What object are we attached to?
array   $layout   Save the layout that we have found for this label
boolean   $transient   Is this label transient?

[ Top ]
Method Summary
static void   avoid()   Mark an area in a view to be avoided
static boolean   collide()   Is there a collision?
static void   drawBegin()   Draw the background for a label
static void   drawFin()   Draw the rest of the label (ideally, on top of anything else that has
static void   drawLabels()   Finish drawing the labels
static void   flushNotCached()   On destruct flush the uncached label bounds into the DB (to cache them)
SMap_Object_Area_Label   __construct()   Give the object a context
void   align()  
boolean   applyTile()   Apply the layout after the bounds
void   copyOver()   Copy this object over a given bounds
array   draw()   Draw a label for an object
void   fetchCachedLayout()   Get cached layout info
string   genKey()   Generate a key for this label
void   layoutArea()   Layout the label in an area
void   layoutBegin()   Layout this label in a manner such that it isn't covering something up
void   layoutFin()   Finish the layout of a label; save any info so it can be drawn or mapped
void   layoutLine()   Layout the label on a line
void   layoutPoint()   Layout a label around a point
void   setFont()  
void   setFontColor()   Set the font color of the label
void   setTransient()  

[ Top ]
Properties
static array   $avoid = array() [line 1859]

Labels should avoid these places.

Maybe because there is already something there...

API Tags:
Access:  protected


[ Top ]
static mixed   $cached = null [line 1864]

What have we cached in the DB?

API Tags:
Usedby:  SMap_Object_Area_Label::fetchCachedLayout()
Usedby:  SMap_Object_Area_Label::drawLabels()
Access:  protected


[ Top ]
static object   $data [line 1873]

Store a reference to the data object

API Tags:
Usedby:  SMap_Object_Area_Label::fetchCachedLayout()
Access:  protected


[ Top ]
static mixed   $drawn = array() [line 1865]
API Tags:
Usedby:  SMap_Object_Area_Label::draw()
Usedby:  SMap_Object_Area_Label::drawLabels()
Access:  protected


[ Top ]
static array   $labels = array() [line 1850]

Label's text should be drawn last so it isn't covered

API Tags:
Usedby:  SMap_Object_Area_Label::drawBegin()
Usedby:  SMap_Object_Area_Label::drawLabels()
Access:  protected


[ Top ]
static mixed   $notCached = array() [line 1866]
API Tags:
Access:  protected


[ Top ]
mixed   $alignX = 5 [line 1802]
API Tags:
Access:  protected


[ Top ]
mixed   $alignY = 5 [line 1803]
API Tags:
Access:  protected


[ Top ]
array   $col [line 1829]

Define the colors of the label

API Tags:
Access:  protected


[ Top ]
integer   $copyDir = null [line 1810]

The label was copied in this direction

API Tags:
Usedby:  SMap_Object_Area_Label::copyOver()
Access:  protected


[ Top ]
mixed   $font = 5 [line 1822]

Define the string

API Tags:
Access:  protected


[ Top ]
string   $label [line 1880]

The label's string

API Tags:
Access:  protected


Redefinition of:
SMap_Object::$label
Are we labeling this object?

[ Top ]
object   $labeledObj [line 1817]

What object are we attached to?

API Tags:
Access:  protected


[ Top ]
array   $layout = array() [line 1843]

Save the layout that we have found for this label

API Tags:
Usedby:  SMap_Object_Area_Label::fetchCachedLayout()
Access:  protected


[ Top ]
boolean   $transient = false [line 1836]

Is this label transient?

API Tags:
Access:  protected


[ Top ]
Methods
static method avoid  [line 2882]

  static void avoid( SMap_View $view, array $bounds  )

Mark an area in a view to be avoided

Creates a list of areas that are "off limits" for drawing labels. Keeps track of the view an area is in, because views are drawn sepeartely.

Parameters:
object The   $view:  view that contains the bounds
array   $bounds:  The bounds to avoid.

API Tags:
Access:  public


[ Top ]
static method collide  [line 2897]

  static boolean collide( SMap_View $view, array $rB  )

Is there a collision?

Check for a collision between the given bounds and the ones already marked off by avoid(). Returns true if there is a collision or the bounds are out of the view.

Parameters:
object The   $view:  containing view.
array   $rB:  The bounds to test

API Tags:
Return:  Was a collision detected?
Access:  public


[ Top ]
static method drawBegin  [line 2037]

  static void drawBegin( SMap_Canvas $canvas, $layout, $vB, $scale  )

Draw the background for a label

Parameters:
SMap_Canvas   $canvas: 
   $layout: 
   $vB: 
   $scale: 

API Tags:
Usedby:  SMap_Object_Area_Label::drawLabels()
Usedby:  SMap_Object_Area_Label::draw()
Access:  protected
Uses:  SMap_Object_Area_Rec::drawShadow()
Uses:  SMap_Object_Area_Rec::findOverlap()
Uses:  SMap_Object_Area_Label::$labels


[ Top ]
static method drawFin  [line 2010]

  static void drawFin( SMap_Canvas $canvas, $xy, $color, $borderColor, $col, $label, $font, $x, $y, $ang  )

Draw the rest of the label (ideally, on top of anything else that has

been drawn)

Parameters:
SMap_Canvas   $canvas: 
   $xy: 
   $color: 
   $borderColor: 
   $col: 
   $label: 
   $font: 
   $x: 
   $y: 
   $ang: 

API Tags:
Usedby:  SMap_Object_Area_Label::drawLabels()
Access:  protected


[ Top ]
static method drawLabels  [line 1963]

  static void drawLabels( SMap_Tile $tile, boolean $fetchCached  )

Finish drawing the labels

This is called after draw() is called on all objects in the tile. It draws the meat of each label, and ensures that all labels get drawn (including those in the DB).

For future reference, flushNotCached() can't be called from here because this function is only called when an image is drawn (duh).

Parameters:
object The   $tile:  containing tile
boolean   $fetchCached:  Should we look for cached labels?

API Tags:
Access:  public
Usedby:  SMap_Tile::createImage()
Uses:  SMap_Data::selectCachedRectInBounds()
Uses:  SMap_Object_Area_Label::drawFin()
Uses:  SMap_Object_Area_Label::$drawn
Uses:  SMap_Object_Area_Label::$labels
Uses:  SMap_Object_Area_Label::drawBegin()
Uses:  SMap_Object_Area_Label::$cached


[ Top ]
static method flushNotCached  [line 1904]

  static void flushNotCached( )

On destruct flush the uncached label bounds into the DB (to cache them)


API Tags:
Access:  public


[ Top ]
Constructor __construct  [line 1885]

  SMap_Object_Area_Label __construct( SMap_View $view, SMap_Layer $layer, SMap_Object $obj, $url, $text  )

Give the object a context

Parameters:
SMap_View   $view: 
SMap_Layer   $layer: 
SMap_Object   $obj: 
   $url: 
   $text: 

API Tags:
Access:  public


Redefinition of:
SMap_Object_Area_Rec::__construct()
Give the object a context

[ Top ]
align  [line 1939]

  void align( $X, $Y  )

Parameters:
   $X: 
   $Y: 

API Tags:
Access:  public


[ Top ]
applyTile  [line 2725]

  boolean applyTile( SMap_Tile $tile  )

Apply the layout after the bounds

Applying a tile to a label is a somewhat tricky matter. The tile must layout(), taking into account any previously laid out labels.

After we have determined the layout of the label, we must detect if it overlaps with any ajacent tiles. If it does, we need to pass a copy of the label to said tile, so it is drawn as needed.

Parameters:
object Tile   $tile:  to apply

API Tags:
Return:  Are we still drawing this object
Access:  public
Uses:  layout()
Uses:  SMap_Object_Area_Label::copyOver()


Redefinition of:
SMap_Object_Area_Rec::applyTile()

[ Top ]
copyOver  [line 2675]

  void copyOver( integer $dir, integer $newX, integer $newY  )

Copy this object over a given bounds

Copy this object using SMap_View::sendObj(). We must also ensure that we aren't copying a label back in the direction of its original tile.

Parameters:
integer   $dir:  Direction to send the object
integer   $newX:  New tile X
integer   $newY:  New tile Y

API Tags:
Usedby:  SMap_Object_Area_Label::applyTile()
Access:  protected
Uses:  SMap_View::sendObj()
Uses:  SMap_Object_Area_Rec::$overlaps
Uses:  SMap_Object_Area_Label::$copyDir


[ Top ]
draw  [line 2854]

  array draw( SMap_Canvas $canvas  )

Draw a label for an object

This gets complex. First, we decide what type of label to draw, is it along a line, point, or in an area? Then we lay out the label taking into account any other labels that may be nearby. This processing happens in layout().

The labels are actually drawn in two stages. The first stage is drawn now in drawBegin(), and the second stage is drawn later in drawFin(). It is done this way so we can draw shadows behind the labels, without drawing the shadows over other labels. The shadows aren't that important.

Parameters:
object Draw   $canvas:  onto this canvas

API Tags:
Return:  Mapping layout
Access:  public
Uses:  layout()
Uses:  SMap_Object_Area_Label::drawBegin()
Uses:  SMap_Object_Area_Label::$drawn


Redefinition of:
SMap_Object_Area_Rec::draw()
Draw this rectangle on an image

[ Top ]
fetchCachedLayout  [line 2557]

  void fetchCachedLayout( SMap_Tile $tile  )

Get cached layout info

First, all cached data for these view bounds is retrieved from the database. All bounds retuned in this way are marked to be avoided.

Then the key is generated. This key is compared to the keys returned in the previous step. Any matching rows are unserialized and processed. The processed data is placed in $overlaps and the unserialized data placed in $layout.

Parameters:
object The   $tile:  containing tile

API Tags:
Uses:  SMap_Object_Area_Label::genKey()
Access:  protected
Usedby:  SMap_Object_Area_Label::layoutBegin()
Uses:  SMap_Object_Area_Rec::findOverlap()
Uses:  SMap_Object_Area_Rec::$overlaps
Uses:  SMap_Object_Area_Label::$data
Uses:  SMap_Object_Area_Label::$layout
Uses:  SMap_Object_Area_Label::$cached


[ Top ]
genKey  [line 2522]

  string genKey( )

Generate a key for this label

Create a distinct ID for this label. This will be used in the database to save the calculated bounds.


API Tags:
Return:  The generated key
Usedby:  SMap_Object_Area_Label::fetchCachedLayout()
Access:  protected


[ Top ]
layoutArea  [line 2481]

  void layoutArea( SMap_Tile $tile, array $pB, integer $fWidth, integer $fHeight  )

Layout the label in an area

Position the label in an area

Parameters:
object The   $tile:  containing tile
array   $pB:  The parent's bounds
integer   $fWidth:  Font width in pixels
integer   $fHeight:  Font height in pixels

API Tags:
Usedby:  SMap_Object_Area_Label::layoutBegin()
Access:  protected


[ Top ]
layoutBegin  [line 2624]

  void layoutBegin( SMap_Tile $tile  )

Layout this label in a manner such that it isn't covering something up

We only do layout once, if anything is added after this label has been laid out, it is ignored. We also check for a previous layout via fetchCachedLayout(). If this label has already been laid out and stored in the database, then that info is used.

If the work hasn't already been done for us, the label must be laid out. Some commonly used dimensions are calculated, such as those of the space used by the font. Then the overlaps which were calculated by SMap_Object_Area_Rec::findOverlap() each have the label applied to them.

Here the approximate dimension of the area is found, compared to the font, and an appropriate solution is used to layout the label. If the label fits in the area, layoutArea() is used. If the area is a line, then layoutLine() is used. Otherwise, layoutPoint() is used, and we get a nice label with a pointer.

The final layout is saved in $layout and used by map() or draw().

Parameters:
object The   $tile:  containing tile

API Tags:
Access:  protected
Uses:  SMap_Object_Area_Label::layoutPoint()
Uses:  SMap_Object_Area_Label::layoutLine()
Uses:  SMap_Object_Area_Label::layoutArea()
Uses:  SMap_Object_Area_Label::fetchCachedLayout()


[ Top ]
layoutFin  [line 2150]

  void layoutFin( SMap_Tile $tile, integer $fWidth, integer $fHeight, float $ang, array $B, array $pB, boolean $hasPtr  )

Finish the layout of a label; save any info so it can be drawn or mapped

Now that the layout bounds have been defined and passed as a parameter, we must do some cleanup.

First we set appropriate $overlaps so this label's rectangle will be drawn at an appropriate place. Then we avoid() this location in future layouts. After that we set $layout and $notCached to contain the appropriate arrays.

Parameters:
object The   $tile:  containing tile
integer   $fWidth:  Font width in pixels
integer   $fHeight:  Font height in pixels
float   $ang:  Angle of the text
array   $B:  Bounds of the label
array   $pB:  Bounds of the parent object
boolean   $hasPtr:  Does the label have a pointer?

API Tags:
Access:  protected


[ Top ]
layoutLine  [line 2323]

  void layoutLine( SMap_Tile $tile, array $pB, integer $fWidth, integer $fHeight  )

Layout the label on a line

Position the label on a line. Move the label around if it collides with anything. You can set the approximate position of a label by adjusting its alignment.

Parameters:
object The   $tile:  containing tile
array   $pB:  The parent's bounds
integer   $fWidth:  Font width in pixels
integer   $fHeight:  Font height in pixels

API Tags:
Usedby:  SMap_Object_Area_Label::layoutBegin()
Access:  protected


[ Top ]
layoutPoint  [line 2211]

  void layoutPoint( SMap_Tile $tile, array $pB, integer $fWidth, integer $fHeight  )

Layout a label around a point

Positions a label around a point (or small rectangle), with a pointer from the label to the point itself. It works by moving the label in a circular pattern until a position is found

Parameters:
object The   $tile:  containing tile
array   $pB:  The parent's bounds
integer   $fWidth:  Font width in pixels
integer   $fHeight:  Font height in pixels

API Tags:
Usedby:  SMap_Object_Area_Label::layoutBegin()
Access:  protected


[ Top ]
setFont  [line 1925]

  void setFont( $font  )

Parameters:
   $font: 

API Tags:
Access:  public


[ Top ]
setFontColor  [line 1918]

  void setFontColor( $r, $g, $b, [ $a = null]  )

Set the font color of the label

Parameters:
   $r: 
   $g: 
   $b: 
   $a: 

API Tags:
Access:  public


[ Top ]
setTransient  [line 1932]

  void setTransient( $t  )

Parameters:
   $t: 

API Tags:
Access:  public


[ Top ]
Constants
A_BOTTOM = 3 [line 1798]

[ Top ]
A_CENTER = 5 [line 1800]

[ Top ]
A_LEFT = 4 [line 1799]

[ Top ]
A_RIGHT = 2 [line 1797]

[ Top ]
A_TOP = 1 [line 1796]

Alignment


[ Top ]

Documentation generated on Mon, 09 Apr 2007 18:54:56 -0500 by phpDocumentor 1.3.0