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
39819854
Commit
39819854
authored
Apr 04, 2017
by
Nico Mack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added DisplayWidget
parent
cb5e1e6b
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
474 additions
and
21 deletions
+474
-21
CPS/src/lu/list/itis/dkd/tui/bootstrapping/DisplayWidgetBootstrapper.java
...itis/dkd/tui/bootstrapping/DisplayWidgetBootstrapper.java
+144
-0
CPS/src/lu/list/itis/dkd/tui/bootstrapping/VariableBootstrapper.java
...list/itis/dkd/tui/bootstrapping/VariableBootstrapper.java
+3
-3
CPS/src/lu/list/itis/dkd/tui/cps/system/EquationSystemBuilder.java
...u/list/itis/dkd/tui/cps/system/EquationSystemBuilder.java
+1
-1
CPS/src/lu/list/itis/dkd/tui/cps/system/executor/SqlExecutor.java
...lu/list/itis/dkd/tui/cps/system/executor/SqlExecutor.java
+9
-4
CPS/src/lu/list/itis/dkd/tui/widget/DisplayWidget.java
CPS/src/lu/list/itis/dkd/tui/widget/DisplayWidget.java
+121
-0
CPS/src/lu/list/itis/dkd/tui/widget/SelectorWidget.java
CPS/src/lu/list/itis/dkd/tui/widget/SelectorWidget.java
+15
-4
CPS/src/lu/list/itis/dkd/tui/widget/ValueWidget.java
CPS/src/lu/list/itis/dkd/tui/widget/ValueWidget.java
+14
-2
CPS/src/lu/list/itis/dkd/tui/widget/builder/BaseDisplayWidgetBuilder.java
...itis/dkd/tui/widget/builder/BaseDisplayWidgetBuilder.java
+82
-0
CPS/src/lu/list/itis/dkd/tui/widget/builder/DisplayWidgetBuilder.java
...ist/itis/dkd/tui/widget/builder/DisplayWidgetBuilder.java
+70
-0
CPS/src/lu/list/itis/dkd/tui/widget/corona/ArcGraph.java
CPS/src/lu/list/itis/dkd/tui/widget/corona/ArcGraph.java
+1
-1
CPS/src/lu/list/itis/dkd/tui/widget/corona/ValueCorona.java
CPS/src/lu/list/itis/dkd/tui/widget/corona/ValueCorona.java
+4
-4
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/ArcGraphBuilder.java
...t/itis/dkd/tui/widget/corona/builder/ArcGraphBuilder.java
+5
-1
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseValueCoronaBuilder.java
...dkd/tui/widget/corona/builder/BaseValueCoronaBuilder.java
+5
-1
No files found.
CPS/src/lu/list/itis/dkd/tui/bootstrapping/DisplayWidgetBootstrapper.java
0 → 100644
View file @
39819854
/**
* 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.bootstrapping
;
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
;
import
lu.list.itis.dkd.tui.widget.BaseWidget
;
import
lu.list.itis.dkd.tui.widget.DisplayWidget
;
import
org.jdom2.Element
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.awt.Color
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Vector
;
/**
* @author mack
* @since [major].[minor]
* @version [major].[minor].[micro]
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public
class
DisplayWidgetBootstrapper
implements
BootstrapCallback
{
private
List
<
Variable
<?>>
variables
;
private
Iterator
<
Variable
<?>>
variableIterator
;
private
Variable
<?>
variable
;
private
Vector
<
Color
>
variableColours
;
private
Integer
index
;
// ***************************************************************************
// * Constants *
// ***************************************************************************
private
static
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
DisplayWidgetBootstrapper
.
class
.
getName
());
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
public
DisplayWidgetBootstrapper
(
List
<
Variable
<?>>
variables
)
{
this
.
variables
=
variables
;
this
.
variableColours
=
ColorFactory
.
makeRainbowColours
(
variables
.
size
());
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
public
List
<
BaseWidget
>
buildWidgetsFromVariables
(
Element
template
,
Integer
widgetId
,
BootstrapContext
context
,
BootstrapCallback
callback
)
throws
BuildException
{
List
<
BaseWidget
>
widgets
=
null
;
index
=
0
;
context
.
setProperty
(
Templating
.
HANDLE_ID_PROPERTY
,
widgetId
);
context
.
setProperty
(
Templating
.
NUMBER_OF_VARIABLES_PROPERTY
,
variables
.
size
());
variableIterator
=
variables
.
iterator
();
if
(
variableIterator
.
hasNext
())
{
this
.
variable
=
variableIterator
.
next
();
widgets
=
TangibleObjectBootstrapper
.
buildWidgetFromTemplate
(
template
,
context
,
this
);
for
(
BaseWidget
widget
:
widgets
)
{
if
(
widget
.
getClass
().
isAssignableFrom
(
DisplayWidget
.
class
))
{
DisplayWidget
display
=
(
DisplayWidget
)
widget
;
display
.
setVariables
(
this
.
variables
);
for
(
Variable
<?>
displayVariable
:
variables
)
displayVariable
.
addListener
(
display
);
}
}
}
else
{
LOGGER
.
warn
(
"Encountered a Widget without any variables. Won't build Widget! ID of offending Widget is {}"
,
widgetId
);
//$NON-NLS-1$
}
return
widgets
;
}
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
@Override
public
BootstrapContext
preInstantiation
(
Element
node
,
BootstrapContext
context
)
{
context
.
setProperty
(
Templating
.
VARIABLE_NAME_PROPERTY
,
variable
.
getName
());
context
.
setProperty
(
Templating
.
VARIABLE_UNIT_PROPERTY
,
variable
.
getUnit
());
if
(
variable
instanceof
TangibleNumericalVariable
)
{
TangibleNumericalVariable
tangibleVariable
=
(
TangibleNumericalVariable
)
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
());
}
Color
colour
=
variableColours
.
get
(
index
);
context
.
setProperty
(
Templating
.
VARIABLE_COLOUR_PROPERTY
,
colour
.
getRGB
());
return
context
;
}
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
@Override
public
BootstrapContext
postInstantiation
(
Element
node
,
BootstrapContext
context
)
{
return
context
;
}
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
@Override
public
BootstrapContext
next
(
BootstrapContext
context
)
{
if
(
variableIterator
.
hasNext
())
{
this
.
variable
=
variableIterator
.
next
();
this
.
index
++;
}
return
context
;
}
// ---------------------------------------------------------------------------
}
CPS/src/lu/list/itis/dkd/tui/bootstrapping/VariableBootstrapper.java
View file @
39819854
...
@@ -27,8 +27,8 @@ import org.jdom2.Element;
...
@@ -27,8 +27,8 @@ import org.jdom2.Element;
* @version [major].[minor].[micro]
* @version [major].[minor].[micro]
*/
*/
public
class
VariableBootstrapper
{
public
class
VariableBootstrapper
{
public
static
Variable
buildVariableFromElement
(
Element
variableNode
,
BootstrapContext
context
,
BootstrapCallback
callback
)
throws
BuildException
{
public
static
Variable
<?>
buildVariableFromElement
(
Element
variableNode
,
BootstrapContext
context
,
BootstrapCallback
callback
)
throws
BuildException
{
Variable
variable
=
null
;
Variable
<?>
variable
=
null
;
if
(
variableNode
==
null
)
if
(
variableNode
==
null
)
return
null
;
return
null
;
...
@@ -56,7 +56,7 @@ public class VariableBootstrapper {
...
@@ -56,7 +56,7 @@ public class VariableBootstrapper {
break
;
break
;
default
:
default
:
throw
new
BuildException
(
"Don't know how to build a Variable of type "
+
type
);
throw
new
BuildException
(
"Don't know how to build a Variable of type "
+
type
);
//$NON-NLS-1$
}
}
return
variable
;
return
variable
;
...
...
CPS/src/lu/list/itis/dkd/tui/cps/system/EquationSystemBuilder.java
View file @
39819854
...
@@ -315,7 +315,7 @@ public class EquationSystemBuilder {
...
@@ -315,7 +315,7 @@ public class EquationSystemBuilder {
numericVariable
.
setMinValue
(
this
.
getDoubleValue
(
attributes
.
get
(
Externalization
.
MINIMUM_ATTRIBUTE
)));
numericVariable
.
setMinValue
(
this
.
getDoubleValue
(
attributes
.
get
(
Externalization
.
MINIMUM_ATTRIBUTE
)));
if
(!
Strings
.
isNullOrEmpty
(
attributes
.
get
(
Externalization
.
MAXIMUM_ATTRIBUTE
)))
if
(!
Strings
.
isNullOrEmpty
(
attributes
.
get
(
Externalization
.
MAXIMUM_ATTRIBUTE
)))
numericVariable
.
setM
in
Value
(
this
.
getDoubleValue
(
attributes
.
get
(
Externalization
.
MAXIMUM_ATTRIBUTE
)));
numericVariable
.
setM
ax
Value
(
this
.
getDoubleValue
(
attributes
.
get
(
Externalization
.
MAXIMUM_ATTRIBUTE
)));
if
(!
Strings
.
isNullOrEmpty
(
attributes
.
get
(
Externalization
.
EQUATE_ATTRIBUTE
)))
if
(!
Strings
.
isNullOrEmpty
(
attributes
.
get
(
Externalization
.
EQUATE_ATTRIBUTE
)))
numericVariable
.
setEquate
(
attributes
.
get
(
Externalization
.
EQUATE_ATTRIBUTE
));
numericVariable
.
setEquate
(
attributes
.
get
(
Externalization
.
EQUATE_ATTRIBUTE
));
...
...
CPS/src/lu/list/itis/dkd/tui/cps/system/executor/SqlExecutor.java
View file @
39819854
...
@@ -193,9 +193,8 @@ public class SqlExecutor extends Executor {
...
@@ -193,9 +193,8 @@ public class SqlExecutor extends Executor {
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
private
PreparedStatement
setStatementParameters
(
PreparedStatement
statement
,
List
<
String
>
placeholders
,
Map
<
String
,
Object
>
context
)
throws
SQLException
{
private
PreparedStatement
setStatementParameters
(
PreparedStatement
statement
,
List
<
String
>
placeholders
,
Map
<
String
,
Object
>
context
)
throws
SQLException
{
for
(
String
placeholder
:
placeholders
)
{
int
index
=
1
;
int
index
=
1
;
for
(
String
placeholder
:
placeholders
)
{
if
(
context
.
containsKey
(
placeholder
))
{
if
(
context
.
containsKey
(
placeholder
))
{
Object
value
=
context
.
get
(
placeholder
);
Object
value
=
context
.
get
(
placeholder
);
if
(
value
instanceof
Array
)
if
(
value
instanceof
Array
)
...
@@ -385,8 +384,14 @@ public class SqlExecutor extends Executor {
...
@@ -385,8 +384,14 @@ public class SqlExecutor extends Executor {
}
}
}
else
{
}
else
{
// Column value is a scalar
// Column value is a scalar
if
(
columnValues
.
size
()
>
0
)
{
Object
[]
values
=
columnValues
.
get
(
0
);
Object
[]
values
=
columnValues
.
get
(
0
);
variable
.
setValueFromObject
(
values
[
index
]);
variable
.
setValueFromObject
(
values
[
index
]);
}
else
{
if
(
LOGGER
.
isTraceEnabled
())
{
LOGGER
.
trace
(
"Query returned no results!"
);
//$NON-NLS-1$
}
}
}
}
}
}
if
(
LOGGER
.
isTraceEnabled
())
{
if
(
LOGGER
.
isTraceEnabled
())
{
...
...
CPS/src/lu/list/itis/dkd/tui/widget/DisplayWidget.java
0 → 100644
View file @
39819854
package
lu.list.itis.dkd.tui.widget
;
import
lu.list.itis.dkd.tui.cps.InputChangeListener
;
import
lu.list.itis.dkd.tui.cps.InputEvent
;
import
lu.list.itis.dkd.tui.cps.variable.NumericalVariable
;
import
lu.list.itis.dkd.tui.cps.variable.Variable
;
import
lu.list.itis.dkd.tui.widget.builder.BaseDisplayWidgetBuilder
;
import
lu.list.itis.dkd.tui.widget.builder.DisplayWidgetBuilder
;
import
lu.list.itis.dkd.tui.widget.corona.ValueCorona
;
import
org.python.google.common.base.Preconditions
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.List
;
/**
* @author nmack
* @date 20 Jan 2016
*
* <br>
* $Log: DisplayWidget.java,v $
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public
class
DisplayWidget
extends
BaseWidget
implements
InputChangeListener
{
HashMap
<
String
,
NumericalVariable
>
variables
;
HashMap
<
String
,
ValueCorona
>
dispatcher
;
// ***************************************************************************
// * Constants *
// ***************************************************************************
private
static
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
DisplayWidget
.
class
.
getSimpleName
());
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
public
DisplayWidget
(
BaseDisplayWidgetBuilder
<
DisplayWidgetBuilder
>
builder
)
{
super
(
builder
);
if
(
builder
.
variables
!=
null
)
{
this
.
setVariables
(
builder
.
variables
);
}
this
.
dispatcher
=
new
HashMap
<
String
,
ValueCorona
>();
List
<
ValueCorona
>
displays
=
this
.
getCoronas
(
ValueCorona
.
class
);
for
(
ValueCorona
display
:
displays
)
{
Variable
<?>
variable
=
display
.
getVariable
();
if
(
variable
!=
null
)
{
dispatcher
.
put
(
variable
.
getName
(),
display
);
}
}
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
// ***************************************************************************
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
public
void
setVariables
(
Collection
<
Variable
<?>>
newVariables
)
{
Preconditions
.
checkArgument
(
variables
==
null
,
"Set of variables can't be null!"
);
//$NON-NLS-1$
this
.
variables
=
new
HashMap
<
String
,
NumericalVariable
>();
for
(
Variable
<?>
variable
:
newVariables
)
{
this
.
variables
.
put
(
variable
.
getName
(),
(
NumericalVariable
)
variable
);
}
List
<
ValueCorona
>
displays
=
this
.
getCoronas
(
ValueCorona
.
class
);
for
(
ValueCorona
display
:
displays
)
{
Variable
<?>
variable
=
display
.
getVariable
();
if
(
variable
!=
null
)
{
String
variableName
=
variable
.
getName
();
if
(
this
.
variables
.
containsKey
(
variableName
))
{
display
.
setVariable
(
this
.
variables
.
get
(
variableName
));
}
else
{
LOGGER
.
warn
(
"Corona requires variable {} unkown to display widget!"
,
variableName
);
//$NON-NLS-1$
}
}
}
}
// ---------------------------------------------------------------------------
@Override
public
void
inputChanged
(
InputEvent
input
)
{
// Variable<?> variable = input.getSource();
// if (dispatcher.containsKey(variable.getName())) {
// ValueCorona display = dispatcher.get(variable.getName());
// display.setInformation(variable.getValue());
// }
for
(
String
variableName
:
this
.
variables
.
keySet
())
{
ValueCorona
display
=
dispatcher
.
get
(
variableName
);
display
.
setInformation
(
this
.
variables
.
get
(
variableName
).
getValue
());
}
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class *
// ***************************************************************************
// ---------------------------------------------------------------------------
}
\ No newline at end of file
CPS/src/lu/list/itis/dkd/tui/widget/SelectorWidget.java
View file @
39819854
...
@@ -22,6 +22,7 @@ public class SelectorWidget extends ValueWidget {
...
@@ -22,6 +22,7 @@ public class SelectorWidget extends ValueWidget {
protected
int
numberOfPositions
;
protected
int
numberOfPositions
;
/** The currently selected position */
/** The currently selected position */
protected
int
currentPosition
=
NONE
;
protected
int
currentPosition
=
NONE
;
protected
int
presetPosition
=
NONE
;
// ***************************************************************************
// ***************************************************************************
// * Constants *
// * Constants *
...
@@ -46,8 +47,10 @@ public class SelectorWidget extends ValueWidget {
...
@@ -46,8 +47,10 @@ public class SelectorWidget extends ValueWidget {
public
SelectorWidget
(
SelectorWidgetBuilder
<?>
builder
)
{
public
SelectorWidget
(
SelectorWidgetBuilder
<?>
builder
)
{
super
(
builder
);
super
(
builder
);
this
.
numberOfPositions
=
this
.
getNumberOfPositions
();
this
.
numberOfPositions
=
this
.
getNumberOfPositions
();
if
(
builder
.
preselect
!=
NONE
)
{
this
.
presetPosition
=
builder
.
preselect
;
this
.
selectPosition
(
builder
.
preselect
);
if
(
presetPosition
!=
NONE
)
{
this
.
selectPosition
(
presetPosition
);
}
}
}
}
...
@@ -72,6 +75,13 @@ public class SelectorWidget extends ValueWidget {
...
@@ -72,6 +75,13 @@ public class SelectorWidget extends ValueWidget {
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
@Override
protected
void
updateFromRotation
(
double
angle
)
{
}
// ---------------------------------------------------------------------------
private
int
getCurrentPosition
(
float
angle
)
{
private
int
getCurrentPosition
(
float
angle
)
{
double
segment
=
TWO_PI
/
numberOfPositions
;
double
segment
=
TWO_PI
/
numberOfPositions
;
int
current
=
0
;
int
current
=
0
;
...
@@ -99,6 +109,7 @@ public class SelectorWidget extends ValueWidget {
...
@@ -99,6 +109,7 @@ public class SelectorWidget extends ValueWidget {
if
(
variable
!=
null
)
{
if
(
variable
!=
null
)
{
variable
.
setValue
((
double
)
position
);
variable
.
setValue
((
double
)
position
);
this
.
updateTethers
((
double
)
position
);
}
}
currentPosition
=
position
;
currentPosition
=
position
;
}
}
...
@@ -138,7 +149,6 @@ public class SelectorWidget extends ValueWidget {
...
@@ -138,7 +149,6 @@ public class SelectorWidget extends ValueWidget {
int
widgetId
=
tuioObject
.
getObjectId
();
int
widgetId
=
tuioObject
.
getObjectId
();
this
.
getCoronas
(
FadingCorona
.
class
).
forEach
(
corona
->
corona
.
fadeIn
());
this
.
getCoronas
(
FadingCorona
.
class
).
forEach
(
corona
->
corona
.
fadeIn
());
StateManager
manager
=
states
.
get
(
widgetId
);
StateManager
manager
=
states
.
get
(
widgetId
);
if
(
manager
.
isRotating
())
{
if
(
manager
.
isRotating
())
{
...
@@ -160,8 +170,9 @@ public class SelectorWidget extends ValueWidget {
...
@@ -160,8 +170,9 @@ public class SelectorWidget extends ValueWidget {
@Override
@Override
public
void
actionDrop
(
TangibleObject
tuioObject
)
{
public
void
actionDrop
(
TangibleObject
tuioObject
)
{
int
position
=
(
this
.
isPersistent
(
tuioObject
.
getObjectId
()))
?
currentPosition
:
presetPosition
;
super
.
actionDrop
(
tuioObject
);
super
.
actionDrop
(
tuioObject
);
this
.
selectPosition
(
currentP
osition
);
this
.
selectPosition
(
p
osition
);
}
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
...
...
CPS/src/lu/list/itis/dkd/tui/widget/ValueWidget.java
View file @
39819854
...
@@ -26,6 +26,7 @@ import lu.list.itis.dkd.tui.adapter.TangibleObject;
...
@@ -26,6 +26,7 @@ import lu.list.itis.dkd.tui.adapter.TangibleObject;
import
lu.list.itis.dkd.tui.content.InformationProvider
;
import
lu.list.itis.dkd.tui.content.InformationProvider
;
import
lu.list.itis.dkd.tui.content.InformationReceiver
;
import
lu.list.itis.dkd.tui.content.InformationReceiver
;
import
lu.list.itis.dkd.tui.cps.utility.Externalization
;
import
lu.list.itis.dkd.tui.cps.utility.Externalization
;
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.cps.variable.tangible.TangibleNumericalVariable
;
import
lu.list.itis.dkd.tui.utility.Point
;
import
lu.list.itis.dkd.tui.utility.Point
;
import
lu.list.itis.dkd.tui.widget.builder.BaseValueWidgetBuilder
;
import
lu.list.itis.dkd.tui.widget.builder.BaseValueWidgetBuilder
;
...
@@ -40,6 +41,7 @@ import java.awt.Graphics2D;
...
@@ -40,6 +41,7 @@ import java.awt.Graphics2D;
import
java.lang.reflect.ParameterizedType
;
import
java.lang.reflect.ParameterizedType
;
import
java.lang.reflect.Type
;
import
java.lang.reflect.Type
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* A simple widget that holds an integer value and may modify the value base on a rotation.
* A simple widget that holds an integer value and may modify the value base on a rotation.
...
@@ -121,7 +123,7 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
...
@@ -121,7 +123,7 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
}
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
pr
ivate
void
updateTethers
(
Double
value
)
{
pr
otected
void
updateTethers
(
Double
value
)
{
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
List
<
DataFeed
>
dataFeeds
=
this
.
getTethers
(
DataFeed
.
class
);
List
<
DataFeed
>
dataFeeds
=
this
.
getTethers
(
DataFeed
.
class
);
for
(
DataFeed
<
Double
>
tether
:
dataFeeds
)
{
for
(
DataFeed
<
Double
>
tether
:
dataFeeds
)
{
...
@@ -226,6 +228,16 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
...
@@ -226,6 +228,16 @@ 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
;
}
}
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
@Override
@Override
public
void
paint
(
Graphics2D
canvas
)
{
public
void
paint
(
Graphics2D
canvas
)
{
...
@@ -254,7 +266,7 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
...
@@ -254,7 +266,7 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
super
.
paint
(
canvas
);
super
.
paint
(
canvas
);
}
}
pr
ivate
void
updateFromRotation
(
double
angle
)
{
pr
otected
void
updateFromRotation
(
double
angle
)
{
double
value
;
double
value
;
if
(
constrainted
)
{
if
(
constrainted
)
{
...
...
CPS/src/lu/list/itis/dkd/tui/widget/builder/BaseDisplayWidgetBuilder.java
0 → 100644
View file @
39819854
package
lu.list.itis.dkd.tui.widget.builder
;
import
lu.list.itis.dkd.tui.bootstrapping.BootstrapCallback
;
import
lu.list.itis.dkd.tui.bootstrapping.BootstrapContext
;
import
lu.list.itis.dkd.tui.cps.variable.Variable
;
import
lu.list.itis.dkd.tui.exception.BuildException
;
import
lu.list.itis.dkd.tui.widget.DisplayWidget
;
import
org.jdom2.Element
;
import
java.util.Collection
;
import
java.util.Vector
;
/**
* @author nmack
* @date 20 Jan 2016
*
* <br>
* $Log: BaseDisplayWidgetBuilder.java,v $
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public
abstract
class
BaseDisplayWidgetBuilder
<
B
extends
BaseDisplayWidgetBuilder
<
B
>>
extends
BaseBuilder
<
B
>
{
public
Collection
<
Variable
<?>>
variables
;
// ***************************************************************************
// * Constants *
// ***************************************************************************
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
* 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
BaseDisplayWidgetBuilder
(
Element
rootElement
,
BootstrapContext
context
,
BootstrapCallback
callback
)
throws
BuildException
{
super
(
rootElement
,
context
,
callback
);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
// ***************************************************************************
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
@SuppressWarnings
(
"unchecked"
)
public
B
withVariables
(
Collection
<
Variable
<?>>
variables
)
{
this
.
variables
=
new
Vector
<
Variable
<?>>();
this
.
variables
.
addAll
(
variables
);
return
(
B
)
this
;
}
// ---------------------------------------------------------------------------
@Override
public
abstract
DisplayWidget
build
();
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class *
// *