Skip to content
Snippets Groups Projects
Commit 2076d076 authored by Tim Molter's avatar Tim Molter
Browse files

formatting [ci skip]

parent de15a67d
No related branches found
No related tags found
No related merge requests found
......@@ -15,16 +15,16 @@
*/
package com.xeiam.xchart;
import com.xeiam.xchart.StyleManager.ChartTheme;
import com.xeiam.xchart.internal.chartpart.ChartPainter;
import com.xeiam.xchart.internal.style.Theme;
import java.awt.*;
import java.awt.Graphics2D;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Map;
import com.xeiam.xchart.StyleManager.ChartTheme;
import com.xeiam.xchart.internal.chartpart.ChartPainter;
import com.xeiam.xchart.internal.style.Theme;
/**
* An XChart Chart
*
......@@ -54,6 +54,7 @@ public class Chart {
* @param chartTheme
*/
public Chart(int width, int height, ChartTheme chartTheme) {
this(width, height, chartTheme.newInstance(chartTheme));
}
......
......@@ -15,15 +15,17 @@
*/
package com.xeiam.xchart;
import java.awt.Color;
import java.awt.Font;
import java.awt.Stroke;
import java.util.Locale;
import java.util.TimeZone;
import com.xeiam.xchart.internal.style.GGPlot2Theme;
import com.xeiam.xchart.internal.style.MatlabTheme;
import com.xeiam.xchart.internal.style.Theme;
import com.xeiam.xchart.internal.style.XChartTheme;
import java.awt.*;
import java.util.Locale;
import java.util.TimeZone;
/**
* The StyleManager is used to manage all things related to styling of the vast number of Chart components
*
......
......@@ -15,14 +15,16 @@
*/
package com.xeiam.xchart.internal.chartpart;
import java.awt.*;
import java.awt.font.*;
import java.awt.BasicStroke;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.text.AttributedCharacterIterator;
import java.text.AttributedString;
import java.util.*;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.xeiam.xchart.Series;
import com.xeiam.xchart.StyleManager;
......@@ -64,6 +66,7 @@ public class Legend implements ChartPart {
* @return
*/
protected double[] getSizeHint(Graphics2D g) {
if (!chartPainter.getStyleManager().isLegendVisible()) {
return new double[] { 0, 0 };
}
......@@ -101,7 +104,8 @@ public class Legend implements ChartPart {
double legendContentWidth = 0;
if (!isBar) {
legendContentWidth = styleManager.getLegendSeriesLineLength() + styleManager.getLegendPadding() + legendTextContentMaxWidth;
} else {
}
else {
legendContentWidth = BOX_SIZE + styleManager.getLegendPadding() + legendTextContentMaxWidth;
}
// Legend Box
......@@ -111,6 +115,7 @@ public class Legend implements ChartPart {
}
private List<Map.Entry<String, Rectangle2D>> getSeriesBounds(Series series, Graphics2D g) {
String lines[] = series.getName().split("\\n");
List<Map.Entry<String, Rectangle2D>> stringBounds = new ArrayList<Map.Entry<String, Rectangle2D>>(lines.length);
for (String line : lines) {
......@@ -128,7 +133,8 @@ public class Legend implements ChartPart {
StyleManager styleManager = getChartPainter().getStyleManager();
if (!styleManager.isLegendVisible()) return;
if (!styleManager.isLegendVisible())
return;
final double[] sizeHint = getSizeHint(g);
......@@ -181,7 +187,6 @@ public class Legend implements ChartPart {
double startx = xOffset + styleManager.getLegendPadding();
double starty = yOffset + styleManager.getLegendPadding();
for (Series series : chartPainter.getAxisPair().getSeriesMap().values()) {
List<Map.Entry<String, Rectangle2D>> seriesBounds = getSeriesBounds(series, g);
float blockHeight = 0;
......@@ -202,7 +207,8 @@ public class Legend implements ChartPart {
g.setColor(series.getMarkerColor());
series.getMarker().paint(g, startx + styleManager.getLegendSeriesLineLength() / 2.0, starty + blockHeight / 2.0);
}
} else {
}
else {
// paint little box
if (series.getStroke() != null) {
g.setColor(series.getStrokeColor());
......@@ -223,7 +229,8 @@ public class Legend implements ChartPart {
}
itemOffsetY = (float) Math.max(itemOffsetY, Marker.SIZE);
starty += blockHeight + fontMetrics.getDescent();
} else {
}
else {
final float x = (float) (startx + BOX_SIZE + styleManager.getLegendPadding());
for (Map.Entry<String, Rectangle2D> entry : seriesBounds) {
double height = entry.getValue().getHeight();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment