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
adc0e622
Commit
adc0e622
authored
Jun 15, 2020
by
Nico Mack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added centred property
parent
caa63ec0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
8 deletions
+17
-8
CPS/src/lu/list/itis/dkd/tui/widget/corona/ArcGraph.java
CPS/src/lu/list/itis/dkd/tui/widget/corona/ArcGraph.java
+15
-8
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseArcGraphBuilder.java
...is/dkd/tui/widget/corona/builder/BaseArcGraphBuilder.java
+2
-0
No files found.
CPS/src/lu/list/itis/dkd/tui/widget/corona/ArcGraph.java
View file @
adc0e622
...
@@ -20,6 +20,7 @@ import java.awt.Graphics2D;
...
@@ -20,6 +20,7 @@ import java.awt.Graphics2D;
import
java.awt.Shape
;
import
java.awt.Shape
;
import
java.awt.Stroke
;
import
java.awt.Stroke
;
import
java.awt.font.FontRenderContext
;
import
java.awt.font.FontRenderContext
;
import
java.awt.font.GlyphVector
;
import
java.awt.font.LineMetrics
;
import
java.awt.font.LineMetrics
;
import
java.awt.geom.AffineTransform
;
import
java.awt.geom.AffineTransform
;
import
java.awt.geom.Arc2D
;
import
java.awt.geom.Arc2D
;
...
@@ -61,6 +62,7 @@ public class ArcGraph extends ValueCorona {
...
@@ -61,6 +62,7 @@ public class ArcGraph extends ValueCorona {
protected
int
labelGap
;
protected
int
labelGap
;
protected
int
insetBorder
;
protected
int
insetBorder
;
protected
boolean
stretchToFit
;
protected
boolean
stretchToFit
;
protected
boolean
centered
;
protected
Font
textFont
;
protected
Font
textFont
;
protected
Stroke
borderStroke
;
protected
Stroke
borderStroke
;
protected
int
strokeWidth
;
protected
int
strokeWidth
;
...
@@ -115,6 +117,7 @@ public class ArcGraph extends ValueCorona {
...
@@ -115,6 +117,7 @@ public class ArcGraph extends ValueCorona {
this
.
labelGap
=
builder
.
labelGap
;
this
.
labelGap
=
builder
.
labelGap
;
this
.
insetBorder
=
builder
.
insetBorder
;
this
.
insetBorder
=
builder
.
insetBorder
;
this
.
stretchToFit
=
builder
.
stretchToFit
;
this
.
stretchToFit
=
builder
.
stretchToFit
;
this
.
centered
=
builder
.
centered
;
this
.
textFont
=
builder
.
textFont
;
this
.
textFont
=
builder
.
textFont
;
this
.
strokeWidth
=
builder
.
strokeWidth
;
this
.
strokeWidth
=
builder
.
strokeWidth
;
...
@@ -154,6 +157,7 @@ public class ArcGraph extends ValueCorona {
...
@@ -154,6 +157,7 @@ public class ArcGraph extends ValueCorona {
this
.
labelFormat
=
original
.
labelFormat
;
this
.
labelFormat
=
original
.
labelFormat
;
this
.
insetBorder
=
original
.
insetBorder
;
this
.
insetBorder
=
original
.
insetBorder
;
this
.
stretchToFit
=
original
.
stretchToFit
;
this
.
stretchToFit
=
original
.
stretchToFit
;
this
.
centered
=
original
.
centered
;
this
.
textFont
=
original
.
textFont
;
this
.
textFont
=
original
.
textFont
;
this
.
strokeWidth
=
original
.
strokeWidth
;
this
.
strokeWidth
=
original
.
strokeWidth
;
...
@@ -192,16 +196,19 @@ public class ArcGraph extends ValueCorona {
...
@@ -192,16 +196,19 @@ public class ArcGraph extends ValueCorona {
AffineTransform
originTranslator
=
new
AffineTransform
();
AffineTransform
originTranslator
=
new
AffineTransform
();
if
(
stretchToFit
)
{
if
(
stretchToFit
)
{
// String fullScale = this.variableFormat.format(this.variable.get);
labelShape
=
ShapeUtils
.
stretchToFit
(
labelShape
,
label
,
textFont
,
false
,
2
*
insetBorder
);
labelShape
=
ShapeUtils
.
stretchToFit
(
labelShape
,
label
,
textFont
,
false
,
2
*
insetBorder
);
Rectangle2D
bounds
=
labelShape
.
getBounds2D
();
if
(
bounds
.
getX
()
<
0
)
originTranslator
.
translate
(-
bounds
.
getX
()
-
insetBorder
,
0
);
labelShape
=
originTranslator
.
createTransformedShape
(
labelShape
);
}
}
if
(
centered
)
{
Rectangle2D
bounds
=
labelShape
.
getBounds2D
();
Rectangle2D
bounds
=
labelShape
.
getBounds2D
();
if
(
bounds
.
getX
()
<
0
)
GlyphVector
glyphVector
=
textFont
.
createGlyphVector
(
new
FontRenderContext
(
null
,
true
,
true
),
label
);
originTranslator
.
translate
(-
bounds
.
getX
()
-
insetBorder
,
0
);
double
requiredWidth
=
glyphVector
.
getLogicalBounds
().
getWidth
();
labelShape
=
originTranslator
.
createTransformedShape
(
labelShape
);
insetBorder
=
(
int
)
(
bounds
.
getWidth
()
-
requiredWidth
)
/
2
;
}
}
}
}
}
...
@@ -405,7 +412,7 @@ public class ArcGraph extends ValueCorona {
...
@@ -405,7 +412,7 @@ public class ArcGraph extends ValueCorona {
if
(
textColour
!=
null
)
{
if
(
textColour
!=
null
)
{
localCanvas
.
setPaint
(
textColour
.
getColor
());
localCanvas
.
setPaint
(
textColour
.
getColor
());
localCanvas
.
setFont
(
textFont
);
localCanvas
.
setFont
(
textFont
);
localCanvas
.
drawString
(
label
,
5
,
(
labelMetrics
.
getAscent
()
/
2
));
localCanvas
.
drawString
(
label
,
insetBorder
,
(
labelMetrics
.
getAscent
()
/
2
));
}
}
localCanvas
.
dispose
();
localCanvas
.
dispose
();
...
...
CPS/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseArcGraphBuilder.java
View file @
adc0e622
...
@@ -58,6 +58,7 @@ public class BaseArcGraphBuilder<B extends BaseArcGraphBuilder<B>> extends Value
...
@@ -58,6 +58,7 @@ public class BaseArcGraphBuilder<B extends BaseArcGraphBuilder<B>> extends Value
public
String
labelFormat
;
public
String
labelFormat
;
public
Font
textFont
;
public
Font
textFont
;
public
boolean
stretchToFit
;
public
boolean
stretchToFit
;
public
boolean
centered
;
// ***************************************************************************
// ***************************************************************************
// * Constants *
// * Constants *
...
@@ -131,6 +132,7 @@ public class BaseArcGraphBuilder<B extends BaseArcGraphBuilder<B>> extends Value
...
@@ -131,6 +132,7 @@ public class BaseArcGraphBuilder<B extends BaseArcGraphBuilder<B>> extends Value
labelGap
=
BootstrappingUtils
.
getContentAsInteger
(
rootElement
,
Externalization
.
LABEL_GAP_NODE
,
BootstrappingUtils
.
OPTIONAL
,
0
,
context
);
labelGap
=
BootstrappingUtils
.
getContentAsInteger
(
rootElement
,
Externalization
.
LABEL_GAP_NODE
,
BootstrappingUtils
.
OPTIONAL
,
0
,
context
);
insetBorder
=
BootstrappingUtils
.
getContentAsInteger
(
rootElement
,
Externalization
.
INSET_BORDER_NODE
,
BootstrappingUtils
.
OPTIONAL
,
0
,
context
);
insetBorder
=
BootstrappingUtils
.
getContentAsInteger
(
rootElement
,
Externalization
.
INSET_BORDER_NODE
,
BootstrappingUtils
.
OPTIONAL
,
0
,
context
);
stretchToFit
=
BootstrappingUtils
.
getContentAsBoolean
(
rootElement
,
CpsNamespace
.
STRETCH_TO_FIT_NODE
,
BootstrappingUtils
.
OPTIONAL
,
Boolean
.
FALSE
,
context
);
stretchToFit
=
BootstrappingUtils
.
getContentAsBoolean
(
rootElement
,
CpsNamespace
.
STRETCH_TO_FIT_NODE
,
BootstrappingUtils
.
OPTIONAL
,
Boolean
.
FALSE
,
context
);
centered
=
BootstrappingUtils
.
getContentAsBoolean
(
rootElement
,
Externalization
.
CENTRED_NODE
,
BootstrappingUtils
.
OPTIONAL
,
Boolean
.
FALSE
,
context
);
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
);
String
fontName
=
BootstrappingUtils
.
getContentAsString
(
rootElement
,
Externalization
.
FONT_NODE
,
BootstrappingUtils
.
OPTIONAL
,
"Monospaced"
);
//$NON-NLS-1$
String
fontName
=
BootstrappingUtils
.
getContentAsString
(
rootElement
,
Externalization
.
FONT_NODE
,
BootstrappingUtils
.
OPTIONAL
,
"Monospaced"
);
//$NON-NLS-1$
...
...
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