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
50212979
Commit
50212979
authored
Oct 30, 2017
by
Nico Mack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved InfoMarker and DisplayMarker from TLUP-GIS package into TULIP-CPS
package
parent
e7b303ef
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
560 additions
and
21 deletions
+560
-21
CPS/src/lu/list/itis/dkd/tui/marker/DisplayMarker.java
CPS/src/lu/list/itis/dkd/tui/marker/DisplayMarker.java
+133
-0
CPS/src/lu/list/itis/dkd/tui/marker/InfoMarker.java
CPS/src/lu/list/itis/dkd/tui/marker/InfoMarker.java
+82
-0
CPS/src/lu/list/itis/dkd/tui/marker/builder/BaseDisplayMarkerBuilder.java
...itis/dkd/tui/marker/builder/BaseDisplayMarkerBuilder.java
+83
-0
CPS/src/lu/list/itis/dkd/tui/marker/builder/BaseInfoMarkerBuilder.java
...st/itis/dkd/tui/marker/builder/BaseInfoMarkerBuilder.java
+109
-0
CPS/src/lu/list/itis/dkd/tui/marker/builder/DisplayMarkerBuilder.java
...ist/itis/dkd/tui/marker/builder/DisplayMarkerBuilder.java
+60
-0
CPS/src/lu/list/itis/dkd/tui/marker/builder/InfoMarkerBuilder.java
...u/list/itis/dkd/tui/marker/builder/InfoMarkerBuilder.java
+60
-0
CPS/src/lu/list/itis/dkd/tui/widget/corona/ShapeGraph.java
CPS/src/lu/list/itis/dkd/tui/widget/corona/ShapeGraph.java
+33
-21
No files found.
CPS/src/lu/list/itis/dkd/tui/marker/DisplayMarker.java
0 → 100644
View file @
50212979
package
lu.list.itis.dkd.tui.marker
;
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.marker.builder.BaseDisplayMarkerBuilder
;
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.awt.Graphics2D
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.List
;
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
@SuppressWarnings
(
"rawtypes"
)
public
class
DisplayMarker
extends
InfoMarker
implements
InputChangeListener
{
private
HashMap
<
String
,
NumericalVariable
>
variables
;
HashMap
<
String
,
ValueCorona
>
dispatcher
;
// ***************************************************************************
// * Constants *
// ***************************************************************************
private
static
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
DisplayMarker
.
class
.
getSimpleName
());
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
@SuppressWarnings
(
"unchecked"
)
public
DisplayMarker
(
BaseDisplayMarkerBuilder
<?>
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
);
}
}
// TODO Auto-generated constructor stub
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * 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$
}
}
}
}
// ---------------------------------------------------------------------------
public
Collection
<
Variable
<?>>
getVariables
()
{
Collection
<
Variable
<?>>
variables
=
new
ArrayList
<>();
List
<
ValueCorona
>
displays
=
this
.
getCoronas
(
ValueCorona
.
class
);
for
(
ValueCorona
display
:
displays
)
{
Variable
<?>
variable
=
display
.
getVariable
();
if
(
variable
!=
null
)
{
variables
.
add
(
variable
);
}
}
return
variables
;
}
// ---------------------------------------------------------------------------
@Override
public
void
paint
(
Graphics2D
canvas
)
{
super
.
paint
(
canvas
);
}
// ---------------------------------------------------------------------------
@Override
public
void
inputChanged
(
InputEvent
input
)
{
String
variableName
=
input
.
getSource
().
getName
();
ValueCorona
display
=
dispatcher
.
get
(
variableName
);
NumericalVariable
variable
=
display
.
getVariable
();
if
(
variable
!=
null
)
{
display
.
setInformation
(
variable
.
getValue
());
}
else
{
LOGGER
.
warn
(
"Corona requires variable {} unkown to display marker!"
,
variableName
);
//$NON-NLS-1$
}
}
// ---------------------------------------------------------------------------
}
CPS/src/lu/list/itis/dkd/tui/marker/InfoMarker.java
0 → 100644
View file @
50212979
package
lu.list.itis.dkd.tui.marker
;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
import
lu.list.itis.dkd.tui.content.InformationProvider
;
import
lu.list.itis.dkd.tui.content.InformationReceiver
;
import
lu.list.itis.dkd.tui.cps.variable.Variable
;
import
lu.list.itis.dkd.tui.marker.builder.BaseInfoMarkerBuilder
;
import
lu.list.itis.dkd.tui.marker.builder.InfoMarkerBuilder
;
import
lu.list.itis.dkd.tui.utility.Point
;
//***************************************************************************
//* Class Definition and Members *
//***************************************************************************
public
class
InfoMarker
<
T
>
extends
TetherableMarker
implements
InformationReceiver
<
T
>,
InformationProvider
<
T
>
{
private
T
information
;
private
Variable
<
T
>
variable
;
// ***************************************************************************
// * Constants *
// ***************************************************************************
// private static Logger LOGGER = LoggerFactory.getLogger(InfoMarker.class.getSimpleName());
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
@SuppressWarnings
(
"unchecked"
)
public
InfoMarker
(
BaseInfoMarkerBuilder
<
InfoMarkerBuilder
>
builder
)
{
super
(
builder
);
this
.
information
=
(
T
)
builder
.
information
;
this
.
variable
=
(
Variable
<
T
>)
builder
.
variable
;
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
// ***************************************************************************
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
@Override
public
T
getInformation
(
Point
position
)
{
return
this
.
getInformation
();
}
// ---------------------------------------------------------------------------
@Override
public
T
getInformation
()
{
if
(
this
.
variable
!=
null
)
{
return
this
.
variable
.
getValue
();
}
else
{
return
this
.
information
;
}
}
// ---------------------------------------------------------------------------
@Override
public
void
setInformation
(
T
information
)
{
if
(
this
.
variable
!=
null
)
{
this
.
variable
.
setValue
(
information
);
}
else
{
this
.
information
=
information
;
}
}
// ---------------------------------------------------------------------------
}
CPS/src/lu/list/itis/dkd/tui/marker/builder/BaseDisplayMarkerBuilder.java
0 → 100644
View file @
50212979
package
lu.list.itis.dkd.tui.marker.builder
;
import
java.util.Collection
;
import
java.util.Vector
;
import
org.jdom2.Element
;
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.marker.DisplayMarker
;
//***************************************************************************
//* Class Definition and Members *
//***************************************************************************
public
abstract
class
BaseDisplayMarkerBuilder
<
B
extends
BaseDisplayMarkerBuilder
<
B
>>
extends
BaseInfoMarkerBuilder
<
B
>
{
public
Collection
<
Variable
<?>>
variables
;
// ***************************************************************************
// * Constants *
// ***************************************************************************
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
protected
BaseDisplayMarkerBuilder
()
{}
// ---------------------------------------------------------------------------
protected
BaseDisplayMarkerBuilder
(
Element
rootElement
)
throws
BuildException
{
super
(
rootElement
);
}
// ---------------------------------------------------------------------------
/**
* 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
BaseDisplayMarkerBuilder
(
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
DisplayMarker
build
();
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class *
// ***************************************************************************
// ---------------------------------------------------------------------------
}
CPS/src/lu/list/itis/dkd/tui/marker/builder/BaseInfoMarkerBuilder.java
0 → 100644
View file @
50212979
package
lu.list.itis.dkd.tui.marker.builder
;
import
org.jdom2.Element
;
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.bootstrapping.VariableBootstrapper
;
import
lu.list.itis.dkd.tui.cps.variable.Variable
;
import
lu.list.itis.dkd.tui.exception.BuildException
;
import
lu.list.itis.dkd.tui.marker.InfoMarker
;
import
lu.list.itis.dkd.tui.utility.Externalization
;
//***************************************************************************
//* Class Definition and Members *
//***************************************************************************
public
abstract
class
BaseInfoMarkerBuilder
<
B
extends
BaseInfoMarkerBuilder
<
B
>>
extends
BaseTetherableMarkerBuilder
<
B
>
{
public
Object
information
;
public
Variable
<?>
variable
;
// ***************************************************************************
// * Constants *
// ***************************************************************************
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
protected
BaseInfoMarkerBuilder
()
{}
// ---------------------------------------------------------------------------
protected
BaseInfoMarkerBuilder
(
Element
rootElement
)
throws
BuildException
{
super
(
rootElement
);
this
.
buildFromBootstrap
(
rootElement
,
null
,
null
);
}
// ---------------------------------------------------------------------------
/**
* Constructor initializing all fields from an {@link Element} containing as child elements all
* the information on fields to initialize.
*
* @param rootElement
* The element harbouring, on child nodes, the necessary information to initialize all
* fields of the builder.
* @throws BuildException
* Thrown when any of the fields fail to populate due to an error in reading information
* from the XML file.
*/
// ---------------------------------------------------------------------------
protected
BaseInfoMarkerBuilder
(
Element
rootElement
,
BootstrapContext
context
,
BootstrapCallback
callback
)
throws
BuildException
{
super
(
rootElement
,
context
,
callback
);
this
.
buildFromBootstrap
(
rootElement
,
context
,
callback
);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
// ***************************************************************************
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
*
* @param rootElement
* @param context
* @param callback
* @throws BuildException
*/
protected
void
buildFromBootstrap
(
@Nullable
Element
rootElement
,
BootstrapContext
context
,
BootstrapCallback
callback
)
throws
BuildException
{
super
.
buildFromBootstrap
(
rootElement
,
context
,
callback
);
Element
informationElement
=
rootElement
.
getChild
(
Externalization
.
INFORMATION
);
if
(
informationElement
!=
null
)
{
Element
variableElement
=
informationElement
.
getChild
(
Externalization
.
VARIABLE_NODE
);
if
(
variableElement
!=
null
)
{
variable
=
VariableBootstrapper
.
buildVariableFromElement
(
variableElement
,
context
,
callback
);
}
}
else
{
this
.
information
=
BootstrappingUtils
.
getContentAsString
(
informationElement
,
null
,
BootstrappingUtils
.
OPTIONAL
,
null
,
context
);
}
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
@Override
public
abstract
InfoMarker
<?>
build
();
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class *
// ***************************************************************************
// ---------------------------------------------------------------------------
}
CPS/src/lu/list/itis/dkd/tui/marker/builder/DisplayMarkerBuilder.java
0 → 100644
View file @
50212979
package
lu.list.itis.dkd.tui.marker.builder
;
import
org.jdom2.Element
;
import
lu.list.itis.dkd.tui.bootstrapping.BootstrapCallback
;
import
lu.list.itis.dkd.tui.bootstrapping.BootstrapContext
;
import
lu.list.itis.dkd.tui.exception.BuildException
;
import
lu.list.itis.dkd.tui.marker.DisplayMarker
;
public
class
DisplayMarkerBuilder
extends
BaseDisplayMarkerBuilder
<
DisplayMarkerBuilder
>
{
// ***************************************************************************
// * 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
DisplayMarkerBuilder
(
Element
rootElement
,
BootstrapContext
context
,
BootstrapCallback
callback
)
throws
BuildException
{
super
(
rootElement
,
context
,
callback
);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
// ***************************************************************************
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
@Override
public
DisplayMarker
build
()
{
return
new
DisplayMarker
(
this
);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class *
// ***************************************************************************
// ---------------------------------------------------------------------------
}
CPS/src/lu/list/itis/dkd/tui/marker/builder/InfoMarkerBuilder.java
0 → 100644
View file @
50212979
package
lu.list.itis.dkd.tui.marker.builder
;
import
lu.list.itis.dkd.tui.bootstrapping.BootstrapCallback
;
import
lu.list.itis.dkd.tui.bootstrapping.BootstrapContext
;
import
lu.list.itis.dkd.tui.exception.BuildException
;
import
lu.list.itis.dkd.tui.marker.InfoMarker
;
import
org.jdom2.Element
;
public
class
InfoMarkerBuilder
extends
BaseInfoMarkerBuilder
<
InfoMarkerBuilder
>
{
// ***************************************************************************
// * 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
InfoMarkerBuilder
(
Element
rootElement
,
BootstrapContext
context
,
BootstrapCallback
callback
)
throws
BuildException
{
super
(
rootElement
,
context
,
callback
);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
// ***************************************************************************
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
@Override
public
InfoMarker
<?>
build
()
{
return
new
InfoMarker
(
this
);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class *
// ***************************************************************************
// ---------------------------------------------------------------------------
}
CPS/src/lu/list/itis/dkd/tui/widget/corona/ShapeGraph.java
View file @
50212979
...
...
@@ -14,7 +14,6 @@
package
lu.list.itis.dkd.tui.widget.corona
;
import
lu.list.itis.dkd.tui.utility.ColorPair
;
import
lu.list.itis.dkd.tui.utility.Point
;
import
lu.list.itis.dkd.tui.widget.corona.builder.ShapeGraphBuilder
;
import
org.pushingpixels.trident.Timeline
;
...
...
@@ -46,7 +45,7 @@ public class ShapeGraph extends ValueCorona {
protected
ColorPair
fillColour
;
protected
ColorPair
strokeColour
;
protected
int
strokeWidth
;
protected
Shape
graphShape
;
//
protected Shape graphShape;
protected
Timeline
blinkingTimeline
;
protected
Timeline
balisticTimeline
;
...
...
@@ -71,7 +70,7 @@ public class ShapeGraph extends ValueCorona {
this
.
fillColour
=
builder
.
fillColour
;
this
.
strokeColour
=
builder
.
strokeColour
;
this
.
strokeWidth
=
builder
.
strokeWidth
;
this
.
graphS
hape
=
builder
.
graphShape
;
this
.
s
hape
=
builder
.
graphShape
;
borderStroke
=
(
builder
.
strokeWidth
>
0
)
?
new
BasicStroke
(
builder
.
strokeWidth
)
:
null
;
...
...
@@ -95,7 +94,7 @@ public class ShapeGraph extends ValueCorona {
this
.
fillColour
=
original
.
fillColour
;
this
.
strokeColour
=
original
.
strokeColour
;
this
.
strokeWidth
=
original
.
strokeWidth
;
this
.
graphShape
=
original
.
graphS
hape
;
this
.
shape
=
original
.
s
hape
;
borderStroke
=
(
original
.
strokeWidth
>
0
)
?
new
BasicStroke
(
original
.
strokeWidth
)
:
null
;
...
...
@@ -131,7 +130,6 @@ public class ShapeGraph extends ValueCorona {
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
public
void
setShownValue
(
double
value
)
{
shownValue
=
value
;
...
...
@@ -150,6 +148,15 @@ public class ShapeGraph extends ValueCorona {
// ---------------------------------------------------------------------------
@Override
public
Shape
getShape
()
{
AffineTransform
transform
=
this
.
getTransform
(
null
);
transform
.
scale
(
scale
,
scale
);
return
transform
.
createTransformedShape
(
super
.
getShape
());
}
// ---------------------------------------------------------------------------
@Override
public
void
paint
(
Graphics2D
canvas
)
{
if
(!
active
)
...
...
@@ -157,35 +164,40 @@ public class ShapeGraph extends ValueCorona {
Graphics2D
localCanvas
=
(
Graphics2D
)
canvas
.
create
();
centre
.
toScreenCoordinates
();
if
(
initialTranslation
!=
null
)
initialTranslation
.
toScreenCoordinates
();
Point
drawAt
=
centre
.
add
(
initialTranslation
);
if
(
this
.
rotateWithHandle
)
{