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
43e6c743
Commit
43e6c743
authored
Nov 22, 2017
by
Nico Mack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Systematic addition of blinkOnOutOfRange property.
Initial commit of VariableHtmlBox corona.
parent
17119bca
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
452 additions
and
85 deletions
+452
-85
CPS/config/CpsNamespace.properties
CPS/config/CpsNamespace.properties
+1
-0
CPS/src/lu/list/itis/dkd/tui/marker/DisplayMarker.java
CPS/src/lu/list/itis/dkd/tui/marker/DisplayMarker.java
+66
-54
CPS/src/lu/list/itis/dkd/tui/utility/CpsNamespace.java
CPS/src/lu/list/itis/dkd/tui/utility/CpsNamespace.java
+2
-0
CPS/src/lu/list/itis/dkd/tui/utility/interpolation/Interpolator.java
...list/itis/dkd/tui/utility/interpolation/Interpolator.java
+15
-0
CPS/src/lu/list/itis/dkd/tui/widget/corona/ArcRangeGraph.java
...src/lu/list/itis/dkd/tui/widget/corona/ArcRangeGraph.java
+4
-1
CPS/src/lu/list/itis/dkd/tui/widget/corona/ShapeGraph.java
CPS/src/lu/list/itis/dkd/tui/widget/corona/ShapeGraph.java
+5
-7
CPS/src/lu/list/itis/dkd/tui/widget/corona/VariableHtmlBox.java
...c/lu/list/itis/dkd/tui/widget/corona/VariableHtmlBox.java
+122
-0
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/ArcGraphBuilder.java
...t/itis/dkd/tui/widget/corona/builder/ArcGraphBuilder.java
+3
-0
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseArcRangeGraphBuilder.java
...d/tui/widget/corona/builder/BaseArcRangeGraphBuilder.java
+2
-0
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseVariableHtmlBoxBuilder.java
...tui/widget/corona/builder/BaseVariableHtmlBoxBuilder.java
+136
-0
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/ShapeGraphBuilder.java
...itis/dkd/tui/widget/corona/builder/ShapeGraphBuilder.java
+4
-23
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/VariableHtmlBoxBuilder.java
...dkd/tui/widget/corona/builder/VariableHtmlBoxBuilder.java
+92
-0
No files found.
CPS/config/CpsNamespace.properties
View file @
43e6c743
...
@@ -3,6 +3,7 @@ BELOW_ELEMENT=below
...
@@ -3,6 +3,7 @@ BELOW_ELEMENT=below
BLINK_ON_OUT_OF_RANGE_NODE
=
blinkOnOutOfRange
BLINK_ON_OUT_OF_RANGE_NODE
=
blinkOnOutOfRange
CAPPED_DISPLAY_NODE
=
cappedDisplay
CAPPED_DISPLAY_NODE
=
cappedDisplay
ITEMS_VARIABLE_NODE
=
itemsVariable
ITEMS_VARIABLE_NODE
=
itemsVariable
HTML_TEMPLATE_NODE
=
htmlTemplate
LABEL_NODE
=
label
LABEL_NODE
=
label
LOWER_BOUND_RADIUS_NODE
=
lowerBoundRadius
LOWER_BOUND_RADIUS_NODE
=
lowerBoundRadius
LOWER_BOUND_VARIABLE_NODE
=
lowerBoundVariable
LOWER_BOUND_VARIABLE_NODE
=
lowerBoundVariable
...
...
CPS/src/lu/list/itis/dkd/tui/marker/DisplayMarker.java
View file @
43e6c743
...
@@ -2,6 +2,7 @@ package lu.list.itis.dkd.tui.marker;
...
@@ -2,6 +2,7 @@ package lu.list.itis.dkd.tui.marker;
import
lu.list.itis.dkd.tui.cps.InputChangeListener
;
import
lu.list.itis.dkd.tui.cps.InputChangeListener
;
import
lu.list.itis.dkd.tui.cps.InputEvent
;
import
lu.list.itis.dkd.tui.cps.InputEvent
;
import
lu.list.itis.dkd.tui.cps.system.VariableBased
;
import
lu.list.itis.dkd.tui.cps.variable.NumericalVariable
;
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.Variable
;
import
lu.list.itis.dkd.tui.marker.builder.BaseDisplayMarkerBuilder
;
import
lu.list.itis.dkd.tui.marker.builder.BaseDisplayMarkerBuilder
;
...
@@ -11,20 +12,20 @@ import org.python.google.common.base.Preconditions;
...
@@ -11,20 +12,20 @@ import org.python.google.common.base.Preconditions;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
java.awt.Graphics2D
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
// ***************************************************************************
// ***************************************************************************
// * Class Definition and Members *
// * Class Definition and Members *
// ***************************************************************************
// ***************************************************************************
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
public
class
DisplayMarker
extends
InfoMarker
implements
InputChangeListener
{
public
class
DisplayMarker
extends
InfoMarker
implements
InputChangeListener
,
VariableBased
{
private
HashMap
<
String
,
NumericalVariable
>
variables
;
private
HashMap
<
String
,
Variable
<?>
>
variables
;
HashMap
<
String
,
ValueCorona
>
dispatcher
;
HashMap
<
String
,
ValueCorona
>
dispatcher
;
// ***************************************************************************
// ***************************************************************************
...
@@ -43,20 +44,8 @@ public class DisplayMarker extends InfoMarker implements InputChangeListener {
...
@@ -43,20 +44,8 @@ public class DisplayMarker extends InfoMarker implements InputChangeListener {
public
DisplayMarker
(
BaseDisplayMarkerBuilder
<?>
builder
)
{
public
DisplayMarker
(
BaseDisplayMarkerBuilder
<?>
builder
)
{
super
(
builder
);
super
(
builder
);
if
(
builder
.
variables
!=
null
)
{
this
.
variables
=
new
HashMap
<>();
this
.
setVariables
(
builder
.
variables
);
this
.
dispatcher
=
new
HashMap
<>();
}
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
);
}
}
// TODO Auto-generated constructor stub
}
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
...
@@ -71,47 +60,40 @@ public class DisplayMarker extends InfoMarker implements InputChangeListener {
...
@@ -71,47 +60,40 @@ public class DisplayMarker extends InfoMarker implements InputChangeListener {
// ***************************************************************************
// ***************************************************************************
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
public
void
setVariables
(
Collection
<
Variable
<?>>
newVariables
)
{
//
public void setVariables(Collection<Variable<?>> newVariables) {
Preconditions
.
checkArgument
(
variables
==
null
,
"Set of variables can't be null!"
);
//$NON-NLS-1$
//
Preconditions.checkArgument(variables == null, "Set of variables can't be null!"); //$NON-NLS-1$
//
this
.
variables
=
new
HashMap
<
String
,
NumericalVariable
>();
//
this.variables = new HashMap<String, NumericalVariable>();
for
(
Variable
<?>
variable
:
newVariables
)
{
//
for (Variable<?> variable : newVariables) {
this
.
variables
.
put
(
variable
.
getName
(),
(
NumericalVariable
)
variable
);
//
this.variables.put(variable.getName(), (NumericalVariable) variable);
}
//
}
//
List
<
ValueCorona
>
displays
=
this
.
getCoronas
(
ValueCorona
.
class
);
//
List<ValueCorona> displays = this.getCoronas(ValueCorona.class);
for
(
ValueCorona
display
:
displays
)
{
//
for (ValueCorona display : displays) {
Variable
<?>
variable
=
display
.
getVariable
();
//
Variable<?> variable = display.getVariable();
if
(
variable
!=
null
)
{
//
if (variable != null) {
String
variableName
=
variable
.
getName
();
//
String variableName = variable.getName();
if
(
this
.
variables
.
containsKey
(
variableName
))
{
//
if (this.variables.containsKey(variableName)) {
display
.
setVariable
(
this
.
variables
.
get
(
variableName
));
//
display.setVariable(this.variables.get(variableName));
}
else
{
//
} else {
LOGGER
.
warn
(
"Corona requires variable {} unkown to display widget!"
,
variableName
);
//$NON-NLS-1$
//
LOGGER.warn("Corona requires variable {} unkown to display widget!", variableName); //$NON-NLS-1$
}
//
}
}
//
}
}
//
}
}
//
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
public
Collection
<
Variable
<?>>
getVariables
()
{
public
Collection
<
Variable
<?>>
getVariables
()
{
Collection
<
Variable
<?>>
variables
=
new
ArrayList
<>();
// Collection<Variable<?>> variables = new ArrayList<>();
List
<
ValueCorona
>
displays
=
this
.
getCoronas
(
ValueCorona
.
class
);
// List<ValueCorona> displays = this.getCoronas(ValueCorona.class);
for
(
ValueCorona
display
:
displays
)
{
// for (ValueCorona display : displays) {
Variable
<?>
variable
=
display
.
getVariable
();
// Variable<?> variable = display.getVariable();
if
(
variable
!=
null
)
{
// if (variable != null) {
variables
.
add
(
variable
);
// variables.add(variable);
}
// }
}
// }
return
variables
;
return
variables
.
values
();
}
// ---------------------------------------------------------------------------
@Override
public
void
paint
(
Graphics2D
canvas
)
{
super
.
paint
(
canvas
);
}
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
...
@@ -129,5 +111,35 @@ public class DisplayMarker extends InfoMarker implements InputChangeListener {
...
@@ -129,5 +111,35 @@ public class DisplayMarker extends InfoMarker implements InputChangeListener {
}
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
// ---------------------------------------------------------------------------
@Override
public
List
<
Variable
<?>>
connectWithSystemVariables
(
Map
<
String
,
Variable
<?>>
systemVariables
)
{
List
<
Variable
<?>>
connected
=
new
ArrayList
<>();
Preconditions
.
checkArgument
(
systemVariables
!=
null
,
"Set of variables can't be null!"
);
//$NON-NLS-1$
List
<
VariableBased
>
displays
=
this
.
getCoronas
(
VariableBased
.
class
);
for
(
VariableBased
display
:
displays
)
{
List
<
Variable
<?>>
newlyConnected
=
display
.
connectWithSystemVariables
(
systemVariables
);
connected
.
addAll
(
newlyConnected
);
if
(
display
instanceof
ValueCorona
)
{
for
(
Variable
<?>
variable
:
newlyConnected
)
{
this
.
dispatcher
.
put
(
variable
.
getName
(),
(
ValueCorona
)
display
);
}
}
}
for
(
Variable
<?>
variable
:
connected
)
{
this
.
variables
.
put
(
variable
.
getName
(),
variable
);
variable
.
addListener
(
this
);
}
return
connected
;
}
// ---------------------------------------------------------------------------
}
}
CPS/src/lu/list/itis/dkd/tui/utility/CpsNamespace.java
View file @
43e6c743
...
@@ -32,6 +32,8 @@ public class CpsNamespace extends NLS {
...
@@ -32,6 +32,8 @@ public class CpsNamespace extends NLS {
public
static
String
CAPPED_DISPLAY_NODE
;
public
static
String
CAPPED_DISPLAY_NODE
;
public
static
String
HTML_TEMPLATE_NODE
;
public
static
String
ITEMS_VARIABLE_NODE
;
public
static
String
ITEMS_VARIABLE_NODE
;
public
static
String
LABEL_NODE
;
public
static
String
LABEL_NODE
;
...
...
CPS/src/lu/list/itis/dkd/tui/utility/interpolation/Interpolator.java
View file @
43e6c743
...
@@ -108,6 +108,21 @@ public class Interpolator {
...
@@ -108,6 +108,21 @@ public class Interpolator {
// ***************************************************************************
// ***************************************************************************
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
public
static
List
<
String
>
extractVariableIdentifiers
(
String
template
)
{
Matcher
variableMatcher
;
List
<
String
>
identifiers
=
new
ArrayList
<>();
variableMatcher
=
VARIABLE_PATTERN
.
matcher
(
template
);
while
(
variableMatcher
.
find
())
{
identifiers
.
add
(
variableMatcher
.
group
(
1
));
}
return
identifiers
;
}
// ---------------------------------------------------------------------------
public
static
List
<
Chunk
<?>>
decompose
(
String
template
,
Map
<
String
,
Variable
<?>>
parameters
)
{
public
static
List
<
Chunk
<?>>
decompose
(
String
template
,
Map
<
String
,
Variable
<?>>
parameters
)
{
Matcher
variableMatcher
;
Matcher
variableMatcher
;
String
format
;
String
format
;
...
...
CPS/src/lu/list/itis/dkd/tui/widget/corona/ArcRangeGraph.java
View file @
43e6c743
...
@@ -40,6 +40,7 @@ public class ArcRangeGraph extends ValueRangeCorona {
...
@@ -40,6 +40,7 @@ public class ArcRangeGraph extends ValueRangeCorona {
private
double
startAngle
;
private
double
startAngle
;
private
double
arcSpan
;
private
double
arcSpan
;
private
boolean
relative
;
private
boolean
relative
;
private
boolean
blinkOnOutOfRange
;
private
double
reference
;
private
double
reference
;
private
int
rampingTime
;
private
int
rampingTime
;
...
@@ -102,6 +103,7 @@ public class ArcRangeGraph extends ValueRangeCorona {
...
@@ -102,6 +103,7 @@ public class ArcRangeGraph extends ValueRangeCorona {
this
.
startAngle
=
builder
.
startAngle
;
this
.
startAngle
=
builder
.
startAngle
;
this
.
arcSpan
=
builder
.
arcSpan
;
this
.
arcSpan
=
builder
.
arcSpan
;
this
.
relative
=
builder
.
relative
;
this
.
relative
=
builder
.
relative
;
this
.
blinkOnOutOfRange
=
builder
.
blinkOnOutOfRange
;
this
.
reference
=
builder
.
reference
;
this
.
reference
=
builder
.
reference
;
this
.
rampingTime
=
builder
.
rampingTime
;
this
.
rampingTime
=
builder
.
rampingTime
;
...
@@ -139,6 +141,7 @@ public class ArcRangeGraph extends ValueRangeCorona {
...
@@ -139,6 +141,7 @@ public class ArcRangeGraph extends ValueRangeCorona {
this
.
startAngle
=
original
.
startAngle
;
this
.
startAngle
=
original
.
startAngle
;
this
.
arcSpan
=
original
.
arcSpan
;
this
.
arcSpan
=
original
.
arcSpan
;
this
.
relative
=
original
.
relative
;
this
.
relative
=
original
.
relative
;
this
.
blinkOnOutOfRange
=
original
.
blinkOnOutOfRange
;
this
.
reference
=
original
.
reference
;
this
.
reference
=
original
.
reference
;
this
.
rampingTime
=
original
.
rampingTime
;
this
.
rampingTime
=
original
.
rampingTime
;
...
@@ -318,7 +321,7 @@ public class ArcRangeGraph extends ValueRangeCorona {
...
@@ -318,7 +321,7 @@ public class ArcRangeGraph extends ValueRangeCorona {
this
.
updateLeader
();
this
.
updateLeader
();
if
(
(
shownUpperValue
==
this
.
upperBoundVariable
.
getMaxValue
())
||
(
relative
&&
(
shownLowerValue
==
this
.
lowerBoundVariable
.
getMinValue
(
))))
if
(
blinkOnOutOfRange
&&
((
shownUpperValue
==
this
.
upperBoundVariable
.
getMaxValue
())
||
(
relative
&&
(
shownLowerValue
==
this
.
lowerBoundVariable
.
getMinValue
()
))))
this
.
startBlinking
();
this
.
startBlinking
();
else
else
this
.
stopBlinking
();
this
.
stopBlinking
();
...
...
CPS/src/lu/list/itis/dkd/tui/widget/corona/ShapeGraph.java
View file @
43e6c743
...
@@ -46,13 +46,11 @@ public class ShapeGraph extends ValueCorona {
...
@@ -46,13 +46,11 @@ public class ShapeGraph extends ValueCorona {
protected
ColorPair
strokeColour
;
protected
ColorPair
strokeColour
;
protected
int
strokeWidth
;
protected
int
strokeWidth
;
protected
Shape
scaledShape
;
protected
Shape
scaledShape
;
protected
boolean
blinkOnOutOfRange
;
protected
Timeline
blinkingTimeline
;
protected
Timeline
blinkingTimeline
;
protected
Timeline
balisticTimeline
;
protected
Timeline
balisticTimeline
;
private
double
shownValue
;
private
double
shownValue
;
private
float
angle
;
private
float
opacity
;
private
double
scale
;
private
Stroke
borderStroke
;
private
Stroke
borderStroke
;
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
...
@@ -67,6 +65,7 @@ public class ShapeGraph extends ValueCorona {
...
@@ -67,6 +65,7 @@ public class ShapeGraph extends ValueCorona {
super
(
builder
);
super
(
builder
);
this
.
lowerBound
=
builder
.
lowerBound
;
this
.
lowerBound
=
builder
.
lowerBound
;
this
.
upperBound
=
builder
.
upperBound
;
this
.
upperBound
=
builder
.
upperBound
;
this
.
blinkOnOutOfRange
=
builder
.
blinkOnOutOfRange
;
this
.
fillColour
=
builder
.
fillColour
;
this
.
fillColour
=
builder
.
fillColour
;
this
.
strokeColour
=
builder
.
strokeColour
;
this
.
strokeColour
=
builder
.
strokeColour
;
this
.
strokeWidth
=
builder
.
strokeWidth
;
this
.
strokeWidth
=
builder
.
strokeWidth
;
...
@@ -92,6 +91,7 @@ public class ShapeGraph extends ValueCorona {
...
@@ -92,6 +91,7 @@ public class ShapeGraph extends ValueCorona {
this
.
lowerBound
=
original
.
lowerBound
;
this
.
lowerBound
=
original
.
lowerBound
;
this
.
upperBound
=
original
.
upperBound
;
this
.
upperBound
=
original
.
upperBound
;
this
.
blinkOnOutOfRange
=
original
.
blinkOnOutOfRange
;
this
.
fillColour
=
original
.
fillColour
;
this
.
fillColour
=
original
.
fillColour
;
this
.
strokeColour
=
original
.
strokeColour
;
this
.
strokeColour
=
original
.
strokeColour
;
this
.
strokeWidth
=
original
.
strokeWidth
;
this
.
strokeWidth
=
original
.
strokeWidth
;
...
@@ -137,16 +137,14 @@ public class ShapeGraph extends ValueCorona {
...
@@ -137,16 +137,14 @@ public class ShapeGraph extends ValueCorona {
shownValue
=
value
;
shownValue
=
value
;
if
(
variable
!=
null
)
{
if
(
variable
!=
null
)
{
// double size = lowerBound + (upperBound - lowerBound) * (shownValue - this.variable.getMinValue())
// / (this.variable.getMaxValue() - this.variable.getMinValue());
double
size
=
lowerBound
+
((
upperBound
-
lowerBound
)
*
this
.
variable
.
getNormalizedValue
());
double
size
=
lowerBound
+
((
upperBound
-
lowerBound
)
*
this
.
variable
.
getNormalizedValue
());
if
(
size
==
upperBound
)
if
(
blinkOnOutOfRange
&&
(
size
==
upperBound
)
)
this
.
startBlinking
();
this
.
startBlinking
();
else
else
this
.
stopBlinking
();
this
.
stopBlinking
();
scale
=
size
/
lowerBound
;
double
scale
=
size
/
lowerBound
;
AffineTransform
scaler
=
AffineTransform
.
getScaleInstance
(
scale
,
scale
);
AffineTransform
scaler
=
AffineTransform
.
getScaleInstance
(
scale
,
scale
);
scaledShape
=
scaler
.
createTransformedShape
(
this
.
shape
);
scaledShape
=
scaler
.
createTransformedShape
(
this
.
shape
);
...
...
CPS/src/lu/list/itis/dkd/tui/widget/corona/VariableHtmlBox.java
0 → 100644
View file @
43e6c743
/**
* 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.widget.corona
;
import
lu.list.itis.dkd.tui.cps.InputChangeListener
;
import
lu.list.itis.dkd.tui.cps.InputEvent
;
import
lu.list.itis.dkd.tui.cps.system.VariableBased
;
import
lu.list.itis.dkd.tui.cps.variable.Variable
;
import
lu.list.itis.dkd.tui.utility.interpolation.Chunk
;
import
lu.list.itis.dkd.tui.utility.interpolation.Interpolator
;
import
lu.list.itis.dkd.tui.widget.corona.builder.BaseVariableHtmlBoxBuilder
;
import
org.python.google.common.base.Strings
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* Extends the static HtmlBox corona by allowing variables inside the Html content.
*
* @author Nico Mack [nico.mack@list.lu]
* @since 2.5.0
* @version 2.5.0
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public
class
VariableHtmlBox
extends
HtmlBox
implements
VariableBased
,
InputChangeListener
{
private
String
htmlTemplate
;
private
List
<
Chunk
<?>>
htmlChunks
;
private
List
<
String
>
identifiers
;
private
Map
<
String
,
Variable
<?>>
parameters
;
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s)
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
* @param builder
*/
// ---------------------------------------------------------------------------
public
VariableHtmlBox
(
BaseVariableHtmlBoxBuilder
<?>
builder
)
{
super
(
builder
);
htmlTemplate
=
builder
.
htmlTemplate
;
this
.
parameters
=
new
HashMap
<>();
if
(!
Strings
.
isNullOrEmpty
(
this
.
htmlTemplate
))
{
identifiers
=
Interpolator
.
extractVariableIdentifiers
(
this
.
htmlTemplate
);
}
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitive(s)
// ***************************************************************************
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body
// ***************************************************************************
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
// ---------------------------------------------------------------------------
@Override
public
List
<
Variable
<?>>
connectWithSystemVariables
(
Map
<
String
,
Variable
<?>>
systemVariables
)
{
List
<
Variable
<?>>
connected
=
new
ArrayList
<>();
for
(
String
identifier
:
identifiers
)
{
if
((
systemVariables
!=
null
)
&&
systemVariables
.
containsKey
(
identifier
))
{
Variable
<?>
variable
=
systemVariables
.
get
(
identifier
);
this
.
parameters
.
put
(
identifier
,
variable
);
connected
.
add
(
variable
);
variable
.
addListener
(
this
);
}
}
if
(!
connected
.
isEmpty
())
{
htmlChunks
=
Interpolator
.
decompose
(
this
.
htmlTemplate
,
this
.
parameters
);
}
return
connected
;
}
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
// ---------------------------------------------------------------------------
@Override
public
void
inputChanged
(
InputEvent
input
)
{
if
(
parameters
.
containsKey
(
input
.
getSource
().
getName
()))
{
this
.
htmlContent
=
Interpolator
.
render
(
htmlChunks
);
this
.
setInformation
(
this
.
htmlContent
);
}
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class
// ***************************************************************************
// ---------------------------------------------------------------------------
}
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/ArcGraphBuilder.java
View file @
43e6c743
...
@@ -38,6 +38,7 @@ public class ArcGraphBuilder extends ValueCoronaBuilder<ArcGraphBuilder> {
...
@@ -38,6 +38,7 @@ public class ArcGraphBuilder extends ValueCoronaBuilder<ArcGraphBuilder> {
public
int
arcSpan
;
public
int
arcSpan
;
public
boolean
relative
;
public
boolean
relative
;
public
boolean
cappedDisplay
;
public
boolean
cappedDisplay
;
public
boolean
blinkOnOutOfRange
;
public
double
reference
;
public
double
reference
;
public
int
rampingTime
;
public
int
rampingTime
;
...
@@ -96,6 +97,7 @@ public class ArcGraphBuilder extends ValueCoronaBuilder<ArcGraphBuilder> {
...
@@ -96,6 +97,7 @@ public class ArcGraphBuilder extends ValueCoronaBuilder<ArcGraphBuilder> {
arcSpan
=
BootstrappingUtils
.
getContentAsInteger
(
rootElement
,
Externalization
.
ARC_SPAN_NODE
,
BootstrappingUtils
.
MANDATORY
,
null
,
context
);
arcSpan
=
BootstrappingUtils
.
getContentAsInteger
(
rootElement
,
Externalization
.
ARC_SPAN_NODE
,
BootstrappingUtils
.
MANDATORY
,
null
,
context
);
relative
=
BootstrappingUtils
.
getContentAsBoolean
(
rootElement
,
CpsNamespace
.
RELATIVE_NODE
,
BootstrappingUtils
.
OPTIONAL
,
Boolean
.
FALSE
,
context
);
relative
=
BootstrappingUtils
.
getContentAsBoolean
(
rootElement
,
CpsNamespace
.
RELATIVE_NODE
,
BootstrappingUtils
.
OPTIONAL
,
Boolean
.
FALSE
,
context
);
cappedDisplay
=
BootstrappingUtils
.
getContentAsBoolean
(
rootElement
,
CpsNamespace
.
CAPPED_DISPLAY_NODE
,
BootstrappingUtils
.
OPTIONAL
,
Boolean
.
FALSE
,
context
);
cappedDisplay
=
BootstrappingUtils
.
getContentAsBoolean
(
rootElement
,
CpsNamespace
.
CAPPED_DISPLAY_NODE
,
BootstrappingUtils
.
OPTIONAL
,
Boolean
.
FALSE
,
context
);
blinkOnOutOfRange
=
BootstrappingUtils
.
getContentAsBoolean
(
rootElement
,
CpsNamespace
.
BLINK_ON_OUT_OF_RANGE_NODE
,
BootstrappingUtils
.
OPTIONAL
,
Boolean
.
FALSE
,
context
);
reference
=
BootstrappingUtils
.
getContentAsDouble
(
rootElement
,
CpsNamespace
.
REFERENCE_NODE
,
BootstrappingUtils
.
OPTIONAL
,
0
d
,
context
);
reference
=
BootstrappingUtils
.
getContentAsDouble
(
rootElement
,
CpsNamespace
.
REFERENCE_NODE
,
BootstrappingUtils
.
OPTIONAL
,
0
d
,
context
);
innerRadius
=
BootstrappingUtils
.
getContentAsDouble
(
rootElement
,
Externalization
.
INNER_RADIUS_NODE
,
BootstrappingUtils
.
MANDATORY
,
null
,
context
);
innerRadius
=
BootstrappingUtils
.
getContentAsDouble
(
rootElement
,
Externalization
.
INNER_RADIUS_NODE
,
BootstrappingUtils
.
MANDATORY
,
null
,
context
);
...
@@ -113,6 +115,7 @@ public class ArcGraphBuilder extends ValueCoronaBuilder<ArcGraphBuilder> {
...
@@ -113,6 +115,7 @@ public class ArcGraphBuilder extends ValueCoronaBuilder<ArcGraphBuilder> {
faceColour
=
buildColorPair
(
rootElement
.
getChild
(
Externalization
.
FACE_COLOUR_ELEMENT
),
BootstrappingUtils
.
OPTIONAL
,
context
);
faceColour
=
buildColorPair
(
rootElement
.
getChild
(
Externalization
.
FACE_COLOUR_ELEMENT
),
BootstrappingUtils
.
OPTIONAL
,
context
);
bezelColour
=
buildColorPair
(
rootElement
.
getChild
(
Externalization
.
BEZEL_COLOUR_ELEMENT
),
BootstrappingUtils
.
OPTIONAL
,
context
);
bezelColour
=
buildColorPair
(
rootElement
.
getChild
(
Externalization
.
BEZEL_COLOUR_ELEMENT
),
BootstrappingUtils
.
OPTIONAL
,
context
);
labelShape
=
ShapeBootstrapper
.
getShape
(
rootElement
.
getChild
(
Externalization
.
LABEL_SHAPE_NODE
),
context
,
callback
);
labelShape
=
ShapeBootstrapper
.
getShape
(
rootElement
.
getChild
(
Externalization
.
LABEL_SHAPE_NODE
),
context
,
callback
);
title
=
BootstrappingUtils
.
getContentAsString
(
rootElement
,
Externalization
.
TITLE_NODE
,
BootstrappingUtils
.
OPTIONAL
,
Externalization
.
EMPTY_STRING
,
context
);
title
=
BootstrappingUtils
.
getContentAsString
(
rootElement
,
Externalization
.
TITLE_NODE
,
BootstrappingUtils
.
OPTIONAL
,
Externalization
.
EMPTY_STRING
,
context
);
...
...
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseArcRangeGraphBuilder.java
View file @
43e6c743
...
@@ -37,6 +37,7 @@ public abstract class BaseArcRangeGraphBuilder<B extends BaseArcRangeGraphBuilde
...
@@ -37,6 +37,7 @@ public abstract class BaseArcRangeGraphBuilder<B extends BaseArcRangeGraphBuilde
public
int
startAngle
;
public
int
startAngle
;
public
int
arcSpan
;
public
int
arcSpan
;
public
boolean
relative
;
public
boolean
relative
;
public
boolean
blinkOnOutOfRange
;
public
double
reference
;
public
double
reference
;
public
int
rampingTime
;
public
int
rampingTime
;
...
@@ -98,6 +99,7 @@ public abstract class BaseArcRangeGraphBuilder<B extends BaseArcRangeGraphBuilde
...
@@ -98,6 +99,7 @@ public abstract class BaseArcRangeGraphBuilder<B extends BaseArcRangeGraphBuilde
startAngle
=
BootstrappingUtils
.
getContentAsInteger
(
rootElement
,
Externalization
.
START_ANGLE_NODE
,
BootstrappingUtils
.
MANDATORY
,
null
,
context
);
startAngle
=
BootstrappingUtils
.
getContentAsInteger
(
rootElement
,
Externalization
.
START_ANGLE_NODE
,
BootstrappingUtils
.
MANDATORY
,
null
,
context
);
arcSpan
=
BootstrappingUtils
.
getContentAsInteger
(
rootElement
,
Externalization
.
ARC_SPAN_NODE
,
BootstrappingUtils
.
MANDATORY
,
null
,
context
);
arcSpan
=
BootstrappingUtils
.
getContentAsInteger
(
rootElement
,
Externalization
.
ARC_SPAN_NODE
,
BootstrappingUtils
.
MANDATORY
,
null
,
context
);
relative
=
BootstrappingUtils
.
getContentAsBoolean
(
rootElement
,
CpsNamespace
.
RELATIVE_NODE
,
BootstrappingUtils
.
OPTIONAL
,
Boolean
.
FALSE
,
context
);
relative
=
BootstrappingUtils
.
getContentAsBoolean
(
rootElement
,
CpsNamespace
.
RELATIVE_NODE
,
BootstrappingUtils
.
OPTIONAL
,
Boolean
.
FALSE
,
context
);
blinkOnOutOfRange
=
BootstrappingUtils
.
getContentAsBoolean
(
rootElement
,
CpsNamespace
.
BLINK_ON_OUT_OF_RANGE_NODE
,
BootstrappingUtils
.
OPTIONAL
,
Boolean
.
FALSE
,
context
);
reference
=
BootstrappingUtils
.
getContentAsDouble
(
rootElement
,
CpsNamespace
.
REFERENCE_NODE
,
BootstrappingUtils
.
OPTIONAL
,
0
d
,
context
);
reference
=
BootstrappingUtils
.
getContentAsDouble
(
rootElement
,
CpsNamespace
.
REFERENCE_NODE
,
BootstrappingUtils
.
OPTIONAL
,
0
d
,
context
);
innerRadius
=
BootstrappingUtils
.
getContentAsDouble
(
rootElement
,
Externalization
.
INNER_RADIUS_NODE
,
BootstrappingUtils
.
MANDATORY
,
null
,
context
);
innerRadius
=
BootstrappingUtils
.
getContentAsDouble
(
rootElement
,
Externalization
.
INNER_RADIUS_NODE
,
BootstrappingUtils
.
MANDATORY
,
null
,
context
);
...
...
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseVariableHtmlBoxBuilder.java
0 → 100644
View file @
43e6c743
/**
* 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.corona.builder
;
import
lu.list.itis.dkd.dbc.annotation.NonNullByDefault
;
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.utility.CpsNamespace
;
import
lu.list.itis.dkd.tui.utility.Point
;
import
lu.list.itis.dkd.tui.widget.corona.HtmlBox
;
import
org.jdom2.Element
;
/**
* {@link CoronaBuilder} extension building {@link HtmlBox} coronas.
*
* @author Nico Mack [nico.mack@list.lu]