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

change way grid lines are painted due to weird bug: when resizing chart, the...

change way grid lines are painted due to weird bug: when resizing chart, the stroke was not getting set on tehy grid lines and plot area border, was sorta randomly flipping between dashed and solid.
parent 5358473b
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@
*/
package org.knowm.xchart.internal.chartpart;
import java.awt.BasicStroke;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
......@@ -26,6 +27,8 @@ import java.awt.geom.Rectangle2D;
*/
public interface ChartPart {
public static BasicStroke SOLID_STROKE = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, new float[] { 3.0f, 0.0f }, 0.0f);
public Rectangle2D getBounds();
public void paint(final Graphics2D g);
......
......@@ -16,7 +16,6 @@
*/
package org.knowm.xchart.internal.chartpart;
import java.awt.BasicStroke;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.font.FontRenderContext;
......@@ -118,7 +117,7 @@ public abstract class Legend_<ST extends Styler, S extends Series> implements Ch
Shape rect = new Rectangle2D.Double(xOffset, yOffset, bounds.getWidth(), bounds.getHeight());
g.setColor(chart.getStyler().getLegendBackgroundColor());
g.fill(rect);
g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, new float[] { 3.0f, 0.0f }, 0.0f));
g.setStroke(SOLID_STROKE);
g.setColor(chart.getStyler().getLegendBorderColor());
g.draw(rect);
......
......@@ -57,13 +57,6 @@ public class PlotSurface_AxesChart<ST extends Styler, S extends Series> extends
g.setColor(stylerAxesChart.getPlotBackgroundColor());
g.fill(rect);
// paint plot border
if (stylerAxesChart.isPlotBorderVisible()) {
g.setColor(stylerAxesChart.getPlotBorderColor());
// g.setStroke(getChartPainter().getstyler().getAxisTickMarksStroke());
g.draw(rect);
}
// paint grid lines and/or inner plot ticks
// horizontal
......@@ -81,9 +74,11 @@ public class PlotSurface_AxesChart<ST extends Styler, S extends Series> extends
if (stylerAxesChart.isPlotGridHorizontalLinesVisible()) {
g.setColor(stylerAxesChart.getPlotGridLinesColor());
g.setStroke(stylerAxesChart.getPlotGridLinesStroke());
Shape line = new Line2D.Double(bounds.getX(), yOffset, bounds.getX() + bounds.getWidth(), yOffset);
// g.setStroke(stylerAxesChart.getPlotGridLinesStroke());
Shape line = stylerAxesChart.getPlotGridLinesStroke().createStrokedShape(new Line2D.Double(bounds.getX(), yOffset, bounds.getX() + bounds.getWidth(), yOffset));
// Shape line = new Line2D.Double(bounds.getX(), yOffset, bounds.getX() + bounds.getWidth(), yOffset);
g.draw(line);
// g.drawLine((int) bounds.getX(), (int) yOffset, (int) (bounds.getX() + bounds.getWidth()), (int) yOffset);
}
// tick marks
......@@ -116,9 +111,10 @@ public class PlotSurface_AxesChart<ST extends Styler, S extends Series> extends
if (stylerAxesChart.isPlotGridVerticalLinesVisible()) {
g.setColor(stylerAxesChart.getPlotGridLinesColor());
g.setStroke(stylerAxesChart.getPlotGridLinesStroke());
Shape line = new Line2D.Double(xOffset, bounds.getY(), xOffset, bounds.getY() + bounds.getHeight());
// g.setStroke(stylerAxesChart.getPlotGridLinesStroke());
// System.out.println();
Shape line = stylerAxesChart.getPlotGridLinesStroke().createStrokedShape(new Line2D.Double(xOffset, bounds.getY(), xOffset, bounds.getY() + bounds.getHeight()));
// Shape line = new Line2D.Double(xOffset, bounds.getY(), xOffset, bounds.getY() + bounds.getHeight());
g.draw(line);
}
// tick marks
......@@ -135,6 +131,13 @@ public class PlotSurface_AxesChart<ST extends Styler, S extends Series> extends
}
}
}
// paint plot border
if (stylerAxesChart.isPlotBorderVisible()) {
g.setColor(stylerAxesChart.getPlotBorderColor());
g.setStroke(SOLID_STROKE);
g.draw(rect);
}
}
}
......@@ -46,7 +46,7 @@ public class Plot_<ST extends Styler, S extends Series> implements ChartPart {
@Override
public void paint(Graphics2D g) {
// g.setColor(Color.green);
// g.setColor(Color.red);
// g.draw(bounds);
plotSurface.paint(g);
......
......@@ -312,7 +312,7 @@ public class GGPlot2Theme implements Theme {
@Override
public Stroke getPlotGridLinesStroke() {
return new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, new float[] { 3.0f, 0.0f }, 0.0f);
return new BasicStroke(.75f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, new float[] { 3.0f, 0.0f }, 0.0f);
}
@Override
......
......@@ -315,7 +315,7 @@ public class MatlabTheme implements Theme {
@Override
public Stroke getPlotGridLinesStroke() {
return new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_ROUND, 10.0f, new float[] { 1.0f, 2.0f }, 0.0f);
return new BasicStroke(0.25f, BasicStroke.CAP_BUTT, BasicStroke.CAP_ROUND, 10.0f, new float[] { 1.0f, 2.0f }, 0.0f);
}
......
......@@ -312,7 +312,7 @@ public class XChartTheme implements Theme {
@Override
public Stroke getPlotGridLinesStroke() {
return new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, new float[] { 3.0f, 3.0f }, 0.0f);
return new BasicStroke(0.25f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, new float[] { 3.0f, 3.0f }, 0.0f);
}
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment