Documentation added. Master merged. #story[1311]
This commit is contained in:
@@ -216,93 +216,66 @@ public class RaceViewController extends Controller {
|
|||||||
* Create speedometer
|
* Create speedometer
|
||||||
*/
|
*/
|
||||||
private void initialiseSpeedometer() {
|
private void initialiseSpeedometer() {
|
||||||
|
//Create the Medusa Gauge
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the Medusa Gauge with most of it's options
|
|
||||||
*/
|
|
||||||
gauge = GaugeBuilder.create()
|
gauge = GaugeBuilder.create()
|
||||||
.prefSize(200,200) // Set the preferred size of the control
|
.prefSize(200,200)
|
||||||
// Related to Foreground Elements
|
.foregroundBaseColor(Color.WHITE)
|
||||||
.foregroundBaseColor(Color.WHITE) // Defines a color for title, subtitle, unit, value, tick label, tick mark, major tick mark, medium tick mark and minor tick mark
|
.title("Title")
|
||||||
// Related to Title Text
|
.subTitle("Speed")
|
||||||
.title("Title") // Set the text for the title
|
.unit("Knots")
|
||||||
// Related to Sub Title Text
|
.decimals(2)
|
||||||
.subTitle("Speed") // Set the text for the subtitle
|
.lcdVisible(true)
|
||||||
// Related to Unit Text
|
.lcdDesign(LcdDesign.STANDARD)
|
||||||
.unit("Knots") // Set the text for the unit
|
.lcdFont(LcdFont.DIGITAL_BOLD)
|
||||||
// Related to Value Text
|
.scaleDirection(Gauge.ScaleDirection.CLOCKWISE)
|
||||||
.decimals(2) // Set the number of decimals for the value/lcd text
|
.minValue(0)
|
||||||
// Related to LCD
|
.maxValue(50)
|
||||||
.lcdVisible(true) // Display a LCD instead of the plain value text
|
.startAngle(320)
|
||||||
.lcdDesign(LcdDesign.STANDARD) // Set the design for the LCD
|
.angleRange(280)
|
||||||
.lcdFont(LcdFont.DIGITAL_BOLD) // Set the font for the LCD (STANDARD, LCD, SLIM, DIGITAL_BOLD, ELEKTRA)
|
.tickLabelDecimals(0)
|
||||||
// Related to scale
|
.tickLabelLocation(TickLabelLocation.INSIDE)
|
||||||
.scaleDirection(Gauge.ScaleDirection.CLOCKWISE) // Define the direction of the Scale (CLOCKWISE, COUNTER_CLOCKWISE)
|
.tickLabelOrientation(TickLabelOrientation.ORTHOGONAL)
|
||||||
.minValue(0) // Set the start value of the scale
|
.onlyFirstAndLastTickLabelVisible(false)
|
||||||
.maxValue(50) // Set the end value of the scale
|
.tickLabelSectionsVisible(false)
|
||||||
.startAngle(320) // Set the start angle of your scale (bottom -> 0, direction -> CCW)
|
.tickLabelColor(Color.BLACK)
|
||||||
.angleRange(280) // Set the angle range of your scale starting from the start angle
|
.tickMarkSectionsVisible(false)
|
||||||
// Related to Tick Labels
|
.majorTickMarksVisible(true)
|
||||||
.tickLabelDecimals(0) // Set the number of decimals for the tick labels
|
.majorTickMarkType(TickMarkType.TRAPEZOID)
|
||||||
.tickLabelLocation(TickLabelLocation.INSIDE) // Define wether the tick labels should be inside or outside the scale (INSIDE, OUTSIDE)
|
.mediumTickMarksVisible(false)
|
||||||
.tickLabelOrientation(TickLabelOrientation.ORTHOGONAL) // Define the orientation of the tick labels (ORTHOGONAL, HORIZONTAL, TANGENT)
|
.mediumTickMarkType(TickMarkType.LINE)
|
||||||
.onlyFirstAndLastTickLabelVisible(false) // Define if only the first and last tick label should be visible
|
.minorTickMarksVisible(true)
|
||||||
.tickLabelSectionsVisible(false) // Define if sections for tick labels should be visible
|
.minorTickMarkType(TickMarkType.LINE)
|
||||||
.tickLabelColor(Color.BLACK) // Define the color for tick labels (overriden by tick label sections)
|
.ledVisible(false)
|
||||||
// Related to Tick Marks
|
.ledType(Gauge.LedType.STANDARD)
|
||||||
.tickMarkSectionsVisible(false) // Define if sections for tick marks should be visible
|
.ledColor(Color.rgb(255, 200, 0))
|
||||||
.majorTickMarksVisible(true) // Define if major tick marks should be visible
|
.ledBlinking(false)
|
||||||
.majorTickMarkType(TickMarkType.TRAPEZOID) // Define the tick mark type for major tick marks (LINE, DOT, TRAPEZOID, TICK_LABEL)
|
.needleShape(Gauge.NeedleShape.ANGLED)
|
||||||
// Related to Medium Tick Marks
|
.needleSize(Gauge.NeedleSize.STANDARD)
|
||||||
.mediumTickMarksVisible(false) // Define if medium tick marks should be visible
|
.needleColor(Color.CRIMSON)
|
||||||
.mediumTickMarkType(TickMarkType.LINE) // Define the tick mark type for medium tick marks (LINE, DOT, TRAPEZOID)
|
.startFromZero(false)
|
||||||
// Related to Minor Tick Marks
|
.returnToZero(false)
|
||||||
.minorTickMarksVisible(true) // Define if minor tick marks should be visible
|
.knobType(Gauge.KnobType.METAL)
|
||||||
.minorTickMarkType(TickMarkType.LINE) // Define the tick mark type for minor tick marks (LINE, DOT, TRAPEZOID)
|
.knobColor(Color.LIGHTGRAY)
|
||||||
// Related to LED
|
.interactive(false)
|
||||||
.ledVisible(false) // Defines if the LED should be visible
|
.onButtonPressed(buttonEvent -> System.out.println("Knob pressed"))
|
||||||
.ledType(Gauge.LedType.STANDARD) // Defines the type of the LED (STANDARD, FLAT)
|
.onButtonReleased(buttonEvent -> System.out.println("Knob released"))
|
||||||
.ledColor(Color.rgb(255, 200, 0)) // Defines the color of the LED
|
.thresholdVisible(true)
|
||||||
.ledBlinking(false) // Defines if the LED should blink
|
.threshold(50)
|
||||||
// Related to Needle
|
.thresholdColor(Color.RED)
|
||||||
.needleShape(Gauge.NeedleShape.ANGLED) // Defines the shape of the needle (ANGLED, ROUND, FLAT)
|
.checkThreshold(true)
|
||||||
.needleSize(Gauge.NeedleSize.STANDARD) // Defines the size of the needle (THIN, STANDARD, THICK)
|
.onThresholdExceeded(thresholdEvent -> System.out.println("Threshold exceeded"))
|
||||||
.needleColor(Color.CRIMSON) // Defines the color of the needle
|
.onThresholdUnderrun(thresholdEvent -> System.out.println("Threshold underrun"))
|
||||||
// Related to Needle behavior
|
.gradientBarEnabled(true)
|
||||||
.startFromZero(false) // Defines if the needle should start from the 0 value
|
.gradientBarStops(new Stop(0.0, Color.BLUE),
|
||||||
.returnToZero(false) // Defines if the needle should always return to the 0 value (only makes sense when animated==true)
|
|
||||||
// Related to Knob
|
|
||||||
.knobType(Gauge.KnobType.METAL) // Defines the type for the center knob (STANDARD, PLAIN, METAL, FLAT)
|
|
||||||
.knobColor(Color.LIGHTGRAY) // Defines the color that should be used for the center knob
|
|
||||||
.interactive(false) // Defines if it should be possible to press the center knob
|
|
||||||
.onButtonPressed(buttonEvent -> System.out.println("Knob pressed")) // Defines a handler that will be triggered when the center knob was pressed
|
|
||||||
.onButtonReleased(buttonEvent -> System.out.println("Knob released")) // Defines a handler that will be triggered when the center knob was released
|
|
||||||
// Related to Threshold
|
|
||||||
.thresholdVisible(true) // Defines if the threshold indicator should be visible
|
|
||||||
.threshold(50) // Defines the value for the threshold
|
|
||||||
.thresholdColor(Color.RED) // Defines the color for the threshold
|
|
||||||
.checkThreshold(true) // Defines if each value should be checked against the threshold
|
|
||||||
.onThresholdExceeded(thresholdEvent -> System.out.println("Threshold exceeded")) // Defines a handler that will be triggered if checkThreshold==true and the threshold is exceeded
|
|
||||||
.onThresholdUnderrun(thresholdEvent -> System.out.println("Threshold underrun")) // Defines a handler that will be triggered if checkThreshold==true and the threshold is underrun
|
|
||||||
// Related to Gradient Bar
|
|
||||||
.gradientBarEnabled(true) // Defines if a gradient filled bar should be visible to visualize a range
|
|
||||||
.gradientBarStops(new Stop(0.0, Color.BLUE),// Defines a conical color gradient that will be use to color the gradient bar
|
|
||||||
new Stop(0.25, Color.CYAN),
|
new Stop(0.25, Color.CYAN),
|
||||||
new Stop(0.5, Color.LIME),
|
new Stop(0.5, Color.LIME),
|
||||||
new Stop(0.75, Color.YELLOW),
|
new Stop(0.75, Color.YELLOW),
|
||||||
new Stop(1.0, Color.RED))
|
new Stop(1.0, Color.RED))
|
||||||
// Related to Markers
|
.markersVisible(true)
|
||||||
.markersVisible(true) // Defines if markers will be visible
|
|
||||||
//.markers(marker1, marker2) // Defines markers that will be drawn
|
|
||||||
// Related to Value
|
|
||||||
//.animated(true) // Defines if the needle will be animated
|
|
||||||
//.animationDuration(500) // Defines the speed of the needle in milliseconds (10 - 10000 ms)
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a gauge with a frame and background that utilizes a Medusa gauge
|
//Create a gauge with a frame and background that utilizes a Medusa gauge
|
||||||
*/
|
|
||||||
fGauge = FGaugeBuilder
|
fGauge = FGaugeBuilder
|
||||||
.create()
|
.create()
|
||||||
.prefSize(200, 200)
|
.prefSize(200, 200)
|
||||||
@@ -312,7 +285,6 @@ public class RaceViewController extends Controller {
|
|||||||
.foregroundVisible(true)
|
.foregroundVisible(true)
|
||||||
.build();
|
.build();
|
||||||
speedPane.getChildren().add(fGauge);
|
speedPane.getChildren().add(fGauge);
|
||||||
//(event -> gauge.setValue(raceState.getBoat(raceState.getPlayerBoatID()).getCurrentSpeed()));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -841,21 +813,26 @@ public class RaceViewController extends Controller {
|
|||||||
}.start();
|
}.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Animation timer loop for the speedometer
|
||||||
|
*/
|
||||||
private void speedometerLoop(){
|
private void speedometerLoop(){
|
||||||
new AnimationTimer(){
|
new AnimationTimer(){
|
||||||
@Override
|
@Override
|
||||||
public void handle(long arg0){
|
public void handle(long arg0){
|
||||||
if (raceState.getRaceStatusEnum() == RaceStatusEnum.FINISHED) {
|
if (raceState.getRaceStatusEnum() == RaceStatusEnum.FINISHED) {
|
||||||
stop(); // stop the timer
|
stop(); // stop the timer
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
//Set the current speed value of the boat
|
||||||
gauge.setValue(raceState.getBoat(raceState.getPlayerBoatID()).getCurrentSpeed());
|
gauge.setValue(raceState.getBoat(raceState.getPlayerBoatID()).getCurrentSpeed());
|
||||||
fGauge.getGauge().setValue(raceState.getBoat(raceState.getPlayerBoatID()).getCurrentSpeed());
|
fGauge.getGauge().setValue(raceState.getBoat(raceState.getPlayerBoatID()).getCurrentSpeed());
|
||||||
//Thread.sleep(50);
|
|
||||||
|
//Create list with sorted boat placements
|
||||||
List<VisualiserBoat> boatList = boatInfoTable.getItems();
|
List<VisualiserBoat> boatList = boatInfoTable.getItems();
|
||||||
for (VisualiserBoat boat : boatList){
|
for (VisualiserBoat boat : boatList){
|
||||||
if(raceState.getPlayerBoatID()==boat.getSourceID()){
|
if(raceState.getPlayerBoatID()==boat.getSourceID()){
|
||||||
|
//Set boat current placement value as title of speedometer
|
||||||
gauge.titleProperty().setValue("Position: " + (boatInfoTable.getItems().indexOf(boat)+1));
|
gauge.titleProperty().setValue("Position: " + (boatInfoTable.getItems().indexOf(boat)+1));
|
||||||
fGauge.getGauge().titleProperty().setValue("Position: " + (boatInfoTable.getItems().indexOf(boat)+1));
|
fGauge.getGauge().titleProperty().setValue("Position: " + (boatInfoTable.getItems().indexOf(boat)+1));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user