Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
NUI
TULIP-CPS
Commits
3c210d83
Commit
3c210d83
authored
Apr 22, 2020
by
Nico Mack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Major changes to the SegmentedArcProperties API
parent
eb8b4c6e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
294 additions
and
36 deletions
+294
-36
CPS/src/lu/list/itis/dkd/tui/widget/corona/SegmentedArcGraph.java
...lu/list/itis/dkd/tui/widget/corona/SegmentedArcGraph.java
+8
-16
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseSegmentedArcGraphBuilder.java
...i/widget/corona/builder/BaseSegmentedArcGraphBuilder.java
+20
-16
CPS/src/lu/list/itis/dkd/tui/widget/corona/inner/SegmentedArcGraphProperties.java
.../tui/widget/corona/inner/SegmentedArcGraphProperties.java
+266
-4
No files found.
CPS/src/lu/list/itis/dkd/tui/widget/corona/SegmentedArcGraph.java
View file @
3c210d83
...
@@ -50,7 +50,6 @@ public class SegmentedArcGraph extends SegmentedArc implements InformationReceiv
...
@@ -50,7 +50,6 @@ public class SegmentedArcGraph extends SegmentedArc implements InformationReceiv
protected
DisplayMode
mode
;
protected
DisplayMode
mode
;
private
VariableManager
variableManager
;
private
VariableManager
variableManager
;
// private List<SegmentedArcGraphProperties> segmentProperties;
private
int
currentlySelected
=
-
1
;
private
int
currentlySelected
=
-
1
;
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
...
@@ -67,7 +66,6 @@ public class SegmentedArcGraph extends SegmentedArc implements InformationReceiv
...
@@ -67,7 +66,6 @@ public class SegmentedArcGraph extends SegmentedArc implements InformationReceiv
super
(
builder
);
super
(
builder
);
this
.
variable
=
builder
.
variable
;
this
.
variable
=
builder
.
variable
;
this
.
mode
=
builder
.
mode
;
this
.
mode
=
builder
.
mode
;
// this.segmentProperties = builder.segmentProperties;
this
.
buildFromProperties
();
this
.
buildFromProperties
();
}
}
...
@@ -82,7 +80,6 @@ public class SegmentedArcGraph extends SegmentedArc implements InformationReceiv
...
@@ -82,7 +80,6 @@ public class SegmentedArcGraph extends SegmentedArc implements InformationReceiv
super
(
original
);
super
(
original
);
this
.
variable
=
original
.
variable
;
this
.
variable
=
original
.
variable
;
this
.
mode
=
original
.
mode
;
this
.
mode
=
original
.
mode
;
// this.segmentProperties = original.segmentProperties;
this
.
buildFromProperties
();
this
.
buildFromProperties
();
}
}
...
@@ -99,12 +96,7 @@ public class SegmentedArcGraph extends SegmentedArc implements InformationReceiv
...
@@ -99,12 +96,7 @@ public class SegmentedArcGraph extends SegmentedArc implements InformationReceiv
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
private
void
setSelected
(
SegmentedArcGraphProperties
property
,
boolean
selectIt
)
{
private
void
setSelected
(
SegmentedArcGraphProperties
property
,
boolean
selectIt
)
{
if
(
property
.
fillColour
!=
null
)
property
.
setSelected
(
selectIt
);
property
.
fillColour
.
setSwitched
(
selectIt
);
if
(
property
.
strokeColour
!=
null
)
property
.
strokeColour
.
setSwitched
(
selectIt
);
if
(
property
.
textColour
!=
null
)
property
.
textColour
.
setSwitched
(
selectIt
);
}
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
...
@@ -157,21 +149,21 @@ public class SegmentedArcGraph extends SegmentedArc implements InformationReceiv
...
@@ -157,21 +149,21 @@ public class SegmentedArcGraph extends SegmentedArc implements InformationReceiv
Shape
segment
=
segments
.
get
(
current
);
Shape
segment
=
segments
.
get
(
current
);
SegmentedArcGraphProperties
properties
=
(
SegmentedArcGraphProperties
)
segmentProperties
.
get
(
current
);
SegmentedArcGraphProperties
properties
=
(
SegmentedArcGraphProperties
)
segmentProperties
.
get
(
current
);
if
(
properties
.
f
illColour
!=
null
)
{
if
(
properties
.
hasF
illColour
()
)
{
localCanvas
.
setPaint
(
properties
.
f
illColour
.
getColor
());
localCanvas
.
setPaint
(
properties
.
getF
illColour
());
localCanvas
.
fill
(
segment
);
localCanvas
.
fill
(
segment
);
}
}
if
(
(
properties
.
s
trokeColour
!=
null
)
&&
(
properties
.
s
troke
!=
null
))
{
if
(
properties
.
hasS
trokeColour
(
)
&&
properties
.
hasS
troke
(
))
{
localCanvas
.
setPaint
(
properties
.
s
trokeColour
.
getColor
());
localCanvas
.
setPaint
(
properties
.
getS
trokeColour
());
localCanvas
.
setStroke
(
properties
.
s
troke
);
localCanvas
.
setStroke
(
properties
.
getS
troke
()
);
localCanvas
.
draw
(
segment
);
localCanvas
.
draw
(
segment
);
}
}
Shape
label
=
labels
.
get
(
current
);
Shape
label
=
labels
.
get
(
current
);
if
((
label
!=
null
)
&&
(
properties
.
t
extColour
!=
null
))
{
if
((
label
!=
null
)
&&
properties
.
hasT
extColour
(
))
{
localCanvas
.
setPaint
(
properties
.
t
extColour
.
getColor
());
localCanvas
.
setPaint
(
properties
.
getT
extColour
());
localCanvas
.
fill
(
label
);
localCanvas
.
fill
(
label
);
}
}
}
}
...
...
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseSegmentedArcGraphBuilder.java
View file @
3c210d83
...
@@ -29,6 +29,7 @@ import lu.list.itis.dkd.tui.utility.ColorPair;
...
@@ -29,6 +29,7 @@ import lu.list.itis.dkd.tui.utility.ColorPair;
import
lu.list.itis.dkd.tui.utility.CpsNamespace
;
import
lu.list.itis.dkd.tui.utility.CpsNamespace
;
import
lu.list.itis.dkd.tui.utility.Externalization
;
import
lu.list.itis.dkd.tui.utility.Externalization
;
import
lu.list.itis.dkd.tui.utility.Point
;
import
lu.list.itis.dkd.tui.utility.Point
;
import
lu.list.itis.dkd.tui.utility.SwitchablePair
;
import
lu.list.itis.dkd.tui.widget.corona.SegmentedArcGraph
;
import
lu.list.itis.dkd.tui.widget.corona.SegmentedArcGraph
;
import
lu.list.itis.dkd.tui.widget.corona.inner.DisplayMode
;
import
lu.list.itis.dkd.tui.widget.corona.inner.DisplayMode
;
import
lu.list.itis.dkd.tui.widget.corona.inner.SegmentedArcGraphProperties
;
import
lu.list.itis.dkd.tui.widget.corona.inner.SegmentedArcGraphProperties
;
...
@@ -113,17 +114,6 @@ public abstract class BaseSegmentedArcGraphBuilder<B extends BaseSegmentedArcGra
...
@@ -113,17 +114,6 @@ public abstract class BaseSegmentedArcGraphBuilder<B extends BaseSegmentedArcGra
if
(
displayModeElement
!=
null
)
{
if
(
displayModeElement
!=
null
)
{
mode
=
DisplayModeBootstrapper
.
buildDisplayModeFromElement
(
rootElement
,
context
,
callback
);
mode
=
DisplayModeBootstrapper
.
buildDisplayModeFromElement
(
rootElement
,
context
,
callback
);
}
}
// this.segmentProperties = new ArrayList<>();
// Element segmentsNode = rootElement.getChild(Externalization.SEGMENTS_NODE);
// if (segmentsNode != null) {
// List<Element> segmentNodes = segmentsNode.getChildren(Externalization.SEGMENT_NODE);
// if (segmentNodes != null) {
// for (Element segmentNode : segmentNodes) {
// this.segmentProperties.add(this.buildSegmentProperty(segmentNode, context, callback));
// }
// }
// }
}
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
...
@@ -131,12 +121,13 @@ public abstract class BaseSegmentedArcGraphBuilder<B extends BaseSegmentedArcGra
...
@@ -131,12 +121,13 @@ public abstract class BaseSegmentedArcGraphBuilder<B extends BaseSegmentedArcGra
@Override
@Override
protected
SegmentedArcGraphProperties
buildSegmentProperty
(
@NonNull
Element
segmentElement
,
BootstrapContext
context
,
BootstrapCallback
callback
)
throws
BuildException
{
protected
SegmentedArcGraphProperties
buildSegmentProperty
(
@NonNull
Element
segmentElement
,
BootstrapContext
context
,
BootstrapCallback
callback
)
throws
BuildException
{
SegmentedArcGraphProperties
property
=
new
SegmentedArcGraphProperties
();
SegmentedArcGraphProperties
property
=
new
SegmentedArcGraphProperties
();
property
.
label
=
BootstrappingUtils
.
getContentAsString
(
segmentElement
,
Externalization
.
LABEL_NODE
,
BootstrappingUtils
.
OPTIONAL
,
Externalization
.
EMPTY_STRING
,
context
);
property
.
setLabel
(
BootstrappingUtils
.
getContentAsString
(
segmentElement
,
Externalization
.
LABEL_NODE
,
BootstrappingUtils
.
OPTIONAL
,
Externalization
.
EMPTY_STRING
,
context
));
property
.
fillColour
=
buildColorPair
(
segmentElement
.
getChild
(
Externalization
.
FILL_COLOUR_ELEMENT
),
context
);
property
.
setFillColourPair
(
buildColorPair
(
segmentElement
.
getChild
(
Externalization
.
FILL_COLOUR_ELEMENT
),
context
));
property
.
textColour
=
buildColorPair
(
segmentElement
.
getChild
(
Externalization
.
TEXT_COLOUR_ELEMENT
),
context
);
property
.
setTextColourPair
(
buildColorPair
(
segmentElement
.
getChild
(
Externalization
.
TEXT_COLOUR_ELEMENT
),
context
));
property
.
strokeColour
=
buildColorPair
(
segmentElement
.
getChild
(
Externalization
.
STROKE_COLOUR_ELEMENT
),
context
);
property
.
setStrokeColourPair
(
buildColorPair
(
segmentElement
.
getChild
(
Externalization
.
STROKE_COLOUR_ELEMENT
),
context
));
property
.
setScalePair
(
buildScalePair
(
segmentElement
.
getChild
(
Externalization
.
SCALE_NODE
),
context
));
int
strokeWidth
=
BootstrappingUtils
.
getContentAsInteger
(
segmentElement
,
Externalization
.
STROKE_WIDTH_NODE
,
BootstrappingUtils
.
OPTIONAL
,
0
,
context
);
int
strokeWidth
=
BootstrappingUtils
.
getContentAsInteger
(
segmentElement
,
Externalization
.
STROKE_WIDTH_NODE
,
BootstrappingUtils
.
OPTIONAL
,
0
,
context
);
property
.
stroke
=
(
strokeWidth
>
0
)
?
new
BasicStroke
(
strokeWidth
)
:
null
;
property
.
s
etS
troke
(
(
strokeWidth
>
0
)
?
new
BasicStroke
(
strokeWidth
)
:
null
)
;
return
property
;
return
property
;
}
}
...
@@ -154,6 +145,19 @@ public abstract class BaseSegmentedArcGraphBuilder<B extends BaseSegmentedArcGra
...
@@ -154,6 +145,19 @@ public abstract class BaseSegmentedArcGraphBuilder<B extends BaseSegmentedArcGra
return
new
ColorPair
(
selectedColour
,
deselectedColour
);
return
new
ColorPair
(
selectedColour
,
deselectedColour
);
}
}
// ---------------------------------------------------------------------------
private
SwitchablePair
<
Double
>
buildScalePair
(
Element
rootElement
,
BootstrapContext
context
)
throws
BuildException
{
if
(
rootElement
==
null
)
{
return
null
;
}
Double
selectedScale
=
BootstrappingUtils
.
getContentAsDouble
(
rootElement
,
Externalization
.
SELECTED_ELEMENT
,
BootstrappingUtils
.
OPTIONAL
,
1.0d
,
context
);
Double
deselectedScale
=
BootstrappingUtils
.
getContentAsDouble
(
rootElement
,
Externalization
.
DESELECTED_ELEMENT
,
BootstrappingUtils
.
OPTIONAL
,
1.0d
,
context
);
return
new
SwitchablePair
<>(
selectedScale
,
deselectedScale
);
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
/** {@inheritDoc} */
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
...
...
CPS/src/lu/list/itis/dkd/tui/widget/corona/inner/SegmentedArcGraphProperties.java
View file @
3c210d83
...
@@ -16,7 +16,12 @@
...
@@ -16,7 +16,12 @@
*/
*/
package
lu.list.itis.dkd.tui.widget.corona.inner
;
package
lu.list.itis.dkd.tui.widget.corona.inner
;
import
lu.list.itis.dkd.tui.event.SelectionListener
;
import
lu.list.itis.dkd.tui.feature.selection.Selectable
;
import
lu.list.itis.dkd.tui.utility.ColorPair
;
import
lu.list.itis.dkd.tui.utility.ColorPair
;
import
lu.list.itis.dkd.tui.utility.SwitchablePair
;
import
java.awt.Color
;
/**
/**
* Class encapsulating all properties pertaining to an individual arc segment.
* Class encapsulating all properties pertaining to an individual arc segment.
...
@@ -30,8 +35,265 @@ import lu.list.itis.dkd.tui.utility.ColorPair;
...
@@ -30,8 +35,265 @@ import lu.list.itis.dkd.tui.utility.ColorPair;
// * Class Definition and Members *
// * Class Definition and Members *
// ***************************************************************************
// ***************************************************************************
public
class
SegmentedArcGraphProperties
extends
SegmentedArcProperties
{
public
class
SegmentedArcGraphProperties
extends
SegmentedArcProperties
implements
Selectable
{
public
ColorPair
fillColour
;
private
ColorPair
fillColourPair
;
public
ColorPair
strokeColour
;
private
ColorPair
strokeColourPair
;
public
ColorPair
textColour
;
private
ColorPair
textColourPair
;
private
SwitchablePair
<
Double
>
scalePair
;
private
boolean
selected
;
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
public
SegmentedArcGraphProperties
()
{
selected
=
false
;
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
* Simple setter method for fillColour.
*
* @param fillColour
* The value to set fillColour to.
*/
// ---------------------------------------------------------------------------
public
void
setFillColourPair
(
ColorPair
fillColourPair
)
{
this
.
fillColourPair
=
fillColourPair
;
}
// ---------------------------------------------------------------------------
/**
* checks whether fillColour property is set or not.
*
* @return
*/
// ---------------------------------------------------------------------------
@Override
public
boolean
hasFillColour
()
{
return
(
fillColourPair
!=
null
);
}
// ---------------------------------------------------------------------------
/**
* Simple getter method for fillColour.
*
* @return The value of fillColour.
*/
// ---------------------------------------------------------------------------
@Override
public
Color
getFillColour
()
{
return
fillColourPair
.
getColor
();
}
// ---------------------------------------------------------------------------
/**
* Simple setter method for fillColour.
*
* @param fillColour
* The value to set fillColour to.
*/
// ---------------------------------------------------------------------------
@Override
public
void
setFillColour
(
Color
fillColour
)
{
// Dummy method, since fillColour is provided by fillColorPair member
}
// ---------------------------------------------------------------------------
/**
* Simple setter method for strokeColour.
*
* @param strokeColour
* The value to set strokeColour to.
*/
// ---------------------------------------------------------------------------
public
void
setStrokeColourPair
(
ColorPair
strokeColourPair
)
{
this
.
strokeColourPair
=
strokeColourPair
;
}
// ---------------------------------------------------------------------------
/**
* checks whether fillColour property is set or not.
*
* @return
*/
// ---------------------------------------------------------------------------
@Override
public
boolean
hasStrokeColour
()
{
return
(
strokeColourPair
!=
null
);
}
// ---------------------------------------------------------------------------
/**
* Simple getter method for fillColour.
*
* @return The value of fillColour.
*/
// ---------------------------------------------------------------------------
@Override
public
Color
getStrokeColour
()
{
return
strokeColourPair
.
getColor
();
}
// ---------------------------------------------------------------------------
/**
* Simple setter method for fillColour.
*
* @param fillColour
* The value to set fillColour to.
*/
// ---------------------------------------------------------------------------
@Override
public
void
setStrokeColour
(
Color
strokeColour
)
{
// Dummy method, since strokeColour is provided by strokeColourPair member
}
// ---------------------------------------------------------------------------
/**
* Simple setter method for textColour.
*
* @param textColour
* The value to set textColour to.
*/
// ---------------------------------------------------------------------------
public
void
setTextColourPair
(
ColorPair
textColourPair
)
{
this
.
textColourPair
=
textColourPair
;
}
// ---------------------------------------------------------------------------
/**
* checks whether fillColour property is set or not.
*
* @return
*/
// ---------------------------------------------------------------------------
@Override
public
boolean
hasTextColour
()
{
return
(
textColourPair
!=
null
);
}
// ---------------------------------------------------------------------------
/**
* Simple getter method for fillColour.
*
* @return The value of fillColour.
*/
// ---------------------------------------------------------------------------
@Override
public
Color
getTextColour
()
{
return
textColourPair
.
getColor
();
}
// ---------------------------------------------------------------------------
/**
* Simple setter method for fillColour.
*
* @param fillColour
* The value to set fillColour to.
*/
// ---------------------------------------------------------------------------
@Override
public
void
setTextColour
(
Color
strokeColour
)
{
// Dummy method, since textColour is provided by textColourPair member
}
// ---------------------------------------------------------------------------
/**
* Simple setter method for fillColour.
*
* @param fillColour
* The value to set fillColour to.
*/
// ---------------------------------------------------------------------------
public
void
setScalePair
(
SwitchablePair
<
Double
>
scalePair
)
{
this
.
scalePair
=
scalePair
;
}
// ---------------------------------------------------------------------------
/**
* checks whether fillColour property is set or not.
*
* @return
*/
// ---------------------------------------------------------------------------
public
boolean
hasScaleColour
()
{
return
(
scalePair
!=
null
);
}
// ---------------------------------------------------------------------------
/**
* Simple getter method for fillColour.
*
* @return The value of fillColour.
*/
// ---------------------------------------------------------------------------
public
Double
getScale
()
{
return
scalePair
.
getCurrent
();
}
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
// ---------------------------------------------------------------------------
@Override
public
void
addSelectionListener
(
SelectionListener
listener
)
{
// Not required.
}
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
// ---------------------------------------------------------------------------
@Override
public
void
removeSelectionListener
(
SelectionListener
listener
)
{
// Not required.
}
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
// ---------------------------------------------------------------------------
@Override
public
void
setSelected
(
boolean
selectIt
)
{
selected
=
selectIt
;
if
(
this
.
fillColourPair
!=
null
)
this
.
fillColourPair
.
setSwitched
(
selectIt
);
if
(
this
.
strokeColourPair
!=
null
)
this
.
strokeColourPair
.
setSwitched
(
selectIt
);
if
(
this
.
textColourPair
!=
null
)
this
.
textColourPair
.
setSwitched
(
selectIt
);
if
(
this
.
scalePair
!=
null
)
this
.
scalePair
.
setSwitched
(
selectIt
);
}
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
// ---------------------------------------------------------------------------
@Override
public
boolean
isSelected
()
{
return
selected
;
}
}
}
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