Skip to content

Commit

Permalink
Change GraphWidget to ChartFX (#657)
Browse files Browse the repository at this point in the history
* Initial switch to chart-fx

* Added autoscroll toggle, range slider pans x-axis (#1)

* Added autoscroll toggle, range slider pans x-axis

* Took out random spaces

* Checkstyle fixes

* Bump BasePlugin version

* Fix small bug with max and autoscroll

* Increase the refresh rate of the graph slightly.

* Remove ToggleButton and move autoscroll to the action menu

* Add stuff to settings along with initial dark mode CSS

* Dark mode works!

* Update chart-fx

* Address review comments

* Address checkstyle and encapsulate graph updater

Co-authored-by: Xzibit <[email protected]>
  • Loading branch information
carbotaniuman and neel-j-dev authored Jul 4, 2020
1 parent 50826b3 commit 824258e
Show file tree
Hide file tree
Showing 8 changed files with 267 additions and 529 deletions.
13 changes: 13 additions & 0 deletions app/src/main/resources/edu/wpi/first/shuffleboard/app/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,16 @@
.settings-pane {
-fx-border-color: -swatch-dark-gray;
}

/*******************************************************************************
* *
* Graph (axis) labels *
* *
******************************************************************************/
.axis-label {
-fx-fill: white;
}

.axis {
-fx-tick-label-fill: white;
}
12 changes: 12 additions & 0 deletions app/src/main/resources/edu/wpi/first/shuffleboard/app/midnight.css
Original file line number Diff line number Diff line change
Expand Up @@ -404,3 +404,15 @@
-fx-border-color: #171F2F;
}

/*******************************************************************************
* *
* Graph (axis) labels *
* *
******************************************************************************/
.axis-label {
-fx-fill: white;
}

.axis {
-fx-tick-label-fill: white;
}
4 changes: 4 additions & 0 deletions plugins/base/base.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
description = """
Base shuffleboard plugin that provides the default data types and widgets.
""".trimMargin()

dependencies {
compile("de.gsi.chart:chartfx-chart:11.1.5")
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package edu.wpi.first.shuffleboard.plugin.base;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import edu.wpi.first.shuffleboard.api.PropertyParser;
import edu.wpi.first.shuffleboard.api.data.DataType;
import edu.wpi.first.shuffleboard.api.data.DataTypes;
import edu.wpi.first.shuffleboard.api.json.ElementTypeAdapter;
import edu.wpi.first.shuffleboard.api.plugin.Description;
import edu.wpi.first.shuffleboard.api.plugin.Plugin;
import edu.wpi.first.shuffleboard.api.prefs.Group;
import edu.wpi.first.shuffleboard.api.prefs.Setting;
import edu.wpi.first.shuffleboard.api.tab.TabInfo;
import edu.wpi.first.shuffleboard.api.util.PreferencesUtils;
import edu.wpi.first.shuffleboard.api.widget.ComponentType;
import edu.wpi.first.shuffleboard.api.widget.LayoutClass;
import edu.wpi.first.shuffleboard.api.widget.WidgetType;
Expand Down Expand Up @@ -61,23 +67,39 @@
import edu.wpi.first.shuffleboard.plugin.base.widget.ToggleSwitchWidget;
import edu.wpi.first.shuffleboard.plugin.base.widget.UltrasonicWidget;
import edu.wpi.first.shuffleboard.plugin.base.widget.VoltageViewWidget;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import javafx.beans.InvalidationListener;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.prefs.Preferences;

@Description(
group = "edu.wpi.first.shuffleboard",
name = "Base",
version = "1.2.0",
version = "1.3.0",
summary = "Defines all the WPILib data types and stock widgets"
)
@SuppressWarnings("PMD.CouplingBetweenObjects")
public class BasePlugin extends Plugin {
private final Preferences preferences = Preferences.userNodeForPackage(getClass());
private GraphWidget.Updater updater;
private InvalidationListener graphSaver;

@Override
public void onLoad() {
this.updater = new GraphWidget.Updater();

this.graphSaver = n -> PreferencesUtils.save(updater.graphUpdateRateProperty(), preferences);
PreferencesUtils.read(updater.graphUpdateRateProperty(), preferences);
updater.graphUpdateRateProperty().addListener(graphSaver);
}

@Override
public void onUnload() {
updater.graphUpdateRateProperty().removeListener(graphSaver);
updater.close();
}

@Override
public List<DataType> getDataTypes() {
Expand Down Expand Up @@ -202,4 +224,16 @@ public List<ElementTypeAdapter<?>> getCustomTypeAdapters() {
);
}

@Override
public List<Group> getSettings() {
return ImmutableList.of(
Group.of("Graph settings",
Setting.of("Graph Update Rate",
"How many times a second graph widgets update at. "
+ "Faster update rates may cause performance issues",
updater.graphUpdateRateProperty()
)
)
);
}
}
Loading

0 comments on commit 824258e

Please sign in to comment.