How do you order of operations on Java FX 2 bindings? - data-binding

EDIT:
I went back and provided a long explanation of each of the below.... Then I started thinking. I think my issue was the division element (getUnitDivisionFactor()) was not observable. I changed this to an observable data type and it all started working. So rather than delete this "stupid question" I will leave it around. Perhaps this will help someone else.
I am using JFXtras 2. There is an "LCD" widget that has a valueProperty binding. It is a double binding. I am binding like this... Which is not working...
xLcd.valueProperty().bind(TinygDriver.getInstance().m.getAxisByName("x").getMachinePositionSimple().subtract(TinygDriver.getInstance().m.getAxisByName("x").getOffset()).divide(tg.m.getUnitDivisionFactor()));
The problem I really need to do the subtraction first..
(getMachinePositionSimple - getOffset()) / getUnitDivisionFactor()
However I am a bit stumped on how to do this in a single binding setup. I think number bindings might be the way to go. However, not quite sure how to set that up right?
Any help would be great.
Riley

The getUnitDivisonFactor() was returning a regular double data type. I changed this to a SimpleDoubleProperty and everything just started working.. See
xLcd.valueProperty().bind(TinygDriver.getInstance().m.getAxisByName("x").getMachinePositionSimple().subtract(tg.m.getAxisByName("x").getOffset()).divide(tg.m.gcodeUnitDivision));

Related

Cocos2d/directC pointer inheritance; adding children vs changing data

OK so like a lot of us novice codehacks, I've gotten to the point where, through trial and error, I can throw together a relatively fun and reasonably stable game without really understanding WHY a lot of my code works, and I have a poor understanding of pointers and data management. I've tried studying, but since I lack a formal academic background in computer science and have 15 years of experience coding, the introductory stuff is way too easy, and the advanced stuff uses a ton of terminology I don't understand paired with code that I do.
I'm trying to understand why it is that sometimes I can define a new variable, point it at another variable, and then change the pointed data indirectly, and sometimes I can't. Here's an example where it DOES work as I expect:
NSString *myString = [MySingleton sharedMySingleton].singletonString;
myString = #"Hello there!";
[myString retain];
By changing the locally defined "myString" i can cause changes to the singleton string.
Here's an example where it DOESN'T work as I expect:
HUDLayer *windowBox = shopWindowBox;
[windowBox addChild: shop];
[windowBox retain];
In this case, HUDLayer is just an essentially blank file, and "shop" is a menu containing my store, and "shopWindowBox" is an instance of HUDLayer. If I call the code with [shopWindowBox addChild: shop], it works, but as soon as I try to define a new HUDLayer and point it, it doesn't work.
I understand that I'm doing a very fundamentally different operation, in one case I'm changing the contents of a string, and in another case I'm adding a child. The conclusion I've come to is "you can't add children to a pointed data", but am I really understanding this correctly, an if so why not?
I found a code error in a different block that was setting its visibility to FALSE.
I was attempting to make the code more plug-and-play by changing "shopWindowBox", "unitWindowBox", and "unlockablesWindowBox" all to be locally defined variable with windowBox, but my "hideUnitWindowBox" and "hideUnlockablesWindowBox" functions were setting the visibility of my shop window to FALSE after populating it.
I guess pointers not only work as I expected, they work BETTER than I expected... I stupidly merged 4 different windows into a single window using pointers.

asp net 2.0 EnableEventValidation = False

This isn't so much a question as to more of a quick tip on some issues I had with my GridView export to Excel..
So I was having the problem that when I exported a GridView to excel spreadsheet, the spreadsheet was essentially blank however strangely enough a couple fields were filled with a tad bit of html (<div>, </div>).. I couldn't really figure out why that was happening but I stumbled upon a link which fixed my issue:
http://www.codeproject.com/Questions/45450/RegisterForEventValidation-can-only-be-called-duri
So for my solution I just added the EnableEventValidation=False in the top of my form and I neglected to add the bit of Me.EnableViewState = False in the behind code. This worked for whatever reason..
Question: Could someone explain what the heck is going on? I feel like every time I get something working with Asp.net it feels like I am mostly just exploiting bugs in the framework to get code working as opposed to using a logical flow like other frameworks I've used.. I still don't understand how something like this can just 'magically' work now and I have know understanding of the reasons why.
It's like if I were to program: A is in B and B is in C.. Therefore A is in C.
Case 1:
RoR: Ok, A is in C, your right mr. programmer, I get it.
Me: Yay, ok on the the next task..
Case 2:
Asp.net: Must set inheritor for object C.. see stacktrace...etc
Me: oh.. hmm ok I'll google that error:.. 45 min later.. Oh here is something weird that doesn't contain any useful docs... I'll try that. Oh it works! Yaay, but lame. I dun get it.

How do I put my return data from an asmx into JSON?

I want to return an array of javascript objects from my asp.net asmx file. ie.
variable = [
{
*value1*: 'value1',
*value2*: 'value2',
...,
},
{
.
.
}
];
I seem have been having trouble reaching this. I'd put this into code but I've been hacking away at it so much it'd probably do more harm than good in having this answered.
Basically I am using a web service to find names as people type the name. I'd use a regular text file or something but its a huge database that's always changing - and don't worry I've indexed the names so searching can be a little snappier - but I would really prefer to stick with this method and just figure out how to get usable JSON back to javascript. I've seen a few that sort of attempt to describe how one would approach this but I honestly think microsofts articles are damn near unreadable.
Thanks in advance for assistance.
EDIT: I'm using the $.ajax() function from jQuery - I've had it working but it seems like I was doing it in bad practice not returning and using actual JSON. Previously I'd take a string back and insert it into html to use the variable it set - very roundabout.
I just figured I'd answer because I hate when people ask a question, discover the answer, then don't share.
I went here http://weblogs.asp.net/scottgu/archive/2007/10/01/tip-trick-building-a-tojson-extension-method-using-net-3-5.aspx which convinced me to convert my site from vb to C# because I actually understand why C# works and I hated vb from the start - I just figured it'd maybe get better and be worth learning a little of. literally all I did was implement that tiny little static class and bam it works how I like it.

Databinding question regarding change highlighting

A short discription of the application I'm developing is: It's a WinForms app, where the UI is databinded to some classes that implement INotifyPropertyChanged. That classes are updated by a background thread, and we want to allow the user to see what has been changed.
The current solution in short: every setter of a property is checking if the new values is different than the current one. In the class I'm holding a flags-enum, where every bit represents one of the properties. So if the value changes, the corresponding bit is set. Additionally there is a timer ticking every 2 secs, that takes back that bit after a while.
First thing I would like to achieve is to get ride of the mess in the property setters, and to have the logic encaplused somewhere. Another reason is that me might run out of bits within the enum, etc etc...
This solution isn't ideal, as it makes it necessary to touch every setter, and maintain an enum property, so I would like to replace this solution with a "better" one (whatever this really means).
I'm wondering if and how somebody else solved that problem already?
tia
Martin
You need to raise a PropertyChanged event when when the value is changed. See for example MSDN

Using one data source for multiple datagrids in Flex3

I want to use one data source (e.g. an Array) for multiple Datagrids that have different filterFunctions attached and show different columns.
First, I thought I use a very straight forward apporach:
create the Array
create an ArrayCollection for every DataGrid and set the "source" property to the Array
create the DataGrids and set their dataProvider property to its designated ArrayCollection
So now. every ArrayCollection can have its own filterFunction, sort state etc. but there needs to be only one Array with all the data in memory.
Now to the point that totally confused me:
As new items are added to the Array, of course no Events are dispatched and I have to call itemUpdated manually on each of the ArrayCollections. While debugging into the code in order to get a deeper understanding for Flex, I tried to figure out, what this misterious "itemUpdated" method does, especially as it notes in the adobe documentation, that, if no "property" is given (e.g. it is null), a simple "refresh()" will occur.
I did not find any calls to "refresh()" in the whole debugging (and I went down the framework whole as deep as possible (btw: lots of funny comments right in the code :-) )).
The only thing I could find was a CollectionChangeEvent getting dispatched with a PropertyChangeEvent in its "item" property. Which was of the kind "UPDATE" (and not, as I would expect "ADD"). When trying to dispatch that event manually, it never worked (e.g. the datagrid did not update).
I know I have to stick with itemUpdated for the moment, but as the dataprovider can get big (in both dimensions), performance does concern me and I wnat to understand what is going on under the hood.
And as expected, no help from adobe :-(
So a big thanks for everyone who read this whole text.
And an even bigger THANKS to anyone who answers and gives me the slightes hint in how I can get out of the confusion and understand (if thats possible at all) Fles a little better.
finest of all regards,
herbert
You have to call ArrayCollection.refresh() for each of your dataProviders to get the dataGrids to show the new changes to the source array.

Resources