Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems with booleans for a selection
    text
    copied!<p>I'm trying to implement something quite simple (in the principle) but i have some troubles with the implementation. </p> <p>In my programm the user has to choose between <strong>1 up to 4 directions</strong> which shall be excluded values. For every direction the user can choose a number range for the values to be excluded (from 0 to 360). But somehow i can't figure out how to make this in an easy way.</p> <p>My panel looks like that : A)</p> <p><img src="https://i.stack.imgur.com/6VrVb.jpg" alt="enter image description here"></p> <p>Here's a short example of what i'm trying to achieve.</p> <p>I want the same result for this : B)</p> <p><img src="https://i.stack.imgur.com/yOghQ.jpg" alt="enter image description here"></p> <p>As for this (but it should work for all the 4 cases of course): C)</p> <p><img src="https://i.stack.imgur.com/4KcRX.jpg" alt="enter image description here"></p> <p>Do you have any idea on how to solve this ? Or some hints? Any help will be greatly appreciated. <strong>(If you want me to provide the code i tryied, i will).</strong></p> <p>Edit : Okey, you wanted some code, here is what i did (but it's not working as i want).</p> <p>content[i].getNwdMean() is the value i want to compare with those in the spinners, to see if my point is in the exclusion zone.</p> <p>buttons.chkExcludedA1, buttons.chkExcludedA2, buttons.chkExcludedA3 and buttons.chkExcludedA4 are the buttons for the directions to exclude.</p> <p>buttons.getDir1A(), getDir2A, getDir3A, getDir4A, getDir1B, getDir2B, getDir3B, getDir4B are the values stored in the spinners, in my example C), getDir1A = 180, getDir1B = 190; getDir2A = 190 and getDir2B = 200.</p> <pre><code> // Is supposed to check the interval in both sides. public static boolean isBetween(double x, double a, double c) { return(x &gt; (a &lt; c ? a : c) &amp;&amp; x &lt; (a &gt; c ? a : c)); } private boolean parsDirections(boolean state) { boolean a1 = false, a2 = false, a3 = false, a4 = false; if (buttons.chkExcludedA1 == true || buttons.chkExcludedA2 == true || buttons.chkExcludedA3 == true || buttons.chkExcludedA4 == true) { if (isBetween(content[i].getNwdMean(), buttons.getDir1A(), buttons.getDir1B()) == false) { a1 = true; } else if (isBetween(content[i].getNwdMean(), buttons.getDir2A(), buttons.getDir2B()) == false) { a2 = true; } else if (isBetween(content[i].getNwdMean(), buttons.getDir3A(), buttons.getDir3B())== false) { a3 = true; } else if (isBetween(content[i].getNwdMean(), buttons.getDir4A(), buttons.getDir4B()) == false) { a4 = true; } } // Basic test to see if it prints what i want, but it doesn't. if (a4 == true &amp;&amp; a2 == true) { print(state); } else if (a1 == true &amp;&amp; a2 == false) { print(state); } else { return state; } return state; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload