com.triomotor.views

BaySchedule

extends: AbstractView

This class is in charge of painting and updating the Bays. Sends an Event through the bayChange Connector when a change occurs

See Also
Graphics, Connector, Scheduling

Property Summary

private Graphicsrecommended
private Graphicsreserved
private Graphicsselected
private Numbery = 12
private Numberheight = 13
private NumberrgbSelected = 0x8F1622
private NumberrgbRecommended = 0xFED32C
private NumberrgbReserved = 0x000000
private NumberrgbBorder = 0x5A728E
private NumberrgbHightLight = 0xFFEFB0
private NumberrgbVerticalHLight = 0xffffff
private ArrayrecommendedHours
private NumberselectionSize = 0
private MovieCliprecommendedBtn
private ConnectorbayChange
private DateselectedDate
private NumberbayNumber

Constructor Summary

BaySchedule()

Method Summary

public bayChangeEvent(event)
public setData(data:Array)
public setSelectionSize(value:Number)
public setBayNumber(n:Number)
public setSelectedDate(d:Date)
private onLoad()
private init()
private setBarsStyle()
private onSelected()
private drawReserved(startTime:Number, totalLength:Number)
private drawRecommended(startTime:Number, totalLength:Number)
private drawSelected(startTime:Number, totalLength:Number)
private drawRecommendedSpaces()
private arrangeRecommendedSpace(startTime:Number, totalLength:Number)

Property Details

recommended

private recommended:Graphics

Graphics object to draw the recommended chart

reserved

private reserved:Graphics

Graphics object to draw the reserved chart

selected

private selected:Graphics

Graphics object to draw the selected chart

y

private y:Number = 12

Y Position, defaults to 12

height

private height:Number = 13

height, defaults to 13

rgbSelected

private rgbSelected:Number = 0x8F1622

Selected color, defaults to 0x8F1622 (Red)

rgbRecommended

private rgbRecommended:Number = 0xFED32C

Recommended color, defaults to 0xFED32C (yellow)

rgbReserved

private rgbReserved:Number = 0x000000

Reserved color, defaults to black

rgbBorder

private rgbBorder:Number = 0x5A728E

border color, its default value is 0x5A728E

rgbHightLight

private rgbHightLight:Number = 0xFFEFB0

HightLight color, its default value is 0xFFEFB0

rgbVerticalHLight

private rgbVerticalHLight:Number = 0xffffff

Vertical HightLight color, its default value is white

recommendedHours

private recommendedHours:Array

Array of Objects containing a list of recommended hours

selectionSize

private selectionSize:Number = 0

The size of the selected graph to render (it's the same as the total labor hours)

recommendedBtn

private recommendedBtn:MovieClip

A reference to the recommended clip that we use as a button to know where the user clicks.

bayChange

private bayChange:Connector

A connector that is called whenever a change in the bay occurs

selectedDate

private selectedDate:Date

the Current date selected in the calendar

bayNumber

private bayNumber:Number

unique number for this specific bay

Constructor Details

BaySchedule

BaySchedule()

Method Details

bayChangeEvent

public bayChangeEvent(event):Void

Description: When the bay changes, the selected Graphic is cleared
Assumptions: selected is already instantiated
Globals: uses selected (Graphics)
Calls: clearAll() in the Graphics selected
Is Called by: The Connector bayChange

Parameters
event -
Returns
Void

setData

public setData(data:Array):Void

Description: Draws the reserved and Recommended spaces with the data received
Assumptions: reserved is already instantiated
Globals: uses reserved and recommendedHours
Calls: clearAll() in the Graphics reserved
drawReserved(), arrangeRecommendedSpace(), drawRecommendedSpaces()
Is Called by: showDetail() in the Scheduling class.
This call is executed when the data is received from the server

Parameters
data (Array) -
Returns
Void

setSelectionSize

public setSelectionSize(value:Number):Void

Description: sets selectionSize and draws recommended spaces
selectionSize is the amount of hours of the current order
Assumptions: none
Globals: uses selectionSize
Calls: drawRecommendedSpaces()
Is Called by: totalLabor Connector

Parameters
value (Number) -
Returns
Void

setBayNumber

public setBayNumber(n:Number):Void

Description: sets the bay Number
Globals: uses bayNumber
Calls: none
Is Called by: init() in the Scheduling class

Parameters
n (Number) - Bay number used for identification
Returns
none

setSelectedDate

public setSelectedDate(d:Date):Void

Description: Sets the selected day
Globals: uses selectedDate
Calls: none
Is Called by: setSelectedDate() in the Scheduling class

Parameters
d (Date) - current Date selected by the user
Returns
Void
See Also
Scheduling.setSelectedDate

onLoad

private onLoad():Void

Description: Creates a button that fires onSelected() when the user clicks the recommended Graphic. Call setBarsStyle() to create the Graphics Objects and instantiates recommendedHours with a default whole space
Globals: instantiates the following globals:
recommendedHours, recommendedBtn
Calls: getClip() of recommended Graphic
setBarsStyle()
Is Called by: This function is called automatically by the player when this object is completely loaded. This is possible because this class extends from the MovieClip Class

Returns
Void

init

private init():Void

Description: Registers this object as a listener of totalLabor and bayChange
Globals: instantiates the global bayChange and uses application
Calls: addListener() in the totalLabor and bayChange Connectors
Is Called by: This function is called by setApplication() in its super class AbstractView

Returns
void

setBarsStyle

private setBarsStyle():Void

Description: Creates the Graphics Object and sets its properties: color, position, background color, border color and hightLight color
Globals: instantiates the following globals:
reserved, recommended, selected
Calls: setLocation() and setColor() in the Graphics Objects
Is Called by: This function is called by onLoad()

Returns
void

onSelected

private onSelected():Void

Description: Gets the position of the mouse to know where to draw the selected bar. Checks if this position is available and if the bar fits well; if not, makes the necessary changes.
Creates an Object with the bay data and fires a bayChange Event with that Object as a parameter. Then draws the selected bar Assumptions: bayChange is instantiated
Globals: uses the following globals:
recommendedHours, bayChange, selectionSize
Calls: drawSelected() fireEvent() in the Connector bayChange
Is Called by: recommendedBtn.onRelease() This Event is executed when the user clicks the recommended Graphic

Returns
Void

drawReserved

private drawReserved(startTime:Number,
                     totalLength:Number):Void

Description: Draws the reserved bar
Assumptions: reserved is instantiated
Globals: uses the globals reserved
Calls: fillRect() in the reserved Graphic
Is Called by: setData()

Parameters
startTime (Number) -
totalLength (Number) -
Returns
Void

drawRecommended

private drawRecommended(startTime:Number,
                        totalLength:Number):Void

Description: Draws the recommended bar
Assumptions: recommended is instantiated
Globals: uses recommended
Calls: draw3DRect(), setColor(), and fillRect() in the recommended Graphic
Is Called by: drawRecommendedSpaces()

Parameters
startTime (Number) -
totalLength (Number) -
Returns
Void

drawSelected

private drawSelected(startTime:Number,
                     totalLength:Number):Void

Description: Draws the selected bar
Assumptions: selected is instantiated
Globals: uses selected
Calls: draw3DRect(), setColor(),fillRect() in the selected Graphic
Is Called by: onSelected()

Parameters
startTime (Number) -
totalLength (Number) -
Returns
Void

drawRecommendedSpaces

private drawRecommendedSpaces():Void

Description: Clears recommended and selected and calls drawRecommended() for each recommended bar that are in the list of recommendedHours
Assumptions: recommended and selected are instantiated
Globals: uses recommended, selected and recommendedHours
Calls: drawRecommended(), clearAll() in recommended, clearAll() in selected
Is Called by: setData(), setSelectionSize()

Returns
Void

arrangeRecommendedSpace

private arrangeRecommendedSpace(startTime:Number,
                                totalLength:Number):Void

Description: Splits the recommendedHour object that contains the startTime and totalLength to reflect the new values. Subtracts the space received from the List of recommendedHours
Assumptions: recommendedHours at least has one item
Globals: uses recommendedHours
Calls: none
Is Called by: setData()

Parameters
startTime (Number) -
totalLength (Number) -
Returns
void