Go to Post Give us six more motors in the kit, and we'll try and come up with something... - Karthik [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 23-01-2015, 20:22
Irene-4574 Irene-4574 is offline
Registered User
FRC #4763
 
Join Date: Feb 2014
Rookie Year: 2014
Location: Fullerton
Posts: 9
Irene-4574 is an unknown quantity at this point
Need help with Smartdashboard SFX

Hey everyone,
I have been trying to utilize custom Java controls for the new SmartDashboard, but the tutorials FIRST provides are a little unclear. I can't seem to get the new control in the SmartDashboard. If someone could just point me in the right direction or link me to a better tutorial that would be great. Any help will be greatly appreciated. Thanks.

This is the exact code from the tutorial:
Code:
package com.example;

import dashfx.controls.DataAnchorPane;
import dashfx.lib.controls.Category;
import dashfx.lib.controls.DashFXProperties;
import dashfx.lib.controls.Designable;
import dashfx.lib.controls.GroupType;
import dashfx.lib.data.DataCoreProvider;
import dashfx.lib.data.SmartValue;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.paint.Color;
import javafx.scene.shape.Ellipse;

/**
 *
 * @author Epic
 */
@Category("Tutorial")
@Designable(value = "X-Y Location", description = "A control to show x/y position in a range")
@GroupType("xyLocation")
@DashFXProperties("Sealed: true, Save Children: false")

public class xyLocation extends DataAnchorPane {
   
    
    private SmartValue xValue;
    private SmartValue yValue;
    private Ellipse ellipse;
    
   @Override

    public void registered(DataCoreProvider provider)
    {
        super.registered(provider);
        unwatch();
      // if we are being registered, then we can finally get the x and y variable
      // otherwise just unwatch as we are being unregistered
	if (provider != null)
	{
            xValue = getObservable("x");
            yValue = getObservable("y");
            rewatch();
	}
    }
    private void rewatch()
    {
        xValue.addListener(xchange);
        yValue.addListener(ychange);
    }
    
    private void unwatch()
    {
        // this function un-binds all the variable
        if (xValue != null)
            xValue.removeListener(xchange);
        if (yValue != null)
            yValue.removeListener(ychange);
    }
        
    private ChangeListener
        ychange = new ChangeListener<Object>() {
            @Override
                public void changed(ObservableValue<? extends Object> ov, Object t, Object t1)
                {
                    ellipse.setCenterY(yValue.getData().asNumber() + 10); // offset by radius
                }
	},
        xchange = new ChangeListener<Object>() {
            @Override
                public void changed(ObservableValue<? extends Object> ov, Object t, Object t1)
                {
                    ellipse.setCenterX(xValue.getData().asNumber() + 10); // offset by radius
                }
	};
        
        // we are displaying results pse = new Ellipse(10, 10, 10, 10);by moving the ellipse. initialize it here
   
    
    ellipse = new Ellipse(10,10,10,10);
    ellipse.setFill(Color.LIGHTBLUE);
    this.getChildren().add(ellipse); // we inherited from DAP so just add it to ourselves
    nameProperty().addListener(new ChangeListener<String>()
    {
         @Override
         public void changed(ObservableValue<? extends String> ov, String t, String t1)
         {
             unwatch();
                try
                {
                    xValue = getObservable("x");
                    yValue = getObservable("y");
                    rewatch();
                }
                catch(NullPointerException n)
                {
                  //fail, ignore, as we must not be registered yet
                }
        }
    });     
     
}

Last edited by Irene-4574 : 23-01-2015 at 20:38.
  #2   Spotlight this post!  
Unread 24-01-2015, 17:39
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Need help with Smartdashboard SFX

Following those instructions top to bottom should work.

The only thing I can think of is you forgot to create a manifest.yaml in the jar
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 21:07.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi