A base class for samples - it is recommended that they extend this class rather than Application, as then the samples can be run either standalone or within FXSampler.
| 47 | * or within FXSampler. |
| 48 | */ |
| 49 | public abstract class SampleBase extends Application implements Sample { |
| 50 | |
| 51 | /** {@inheritDoc} */ |
| 52 | @Override public void start(Stage primaryStage) { |
| 53 | ServiceLoader<FXSamplerConfiguration> configurationServiceLoader = ServiceLoader.load(FXSamplerConfiguration.class); |
| 54 | |
| 55 | primaryStage.setTitle(getSampleName()); |
| 56 | |
| 57 | Scene scene = new Scene((Parent)buildSample(this, primaryStage), 800, 800); |
| 58 | scene.getStylesheets().add(SampleBase.class.getResource("fxsampler.css").toExternalForm()); |
| 59 | for (FXSamplerConfiguration fxsamplerConfiguration : configurationServiceLoader) { |
| 60 | String stylesheet = fxsamplerConfiguration.getSceneStylesheet(); |
| 61 | if (stylesheet != null) { |
| 62 | scene.getStylesheets().add(stylesheet); |
| 63 | } |
| 64 | } |
| 65 | primaryStage.setScene(scene); |
| 66 | primaryStage.show(); |
| 67 | } |
| 68 | |
| 69 | /** {@inheritDoc} */ |
| 70 | @Override public boolean isVisible() { |
| 71 | return true; |
| 72 | } |
| 73 | |
| 74 | /** {@inheritDoc} */ |
| 75 | @Override public Node getControlPanel() { |
| 76 | return null; |
| 77 | } |
| 78 | |
| 79 | /** {@inheritDoc} */ |
| 80 | @Override |
| 81 | public double getControlPanelDividerPosition() { |
| 82 | return 0.6; |
| 83 | } |
| 84 | |
| 85 | /** {@inheritDoc} */ |
| 86 | @Override public String getSampleDescription() { |
| 87 | return ""; |
| 88 | } |
| 89 | |
| 90 | /** {@inheritDoc} */ |
| 91 | @Override public String getProjectName() { |
| 92 | return "ControlsFX"; |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Utility method to create the default look for samples. |
| 97 | */ |
| 98 | public static Node buildSample(Sample sample, Stage stage) { |
| 99 | SplitPane splitPane = new SplitPane(); |
| 100 | |
| 101 | // we guarantee that the build order is panel then control panel. |
| 102 | final Node samplePanel = sample.getPanel(stage); |
| 103 | final Node controlPanel = sample.getControlPanel(); |
| 104 | splitPane.setDividerPosition(0, sample.getControlPanelDividerPosition()); |
| 105 | |
| 106 | if (samplePanel != null) { |
nothing calls this directly
no outgoing calls
no test coverage detected