Set limits and more appearance changes for speedometer. #story[1311]
This commit is contained in:
@@ -213,82 +213,10 @@ public class RaceViewController extends Controller {
|
||||
* Create speedometer
|
||||
*/
|
||||
private void initialiseSpeedometer() {
|
||||
// gauge = GaugeBuilder.create().prefSize(200, 200).title("Speedometer").subTitle("Speed").unit("Knots").skinType(Gauge.SkinType.FLAT).build();
|
||||
// gauge.setValueColor(Color.WHITE);
|
||||
// gauge.setTitleColor(Color.WHITE);
|
||||
// gauge.setSubTitleColor(Color.WHITE);
|
||||
// gauge.setBarColor(Color.WHITE);
|
||||
// gauge.setUnitColor(Color.WHITE);
|
||||
// gauge.setMaxValue(40);
|
||||
// fGauge = FGaugeBuilder.create()
|
||||
// .prefSize(200, 200)
|
||||
// .gauge(gauge)
|
||||
// .gaugeDesign(GaugeDesign.METAL)
|
||||
// .gaugeBackground(GaugeDesign.GaugeBackground.CARBON)
|
||||
// .foregroundVisible(true)
|
||||
// .build();
|
||||
// gauge.valueProperty().setValue(0);
|
||||
// gauge.setAnimated(true);
|
||||
// //fGauge.getGauge().valueProperty().setValue(0);
|
||||
// //fGauge.getGauge().maxValueProperty().setValue(50);
|
||||
// speedPane.getChildren().add(fGauge);
|
||||
/**
|
||||
* Definition of Sections that can be used for
|
||||
* - Sections
|
||||
* - Areas
|
||||
* - TickMarkSections
|
||||
* - TickLabelSections
|
||||
*
|
||||
* Sections will be checked against current value if gauge.getCheckSectionsForValue == true
|
||||
*/
|
||||
Section section1 = SectionBuilder.create()
|
||||
.start(50)
|
||||
.stop(75)
|
||||
.color(Color.rgb(255, 200, 0, 0.7))
|
||||
.onSectionEntered(sectionEvent -> System.out.println("Entered Section 1"))
|
||||
.onSectionLeft(sectionEvent -> System.out.println("Left Section 1"))
|
||||
.build();
|
||||
|
||||
Section section2 = SectionBuilder.create()
|
||||
.start(75)
|
||||
.stop(100)
|
||||
.color(Color.rgb(255, 0, 0, 0.7))
|
||||
.onSectionEntered(sectionEvent -> System.out.println("Entered Section 2"))
|
||||
.onSectionLeft(sectionEvent -> System.out.println("Left Section 2"))
|
||||
.build();
|
||||
|
||||
/**
|
||||
* Definition of Markers
|
||||
* You can attach a listener for the following event types
|
||||
* - MARKER_PRESSED
|
||||
* - MARKER_RELEASED
|
||||
* - MARKER_EXCEEDED
|
||||
* - MARKER_UNDERRUN
|
||||
* via the MarkerBuilder
|
||||
* To receive MARKER_EXCEEDED and MARKER_UNDERRUN events you have to check the
|
||||
* current value against each marker by calling the markers checkForValue() method
|
||||
*/
|
||||
Marker marker1 = MarkerBuilder.create()
|
||||
.value(25)
|
||||
.text("Marker 1")
|
||||
.color(Color.HOTPINK)
|
||||
.markerType(Marker.MarkerType.DOT)
|
||||
.onMarkerPressed(markerEvent -> System.out.println("Marker 1 pressed"))
|
||||
.onMarkerReleased(markerEvent -> System.out.println("Marker 1 released"))
|
||||
.build();
|
||||
|
||||
Marker marker2 = MarkerBuilder.create()
|
||||
.value(75)
|
||||
.text("Marker 2")
|
||||
.color(Color.CYAN)
|
||||
.markerType(Marker.MarkerType.STANDARD)
|
||||
.onMarkerPressed(markerEvent -> System.out.println("Marker 2 pressed"))
|
||||
.onMarkerReleased(markerEvent -> System.out.println("Marker 2 released"))
|
||||
.build();
|
||||
|
||||
/**
|
||||
* Create the Medusa Gauge with most of it's options
|
||||
* Simply play with the boolean variables first to see what mean.
|
||||
*/
|
||||
gauge = GaugeBuilder.create()
|
||||
.prefSize(200,200) // Set the preferred size of the control
|
||||
@@ -297,9 +225,9 @@ public class RaceViewController extends Controller {
|
||||
// Related to Title Text
|
||||
.title("Title") // Set the text for the title
|
||||
// Related to Sub Title Text
|
||||
.subTitle("SubTitle") // Set the text for the subtitle
|
||||
.subTitle("Speed") // Set the text for the subtitle
|
||||
// Related to Unit Text
|
||||
.unit("Unit") // Set the text for the unit
|
||||
.unit("Knots") // Set the text for the unit
|
||||
// Related to Value Text
|
||||
.decimals(2) // Set the number of decimals for the value/lcd text
|
||||
// Related to LCD
|
||||
@@ -309,7 +237,7 @@ public class RaceViewController extends Controller {
|
||||
// Related to scale
|
||||
.scaleDirection(Gauge.ScaleDirection.CLOCKWISE) // Define the direction of the Scale (CLOCKWISE, COUNTER_CLOCKWISE)
|
||||
.minValue(0) // Set the start value of the scale
|
||||
.maxValue(100) // Set the end value of the scale
|
||||
.maxValue(50) // Set the end value of the scale
|
||||
.startAngle(320) // Set the start angle of your scale (bottom -> 0, direction -> CCW)
|
||||
.angleRange(280) // Set the angle range of your scale starting from the start angle
|
||||
// Related to Tick Labels
|
||||
@@ -318,12 +246,9 @@ public class RaceViewController extends Controller {
|
||||
.tickLabelOrientation(TickLabelOrientation.ORTHOGONAL) // Define the orientation of the tick labels (ORTHOGONAL, HORIZONTAL, TANGENT)
|
||||
.onlyFirstAndLastTickLabelVisible(false) // Define if only the first and last tick label should be visible
|
||||
.tickLabelSectionsVisible(false) // Define if sections for tick labels should be visible
|
||||
.tickLabelSections(section1, section2) // Define sections to color tick labels
|
||||
.tickLabelColor(Color.BLACK) // Define the color for tick labels (overriden by tick label sections)
|
||||
// Related to Tick Marks
|
||||
.tickMarkSectionsVisible(false) // Define if sections for tick marks should be visible
|
||||
.tickMarkSections(section1, section2) // Define sections to color tick marks
|
||||
// Related to Major Tick Marks
|
||||
.majorTickMarksVisible(true) // Define if major tick marks should be visible
|
||||
.majorTickMarkType(TickMarkType.TRAPEZOID) // Define the tick mark type for major tick marks (LINE, DOT, TRAPEZOID, TICK_LABEL)
|
||||
// Related to Medium Tick Marks
|
||||
@@ -366,7 +291,7 @@ public class RaceViewController extends Controller {
|
||||
new Stop(1.0, Color.RED))
|
||||
// Related to Markers
|
||||
.markersVisible(true) // Defines if markers will be visible
|
||||
.markers(marker1, marker2) // Defines markers that will be drawn
|
||||
//.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)
|
||||
@@ -374,27 +299,6 @@ public class RaceViewController extends Controller {
|
||||
|
||||
/**
|
||||
* Create a gauge with a frame and background that utilizes a Medusa gauge
|
||||
* You can choose between the following GaugeDesigns
|
||||
* - METAL
|
||||
* - TILTED_GRAY
|
||||
* - STEEL
|
||||
* - BRASS
|
||||
* - GOLD
|
||||
* - BLACK_METAL
|
||||
* - SHINY_METAL
|
||||
* - ENZO
|
||||
* - FLAT (when used one could set the frame color by calling GaugeDesign.FLAT.frameColor = Color.ORANGE;)
|
||||
* - TRANSPARENT
|
||||
*
|
||||
* and the following GaugeBackgrounds
|
||||
* - DARK_GRAY
|
||||
* - BEIGE
|
||||
* - ANTHRACITE
|
||||
* - LIGHT_GRAY
|
||||
* - WHITE
|
||||
* - BLACK
|
||||
* - CARBON
|
||||
* - TRANSPARENT
|
||||
*/
|
||||
fGauge = FGaugeBuilder
|
||||
.create()
|
||||
@@ -856,10 +760,9 @@ public class RaceViewController extends Controller {
|
||||
|
||||
} else {
|
||||
try {
|
||||
System.out.println(gauge.getValue());
|
||||
gauge.setValue(raceState.getBoat(raceState.getPlayerBoatID()).getCurrentSpeed());
|
||||
fGauge.getGauge().setValue(raceState.getBoat(raceState.getPlayerBoatID()).getCurrentSpeed());
|
||||
Thread.sleep(50);
|
||||
//Thread.sleep(50);
|
||||
for (VisualiserBoat boat : boatInfoTable.getItems()){
|
||||
if(raceState.getPlayerBoatID()==boat.getSourceID()){
|
||||
gauge.setTitle("Position: " + (boatInfoTable.getItems().indexOf(boat)+1));
|
||||
@@ -868,8 +771,6 @@ public class RaceViewController extends Controller {
|
||||
}
|
||||
} catch (BoatNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user