Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
NUI
TULIP-CPS
Commits
c8d85421
Commit
c8d85421
authored
Nov 30, 2020
by
Nico Mack
Browse files
Added GraduationHelper class
Minor API change to VectorBasedCallback class
parent
ed5fb542
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
9 deletions
+98
-9
CPS/src/lu/list/itis/dkd/tui/bootstrapping/VectorBasedCallback.java
.../list/itis/dkd/tui/bootstrapping/VectorBasedCallback.java
+16
-9
CPS/src/lu/list/itis/dkd/tui/utility/graduation/GraduationHelper.java
...ist/itis/dkd/tui/utility/graduation/GraduationHelper.java
+82
-0
No files found.
CPS/src/lu/list/itis/dkd/tui/bootstrapping/VectorBasedCallback.java
View file @
c8d85421
...
@@ -38,7 +38,7 @@ import java.util.Map;
...
@@ -38,7 +38,7 @@ import java.util.Map;
*/
*/
// ***************************************************************************
// ***************************************************************************
// * Class Definition and Members
*
// * Class Definition and Members
// ***************************************************************************
// ***************************************************************************
public
class
VectorBasedCallback
implements
BootstrapCallback
{
public
class
VectorBasedCallback
implements
BootstrapCallback
{
...
@@ -50,14 +50,14 @@ public class VectorBasedCallback implements BootstrapCallback {
...
@@ -50,14 +50,14 @@ public class VectorBasedCallback implements BootstrapCallback {
private
Integer
size
;
private
Integer
size
;
// ***************************************************************************
// ***************************************************************************
// * Constants
*
// * Constants
// ***************************************************************************
// ***************************************************************************
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
VectorBasedCallback
.
class
.
getName
());
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
VectorBasedCallback
.
class
.
getName
());
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ***************************************************************************
// ***************************************************************************
// * Constructor(s)
*
// * Constructor(s)
// ***************************************************************************
// ***************************************************************************
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
...
@@ -79,7 +79,7 @@ public class VectorBasedCallback implements BootstrapCallback {
...
@@ -79,7 +79,7 @@ public class VectorBasedCallback implements BootstrapCallback {
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ***************************************************************************
// ***************************************************************************
// * Class Body
*
// * Class Body
// ***************************************************************************
// ***************************************************************************
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
...
@@ -87,10 +87,6 @@ public class VectorBasedCallback implements BootstrapCallback {
...
@@ -87,10 +87,6 @@ public class VectorBasedCallback implements BootstrapCallback {
List
<
BaseWidget
>
widgets
=
null
;
List
<
BaseWidget
>
widgets
=
null
;
Map
<
String
,
Variable
<?>>
systemVariables
=
new
HashMap
<>();
Map
<
String
,
Variable
<?>>
systemVariables
=
new
HashMap
<>();
/*
* index = 0; context.setProperty(Templating.HANDLE_ID_PROPERTY, widgetId);
* context.setProperty(Templating.SIZE_OF_VECTORS_PROPERTY, size);
*/
this
.
initialize
(
null
,
context
);
this
.
initialize
(
null
,
context
);
for
(
Variable
<?>
systemVariable
:
variables
)
{
for
(
Variable
<?>
systemVariable
:
variables
)
{
...
@@ -102,7 +98,6 @@ public class VectorBasedCallback implements BootstrapCallback {
...
@@ -102,7 +98,6 @@ public class VectorBasedCallback implements BootstrapCallback {
for
(
BaseWidget
widget
:
widgets
)
{
for
(
BaseWidget
widget
:
widgets
)
{
List
<
Variable
<?>>
connected
;
List
<
Variable
<?>>
connected
;
// if (widget.getClass().isAssignableFrom(VariableBased.class)) {
if
(
widget
instanceof
VariableBased
)
{
if
(
widget
instanceof
VariableBased
)
{
VariableBased
display
=
(
VariableBased
)
widget
;
VariableBased
display
=
(
VariableBased
)
widget
;
connected
=
display
.
connectWithSystemVariables
(
systemVariables
);
connected
=
display
.
connectWithSystemVariables
(
systemVariables
);
...
@@ -180,4 +175,16 @@ public class VectorBasedCallback implements BootstrapCallback {
...
@@ -180,4 +175,16 @@ public class VectorBasedCallback implements BootstrapCallback {
return
reset
(
context
);
return
reset
(
context
);
}
}
// ---------------------------------------------------------------------------
public
int
getSize
()
{
return
this
.
size
;
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class
// ***************************************************************************
// ---------------------------------------------------------------------------
}
}
CPS/src/lu/list/itis/dkd/tui/utility/graduation/GraduationHelper.java
0 → 100644
View file @
c8d85421
/**
* Copyright Luxembourg Institute of Science and Technology, 2020. All rights reserved. If you wish
* to use this code for any purpose, please contact the author(s).
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package
lu.list.itis.dkd.tui.utility.graduation
;
/**
* @author nico.mack@list.lu
* @since 2.9
* @version 1.0.0
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public
class
GraduationHelper
{
// ***************************************************************************
// * Constants *
// ***************************************************************************
private
static
final
int
[]
DIVISIONS
=
{
3
,
4
,
5
,
10
};
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
private
GraduationHelper
()
{
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
// ***************************************************************************
// ---------------------------------------------------------------------------
private
static
int
getPower
(
double
value
)
{
int
decimals
=
(
int
)
Math
.
floor
(
Math
.
log10
(
value
));
int
powerOfTen
=
(
int
)
Math
.
pow
(
10
,
decimals
);
return
powerOfTen
;
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
public
static
int
getGraduationLevels
(
double
value
)
{
int
powerOfTen
=
getPower
(
value
)
/
10
;
double
normalized
=
value
/
powerOfTen
;
int
numberOfLevels
=
-
1
;
for
(
int
range
=
0
;
range
<
DIVISIONS
.
length
;
range
++)
{
if
(
normalized
%
DIVISIONS
[
range
]
==
0
)
{
numberOfLevels
=
DIVISIONS
[
range
];
break
;
}
}
return
numberOfLevels
;
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class *
// ***************************************************************************
// ---------------------------------------------------------------------------
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment