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
37e3695e
Commit
37e3695e
authored
Aug 08, 2017
by
Nico Mack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preparation for multiple widgets with identical object IDs.
parent
a91b8acb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
172 additions
and
49 deletions
+172
-49
CPS/src/lu/list/itis/dkd/tui/cps/variable/BooleanVariable.java
...rc/lu/list/itis/dkd/tui/cps/variable/BooleanVariable.java
+1
-1
CPS/src/lu/list/itis/dkd/tui/cps/variable/NumericalVariable.java
.../lu/list/itis/dkd/tui/cps/variable/NumericalVariable.java
+14
-11
CPS/src/lu/list/itis/dkd/tui/widget/corona/ArcGraph.java
CPS/src/lu/list/itis/dkd/tui/widget/corona/ArcGraph.java
+54
-7
CPS/src/lu/list/itis/dkd/tui/widget/corona/ConditionalCorona.java
...lu/list/itis/dkd/tui/widget/corona/ConditionalCorona.java
+57
-30
CPS/src/lu/list/itis/dkd/tui/widget/corona/ShapeGraph.java
CPS/src/lu/list/itis/dkd/tui/widget/corona/ShapeGraph.java
+31
-0
CPS/src/lu/list/itis/dkd/tui/widget/corona/ValueCorona.java
CPS/src/lu/list/itis/dkd/tui/widget/corona/ValueCorona.java
+15
-0
No files found.
CPS/src/lu/list/itis/dkd/tui/cps/variable/BooleanVariable.java
View file @
37e3695e
...
...
@@ -54,7 +54,7 @@ public class BooleanVariable extends Variable<Boolean> {
/** {@inheritDoc} */
@Override
public
Variable
<
Boolean
>
clone
()
{
public
BooleanVariable
clone
()
{
BooleanVariable
variable
=
new
BooleanVariable
(
name
,
value
);
variable
.
listeners
=
new
Vector
<>(
listeners
);
return
variable
;
...
...
CPS/src/lu/list/itis/dkd/tui/cps/variable/NumericalVariable.java
View file @
37e3695e
...
...
@@ -24,6 +24,8 @@ import lu.list.itis.dkd.dbc.annotation.NonNullByDefault;
import
lu.list.itis.dkd.dbc.annotation.Nullable
;
import
lu.list.itis.dkd.tui.cps.utility.Externalization
;
import
com.google.common.base.Objects
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -46,7 +48,7 @@ public class NumericalVariable extends Variable<Double> {
private
DecimalFormat
format
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
NumericalVariable
.
class
.
getSimpleName
());
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
NumericalVariable
.
class
.
getSimpleName
());
/**
* Constructor resorting to the super constructor to initialise the name and unit and locally
...
...
@@ -116,7 +118,7 @@ public class NumericalVariable extends Variable<Double> {
*/
@Override
public
int
hashCode
()
{
return
toString
().
hashCode
(
);
return
Objects
.
hashCode
(
name
,
unit
,
value
);
}
/**
...
...
@@ -146,14 +148,15 @@ public class NumericalVariable extends Variable<Double> {
/** {@inheritDoc} */
@Override
public
void
setValue
(
Double
newValue
)
{
// Double newValue;
// newValue = (Double) this.valueFromString(value.toString());
if
(
newValue
<
this
.
minValue
)
newValue
=
this
.
minValue
;
else
if
(
newValue
>
this
.
maxValue
)
newValue
=
this
.
maxValue
;
super
.
setValue
(
newValue
);
double
val
=
(
newValue
!=
null
)
?
newValue
:
0
d
;
if
(
val
<
this
.
minValue
)
val
=
this
.
minValue
;
else
if
(
val
>
this
.
maxValue
)
val
=
this
.
maxValue
;
super
.
setValue
(
val
);
}
/** {@inheritDoc} */
...
...
@@ -252,7 +255,7 @@ public class NumericalVariable extends Variable<Double> {
try
{
newValue
=
Double
.
parseDouble
(
stringValue
);
}
catch
(
NumberFormatException
e
)
{
logger
.
error
(
"The provided value ({}) does not match the format stored by this variable instance."
,
stringValue
,
e
);
//$NON-NLS-1$
LOGGER
.
error
(
"The provided value ({}) does not match the format stored by this variable instance."
,
stringValue
,
e
);
//$NON-NLS-1$
throw
e
;
}
return
newValue
;
...
...
CPS/src/lu/list/itis/dkd/tui/widget/corona/ArcGraph.java
View file @
37e3695e
...
...
@@ -52,6 +52,7 @@ public class ArcGraph extends ValueCorona {
private
Shape
labelShape
;
private
Font
textFont
;
private
Stroke
borderStroke
;
private
int
strokeWidth
;
private
Area
outer
;
private
Area
inner
;
...
...
@@ -80,8 +81,6 @@ public class ArcGraph extends ValueCorona {
public
ArcGraph
(
ArcGraphBuilder
builder
)
{
super
(
builder
);
double
diameter
;
this
.
startAngle
=
builder
.
startAngle
;
this
.
arcSpan
=
builder
.
arcSpan
;
this
.
relative
=
builder
.
relative
;
...
...
@@ -97,6 +96,51 @@ public class ArcGraph extends ValueCorona {
this
.
bezelColour
=
builder
.
bezelColour
;
this
.
labelShape
=
builder
.
labelShape
;
this
.
textFont
=
builder
.
textFont
;
this
.
strokeWidth
=
builder
.
strokeWidth
;
this
.
buildFromProperties
();
}
// ---------------------------------------------------------------------------
/**
* Copy constructor to clone corona.
*
* @param original
* specifies the original corona to create an exact copy from.
*/
// ---------------------------------------------------------------------------
public
ArcGraph
(
ArcGraph
original
)
{
super
(
original
);
this
.
startAngle
=
original
.
startAngle
;
this
.
arcSpan
=
original
.
arcSpan
;
this
.
relative
=
original
.
relative
;
this
.
reference
=
original
.
reference
;
this
.
innerRadius
=
original
.
innerRadius
;
this
.
outerRadius
=
original
.
outerRadius
;
this
.
fillColour
=
original
.
fillColour
;
this
.
strokeColour
=
original
.
strokeColour
;
this
.
labelColour
=
original
.
labelColour
;
this
.
textColour
=
original
.
textColour
;
this
.
faceColour
=
original
.
faceColour
;
this
.
bezelColour
=
original
.
bezelColour
;
this
.
labelShape
=
original
.
labelShape
;
this
.
textFont
=
original
.
textFont
;
this
.
strokeWidth
=
original
.
strokeWidth
;
this
.
buildFromProperties
();
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
// ***************************************************************************
// ---------------------------------------------------------------------------
private
void
buildFromProperties
()
{
double
diameter
;
diameter
=
2
*
innerRadius
;
inner
=
new
Area
(
new
Ellipse2D
.
Double
(-
innerRadius
,
-
innerRadius
,
diameter
,
diameter
));
...
...
@@ -119,15 +163,11 @@ public class ArcGraph extends ValueCorona {
labelShape
=
originTranslator
.
createTransformedShape
(
labelShape
);
}
borderStroke
=
(
builder
.
strokeWidth
>
0
)
?
new
BasicStroke
(
builder
.
strokeWidth
)
:
null
;
borderStroke
=
(
strokeWidth
>
0
)
?
new
BasicStroke
(
strokeWidth
)
:
null
;
this
.
setInformation
((
relative
)
?
this
.
reference
:
this
.
variable
.
getMinValue
());
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
// ***************************************************************************
// ---------------------------------------------------------------------------
private
Point
getOffsetFromCenter
()
{
...
...
@@ -338,6 +378,13 @@ public class ArcGraph extends ValueCorona {
}
}
// ---------------------------------------------------------------------------
@Override
public
ArcGraph
clone
()
{
return
new
ArcGraph
(
this
);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class *
...
...
CPS/src/lu/list/itis/dkd/tui/widget/corona/ConditionalCorona.java
View file @
37e3695e
...
...
@@ -17,7 +17,9 @@ import lu.list.itis.dkd.dbc.annotation.NonNullByDefault;
import
lu.list.itis.dkd.tui.cps.system.Equation
;
import
lu.list.itis.dkd.tui.cps.variable.BooleanVariable
;
import
lu.list.itis.dkd.tui.cps.variable.Variable
;
import
lu.list.itis.dkd.tui.utility.ImageUtilities
;
import
lu.list.itis.dkd.tui.utility.Point
;
import
lu.list.itis.dkd.tui.utility.ScreenCoordinates
;
import
lu.list.itis.dkd.tui.widget.corona.builder.ConditionalCoronaBuilder
;
import
java.awt.Graphics2D
;
...
...
@@ -44,7 +46,8 @@ public class ConditionalCorona extends Corona {
*/
private
LinkedHashSet
<
String
>
triggers
=
new
LinkedHashSet
<>();
private
java
.
awt
.
Image
image
;
protected
java
.
awt
.
Image
image
;
protected
Point
imageCentre
;
/**
* @param builder
...
...
@@ -58,6 +61,22 @@ public class ConditionalCorona extends Corona {
this
.
triggers
=
builder
.
triggers
;
this
.
variables
=
builder
.
variables
;
this
.
image
=
builder
.
image
;
imageCentre
=
(
image
!=
null
)
?
new
Point
(
image
.
getWidth
(
null
)
/
2
,
image
.
getHeight
(
null
)
/
2
,
0
,
ScreenCoordinates
.
class
)
:
new
Point
();
}
public
ConditionalCorona
(
ConditionalCorona
original
)
{
super
(
original
);
this
.
trigger
=
original
.
trigger
;
this
.
triggerVariable
=
original
.
triggerVariable
.
clone
();
this
.
triggers
=
new
LinkedHashSet
<>(
original
.
triggers
);
this
.
variables
=
new
LinkedHashSet
<>(
original
.
variables
);
this
.
image
=
ImageUtilities
.
deepCopy
(
original
.
image
);
imageCentre
=
(
image
!=
null
)
?
new
Point
(
image
.
getWidth
(
null
)
/
2
,
image
.
getHeight
(
null
)
/
2
,
0
,
ScreenCoordinates
.
class
)
:
new
Point
();
}
/** {@inheritDoc} */
...
...
@@ -68,37 +87,39 @@ public class ConditionalCorona extends Corona {
return
;
}
centre
.
toScreenCoordinates
();
if
(
initialTranslation
!=
null
)
{
initialTranslation
.
toScreenCoordinates
();
}
else
{
initialTranslation
=
new
Point
();
}
Point
drawAt
=
centre
.
add
(
initialTranslation
);
AffineTransform
rotation
=
new
AffineTransform
();
rotation
.
rotate
(
rotateWithHandle
?
drawAt
.
getAngle
()
:
initialTranslation
!=
null
?
initialTranslation
.
getAngle
()
:
0
,
centre
.
getX
(),
centre
.
getY
());
rotation
.
translate
(
drawAt
.
x
,
drawAt
.
y
);
if
(
spinOnCoronaCentre
)
{
rotation
.
rotate
(
rotateWithHandle
?
-
drawAt
.
getAngle
()
:
0
);
rotation
.
translate
(-
image
.
getWidth
(
null
)
/
2
,
-
image
.
getHeight
(
null
)
/
2
);
}
rotation
.
transform
(
new
Point
(),
drawAt
);
if
(
Double
.
compare
(
initialRotation
,
0
d
)
!=
0
)
{
AffineTransform
transformation
=
new
AffineTransform
();
transformation
.
rotate
(
initialRotation
,
spinOnCoronaCentre
?
drawAt
.
getX
()
+
image
.
getWidth
(
null
)
/
2
:
drawAt
.
getX
(),
spinOnCoronaCentre
?
drawAt
.
getY
()
+
image
.
getHeight
(
null
)
/
2
:
drawAt
.
getY
());
canvas
.
setTransform
(
transformation
);
}
canvas
.
drawImage
(
image
,
(
int
)
drawAt
.
x
,
(
int
)
drawAt
.
y
,
null
);
canvas
.
setTransform
(
new
AffineTransform
());
// centre.toScreenCoordinates();
// if (initialTranslation != null) {
// initialTranslation.toScreenCoordinates();
// } else {
// initialTranslation = new Point();
// }
//
// Point drawAt = centre.add(initialTranslation);
//
// AffineTransform rotation = new AffineTransform();
// rotation.rotate(rotateWithHandle ? drawAt.getAngle() : initialTranslation != null ?
// initialTranslation.getAngle() : 0, centre.getX(), centre.getY());
// rotation.translate(drawAt.x, drawAt.y);
//
// if (spinOnCoronaCentre) {
// rotation.rotate(rotateWithHandle ? -drawAt.getAngle() : 0);
// rotation.translate(-image.getWidth(null) / 2, -image.getHeight(null) / 2);
// }
//
// rotation.transform(new Point(), drawAt);
//
// if (Double.compare(initialRotation, 0d) != 0) {
// AffineTransform transformation = new AffineTransform();
// transformation.rotate(initialRotation, spinOnCoronaCentre ? drawAt.getX() +
// image.getWidth(null) / 2 : drawAt.getX(), spinOnCoronaCentre ? drawAt.getY() +
// image.getHeight(null) / 2 : drawAt.getY());
// canvas.setTransform(transformation);
// }
AffineTransform
transform
=
this
.
getTransform
(
imageCentre
);
canvas
.
drawImage
(
image
,
transform
,
null
);
}
/**
* Method used to add a variable to the set of variables held by this corona.
*
...
...
@@ -117,4 +138,10 @@ public class ConditionalCorona extends Corona {
public
LinkedHashSet
<
String
>
getTriggers
()
{
return
triggers
;
}
@Override
public
ConditionalCorona
clone
()
{
return
new
ConditionalCorona
(
this
);
}
}
\ No newline at end of file
CPS/src/lu/list/itis/dkd/tui/widget/corona/ShapeGraph.java
View file @
37e3695e
...
...
@@ -76,8 +76,32 @@ public class ShapeGraph extends ValueCorona {
borderStroke
=
(
builder
.
strokeWidth
>
0
)
?
new
BasicStroke
(
builder
.
strokeWidth
)
:
null
;
this
.
setInformation
(
this
.
variable
.
getMinValue
());
}
// ---------------------------------------------------------------------------
/**
* Copy constructor to clone corona.
*
* @param original
* specifies the original corona to create an exact copy from.
*/
// ---------------------------------------------------------------------------
public
ShapeGraph
(
ShapeGraph
original
)
{
super
(
original
);
this
.
lowerBound
=
original
.
lowerBound
;
this
.
upperBound
=
original
.
upperBound
;
this
.
fillColour
=
original
.
fillColour
;
this
.
strokeColour
=
original
.
strokeColour
;
this
.
strokeWidth
=
original
.
strokeWidth
;
this
.
graphShape
=
original
.
graphShape
;
borderStroke
=
(
original
.
strokeWidth
>
0
)
?
new
BasicStroke
(
original
.
strokeWidth
)
:
null
;
this
.
setInformation
(
this
.
variable
.
getMinValue
());
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
...
...
@@ -189,6 +213,13 @@ public class ShapeGraph extends ValueCorona {
}
}
// ---------------------------------------------------------------------------
@Override
public
ShapeGraph
clone
()
{
return
new
ShapeGraph
(
this
);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class *
...
...
CPS/src/lu/list/itis/dkd/tui/widget/corona/ValueCorona.java
View file @
37e3695e
...
...
@@ -35,6 +35,14 @@ public class ValueCorona extends Corona implements InformationReceiver<Object> {
this
.
selected
=
false
;
}
// ---------------------------------------------------------------------------
public
ValueCorona
(
ValueCorona
original
)
{
super
(
original
);
this
.
variable
=
(
original
.
variable
!=
null
)
?
original
.
variable
.
clone
()
:
null
;
this
.
selected
=
false
;
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
...
...
@@ -82,6 +90,13 @@ public class ValueCorona extends Corona implements InformationReceiver<Object> {
}
}
// ---------------------------------------------------------------------------
@Override
public
ValueCorona
clone
()
{
return
new
ValueCorona
(
this
);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * 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