diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTick.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTick.java index c0a96ea141ff911731c58d210abe782ec5740b8e..dde167ff84ed1d7e3fdf0aa8ecefe43c02b3b772 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTick.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTick.java @@ -100,11 +100,6 @@ public class AxisTick implements ChartPart { } - // if (getChart().getStyleManager()) { - // - // gridStep = new LogarithmicAxisTickCalculator(axis.getDirection(), workingSpace, axis.getMin(), axis.getMax(), getChart().getStyleManager()); - // } - if (isVisible) { axisTickLabels.paint(g); diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Legend.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Legend.java index 2a1dc9242798c160c65480f3636f7e074f5c8699..bdc73f0ae14d01a1fcf1570d289795b4009fd8b2 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Legend.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Legend.java @@ -24,6 +24,7 @@ import java.util.Map; import com.xeiam.xchart.Chart; import com.xeiam.xchart.Series; import com.xeiam.xchart.internal.markers.Marker; +import com.xeiam.xchart.style.StyleManager.ChartType; /** * @author timmolter @@ -31,6 +32,7 @@ import com.xeiam.xchart.internal.markers.Marker; public class Legend implements ChartPart { private static final int LEGEND_MARGIN = 6; + private static final int BOX_SIZE = 20; /** parent */ private final Chart chart; @@ -77,13 +79,21 @@ public class Legend implements ChartPart { } // determine legend content height - int legendContentHeight = 0; - int maxContentHeight = Math.max(legendTextContentMaxHeight, Marker.SIZE); - legendContentHeight = maxContentHeight * seriesMap.size() + chart.getStyleManager().getLegendPadding() * (seriesMap.size() - 1); + int maxContentHeight = 0; + if (getChart().getStyleManager().getChartType() != ChartType.Bar) { + maxContentHeight = Math.max(legendTextContentMaxHeight, Marker.SIZE); + } else { + maxContentHeight = Math.max(legendTextContentMaxHeight, BOX_SIZE); + } + int legendContentHeight = maxContentHeight * seriesMap.size() + chart.getStyleManager().getLegendPadding() * (seriesMap.size() - 1); // determine legend content width - int legendContentWidth = (int) (3.0 * Marker.SIZE + chart.getStyleManager().getLegendPadding() + legendTextContentMaxWidth); - + int legendContentWidth = 0; + if (getChart().getStyleManager().getChartType() != ChartType.Bar) { + legendContentWidth = (int) (3.0 * Marker.SIZE + chart.getStyleManager().getLegendPadding() + legendTextContentMaxWidth); + } else { + legendContentWidth = BOX_SIZE + chart.getStyleManager().getLegendPadding() + legendTextContentMaxWidth; + } // Draw Legend Box int legendBoxWidth = legendContentWidth + 2 * chart.getStyleManager().getLegendPadding(); int legendBoxHeight = legendContentHeight + 2 * chart.getStyleManager().getLegendPadding(); @@ -146,23 +156,41 @@ public class Legend implements ChartPart { int starty = yOffset + chart.getStyleManager().getLegendPadding(); for (Integer seriesId : seriesMap.keySet()) { Series series = seriesMap.get(seriesId); - // paint line - if (series.getStroke() != null) { - g.setColor(series.getStrokeColor()); - g.setStroke(series.getStroke()); - g.drawLine(startx, starty - Marker.Y_OFFSET, (int) (startx + Marker.SIZE * 3.0), starty - Marker.Y_OFFSET); - } - // paint marker - if (series.getMarker() != null) { - g.setColor(series.getMarkerColor()); - series.getMarker().paint(g, (int) (startx + (Marker.SIZE * 1.5)), starty - Marker.Y_OFFSET); + + if (getChart().getStyleManager().getChartType() != ChartType.Bar) { + // paint line + if (series.getStroke() != null) { + g.setColor(series.getStrokeColor()); + g.setStroke(series.getStroke()); + g.drawLine(startx, starty - Marker.Y_OFFSET, (int) (startx + Marker.SIZE * 3.0), starty - Marker.Y_OFFSET); + } + // paint marker + if (series.getMarker() != null) { + g.setColor(series.getMarkerColor()); + series.getMarker().paint(g, (int) (startx + (Marker.SIZE * 1.5)), starty - Marker.Y_OFFSET); + } + } else { + // paint box + if (series.getStroke() != null) { + g.setColor(series.getStrokeColor()); + 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.drawPolygon(new int[] { startx, startx + BOX_SIZE, startx + BOX_SIZE, startx }, new int[] { starty, starty, starty + BOX_SIZE, starty + BOX_SIZE }, 4); + + } } // paint series name g.setColor(chart.getStyleManager().getChartFontColor()); TextLayout layout = new TextLayout(series.getName(), chart.getStyleManager().getLegendFont(), new FontRenderContext(null, true, false)); - layout.draw(g, (float) (startx + Marker.SIZE + (Marker.SIZE * 1.5) + chart.getStyleManager().getLegendPadding()), (starty + Marker.SIZE)); - starty = starty + legendTextContentMaxHeight + chart.getStyleManager().getLegendPadding(); + if (getChart().getStyleManager().getChartType() != ChartType.Bar) { + layout.draw(g, (float) (startx + Marker.SIZE + (Marker.SIZE * 1.5) + chart.getStyleManager().getLegendPadding()), + (int) (starty + (Marker.SIZE + chart.getStyleManager().getLegendPadding()) / 2.0)); + starty = starty + legendTextContentMaxHeight + chart.getStyleManager().getLegendPadding(); + } else { + layout.draw(g, startx + BOX_SIZE + chart.getStyleManager().getLegendPadding(), (int) (starty + (BOX_SIZE + chart.getStyleManager().getLegendPadding()) / 2.0)); + starty = starty + legendTextContentMaxHeight + chart.getStyleManager().getLegendPadding(); + } } // bounds diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotContent.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotContent.java index 425a84d42a5afb1602166d82651017d3a0ad9638..9d4799bd9690e027553d16bae834c834928dab09 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotContent.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotContent.java @@ -38,7 +38,7 @@ public class PlotContent implements ChartPart { /** parent */ private Plot plot; - private final Stroke errorBarStroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL); + private final Stroke errorBarStroke = new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL); /** * Constructor diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotSurface.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotSurface.java index 5080ecc92a873da97c9d365f968f8ef165f8e18c..163c947ad58fa58b58c87bb9476ec741ff95b0f9 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotSurface.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotSurface.java @@ -21,6 +21,7 @@ import java.awt.Stroke; import java.util.List; import com.xeiam.xchart.Chart; +import com.xeiam.xchart.style.StyleManager.ChartType; /** * @author timmolter @@ -82,15 +83,18 @@ public class PlotSurface implements ChartPart { } // vertical - List<Integer> xAxisTickLocations = getChart().getAxisPair().getxAxis().getAxisTick().getTickLocations(); - for (int i = 0; i < xAxisTickLocations.size(); i++) { + if (getChart().getStyleManager().getChartType() != ChartType.Bar) { - int tickLocation = xAxisTickLocations.get(i); + List<Integer> xAxisTickLocations = getChart().getAxisPair().getxAxis().getAxisTick().getTickLocations(); + for (int i = 0; i < xAxisTickLocations.size(); i++) { - g.setColor(getChart().getStyleManager().getPlotGridLinesColor()); - g.setStroke(stroke); + int tickLocation = xAxisTickLocations.get(i); + + g.setColor(getChart().getStyleManager().getPlotGridLinesColor()); + g.setStroke(stroke); - g.drawLine((int) (bounds.getX() + tickLocation - 1), (int) (bounds.getY()), (int) (bounds.getX() + tickLocation - 1), (int) (bounds.getY() + bounds.getHeight() - 1)); + g.drawLine((int) (bounds.getX() + tickLocation - 1), (int) (bounds.getY()), (int) (bounds.getX() + tickLocation - 1), (int) (bounds.getY() + bounds.getHeight() - 1)); + } } } } diff --git a/xchart/src/main/java/com/xeiam/xchart/style/SeriesLineStyle.java b/xchart/src/main/java/com/xeiam/xchart/style/SeriesLineStyle.java index f8a01980e7ba965a53525b27dfeb64a2103d99a1..fef49a8eb4637590a3d725b7e472bceeec29bebc 100644 --- a/xchart/src/main/java/com/xeiam/xchart/style/SeriesLineStyle.java +++ b/xchart/src/main/java/com/xeiam/xchart/style/SeriesLineStyle.java @@ -28,16 +28,16 @@ public enum SeriesLineStyle { NONE(-1, null), /** SOLID */ - SOLID(0, new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)), + SOLID(0, new BasicStroke(1.8f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)), /** DASH_DOT */ - DASH_DOT(1, new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, new float[] { 3.0f, 1.0f }, 0.0f)), + DASH_DOT(1, new BasicStroke(1.8f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, new float[] { 3.0f, 1.0f }, 0.0f)), /** DASH_DASH */ - DASH_DASH(2, new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, new float[] { 3.0f, 3.0f }, 0.0f)), + DASH_DASH(2, new BasicStroke(1.8f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, new float[] { 3.0f, 3.0f }, 0.0f)), /** DOT_DOT */ - DOT_DOT(3, new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, new float[] { 1.0f, 1.0f }, 0.0f)); + DOT_DOT(3, new BasicStroke(1.8f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, new float[] { 1.0f, 1.0f }, 0.0f)); /** The index */ private int index;