Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
NUI
TULIP-CPS
Commits
8af4ee59
Commit
8af4ee59
authored
Jun 16, 2020
by
Nico Mack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor API changes and improvements
parent
adc0e622
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
204 additions
and
101 deletions
+204
-101
CPS/src/lu/list/itis/dkd/tui/bootstrapping/VariableBootstrapper.java
...list/itis/dkd/tui/bootstrapping/VariableBootstrapper.java
+2
-0
CPS/src/lu/list/itis/dkd/tui/cps/variable/NumericalVariable.java
.../lu/list/itis/dkd/tui/cps/variable/NumericalVariable.java
+12
-0
CPS/src/lu/list/itis/dkd/tui/utility/ValueRange.java
CPS/src/lu/list/itis/dkd/tui/utility/ValueRange.java
+6
-0
CPS/src/lu/list/itis/dkd/tui/widget/SelectorWidget.java
CPS/src/lu/list/itis/dkd/tui/widget/SelectorWidget.java
+2
-2
CPS/src/lu/list/itis/dkd/tui/widget/builder/BaseSelectorWidgetBuilder.java
...tis/dkd/tui/widget/builder/BaseSelectorWidgetBuilder.java
+144
-0
CPS/src/lu/list/itis/dkd/tui/widget/builder/SelectorWidgetBuilder.java
...st/itis/dkd/tui/widget/builder/SelectorWidgetBuilder.java
+38
-99
No files found.
CPS/src/lu/list/itis/dkd/tui/bootstrapping/VariableBootstrapper.java
View file @
8af4ee59
...
@@ -51,12 +51,14 @@ public class VariableBootstrapper {
...
@@ -51,12 +51,14 @@ public class VariableBootstrapper {
double
scale
=
BootstrappingUtils
.
getContentAsDouble
(
variableNode
,
EquationSystemBundle
.
SCALE_ATTRIBUTE
,
BootstrappingUtils
.
OPTIONAL
,
1.0
,
context
);
double
scale
=
BootstrappingUtils
.
getContentAsDouble
(
variableNode
,
EquationSystemBundle
.
SCALE_ATTRIBUTE
,
BootstrappingUtils
.
OPTIONAL
,
1.0
,
context
);
double
numericValue
=
BootstrappingUtils
.
getContentAsDouble
(
variableNode
,
EquationSystemBundle
.
INITIAL_ATTRIBUTE
,
BootstrappingUtils
.
OPTIONAL
,
0.0
,
context
);
double
numericValue
=
BootstrappingUtils
.
getContentAsDouble
(
variableNode
,
EquationSystemBundle
.
INITIAL_ATTRIBUTE
,
BootstrappingUtils
.
OPTIONAL
,
0.0
,
context
);
int
decimals
=
BootstrappingUtils
.
getContentAsInteger
(
variableNode
,
EquationSystemBundle
.
DECIMALS_ATTRIBUTE
,
BootstrappingUtils
.
OPTIONAL
,
-
1
,
context
);
int
decimals
=
BootstrappingUtils
.
getContentAsInteger
(
variableNode
,
EquationSystemBundle
.
DECIMALS_ATTRIBUTE
,
BootstrappingUtils
.
OPTIONAL
,
-
1
,
context
);
double
epsilon
=
BootstrappingUtils
.
getContentAsDouble
(
variableNode
,
EquationSystemBundle
.
EPSILON_ATTRIBUTE
,
BootstrappingUtils
.
OPTIONAL
,
1
e
-
6
,
context
);
NumericalVariable
numerical
=
new
NumericalVariable
(
name
,
unit
,
numericValue
);
NumericalVariable
numerical
=
new
NumericalVariable
(
name
,
unit
,
numericValue
);
numerical
.
setMinValue
(
minValue
);
numerical
.
setMinValue
(
minValue
);
numerical
.
setMaxValue
(
maxValue
);
numerical
.
setMaxValue
(
maxValue
);
numerical
.
setInitialValue
(
initialValue
);
numerical
.
setInitialValue
(
initialValue
);
numerical
.
setScale
(
scale
);
numerical
.
setScale
(
scale
);
numerical
.
setEpsilon
(
epsilon
);
if
(
decimals
>=
0
)
{
if
(
decimals
>=
0
)
{
numerical
.
setNumberOfDecimals
(
decimals
);
numerical
.
setNumberOfDecimals
(
decimals
);
}
}
...
...
CPS/src/lu/list/itis/dkd/tui/cps/variable/NumericalVariable.java
View file @
8af4ee59
...
@@ -502,6 +502,18 @@ public class NumericalVariable extends Variable<Double> {
...
@@ -502,6 +502,18 @@ public class NumericalVariable extends Variable<Double> {
return
this
.
normalizeValue
(
rawValue
);
return
this
.
normalizeValue
(
rawValue
);
}
}
// ---------------------------------------------------------------------------
/**
*
* @param rawValue
* @return
*/
// ---------------------------------------------------------------------------
public
double
getRoundedToPrecision
(
double
rawValue
)
{
return
this
.
roundToPrecision
(
rawValue
);
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/**
/**
*
*
...
...
CPS/src/lu/list/itis/dkd/tui/utility/ValueRange.java
View file @
8af4ee59
...
@@ -123,6 +123,12 @@ public class ValueRange<T extends Comparable<T>> implements Comparable<T>, Clone
...
@@ -123,6 +123,12 @@ public class ValueRange<T extends Comparable<T>> implements Comparable<T>, Clone
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
public
boolean
valueInRange
(
T
candidate
)
{
return
(
this
.
lowerValue
.
compareTo
(
candidate
)
<=
0
)
&&
(
this
.
upperValue
.
compareTo
(
candidate
)
>
0
);
}
// ---------------------------------------------------------------------------
@Override
@Override
public
ValueRange
<
T
>
clone
()
{
public
ValueRange
<
T
>
clone
()
{
return
new
ValueRange
<
T
>(
this
);
return
new
ValueRange
<
T
>(
this
);
...
...
CPS/src/lu/list/itis/dkd/tui/widget/SelectorWidget.java
View file @
8af4ee59
...
@@ -11,7 +11,7 @@ import lu.list.itis.dkd.tui.utility.AngleUtils;
...
@@ -11,7 +11,7 @@ import lu.list.itis.dkd.tui.utility.AngleUtils;
import
lu.list.itis.dkd.tui.utility.CpsSignature
;
import
lu.list.itis.dkd.tui.utility.CpsSignature
;
import
lu.list.itis.dkd.tui.utility.Point
;
import
lu.list.itis.dkd.tui.utility.Point
;
import
lu.list.itis.dkd.tui.utility.ValueRange
;
import
lu.list.itis.dkd.tui.utility.ValueRange
;
import
lu.list.itis.dkd.tui.widget.builder.SelectorWidgetBuilder
;
import
lu.list.itis.dkd.tui.widget.builder.
Base
SelectorWidgetBuilder
;
import
lu.list.itis.dkd.tui.widget.corona.SelectableCorona
;
import
lu.list.itis.dkd.tui.widget.corona.SelectableCorona
;
import
lu.list.itis.dkd.tui.widget.state.StateManager
;
import
lu.list.itis.dkd.tui.widget.state.StateManager
;
import
lu.list.itis.dkd.tui.widget.state.StateManager.Direction
;
import
lu.list.itis.dkd.tui.widget.state.StateManager.Direction
;
...
@@ -87,7 +87,7 @@ public class SelectorWidget extends ValueWidget {
...
@@ -87,7 +87,7 @@ public class SelectorWidget extends ValueWidget {
*/
*/
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
public
SelectorWidget
(
SelectorWidgetBuilder
<?>
builder
)
{
public
SelectorWidget
(
Base
SelectorWidgetBuilder
<?>
builder
)
{
super
(
builder
);
super
(
builder
);
selectableCoronas
=
getCoronas
(
SelectableCorona
.
class
);
selectableCoronas
=
getCoronas
(
SelectableCorona
.
class
);
...
...
CPS/src/lu/list/itis/dkd/tui/widget/builder/BaseSelectorWidgetBuilder.java
0 → 100644
View file @
8af4ee59
package
lu.list.itis.dkd.tui.widget.builder
;
import
lu.list.itis.dkd.dbc.annotation.Nullable
;
import
lu.list.itis.dkd.tui.bootstrapping.BootstrapCallback
;
import
lu.list.itis.dkd.tui.bootstrapping.BootstrapContext
;
import
lu.list.itis.dkd.tui.bootstrapping.BootstrappingUtils
;
import
lu.list.itis.dkd.tui.exception.BuildException
;
import
lu.list.itis.dkd.tui.feature.selection.SelectionGroup
;
import
lu.list.itis.dkd.tui.utility.CpsNamespace
;
import
lu.list.itis.dkd.tui.utility.Externalization
;
import
lu.list.itis.dkd.tui.widget.SelectorWidget
;
import
org.jdom2.Element
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author nmack
* @date 13 Jan 2016
*
* <br>
* $Log: LayerWidgetBuilder.java,v $
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public
class
BaseSelectorWidgetBuilder
<
B
extends
BaseSelectorWidgetBuilder
<
B
>>
extends
BaseValueWidgetBuilder
<
B
>
{
public
Integer
numberOfPositions
;
public
Integer
preselect
;
public
Map
<
String
,
SelectionGroup
>
selectionGroups
;
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
* Simple no-arg constructor initializing all fields.
*/
// ---------------------------------------------------------------------------
public
BaseSelectorWidgetBuilder
()
{
super
();
preselect
=
SelectorWidget
.
NONE
;
}
// ---------------------------------------------------------------------------
/**
* Constructor initializing all fields from an {@link Element} containing as child elements all the
* information on fields to initialize.
*
* @param rootElement
* The element harbouring, on child nodes, the necessary information to initialize all fields
* of the builder.
* @throws BuildException
* Thrown when any of the fields fail to populate due to an error in reading information
* from the XML file.
*/
// ---------------------------------------------------------------------------
public
BaseSelectorWidgetBuilder
(
Element
rootElement
)
throws
BuildException
{
super
(
rootElement
);
this
.
buildFromBootstrap
(
rootElement
,
null
,
null
);
}
// ---------------------------------------------------------------------------
/**
* Constructor initializing all fields from an {@link Element} containing as child elements all the
* information on fields to initialize.
*
* @param rootElement
* The element harbouring, on child nodes, the necessary information to initialize all fields
* of the builder.
* @throws BuildException
* Thrown when any of the fields fail to populate due to an error in reading information
* from the XML file.
*/
// ---------------------------------------------------------------------------
public
BaseSelectorWidgetBuilder
(
Element
rootElement
,
BootstrapContext
context
,
BootstrapCallback
callback
)
throws
BuildException
{
super
(
rootElement
,
context
,
callback
);
this
.
buildFromBootstrap
(
rootElement
,
context
,
callback
);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitive(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
*
* @param rootElement
* @param context
* @param callback
* @throws BuildException
*/
// ---------------------------------------------------------------------------
private
void
buildFromBootstrap
(
@Nullable
Element
rootElement
,
BootstrapContext
context
,
BootstrapCallback
callback
)
throws
BuildException
{
numberOfPositions
=
BootstrappingUtils
.
getContentAsInteger
(
rootElement
,
CpsNamespace
.
POSITIONS_NODE
,
BootstrappingUtils
.
OPTIONAL
,
SelectorWidget
.
NONE
,
context
);
preselect
=
BootstrappingUtils
.
getContentAsInteger
(
rootElement
,
Externalization
.
PRESELECT_NODE
,
BootstrappingUtils
.
OPTIONAL
,
SelectorWidget
.
NONE
,
context
);
selectionGroups
=
new
HashMap
<>();
Element
selectionGroupsElement
=
rootElement
.
getChild
(
Externalization
.
SELECTION_GROUPS_NODE
);
if
(
selectionGroupsElement
!=
null
)
{
List
<
Element
>
selectionGroupElements
=
selectionGroupsElement
.
getChildren
(
Externalization
.
SELECTION_GROUP_NODE
);
for
(
Element
selectionGroupElement
:
selectionGroupElements
)
{
SelectionGroup
group
=
new
SelectionGroup
(
selectionGroupElement
);
selectionGroups
.
put
(
group
.
getName
(),
group
);
}
}
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
@SuppressWarnings
(
"unchecked"
)
public
B
withPreselect
(
Integer
index
)
{
this
.
preselect
=
index
;
return
(
B
)
this
;
}
// ---------------------------------------------------------------------------
@Override
public
SelectorWidget
build
()
{
return
new
SelectorWidget
(
this
);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class *
// ***************************************************************************
// ---------------------------------------------------------------------------
}
CPS/src/lu/list/itis/dkd/tui/widget/builder/SelectorWidgetBuilder.java
View file @
8af4ee59
/**
* Copyright Luxembourg Institute of Science and Technology, 2016.
*
* This file is part of TULIP.
*
* TULIP is licensed under a dual-licensing scheme. For non-commercial purposes, the LGPL version 3,
* as stated below, is applicable. For all commercial purposes TULIP is licensed under a LIST
* proprietary license. Please contact LIST at tto@list.lu to obtain a commercial license.
*
* For all non-commercial purposes, TULIP is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, version 3 of the License.
*
* TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with TULIP. If
* not, see <http://www.gnu.org/licenses/lgpl-3.0.html>.
*/
package
lu.list.itis.dkd.tui.widget.builder
;
package
lu.list.itis.dkd.tui.widget.builder
;
import
lu.list.itis.dkd.dbc.annotation.Nullable
;
import
lu.list.itis.dkd.tui.bootstrapping.BootstrapCallback
;
import
lu.list.itis.dkd.tui.bootstrapping.BootstrapCallback
;
import
lu.list.itis.dkd.tui.bootstrapping.BootstrapContext
;
import
lu.list.itis.dkd.tui.bootstrapping.BootstrapContext
;
import
lu.list.itis.dkd.tui.bootstrapping.BootstrappingUtils
;
import
lu.list.itis.dkd.tui.exception.BuildException
;
import
lu.list.itis.dkd.tui.exception.BuildException
;
import
lu.list.itis.dkd.tui.feature.selection.SelectionGroup
;
import
lu.list.itis.dkd.tui.utility.CpsNamespace
;
import
lu.list.itis.dkd.tui.utility.Externalization
;
import
lu.list.itis.dkd.tui.widget.SelectorWidget
;
import
lu.list.itis.dkd.tui.widget.SelectorWidget
;
import
lu.list.itis.dkd.tui.widget.ValueWidget
;
import
org.jdom2.Element
;
import
org.jdom2.Element
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* @author nmack
* The concrete builder that will build a new instance of {@link ValueWidget} with each call to
* @date 13 Jan 2016
* {@link #build()}.
*
*
* <br>
* @author Eric Tobias [eric.tobias@list.lu]
* $Log: LayerWidgetBuilder.java,v $
* @since 1.3
* @version 1.3.0
*/
*/
public
class
SelectorWidgetBuilder
extends
BaseSelectorWidgetBuilder
<
SelectorWidgetBuilder
>
{
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public
class
SelectorWidgetBuilder
<
B
extends
SelectorWidgetBuilder
<
B
>>
extends
BaseValueWidgetBuilder
<
B
>
{
public
Integer
numberOfPositions
;
public
Integer
preselect
;
public
Map
<
String
,
SelectionGroup
>
selectionGroups
;
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
/**
* Simple no-arg constructor initializing all fields.
* Simple no-arg constructor initializing all fields.
*/
*/
// ---------------------------------------------------------------------------
public
SelectorWidgetBuilder
()
{
public
SelectorWidgetBuilder
()
{
super
();
super
();
preselect
=
SelectorWidget
.
NONE
;
}
}
// ---------------------------------------------------------------------------
/**
/**
* Constructor initializing all fields from an {@link Element} containing as child elements all
the
* Constructor initializing all fields from an {@link Element} containing as child elements all
* information on fields to initialize.
*
the
information on fields to initialize.
*
*
* @param rootElement
* @param rootElement
* The element harbouring, on child nodes, the necessary information to initialize all
fields
* The element harbouring, on child nodes, the necessary information to initialize all
* of the builder.
*
fields
of the builder.
* @throws BuildException
* @throws BuildException
* Thrown when any of the fields fail to populate due to an error in reading information
* Thrown when any of the fields fail to populate due to an error in reading information
* from the XML file.
* from the XML file.
*/
*/
// ---------------------------------------------------------------------------
public
SelectorWidgetBuilder
(
Element
rootElement
)
throws
BuildException
{
public
SelectorWidgetBuilder
(
Element
rootElement
)
throws
BuildException
{
super
(
rootElement
);
super
(
rootElement
);
this
.
buildFromBootstrap
(
rootElement
,
null
,
null
);
}
}
// ---------------------------------------------------------------------------
/**
/**
* Constructor initializing all fields from an {@link Element} containing as child elements all
the
* Constructor initializing all fields from an {@link Element} containing as child elements all
* information on fields to initialize.
*
the
information on fields to initialize.
*
*
* @param rootElement
* @param rootElement
* The element harbouring, on child nodes, the necessary information to initialize all
fields
* The element harbouring, on child nodes, the necessary information to initialize all
* of the builder.
*
fields
of the builder.
* @throws BuildException
* @throws BuildException
* Thrown when any of the fields fail to populate due to an error in reading information
* Thrown when any of the fields fail to populate due to an error in reading information
* from the XML file.
* from the XML file.
*/
*/
// ---------------------------------------------------------------------------
public
SelectorWidgetBuilder
(
Element
rootElement
,
BootstrapContext
context
,
BootstrapCallback
callback
)
throws
BuildException
{
public
SelectorWidgetBuilder
(
Element
rootElement
,
BootstrapContext
context
,
BootstrapCallback
callback
)
throws
BuildException
{
super
(
rootElement
,
context
,
callback
);
super
(
rootElement
,
context
,
callback
);
this
.
buildFromBootstrap
(
rootElement
,
context
,
callback
);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitive(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
*
* @param rootElement
* @param context
* @param callback
* @throws BuildException
*/
// ---------------------------------------------------------------------------
private
void
buildFromBootstrap
(
@Nullable
Element
rootElement
,
BootstrapContext
context
,
BootstrapCallback
callback
)
throws
BuildException
{
numberOfPositions
=
BootstrappingUtils
.
getContentAsInteger
(
rootElement
,
CpsNamespace
.
POSITIONS_NODE
,
BootstrappingUtils
.
OPTIONAL
,
SelectorWidget
.
NONE
,
context
);
preselect
=
BootstrappingUtils
.
getContentAsInteger
(
rootElement
,
Externalization
.
PRESELECT_NODE
,
BootstrappingUtils
.
OPTIONAL
,
SelectorWidget
.
NONE
,
context
);
selectionGroups
=
new
HashMap
<>();
Element
selectionGroupsElement
=
rootElement
.
getChild
(
Externalization
.
SELECTION_GROUPS_NODE
);
if
(
selectionGroupsElement
!=
null
)
{
List
<
Element
>
selectionGroupElements
=
selectionGroupsElement
.
getChildren
(
Externalization
.
SELECTION_GROUP_NODE
);
for
(
Element
selectionGroupElement
:
selectionGroupElements
)
{
SelectionGroup
group
=
new
SelectionGroup
(
selectionGroupElement
);
selectionGroups
.
put
(
group
.
getName
(),
group
);
}
}
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
@SuppressWarnings
(
"unchecked"
)
public
B
withPreselect
(
Integer
index
)
{
this
.
preselect
=
index
;
return
(
B
)
this
;
}
}
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
@Override
@Override
public
SelectorWidget
build
()
{
public
SelectorWidget
build
()
{
return
new
SelectorWidget
(
this
);
return
new
SelectorWidget
(
this
);
}
}
}
// ---------------------------------------------------------------------------
\ No newline at end of file
// ***************************************************************************
// * 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