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

clean up debugging bounding boxes and commented out code [ci skip]

parent fa034258
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,11 @@ import com.xeiam.xchart.demo.charts.ExampleChart; ...@@ -30,6 +30,11 @@ import com.xeiam.xchart.demo.charts.ExampleChart;
/** /**
* Year scale * Year scale
* <p>
* Demonstrates the following:
* <ul>
* <li>Rotated X-Axis labels
* <li>Setting a custom date formatter String
*/ */
public class DateChart08 implements ExampleChart { public class DateChart08 implements ExampleChart {
...@@ -47,11 +52,6 @@ public class DateChart08 implements ExampleChart { ...@@ -47,11 +52,6 @@ public class DateChart08 implements ExampleChart {
Chart chart = new ChartBuilder().width(800).height(600).title("Year Scale").build(); Chart chart = new ChartBuilder().width(800).height(600).title("Year Scale").build();
chart.getStyleManager().setLegendVisible(false); chart.getStyleManager().setLegendVisible(false);
chart.getStyleManager().setXAxisLabelRotation(45); chart.getStyleManager().setXAxisLabelRotation(45);
// chart.getStyleManager().setXAxisLabelRotation(90);
// chart.getStyleManager().setXAxisLabelRotation(20);
// chart.getStyleManager().setXAxisLabelRotation(80);
// chart.getStyleManager().setXAxisLabelAlignment(TextAlignment.Right);
chart.getStyleManager().setDatePattern("yyyy-MM-dd");
// generate data // generate data
List<Date> xData = new ArrayList<Date>(); List<Date> xData = new ArrayList<Date>();
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
*/ */
package com.xeiam.xchart.internal.chartpart; package com.xeiam.xchart.internal.chartpart;
import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Shape; import java.awt.Shape;
import java.awt.font.FontRenderContext; import java.awt.font.FontRenderContext;
...@@ -178,8 +177,8 @@ public class Axis implements ChartPart { ...@@ -178,8 +177,8 @@ public class Axis implements ChartPart {
- getChartPainter().getStyleManager().getChartPadding(); - getChartPainter().getStyleManager().getChartPadding();
Rectangle2D yAxisRectangle = new Rectangle2D.Double(xOffset, yOffset, width, height); Rectangle2D yAxisRectangle = new Rectangle2D.Double(xOffset, yOffset, width, height);
this.paintZone = yAxisRectangle; this.paintZone = yAxisRectangle;
g.setColor(Color.green); // g.setColor(Color.green);
g.draw(yAxisRectangle); // g.draw(yAxisRectangle);
// fill in Axis with sub-components // fill in Axis with sub-components
axisTitle.paint(g); axisTitle.paint(g);
...@@ -191,8 +190,8 @@ public class Axis implements ChartPart { ...@@ -191,8 +190,8 @@ public class Axis implements ChartPart {
height = paintZone.getHeight(); height = paintZone.getHeight();
bounds = new Rectangle2D.Double(xOffset, yOffset, width, height); bounds = new Rectangle2D.Double(xOffset, yOffset, width, height);
g.setColor(Color.yellow); // g.setColor(Color.yellow);
g.draw(bounds); // g.draw(bounds);
} }
else { // X-Axis else { // X-Axis
...@@ -233,8 +232,8 @@ public class Axis implements ChartPart { ...@@ -233,8 +232,8 @@ public class Axis implements ChartPart {
// the paint zone // the paint zone
this.paintZone = xAxisRectangle; this.paintZone = xAxisRectangle;
g.setColor(Color.green); // g.setColor(Color.green);
g.draw(xAxisRectangle); // g.draw(xAxisRectangle);
// now paint the X-Axis given the above paint zone // now paint the X-Axis given the above paint zone
axisTitle.paint(g); axisTitle.paint(g);
...@@ -242,8 +241,8 @@ public class Axis implements ChartPart { ...@@ -242,8 +241,8 @@ public class Axis implements ChartPart {
bounds = paintZone; bounds = paintZone;
g.setColor(Color.yellow); // g.setColor(Color.yellow);
g.draw(bounds); // g.draw(bounds);
} }
} }
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
*/ */
package com.xeiam.xchart.internal.chartpart; package com.xeiam.xchart.internal.chartpart;
import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Shape; import java.awt.Shape;
import java.awt.font.FontRenderContext; import java.awt.font.FontRenderContext;
...@@ -144,7 +143,7 @@ public class AxisTickLabels implements ChartPart { ...@@ -144,7 +143,7 @@ public class AxisTickLabels implements ChartPart {
FontRenderContext frc = g.getFontRenderContext(); FontRenderContext frc = g.getFontRenderContext();
TextLayout textLayout = new TextLayout(tickLabel, getChartPainter().getStyleManager().getAxisTickLabelsFont(), frc); TextLayout textLayout = new TextLayout(tickLabel, getChartPainter().getStyleManager().getAxisTickLabelsFont(), frc);
System.out.println(textLayout.getOutline(null).getBounds().toString()); // System.out.println(textLayout.getOutline(null).getBounds().toString());
// Shape shape = v.getOutline(); // Shape shape = v.getOutline();
AffineTransform rot = AffineTransform.getRotateInstance(-1 * Math.toRadians(getChartPainter().getStyleManager().getXAxisLabelRotation()), 0, 0); AffineTransform rot = AffineTransform.getRotateInstance(-1 * Math.toRadians(getChartPainter().getStyleManager().getXAxisLabelRotation()), 0, 0);
...@@ -165,14 +164,9 @@ public class AxisTickLabels implements ChartPart { ...@@ -165,14 +164,9 @@ public class AxisTickLabels implements ChartPart {
default: default:
xPos = shiftedTickLocation - tickLabelBounds.getWidth() / 2.0; xPos = shiftedTickLocation - tickLabelBounds.getWidth() / 2.0;
} }
System.out.println("tickLabelBounds: " + tickLabelBounds.toString()); // System.out.println("tickLabelBounds: " + tickLabelBounds.toString());
// double shift = tickLabelBounds.getWidth() * Math.sin(Math.toRadians(getChartPainter().getStyleManager().getXAxisLabelRotation()));
double shiftX = -1 * tickLabelBounds.getX() * Math.sin(Math.toRadians(getChartPainter().getStyleManager().getXAxisLabelRotation())); double shiftX = -1 * tickLabelBounds.getX() * Math.sin(Math.toRadians(getChartPainter().getStyleManager().getXAxisLabelRotation()));
// double shiftY = textLayout.getOutline(null).getBounds().getHeight() * Math.cos(Math.toRadians(getChartPainter().getStyleManager().getXAxisLabelRotation()));
// double shiftY = 0;
double shiftY = -1 * (tickLabelBounds.getY() + tickLabelBounds.getHeight()); double shiftY = -1 * (tickLabelBounds.getY() + tickLabelBounds.getHeight());
// double shift = tickLabelBounds.getWidth() / 2.0;
// double shift = 0;
System.out.println(shiftX); System.out.println(shiftX);
System.out.println("shiftY: " + shiftY); System.out.println("shiftY: " + shiftY);
at.translate(xPos + shiftX, yOffset + shiftY); at.translate(xPos + shiftX, yOffset + shiftY);
...@@ -181,10 +175,10 @@ public class AxisTickLabels implements ChartPart { ...@@ -181,10 +175,10 @@ public class AxisTickLabels implements ChartPart {
g.fill(shape); g.fill(shape);
g.setTransform(orig); g.setTransform(orig);
// debug box // // debug box
g.setColor(Color.MAGENTA); // g.setColor(Color.MAGENTA);
g.draw(new Rectangle2D.Double(xPos, yOffset - tickLabelBounds.getHeight(), tickLabelBounds.getWidth(), tickLabelBounds.getHeight())); // g.draw(new Rectangle2D.Double(xPos, yOffset - tickLabelBounds.getHeight(), tickLabelBounds.getWidth(), tickLabelBounds.getHeight()));
g.setColor(getChartPainter().getStyleManager().getAxisTickLabelsColor()); // g.setColor(getChartPainter().getStyleManager().getAxisTickLabelsColor());
if (tickLabelBounds.getHeight() > maxTickLabelHeight) { if (tickLabelBounds.getHeight() > maxTickLabelHeight) {
maxTickLabelHeight = tickLabelBounds.getHeight(); maxTickLabelHeight = tickLabelBounds.getHeight();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment