/*
 * Pedestrian.fx
 *
 * Created on Feb 10, 2010, 4:53:26 PM
 */
package mdot_gui;

import javafx.scene.CustomNode;
import javafx.scene.Node;
import javafx.scene.Group;
import javafx.scene.paint.Color;
import mdot_gui.Constants;
import javafx.scene.layout.HBox;
import javafx.scene.text.Font;
import javafx.scene.text.Text;

/**
 * @author Ali
 */
public class ControlPanel extends CustomNode {

    public override function create(): Node {
        visible = false;
        id = "ControlPanel";
        Group {
            var headerText: Text = Text {
                        font: Font { size: 40 }
                        fill: Color.WHITE
                        content: "Virtual Control Panel"
                    }
            var gaugeTypeUsed = BasicGauge { };
            var rpmGauge: GaugeDEFAULT = GaugeDEFAULT {
                        ui: BasicGaugeDEFAULT { }
                        primaryLabel: "RPM x 1000"
                        secondaryLabelVisible: false
                        min: 0.0, max: 10.0
                        value: bind (MainScreen.rpm) / 1000
                        dispValueMultiplier: 1000
                        background: gaugeTypeUsed.customBackground(Color.GREEN)
                        dialLinesLongEvery: 5
                        //speed: Gauge.FASTEST
                        speed:GaugeDEFAULT.USERDEFINED
                        userDefinedSpeed:0.3s
                        highlightRange: [
                            GaugeDEFAULT.range {
                                start: 0
                                end: 5.5
                                color: Color.GREEN
                                opacity: 0.8
                            },
                            GaugeDEFAULT.range {
                                start: 5.5
                                end: 6
                                color: Color.YELLOW
                                dialLongLinesColor: Color.YELLOW
                                dialShortLinesColor: Color.YELLOW
                                opacity: .5
                            },
                            GaugeDEFAULT.range {
                                start: 6
                                end: 10
                                color: Color.RED
                                dialLongLinesColor: Color.RED
                                dialShortLinesColor: Color.RED
                                opacity: .8
                            }
                        ]
                    }
            var mphGauge: GaugeDEFAULT = GaugeDEFAULT {
                        ui: BasicGaugeDEFAULT { }
                        primaryLabel: "MPH"
                        secondaryLabel: "Speed"
                        speed:GaugeDEFAULT.USERDEFINED
                        userDefinedSpeed:0.3s
                        min: 0.0, max: 100.0
                        value: bind MainScreen.mph
                        background: gaugeTypeUsed.customBackground(Color.DARKBLUE)
                    }
           
            content: [
                Group {
                    translateX: Constants.WINDOW_WIDTH / 2 - (headerText.boundsInLocal.width) / 2
                    //translateY: 50
                    translateY: Constants.WINDOW_HEIGHT/5
                    content: headerText
                }
                Group {
                    scaleX: 0.75
                    scaleY: 0.75
                    translateX: Constants.WINDOW_WIDTH / 2 - (rpmGauge.boundsInLocal.width + mphGauge.boundsInLocal.width + 10) / 2
                    translateY: Constants.WINDOW_HEIGHT / 5
                    content: [
                        HBox {
                            spacing: 20
                            content: [
                                rpmGauge,
                                mphGauge
                            ]
                        }
                    ]
                }
            ]
        }
    }

}
