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
TULIP-CPS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
NUI
TULIP-CPS
Commits
62273dfb
Commit
62273dfb
authored
Aug 31, 2017
by
Nico Mack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ArcRangeGraph Corona
parent
fa44bf40
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
1368 additions
and
86 deletions
+1368
-86
CPS/src/lu/list/itis/dkd/tui/bootstrapping/DisplayWidgetBootstrapper.java
...itis/dkd/tui/bootstrapping/DisplayWidgetBootstrapper.java
+7
-6
CPS/src/lu/list/itis/dkd/tui/bootstrapping/VariableBootstrapper.java
...list/itis/dkd/tui/bootstrapping/VariableBootstrapper.java
+6
-6
CPS/src/lu/list/itis/dkd/tui/cps/system/EquationSystemBuilder.java
...u/list/itis/dkd/tui/cps/system/EquationSystemBuilder.java
+1
-4
CPS/src/lu/list/itis/dkd/tui/cps/system/VariableBased.java
CPS/src/lu/list/itis/dkd/tui/cps/system/VariableBased.java
+28
-0
CPS/src/lu/list/itis/dkd/tui/cps/variable/NumericalVariable.java
.../lu/list/itis/dkd/tui/cps/variable/NumericalVariable.java
+4
-0
CPS/src/lu/list/itis/dkd/tui/cps/variable/Variable.java
CPS/src/lu/list/itis/dkd/tui/cps/variable/Variable.java
+13
-0
CPS/src/lu/list/itis/dkd/tui/utility/ValueRange.java
CPS/src/lu/list/itis/dkd/tui/utility/ValueRange.java
+95
-0
CPS/src/lu/list/itis/dkd/tui/widget/SelectorWidget.java
CPS/src/lu/list/itis/dkd/tui/widget/SelectorWidget.java
+25
-20
CPS/src/lu/list/itis/dkd/tui/widget/ValueWidget.java
CPS/src/lu/list/itis/dkd/tui/widget/ValueWidget.java
+13
-13
CPS/src/lu/list/itis/dkd/tui/widget/builder/BaseValueWidgetBuilder.java
...t/itis/dkd/tui/widget/builder/BaseValueWidgetBuilder.java
+4
-13
CPS/src/lu/list/itis/dkd/tui/widget/corona/ArcGraph.java
CPS/src/lu/list/itis/dkd/tui/widget/corona/ArcGraph.java
+40
-20
CPS/src/lu/list/itis/dkd/tui/widget/corona/ArcRangeGraph.java
...src/lu/list/itis/dkd/tui/widget/corona/ArcRangeGraph.java
+478
-0
CPS/src/lu/list/itis/dkd/tui/widget/corona/ValueRangeCorona.java
.../lu/list/itis/dkd/tui/widget/corona/ValueRangeCorona.java
+169
-0
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/ArcGraphBuilder.java
...t/itis/dkd/tui/widget/corona/builder/ArcGraphBuilder.java
+4
-0
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/ArcRangeGraphBuilder.java
...s/dkd/tui/widget/corona/builder/ArcRangeGraphBuilder.java
+69
-0
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseArcRangeGraphBuilder.java
...d/tui/widget/corona/builder/BaseArcRangeGraphBuilder.java
+236
-0
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseValueCoronaBuilder.java
...dkd/tui/widget/corona/builder/BaseValueCoronaBuilder.java
+4
-4
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseValueRangeCoronaBuilder.java
...ui/widget/corona/builder/BaseValueRangeCoronaBuilder.java
+103
-0
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/ValueRangeCoronaBuilder.java
...kd/tui/widget/corona/builder/ValueRangeCoronaBuilder.java
+69
-0
No files found.
CPS/src/lu/list/itis/dkd/tui/bootstrapping/DisplayWidgetBootstrapper.java
View file @
62273dfb
...
...
@@ -14,8 +14,8 @@
package
lu.list.itis.dkd.tui.bootstrapping
;
import
lu.list.itis.dkd.tui.cps.variable.NumericalVariable
;
import
lu.list.itis.dkd.tui.cps.variable.Variable
;
import
lu.list.itis.dkd.tui.cps.variable.tangible.TangibleNumericalVariable
;
import
lu.list.itis.dkd.tui.exception.BuildException
;
import
lu.list.itis.dkd.tui.utility.ColorFactory
;
import
lu.list.itis.dkd.tui.utility.Templating
;
...
...
@@ -105,13 +105,14 @@ public class DisplayWidgetBootstrapper implements BootstrapCallback {
@Override
public
BootstrapContext
preInstantiation
(
Element
node
,
BootstrapContext
context
)
{
context
.
setProperty
(
Templating
.
VARIABLE_NAME_PROPERTY
,
variable
.
getName
());
context
.
setProperty
(
Templating
.
VARIABLE_DISPLAY_NAME_PROPERTY
,
variable
.
getDisplayName
());
context
.
setProperty
(
Templating
.
VARIABLE_UNIT_PROPERTY
,
variable
.
getUnit
());
if
(
variable
instanceof
Tangible
NumericalVariable
)
{
TangibleNumericalVariable
tangibleVariable
=
(
Tangible
NumericalVariable
)
variable
;
context
.
setProperty
(
Templating
.
VARIABLE_MINVALUE_PROPERTY
,
tangibleVariable
.
getMinValue
());
context
.
setProperty
(
Templating
.
VARIABLE_MAXVALUE_PROPERTY
,
tangibleVariable
.
getMaxValue
());
context
.
setProperty
(
Templating
.
VARIABLE_SCALE_PROPERTY
,
tangibleVariable
.
getScale
());
if
(
variable
instanceof
NumericalVariable
)
{
NumericalVariable
numerical
=
(
NumericalVariable
)
variable
;
context
.
setProperty
(
Templating
.
VARIABLE_MINVALUE_PROPERTY
,
numerical
.
getMinValue
());
context
.
setProperty
(
Templating
.
VARIABLE_MAXVALUE_PROPERTY
,
numerical
.
getMaxValue
());
context
.
setProperty
(
Templating
.
VARIABLE_SCALE_PROPERTY
,
numerical
.
getScale
());
}
Color
colour
=
variableColours
.
get
(
index
);
...
...
CPS/src/lu/list/itis/dkd/tui/bootstrapping/VariableBootstrapper.java
View file @
62273dfb
...
...
@@ -15,9 +15,9 @@ package lu.list.itis.dkd.tui.bootstrapping;
import
lu.list.itis.dkd.tui.cps.utility.Externalization
;
import
lu.list.itis.dkd.tui.cps.variable.BooleanVariable
;
import
lu.list.itis.dkd.tui.cps.variable.NumericalVariable
;
import
lu.list.itis.dkd.tui.cps.variable.TextVariable
;
import
lu.list.itis.dkd.tui.cps.variable.Variable
;
import
lu.list.itis.dkd.tui.cps.variable.tangible.TangibleNumericalVariable
;
import
lu.list.itis.dkd.tui.exception.BuildException
;
import
org.jdom2.Element
;
...
...
@@ -43,11 +43,11 @@ public class VariableBootstrapper {
double
scale
=
BootstrappingUtils
.
getContentAsDouble
(
variableNode
,
Externalization
.
SCALE_ATTRIBUTE
,
BootstrappingUtils
.
OPTIONAL
,
1.0
,
context
);
double
numericValue
=
BootstrappingUtils
.
getContentAsDouble
(
variableNode
,
Externalization
.
INITIAL_ATTRIBUTE
,
BootstrappingUtils
.
OPTIONAL
,
0.0
,
context
);
TangibleNumericalVariable
tangibleVariable
=
new
Tangible
NumericalVariable
(
name
,
unit
,
numericValue
);
tangibleVariable
.
setMinValue
(
minValue
);
tangibleVariable
.
setMaxValue
(
maxValue
);
tangibleVariable
.
setScale
(
scale
);
variable
=
tangibleVariable
;
NumericalVariable
numerical
=
new
NumericalVariable
(
name
,
unit
,
numericValue
);
numerical
.
setMinValue
(
minValue
);
numerical
.
setMaxValue
(
maxValue
);
numerical
.
setScale
(
scale
);
variable
=
numerical
;
break
;
case
Externalization
.
LOGIC_TYPE
:
boolean
booleanValue
=
BootstrappingUtils
.
getContentAsBoolean
(
variableNode
,
Externalization
.
INITIAL_ATTRIBUTE
,
BootstrappingUtils
.
OPTIONAL
,
false
,
context
);
...
...
CPS/src/lu/list/itis/dkd/tui/cps/system/EquationSystemBuilder.java
View file @
62273dfb
...
...
@@ -198,7 +198,7 @@ public class EquationSystemBuilder {
variableClass
=
properties
.
getProperty
(
Externalization
.
NUMERIC_VARIABLE_CLASS
);
variable
=
(
Variable
<
T
>)
Class
.
forName
(
variableClass
)
.
getConstructor
(
String
.
class
,
String
.
class
,
d
ouble
.
class
)
.
getConstructor
(
String
.
class
,
String
.
class
,
D
ouble
.
class
)
.
newInstance
(
name
,
unit
,
0
d
);
if
(!
Strings
.
isNullOrEmpty
(
value
))
variable
.
setValue
(
variable
.
valueFromString
(
value
));
...
...
@@ -316,9 +316,6 @@ public class EquationSystemBuilder {
private
Variable
<?>
createVariable
(
HashMap
<
String
,
String
>
attributes
)
{
Variable
<?>
variable
;
// String scale = xmlElement.getAttributeValue(Externalization.SCALE_ATTRIBUTE);
// String decimals = xmlElement.getAttributeValue(Externalization.DECIMALS_ATTRIBUTE);
variable
=
this
.
instantiateVariable
(
attributes
.
get
(
Externalization
.
NAME_ATTRIBUTE
),
attributes
.
get
(
Externalization
.
TYPE_ATTRIBUTE
),
attributes
.
get
(
Externalization
.
UNIT_ATTRIBUTE
),
...
...
CPS/src/lu/list/itis/dkd/tui/cps/system/VariableBased.java
0 → 100644
View file @
62273dfb
/**
* Copyright Luxembourg Institute of Science and Technology, 2017. 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.cps.system
;
import
lu.list.itis.dkd.tui.cps.variable.Variable
;
import
java.util.Map
;
/**
* @author Nico Mack [nico.mack@list.lu]
* @since 2.5
* @version 2.5.0
*/
public
interface
VariableBased
{
public
void
connectWithSystemVariables
(
Map
<
String
,
Variable
<?>>
systemVariables
);
}
CPS/src/lu/list/itis/dkd/tui/cps/variable/NumericalVariable.java
View file @
62273dfb
...
...
@@ -110,6 +110,10 @@ public class NumericalVariable extends Variable<Double> {
return
builder
.
toString
();
}
public
String
formatValue
()
{
return
format
.
format
(
value
/
scale
);
}
/**
* {@inheritDoc}<br>
* <br>
...
...
CPS/src/lu/list/itis/dkd/tui/cps/variable/Variable.java
View file @
62273dfb
...
...
@@ -386,6 +386,19 @@ public abstract class Variable<V> implements Cloneable {
this
.
notifyInputChangeListeners
(
new
InputEvent
(
this
));
}
@SuppressWarnings
(
"unchecked"
)
public
static
<
V
extends
Variable
<?>>
V
castTo
(
Variable
<?>
variable
,
Class
<
V
>
clazz
)
{
V
casted
=
null
;
if
(
variable
.
getClass
().
isAssignableFrom
(
clazz
))
{
casted
=
(
V
)
variable
;
}
else
{
LOGGER
.
error
(
"Variable {} of type {} could not be cast to NumericalVariable!"
,
variable
.
getName
(),
variable
.
getClass
().
getSimpleName
());
//$NON-NLS-1$
}
return
casted
;
}
/** {@inheritDoc} */
@Override
public
abstract
Variable
<
V
>
clone
();
...
...
CPS/src/lu/list/itis/dkd/tui/utility/ValueRange.java
0 → 100644
View file @
62273dfb
/**
* Copyright Luxembourg Institute of Science and Technology, 2017. 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
;
/**
* @author Nico Mack [nico.mack@list.lu]
* @since 2.5
* @version 2.5.0
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public
class
ValueRange
{
private
Object
lowerValue
;
private
Object
upperValue
;
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
public
ValueRange
(
Object
lower
,
Object
upper
)
{
this
.
lowerValue
=
lower
;
this
.
upperValue
=
upper
;
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
* Simple getter method for lowerValue.
*
* @return The value of lowerValue.
*/
// ---------------------------------------------------------------------------
public
Object
getLowerValue
()
{
return
lowerValue
;
}
// ---------------------------------------------------------------------------
/**
* Simple setter method for lowerValue.
*
* @param lowerValue
* The value to set lowerValue to.
*/
// ---------------------------------------------------------------------------
public
void
setLowerValue
(
Object
lowerValue
)
{
this
.
lowerValue
=
lowerValue
;
}
// ---------------------------------------------------------------------------
/**
* Simple getter method for upperValue.
*
* @return The value of upperValue.
*/
// ---------------------------------------------------------------------------
public
Object
getUpperValue
()
{
return
upperValue
;
}
// ---------------------------------------------------------------------------
/**
* Simple setter method for upperValue.
*
* @param upperValue
* The value to set upperValue to.
*/
// ---------------------------------------------------------------------------
public
void
setUpperValue
(
Object
upperValue
)
{
this
.
upperValue
=
upperValue
;
}
}
CPS/src/lu/list/itis/dkd/tui/widget/SelectorWidget.java
View file @
62273dfb
...
...
@@ -3,12 +3,13 @@ package lu.list.itis.dkd.tui.widget;
import
lu.list.itis.dkd.tui.adapter.TangibleObject
;
import
lu.list.itis.dkd.tui.utility.Point
;
import
lu.list.itis.dkd.tui.widget.builder.SelectorWidgetBuilder
;
import
lu.list.itis.dkd.tui.widget.corona.
Indexed
Corona
;
import
lu.list.itis.dkd.tui.widget.corona.
Selectable
Corona
;
import
lu.list.itis.dkd.tui.widget.state.StateManager
;
import
com.google.common.base.Preconditions
;
import
com.google.common.collect.Multimap
;
import
com.google.common.collect.TreeMultimap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -82,16 +83,20 @@ public class SelectorWidget extends ValueWidget {
// ---------------------------------------------------------------------------
protected
int
getNumberOfPositions
()
{
List
<
IndexedCorona
>
selectableCoronas
=
getCoronas
(
Indexed
Corona
.
class
);
HashSet
<
Integer
>
alreadySeen
=
new
HashSet
<>
();
List
<
SelectableCorona
>
selectableCoronas
=
getCoronas
(
Selectable
Corona
.
class
);
Multimap
<
Integer
,
SelectableCorona
>
alreadySeen
=
TreeMultimap
.
create
();
for
(
Indexed
Corona
corona
:
selectableCoronas
)
{
for
(
Selectable
Corona
corona
:
selectableCoronas
)
{
Integer
index
=
corona
.
getIndex
();
Preconditions
.
checkArgument
(!
alreadySeen
.
contains
(
index
),
"Duplicate Index detected for indexed Corona!"
);
//$NON-NLS-1$
alreadySeen
.
add
(
index
);
if
(
alreadySeen
.
containsKey
(
index
))
{
for
(
SelectableCorona
identical
:
alreadySeen
.
get
(
index
))
{
Preconditions
.
checkArgument
(!
identical
.
getClass
().
equals
(
corona
.
getClass
()),
"Duplicate Index detected for indexed Corona!"
);
//$NON-NLS-1$
}
}
alreadySeen
.
put
(
index
,
corona
);
}
return
selectableCoronas
.
size
();
return
alreadySeen
.
keySet
()
.
size
();
}
// ---------------------------------------------------------------------------
...
...
@@ -103,20 +108,20 @@ public class SelectorWidget extends ValueWidget {
// ---------------------------------------------------------------------------
protected
float
moduloTwoPi
(
float
rawAngle
)
{
double
angle
=
rawAngle
%
TWO_PI
;
if
(
angle
<
0
)
angle
+=
TWO_PI
;
return
(
float
)
angle
;
}
//
protected float moduloTwoPi(float rawAngle) {
//
double angle = rawAngle % TWO_PI;
//
if (angle < 0)
//
angle += TWO_PI;
//
return (float) angle;
//
//
}
// ---------------------------------------------------------------------------
protected
int
getCurrentPosition
(
float
newAngle
)
{
double
segment
=
TWO_PI
/
numberOfPositions
;
int
current
=
0
;
float
angle
=
this
.
moduloTwoPi
(
newAngle
);
float
angle
=
Point
.
moduloTwoPi
(
newAngle
);
// detect in which segment the current rotation is
for
(
int
position
=
0
;
position
<
numberOfPositions
;
position
++)
{
...
...
@@ -152,7 +157,7 @@ public class SelectorWidget extends ValueWidget {
protected
void
selectPosition
(
int
position
)
{
if
(
position
!=
currentPosition
)
{
this
.
getCoronas
(
Indexed
Corona
.
class
).
forEach
(
indexed
->
indexed
.
setSelected
(
indexed
.
getIndex
()
==
position
));
this
.
getCoronas
(
Selectable
Corona
.
class
).
forEach
(
indexed
->
indexed
.
setSelected
(
indexed
.
getIndex
()
==
position
));
if
(
variable
!=
null
)
{
variable
.
setValue
((
double
)
position
);
...
...
@@ -173,7 +178,7 @@ public class SelectorWidget extends ValueWidget {
this
.
selectPosition
(
presetPosition
);
Point
centre
=
this
.
getPosition
();
if
(
centre
!=
null
)
{
presetAngleOffset
=
this
.
moduloTwoPi
(
this
.
getCurrentAngle
(
currentPosition
)
-
(
centre
.
getAngle
()
-
presetAngleOffset
));
presetAngleOffset
=
Point
.
moduloTwoPi
(
this
.
getCurrentAngle
(
currentPosition
)
-
(
centre
.
getAngle
()
-
presetAngleOffset
));
}
}
}
...
...
@@ -203,7 +208,7 @@ public class SelectorWidget extends ValueWidget {
@Override
public
void
actionMove
(
TangibleObject
tuioObject
)
{
double
angle
=
this
.
moduloTwoPi
(
tuioObject
.
getAngle
()
+
presetAngleOffset
);
double
angle
=
Point
.
moduloTwoPi
(
tuioObject
.
getAngle
()
+
presetAngleOffset
);
TangibleObject
clone
=
tuioObject
.
constrainedClone
(
new
Point
(
tuioObject
.
getX
(),
tuioObject
.
getY
(),
(
float
)
angle
));
super
.
actionMove
(
clone
);
...
...
@@ -235,7 +240,7 @@ public class SelectorWidget extends ValueWidget {
isPersistent
=
this
.
isPersistent
(
tuioObject
.
getObjectId
());
int
position
=
(
isPersistent
)
?
currentPosition
:
presetPosition
;
presetAngleOffset
=
(
isPersistent
)
?
this
.
moduloTwoPi
(
this
.
getCurrentAngle
(
position
)
-
tuioObject
.
getAngle
())
:
0
;
presetAngleOffset
=
(
isPersistent
)
?
Point
.
moduloTwoPi
(
this
.
getCurrentAngle
(
position
)
-
tuioObject
.
getAngle
())
:
0
;
TangibleObject
clone
=
tuioObject
.
constrainedClone
(
new
Point
(
tuioObject
.
getX
(),
tuioObject
.
getY
(),
presetAngleOffset
));
super
.
actionDrop
(
clone
);
...
...
CPS/src/lu/list/itis/dkd/tui/widget/ValueWidget.java
View file @
62273dfb
...
...
@@ -26,8 +26,8 @@ import lu.list.itis.dkd.tui.adapter.TangibleObject;
import
lu.list.itis.dkd.tui.content.InformationProvider
;
import
lu.list.itis.dkd.tui.content.InformationReceiver
;
import
lu.list.itis.dkd.tui.cps.utility.Externalization
;
import
lu.list.itis.dkd.tui.cps.variable.NumericalVariable
;
import
lu.list.itis.dkd.tui.cps.variable.Variable
;
import
lu.list.itis.dkd.tui.cps.variable.tangible.TangibleNumericalVariable
;
import
lu.list.itis.dkd.tui.utility.Point
;
import
lu.list.itis.dkd.tui.widget.builder.BaseValueWidgetBuilder
;
import
lu.list.itis.dkd.tui.widget.corona.ConditionalCorona
;
...
...
@@ -69,7 +69,7 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
/** The value of the angle that is considered as one step. */
protected
double
stepSize
;
/** The variable holding the value to be stored and manipulated by the widget. */
protected
Tangible
NumericalVariable
variable
;
protected
NumericalVariable
variable
;
/** The base value to be set for the variable. */
protected
double
initialValue
;
/** Whether the value held by the widget is to be modified on a rotation of a handle. */
...
...
@@ -150,14 +150,14 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
private
void
buildFromProperties
()
{
if
(
this
.
variable
==
null
)
{
String
variableName
=
((
this
.
name
!=
null
)
&&
(
this
.
name
.
length
()
>
0
))
?
this
.
name
:
DEFAULT_VARIABLE
;
this
.
variable
=
new
TangibleNumericalVariable
(
variableName
,
Externalization
.
EMPTY_STRING
,
0
);
this
.
variable
=
new
NumericalVariable
(
variableName
,
Externalization
.
EMPTY_STRING
,
0
d
);
}
if
(!
modifyValueOnRotation
)
{
this
.
initialValue
=
getVariable
().
get
Information
();
this
.
initialValue
=
getVariable
().
get
Value
();
getVariable
().
setValue
(
0
d
);
}
else
{
this
.
initialValue
=
getVariable
().
get
Information
();
this
.
initialValue
=
getVariable
().
get
Value
();
}
constrainted
=
!(
Double
.
isNaN
(
lowerStopAngle
)
||
Double
.
isNaN
(
upperStopAngle
));
...
...
@@ -278,7 +278,7 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
@Override
public
@Nullable
Double
getInformation
(
Point
position
)
{
return
variable
.
get
Information
(
position
);
return
variable
.
get
Value
(
);
}
// ---------------------------------------------------------------------------
...
...
@@ -298,7 +298,7 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
*/
// ---------------------------------------------------------------------------
public
Tangible
NumericalVariable
getVariable
()
{
public
NumericalVariable
getVariable
()
{
return
variable
;
}
...
...
@@ -312,7 +312,7 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
*/
// ---------------------------------------------------------------------------
public
void
setVariable
(
Tangible
NumericalVariable
variable
)
{
public
void
setVariable
(
NumericalVariable
variable
)
{
this
.
variable
=
variable
;
for
(
ConditionalCorona
conditionalCorona
:
getCoronas
(
ConditionalCorona
.
class
))
{
...
...
@@ -324,9 +324,9 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
public
void
connectWithInputs
(
Map
<
String
,
Variable
<?>>
inputs
)
{
if
((
inputs
!=
null
)
&&
inputs
.
containsKey
(
this
.
variable
.
getName
()))
{
Variable
<?>
input
=
inputs
.
get
(
this
.
variable
.
getName
()
);
if
(
this
.
variable
.
getClass
().
isAssignableFrom
(
input
.
getClass
())
)
{
this
.
variable
=
(
TangibleNumericalVariable
)
input
;
NumericalVariable
numeric
=
Variable
.
castTo
(
inputs
.
get
(
this
.
variable
.
getName
()),
NumericalVariable
.
class
);
if
(
numeric
!=
null
)
{
this
.
variable
=
numeric
;
}
}
}
...
...
@@ -347,12 +347,12 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
String
typeName
=
((
ParameterizedType
)
type
).
getActualTypeArguments
()[
0
].
getTypeName
();
if
(
typeName
.
equals
(
String
.
class
.
getTypeName
()))
{
String
information
=
(
variable
.
get
Information
()
!=
null
)
?
variable
.
getInformation
().
toString
()
:
null
;
String
information
=
(
variable
.
get
Value
()
!=
null
)
?
variable
.
getValue
().
toString
()
:
null
;
((
InformationReceiver
<
String
>)
corona
).
setInformation
(
information
);
continue
;
}
if
(
typeName
.
equals
(
Double
.
class
.
getTypeName
()))
{
((
InformationReceiver
<
Double
>)
corona
).
setInformation
(
variable
.
get
Information
());
((
InformationReceiver
<
Double
>)
corona
).
setInformation
(
variable
.
get
Value
());
continue
;
}
}
...
...
CPS/src/lu/list/itis/dkd/tui/widget/builder/BaseValueWidgetBuilder.java
View file @
62273dfb
...
...
@@ -26,7 +26,7 @@ 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.bootstrapping.VariableBootstrapper
;
import
lu.list.itis.dkd.tui.cps.variable.
tangible.Tangible
NumericalVariable
;
import
lu.list.itis.dkd.tui.cps.variable.NumericalVariable
;
import
lu.list.itis.dkd.tui.exception.BuildException
;
import
lu.list.itis.dkd.tui.utility.Externalization
;
import
lu.list.itis.dkd.tui.widget.ValueWidget
;
...
...
@@ -56,12 +56,9 @@ public abstract class BaseValueWidgetBuilder<B extends BaseValueWidgetBuilder<B>
/** The value of the angle that is considered as one step. */
public
double
stepSize
;
/** The variable holding the value to be stored and manipulated by the widget. */
public
Tangible
NumericalVariable
variable
;
public
NumericalVariable
variable
;
/** Whether the value held by the widget is to be modified on a rotation of a handle. */
public
boolean
modifyValueOnRotation
=
false
;
/** Whether the value is dynamic, that is if it changes and is not simply triggered. */
@Deprecated
public
boolean
dynamic
;
/**
* Simple no-arg constructor for the {@link BaseValueWidgetBuilder}.
...
...
@@ -116,7 +113,7 @@ public abstract class BaseValueWidgetBuilder<B extends BaseValueWidgetBuilder<B>
* @throws BuildException
*/
private
void
buildFromBootstrap
(
@Nullable
Element
rootElement
,
BootstrapContext
context
,
BootstrapCallback
callback
)
throws
BuildException
{
variable
=
(
Tangible
NumericalVariable
)
VariableBootstrapper
.
buildVariableFromElement
(
rootElement
.
getChild
(
Externalization
.
VARIABLE_NODE
),
context
,
callback
);
variable
=
(
NumericalVariable
)
VariableBootstrapper
.
buildVariableFromElement
(
rootElement
.
getChild
(
Externalization
.
VARIABLE_NODE
),
context
,
callback
);
modifyValueOnRotation
=
BootstrappingUtils
.
getContentAsBoolean
(
rootElement
,
Externalization
.
MODIFY_VALUE_ON_ROTATION_NODE
,
BootstrappingUtils
.
OPTIONAL
,
true
,
context
);
if
(
modifyValueOnRotation
)
{
...
...
@@ -190,17 +187,11 @@ public abstract class BaseValueWidgetBuilder<B extends BaseValueWidgetBuilder<B>
* @return An instance of the builder for chain-calling.
*/
@SuppressWarnings
(
"unchecked"
)
public
B
withVariable
(
Tangible
NumericalVariable
_variable
)
{
public
B
withVariable
(
NumericalVariable
_variable
)
{
this
.
variable
=
_variable
;
return
(
B
)
this
;
}
/*
* @SuppressWarnings("unchecked") public B variableIsDynamic(boolean dynamic) { this.dynamic =
* dynamic; return (B) this; }
*/
/** {@inheritDoc} */
@Override
public
abstract
ValueWidget
build
();
...
...
CPS/src/lu/list/itis/dkd/tui/widget/corona/ArcGraph.java
View file @
62273dfb
...
...
@@ -34,6 +34,7 @@ import java.awt.geom.Rectangle2D;
// ***************************************************************************
public
class
ArcGraph
extends
ValueCorona
{
private
String
title
;
private
double
innerRadius
;
private
double
outerRadius
;
private
int
startAngle
;
...
...
@@ -54,6 +55,8 @@ public class ArcGraph extends ValueCorona {
private
Stroke
borderStroke
;
private
int
strokeWidth
;
private
int
rampingTime
;
private
Area
outer
;
private
Area
inner
;
private
Area
arc
;
...
...
@@ -81,6 +84,8 @@ public class ArcGraph extends ValueCorona {
public
ArcGraph
(
ArcGraphBuilder
builder
)
{
super
(
builder
);
this
.
title
=
builder
.
title
;
this
.
startAngle
=
builder
.
startAngle
;
this
.
arcSpan
=
builder
.
arcSpan
;
this
.
relative
=
builder
.
relative
;
...
...
@@ -97,6 +102,7 @@ public class ArcGraph extends ValueCorona {
this
.
labelShape
=
builder
.
labelShape
;
this
.
textFont
=
builder
.
textFont
;
this
.
strokeWidth
=
builder
.
strokeWidth
;
this
.
rampingTime
=
builder
.
rampingTime
;
this
.
buildFromProperties
();
}
...
...
@@ -129,6 +135,7 @@ public class ArcGraph extends ValueCorona {
this
.
labelShape
=
original
.
labelShape
;
this
.
textFont
=
original
.
textFont
;
this
.
strokeWidth
=
original
.
strokeWidth
;
this
.
rampingTime
=
original
.
rampingTime
;
this
.
buildFromProperties
();
}
...
...
@@ -142,6 +149,10 @@ public class ArcGraph extends ValueCorona {
private
void
buildFromProperties
()
{
double
diameter
;
if
((
this
.
label
==
null
)
||
this
.
label
.
isEmpty
())
{
this
.
label
=
this
.
variable
.
getDisplayName
();
}
diameter
=
2
*
innerRadius
;
inner
=
new
Area
(
new
Ellipse2D
.
Double
(-
innerRadius
,
-
innerRadius
,
diameter
,
diameter
));
...
...
@@ -287,20 +298,24 @@ public class ArcGraph extends ValueCorona {
Graphics2D
localCanvas
=
(
Graphics2D
)
canvas
.
create
();
centre
.
toScreenCoordinates
();
if
(
initialTranslation
!=
null
)
initialTranslation
.
toScreenCoordinates
();
Point
drawAt
=
centre
.
add
(
initialTranslation
);
// centre.toScreenCoordinates();
// if (initialTranslation != null)
// initialTranslation.toScreenCoordinates();
// Point drawAt = centre.add(initialTranslation);
//
// if (this.rotateWithHandle) {
// angle = (float) ((drawAt.getAngle() - rotation) % TWO_PI);
// } else {
// rotation = (float) ((drawAt.getAngle() - angle) % TWO_PI);
// }
//
// AffineTransform translation = new AffineTransform();
// translation.translate(drawAt.x, drawAt.y);
// translation.rotate(angle);
AffineTransform
translation
=
this
.
getTransform
(
null
);
if
(
this
.
rotateWithHandle
)
{
angle
=
(
float
)
((
drawAt
.
getAngle
()
-
rotation
)
%
TWO_PI
);
}
else
{
rotation
=
(
float
)
((
drawAt
.
getAngle
()
-
angle
)
%
TWO_PI
);
}
AffineTransform
translation
=
new
AffineTransform
();
translation
.
translate
(
drawAt
.
x
,
drawAt
.
y
);
translation
.
rotate
(
angle
);
localCanvas
.
setTransform
(
translation
);
if
(
this
.
opacity
<
1.0f
)
...
...
@@ -360,19 +375,24 @@ public class ArcGraph extends ValueCorona {
if
(
variable
!=
null
)
{
double
value
=
this
.
variable
.
getValue
();
if
((
balisticTimeline
!=
null
)
&&
(!
balisticTimeline
.
isDone
()))
balisticTimeline
.
cancel
();
if
(
rampingTime
>
0
)
{
if
((
balisticTimeline
!=
null
)
&&
(!
balisticTimeline
.
isDone
()))
balisticTimeline
.
cancel
();
balisticTimeline
=
new
Timeline
(
this
);
balisticTimeline
.
addPropertyToInterpolate
(
"shownValue"
,
shownValue
,
value
);
//$NON-NLS-1$
balisticTimeline
.
setDuration
(
500
);
balisticTimeline
.
play
();
balisticTimeline
=
new
Timeline
(
this
);
balisticTimeline
.
addPropertyToInterpolate
(
"shownValue"
,
shownValue
,
value
);
//$NON-NLS-1$
balisticTimeline
.
setDuration
(
rampingTime
);