Skip to content
Snippets Groups Projects
Commit 89cae126 authored by Tim Molter's avatar Tim Molter Committed by Niklas Polke
Browse files

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

parent 7681e09a
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,11 @@ import com.xeiam.xchart.demo.charts.ExampleChart;
/**
* Year scale
* <p>
* Demonstrates the following:
* <ul>
* <li>Rotated X-Axis labels
* <li>Setting a custom date formatter String
*/
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.getStyleManager().setLegendVisible(false);
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
List<Date> xData = new ArrayList<Date>();
......
......@@ -15,7 +15,6 @@
*/
package com.xeiam.xchart.internal.chartpart;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.font.FontRenderContext;
......@@ -159,27 +158,27 @@ public class Axis implements ChartPart {
getChartPainter().getWidth()
- width // y-axis approx. width
- width // y-axis approx. width
- chartLegendWidth
- chartLegendWidth
- 2
* getChartPainter().getStyleManager().getChartPadding()
- 2
* getChartPainter().getStyleManager().getChartPadding()
- (getChartPainter().getStyleManager().isYAxisTicksVisible() ? (getChartPainter().getStyleManager().getPlotPadding()) : 0)
- (getChartPainter().getStyleManager().isYAxisTicksVisible() ? (getChartPainter().getStyleManager().getPlotPadding()) : 0)
- (getChartPainter().getStyleManager().getLegendPosition() == LegendPosition.OutsideE && getChartPainter().getStyleManager().isLegendVisible() ? getChartPainter().getStyleManager()
.getChartPadding() : 0)
- (getChartPainter().getStyleManager().getLegendPosition() == LegendPosition.OutsideE && getChartPainter().getStyleManager().isLegendVisible() ? getChartPainter().getStyleManager()
.getChartPadding() : 0)
;
;
double height =
getChartPainter().getHeight() - yOffset - axisPair.getXAxis().getXAxisHeightHint(approximateXAxisWidth) - getChartPainter().getStyleManager().getPlotPadding()
- getChartPainter().getStyleManager().getChartPadding();
- getChartPainter().getStyleManager().getChartPadding();
Rectangle2D yAxisRectangle = new Rectangle2D.Double(xOffset, yOffset, width, height);
this.paintZone = yAxisRectangle;
g.setColor(Color.green);
g.draw(yAxisRectangle);
// g.setColor(Color.green);
// g.draw(yAxisRectangle);
// fill in Axis with sub-components
axisTitle.paint(g);
......@@ -191,8 +190,8 @@ public class Axis implements ChartPart {
height = paintZone.getHeight();
bounds = new Rectangle2D.Double(xOffset, yOffset, width, height);
g.setColor(Color.yellow);
g.draw(bounds);
// g.setColor(Color.yellow);
// g.draw(bounds);
}
else { // X-Axis
......@@ -202,7 +201,7 @@ public class Axis implements ChartPart {
double xOffset =
axisPair.getYAxis().getBounds().getWidth() + (getChartPainter().getStyleManager().isYAxisTicksVisible() ? getChartPainter().getStyleManager().getPlotPadding() : 0)
+ getChartPainter().getStyleManager().getChartPadding();
+ getChartPainter().getStyleManager().getChartPadding();
double yOffset = axisPair.getYAxis().getBounds().getY() + axisPair.getYAxis().getBounds().getHeight() + getChartPainter().getStyleManager().getPlotPadding();
double chartLegendWidth = 0;
......@@ -214,27 +213,27 @@ public class Axis implements ChartPart {
getChartPainter().getWidth()
- axisPair.getYAxis().getBounds().getWidth() // y-axis was already painted
- axisPair.getYAxis().getBounds().getWidth() // y-axis was already painted
- chartLegendWidth
- chartLegendWidth
- 2
* getChartPainter().getStyleManager().getChartPadding()
- 2
* getChartPainter().getStyleManager().getChartPadding()
- (getChartPainter().getStyleManager().isYAxisTicksVisible() ? (getChartPainter().getStyleManager().getPlotPadding()) : 0)
- (getChartPainter().getStyleManager().isYAxisTicksVisible() ? (getChartPainter().getStyleManager().getPlotPadding()) : 0)
- (getChartPainter().getStyleManager().getLegendPosition() == LegendPosition.OutsideE && getChartPainter().getStyleManager().isLegendVisible() ? getChartPainter().getStyleManager()
.getChartPadding() : 0)
- (getChartPainter().getStyleManager().getLegendPosition() == LegendPosition.OutsideE && getChartPainter().getStyleManager().isLegendVisible() ? getChartPainter().getStyleManager()
.getChartPadding() : 0)
;
;
double height = this.getXAxisHeightHint(width);
Rectangle2D xAxisRectangle = new Rectangle2D.Double(xOffset, yOffset, width, height);
// the paint zone
this.paintZone = xAxisRectangle;
g.setColor(Color.green);
g.draw(xAxisRectangle);
// g.setColor(Color.green);
// g.draw(xAxisRectangle);
// now paint the X-Axis given the above paint zone
axisTitle.paint(g);
......@@ -242,8 +241,8 @@ public class Axis implements ChartPart {
bounds = paintZone;
g.setColor(Color.yellow);
g.draw(bounds);
// g.setColor(Color.yellow);
// g.draw(bounds);
}
}
......
......@@ -15,7 +15,6 @@
*/
package com.xeiam.xchart.internal.chartpart;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.font.FontRenderContext;
......@@ -144,7 +143,7 @@ public class AxisTickLabels implements ChartPart {
FontRenderContext frc = g.getFontRenderContext();
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();
AffineTransform rot = AffineTransform.getRotateInstance(-1 * Math.toRadians(getChartPainter().getStyleManager().getXAxisLabelRotation()), 0, 0);
......@@ -165,14 +164,9 @@ public class AxisTickLabels implements ChartPart {
default:
xPos = shiftedTickLocation - tickLabelBounds.getWidth() / 2.0;
}
System.out.println("tickLabelBounds: " + tickLabelBounds.toString());
// double shift = tickLabelBounds.getWidth() * Math.sin(Math.toRadians(getChartPainter().getStyleManager().getXAxisLabelRotation()));
// System.out.println("tickLabelBounds: " + tickLabelBounds.toString());
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 shift = tickLabelBounds.getWidth() / 2.0;
// double shift = 0;
System.out.println(shiftX);
System.out.println("shiftY: " + shiftY);
at.translate(xPos + shiftX, yOffset + shiftY);
......@@ -181,10 +175,10 @@ public class AxisTickLabels implements ChartPart {
g.fill(shape);
g.setTransform(orig);
// debug box
g.setColor(Color.MAGENTA);
g.draw(new Rectangle2D.Double(xPos, yOffset - tickLabelBounds.getHeight(), tickLabelBounds.getWidth(), tickLabelBounds.getHeight()));
g.setColor(getChartPainter().getStyleManager().getAxisTickLabelsColor());
// // debug box
// g.setColor(Color.MAGENTA);
// g.draw(new Rectangle2D.Double(xPos, yOffset - tickLabelBounds.getHeight(), tickLabelBounds.getWidth(), tickLabelBounds.getHeight()));
// g.setColor(getChartPainter().getStyleManager().getAxisTickLabelsColor());
if (tickLabelBounds.getHeight() > maxTickLabelHeight) {
maxTickLabelHeight = tickLabelBounds.getHeight();
......
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