Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
XChart
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Brady James Garvin
XChart
Commits
d14ccb35
Commit
d14ccb35
authored
12 years ago
by
Tim Molter
Browse files
Options
Downloads
Patches
Plain Diff
fixed legend layout
parent
ef13c8f1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Legend.java
+8
-10
8 additions, 10 deletions
...main/java/com/xeiam/xchart/internal/chartpart/Legend.java
with
8 additions
and
10 deletions
xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Legend.java
+
8
−
10
View file @
d14ccb35
...
@@ -97,7 +97,7 @@ public class Legend implements ChartPart {
...
@@ -97,7 +97,7 @@ public class Legend implements ChartPart {
// Draw Legend Box
// Draw Legend Box
int
legendBoxWidth
=
legendContentWidth
+
2
*
chart
.
getStyleManager
().
getLegendPadding
();
int
legendBoxWidth
=
legendContentWidth
+
2
*
chart
.
getStyleManager
().
getLegendPadding
();
int
legendBoxHeight
=
legendContentHeight
+
2
*
chart
.
getStyleManager
().
getLegendPadding
();
int
legendBoxHeight
=
legendContentHeight
+
2
*
chart
.
getStyleManager
().
getLegendPadding
();
return
new
int
[]
{
legendBoxWidth
,
legendBoxHeight
,
legendText
Content
Max
Height
};
return
new
int
[]
{
legendBoxWidth
,
legendBoxHeight
,
max
ContentHeight
};
}
else
{
}
else
{
return
new
int
[]
{
0
,
0
,
0
};
return
new
int
[]
{
0
,
0
,
0
};
}
}
...
@@ -115,7 +115,7 @@ public class Legend implements ChartPart {
...
@@ -115,7 +115,7 @@ public class Legend implements ChartPart {
int
legendBoxWidth
=
getSizeHint
()[
0
];
int
legendBoxWidth
=
getSizeHint
()[
0
];
int
legendBoxHeight
=
getSizeHint
()[
1
];
int
legendBoxHeight
=
getSizeHint
()[
1
];
int
legendText
Content
Max
Height
=
getSizeHint
()[
2
];
int
max
ContentHeight
=
getSizeHint
()[
2
];
// legend draw position
// legend draw position
int
xOffset
=
0
;
int
xOffset
=
0
;
...
@@ -162,12 +162,12 @@ public class Legend implements ChartPart {
...
@@ -162,12 +162,12 @@ public class Legend implements ChartPart {
if
(
series
.
getStroke
()
!=
null
)
{
if
(
series
.
getStroke
()
!=
null
)
{
g
.
setColor
(
series
.
getStrokeColor
());
g
.
setColor
(
series
.
getStrokeColor
());
g
.
setStroke
(
series
.
getStroke
());
g
.
setStroke
(
series
.
getStroke
());
g
.
drawLine
(
startx
,
starty
-
Marker
.
Y_OFFSET
,
(
int
)
(
startx
+
Marker
.
SIZE
*
3.0
),
starty
-
Marker
.
Y_OFFSET
);
g
.
drawLine
(
startx
,
starty
+
(
int
)
(
maxContentHeight
/
2.0
)
,
(
int
)
(
startx
+
Marker
.
SIZE
*
3.0
),
starty
+
(
int
)
(
maxContentHeight
/
2.0
)
);
}
}
// paint marker
// paint marker
if
(
series
.
getMarker
()
!=
null
)
{
if
(
series
.
getMarker
()
!=
null
)
{
g
.
setColor
(
series
.
getMarkerColor
());
g
.
setColor
(
series
.
getMarkerColor
());
series
.
getMarker
().
paint
(
g
,
(
int
)
(
startx
+
(
Marker
.
SIZE
*
1.5
)),
starty
-
Marker
.
Y_OFFSET
);
series
.
getMarker
().
paint
(
g
,
(
int
)
(
startx
+
(
Marker
.
SIZE
*
1.5
)),
starty
+
(
int
)
(
maxContentHeight
/
2.0
)
);
}
}
}
else
{
}
else
{
// paint box
// paint box
...
@@ -176,7 +176,6 @@ public class Legend implements ChartPart {
...
@@ -176,7 +176,6 @@ public class Legend implements ChartPart {
g
.
fillPolygon
(
new
int
[]
{
startx
,
startx
+
BOX_SIZE
,
startx
+
BOX_SIZE
,
startx
},
new
int
[]
{
starty
,
starty
,
starty
+
BOX_SIZE
,
starty
+
BOX_SIZE
},
4
);
g
.
fillPolygon
(
new
int
[]
{
startx
,
startx
+
BOX_SIZE
,
startx
+
BOX_SIZE
,
startx
},
new
int
[]
{
starty
,
starty
,
starty
+
BOX_SIZE
,
starty
+
BOX_SIZE
},
4
);
g
.
setStroke
(
series
.
getStroke
());
g
.
setStroke
(
series
.
getStroke
());
g
.
drawPolygon
(
new
int
[]
{
startx
,
startx
+
BOX_SIZE
,
startx
+
BOX_SIZE
,
startx
},
new
int
[]
{
starty
,
starty
,
starty
+
BOX_SIZE
,
starty
+
BOX_SIZE
},
4
);
g
.
drawPolygon
(
new
int
[]
{
startx
,
startx
+
BOX_SIZE
,
startx
+
BOX_SIZE
,
startx
},
new
int
[]
{
starty
,
starty
,
starty
+
BOX_SIZE
,
starty
+
BOX_SIZE
},
4
);
}
}
}
}
...
@@ -184,13 +183,12 @@ public class Legend implements ChartPart {
...
@@ -184,13 +183,12 @@ public class Legend implements ChartPart {
g
.
setColor
(
chart
.
getStyleManager
().
getChartFontColor
());
g
.
setColor
(
chart
.
getStyleManager
().
getChartFontColor
());
TextLayout
layout
=
new
TextLayout
(
series
.
getName
(),
chart
.
getStyleManager
().
getLegendFont
(),
new
FontRenderContext
(
null
,
true
,
false
));
TextLayout
layout
=
new
TextLayout
(
series
.
getName
(),
chart
.
getStyleManager
().
getLegendFont
(),
new
FontRenderContext
(
null
,
true
,
false
));
if
(
getChart
().
getStyleManager
().
getChartType
()
!=
ChartType
.
Bar
)
{
if
(
getChart
().
getStyleManager
().
getChartType
()
!=
ChartType
.
Bar
)
{
layout
.
draw
(
g
,
(
float
)
(
startx
+
Marker
.
SIZE
+
(
Marker
.
SIZE
*
1.5
)
+
chart
.
getStyleManager
().
getLegendPadding
()),
layout
.
draw
(
g
,
(
float
)
(
startx
+
Marker
.
SIZE
+
(
Marker
.
SIZE
*
1.5
)
+
chart
.
getStyleManager
().
getLegendPadding
()),
starty
(
int
)
(
starty
+
(
Marker
.
SIZE
+
chart
.
getStyleManager
().
getLegendPadding
())
/
2.0
));
+
(
int
)
((
maxContentHeight
+
layout
.
getPixelBounds
(
null
,
0
,
0
).
getHeight
())
/
2.0
));
starty
=
starty
+
legendTextContentMaxHeight
+
chart
.
getStyleManager
().
getLegendPadding
();
}
else
{
}
else
{
layout
.
draw
(
g
,
startx
+
BOX_SIZE
+
chart
.
getStyleManager
().
getLegendPadding
(),
(
int
)
(
starty
+
(
BOX_SIZE
+
chart
.
getStyleManager
().
getLegendPadding
())
/
2.0
));
layout
.
draw
(
g
,
startx
+
BOX_SIZE
+
chart
.
getStyleManager
().
getLegendPadding
(),
starty
+
(
int
)
((
maxContentHeight
+
layout
.
getPixelBounds
(
null
,
0
,
0
).
getHeight
())
/
2.0
));
starty
=
starty
+
legendTextContentMaxHeight
+
chart
.
getStyleManager
().
getLegendPadding
();
}
}
starty
=
starty
+
maxContentHeight
+
chart
.
getStyleManager
().
getLegendPadding
();
}
}
// bounds
// bounds
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment