Permalink
Browse files

Removed redundant local variables.

  • Loading branch information...
eseifert committed Jul 29, 2017
1 parent 6898779 commit b7ae9c7bd56f790ede888900c0a30af4935378a2
Showing with 74 additions and 105 deletions.
  1. +1 −3 gral-core/src/main/java/de/erichseifert/gral/data/AbstractDataSource.java
  2. +1 −2 gral-core/src/main/java/de/erichseifert/gral/data/DataAccessor.java
  3. +1 −2 gral-core/src/main/java/de/erichseifert/gral/graphics/Label.java
  4. +1 −3 gral-core/src/main/java/de/erichseifert/gral/graphics/layout/StackedLayout.java
  5. +1 −2 gral-core/src/main/java/de/erichseifert/gral/plots/AbstractPlot.java
  6. +4 −7 gral-core/src/main/java/de/erichseifert/gral/plots/BarPlot.java
  7. +2 −3 gral-core/src/main/java/de/erichseifert/gral/plots/BoxPlot.java
  8. +4 −5 gral-core/src/main/java/de/erichseifert/gral/plots/PiePlot.java
  9. +2 −3 gral-core/src/main/java/de/erichseifert/gral/plots/RasterPlot.java
  10. +2 −4 gral-core/src/main/java/de/erichseifert/gral/plots/XYPlot.java
  11. +37 −41 gral-core/src/main/java/de/erichseifert/gral/plots/axes/AbstractAxisRenderer2D.java
  12. +1 −2 gral-core/src/main/java/de/erichseifert/gral/plots/axes/Axis.java
  13. +1 −2 gral-core/src/main/java/de/erichseifert/gral/plots/legends/ValueLegend.java
  14. +1 −2 gral-core/src/main/java/de/erichseifert/gral/plots/lines/AbstractLineRenderer2D.java
  15. +2 −3 gral-core/src/main/java/de/erichseifert/gral/plots/lines/DefaultLineRenderer2D.java
  16. +2 −3 gral-core/src/main/java/de/erichseifert/gral/plots/lines/DiscreteLineRenderer2D.java
  17. +2 −3 gral-core/src/main/java/de/erichseifert/gral/plots/lines/SmoothLineRenderer2D.java
  18. +4 −7 gral-core/src/main/java/de/erichseifert/gral/plots/points/DefaultPointRenderer2D.java
  19. +1 −2 gral-core/src/main/java/de/erichseifert/gral/util/StatefulTokenizer.java
  20. +3 −4 gral-core/src/test/java/de/erichseifert/gral/navigation/MockNavigator.java
  21. +1 −2 gral-examples/src/main/java/de/erichseifert/gral/examples/xyplot/MultiplePointRenderers.java
@@ -286,9 +286,7 @@ public int getColumnCount() {
* @return The data types of all column in the data source
*/
public Class<? extends Comparable<?>>[] getColumnTypes() {
Class<? extends Comparable<?>>[] types =
Arrays.copyOf(this.types, this.types.length);
return types;
return Arrays.copyOf(this.types, this.types.length);
}
/**
@@ -166,8 +166,7 @@ public boolean hasNext() {
}
public Comparable<?> next() {
Comparable<?> value = get(i++);
return value;
return get(i++);
}
public void remove() {
@@ -188,9 +188,8 @@ protected Shape getOutline(boolean wordWrap) {
Math.abs(Math.sin(rotation))*getHeight());
}
double alignment = getTextAlignment();
Shape outline = GraphicsUtils.getOutline(
return GraphicsUtils.getOutline(
getText(), font, wrappingWidth, alignment);
return outline;
}
/**
@@ -203,9 +203,7 @@ public Dimension2D getPreferredSize(Container container) {
width += insets.getRight();
height += insets.getBottom();
Dimension2D bounds =
new de.erichseifert.gral.graphics.Dimension2D.Double(width, height);
return bounds;
return new de.erichseifert.gral.graphics.Dimension2D.Double(width, height);
}
private Constraints getConstraints(Drawable component, Container container) {
@@ -644,8 +644,7 @@ public void clear() {
*/
private String getMapping(DataSource source, int col) {
Map<Integer, String> columnToAxisMapping = columnToAxisMappingByDataSource.get(source);
String axisName = columnToAxisMapping != null ? columnToAxisMapping.get(col) : null;
return axisName;
return columnToAxisMapping != null ? columnToAxisMapping.get(col) : null;
}
/**
@@ -278,9 +278,8 @@ public Shape getPointShape(PointData data) {
barHeight = barHeightMin;
}
Shape shape = getBarShape(
return getBarShape(
barXMin - barX, barY, barWidth, barHeight);
return shape;
}
/**
@@ -302,8 +301,7 @@ protected Shape getBarShape(double x, double y, double width, double height) {
tx.scale(width/shapeBounds.getWidth(), height/shapeBounds.getHeight());
tx.translate(-shapeBounds.getMinX(), -shapeBounds.getMinY());
Shape shapeTransformed = tx.createTransformedShape(shape);
return shapeTransformed;
return tx.createTransformedShape(shape);
}
/**
@@ -315,9 +313,9 @@ protected Shape getBarShape(double x, double y, double width, double height) {
*/
@Override
public Drawable getValue(final PointData data, final Shape shape) {
Drawable drawable = new AbstractDrawable() {
return new AbstractDrawable() {
/** Version id for serialization. */
private static final long serialVersionUID = -1133369168849171793L;
private static final long serialVersionUID1 = -1133369168849171793L;
public void draw(DrawingContext context) {
PointRenderer renderer = BarRenderer.this;
@@ -329,7 +327,6 @@ public void draw(DrawingContext context) {
}
}
};
return drawable;
}
}
@@ -642,15 +642,14 @@ public Shape getPointShape(PointData data) {
* @return Component that can be used to draw the value label.
*/
public Drawable getValue(final PointData data, final Shape shape) {
Drawable drawable = new AbstractDrawable() {
return new AbstractDrawable() {
/** Version id for serialization. */
private static final long serialVersionUID = 6788431763837737592L;
private static final long serialVersionUID1 = 6788431763837737592L;
public void draw(DrawingContext context) {
// TODO Implement rendering of value label
}
};
return drawable;
}
}
@@ -717,9 +717,9 @@ protected void drawValueLabel(DrawingContext context, Slice slice,
@Override
public Drawable getValue(final PointData data, final Shape shape) {
Drawable drawable = new AbstractDrawable() {
return new AbstractDrawable() {
/** Version id for serialization. */
private static final long serialVersionUID = 8389872806138135038L;
private static final long serialVersionUID1 = 8389872806138135038L;
public void draw(DrawingContext context) {
PointRenderer renderer = PieSliceRenderer.this;
@@ -738,14 +738,13 @@ public void draw(DrawingContext context) {
double plotAreaSize = Math.min(
plotArea.getWidth(), plotArea.getHeight())/2.0;
double radiusRel = plot.getRadius();
double radius = plotAreaSize*radiusRel;
double radius1 = plotAreaSize*radiusRel;
if (renderer.isValueVisible()) {
drawValueLabel(context, slice, radius, row, data.index);
drawValueLabel(context, slice, radius1, row, data.index);
}
}
};
return drawable;
}
}
@@ -260,15 +260,14 @@ public Shape getPointShape(PointData data) {
* @return Component that can be used to draw the value label.
*/
public Drawable getValue(final PointData data, final Shape shape) {
Drawable drawable = new AbstractDrawable() {
return new AbstractDrawable() {
/** Version id for serialization. */
private static final long serialVersionUID = -8402945980942955359L;
private static final long serialVersionUID1 = -8402945980942955359L;
public void draw(DrawingContext context) {
// TODO Implement rendering of value label
}
};
return drawable;
}
}
@@ -416,8 +416,7 @@ protected void drawPlot(DrawingContext context) {
List<AreaRenderer> areaRenderers = new ArrayList<>(plot.getAreaRenderers(s));
Collections.reverse(areaRenderers);
for (AreaRenderer areaRenderer : areaRenderers) {
Shape area = areaRenderer.getAreaShape(points);
Shape punchedArea = area;
Shape punchedArea = areaRenderer.getAreaShape(points);
for (PointRenderer pointRenderer : pointRenderers) {
List<Shape> punchShapes = new ArrayList<>(points.size());
for (DataPoint point : points) {
@@ -433,8 +432,7 @@ protected void drawPlot(DrawingContext context) {
List<LineRenderer> lineRenderers = new ArrayList<>(plot.getLineRenderers(s));
Collections.reverse(lineRenderers);
for (LineRenderer lineRenderer : lineRenderers) {
Shape line = lineRenderer.getLineShape(points);
Shape punchedLine = line;
Shape punchedLine = lineRenderer.getLineShape(points);
for (PointRenderer pointRenderer : pointRenderers) {
List<Shape> punchShapes = new ArrayList<>(points.size());
for (DataPoint point : points) {
@@ -196,9 +196,9 @@ public AbstractAxisRenderer2D() {
* @see Axis
*/
public Drawable getRendererComponent(final Axis axis) {
final Drawable component = new AbstractDrawable() {
return new AbstractDrawable() {
/** Version id for serialization. */
private static final long serialVersionUID = 3605211198378801694L;
private static final long serialVersionUID1 = 3605211198378801694L;
/**
* Draws the {@code Drawable} with the specified drawing context.
@@ -223,9 +223,9 @@ public void draw(DrawingContext context) {
Stroke axisStroke = renderer.getShapeStroke();
boolean isShapeVisible = renderer.isShapeVisible();
if (isShapeVisible) {
Shape shape = renderer.getShape();
Shape shape1 = renderer.getShape();
GraphicsUtils.drawPaintedShape(
graphics, shape, axisPaint, null, axisStroke);
graphics, shape1, axisPaint, null, axisStroke);
}
double fontSize =
@@ -241,7 +241,7 @@ public void draw(DrawingContext context) {
boolean isTickLabelVisible =
renderer.isTickLabelsVisible();
boolean isTickLabelOutside = renderer.isTickLabelsOutside();
double tickLabelRotation = renderer.getTickLabelRotation();
double tickLabelRotation1 = renderer.getTickLabelRotation();
double tickLabelDist = renderer.getTickLabelDistanceAbsolute();
Line2D tickShape = new Line2D.Double();
@@ -254,25 +254,25 @@ public void draw(DrawingContext context) {
Point2D tickPoint = tick.position.getPoint2D();
Point2D tickNormal = tick.normal.getPoint2D();
double tickLength;
double tickAlignment;
double tickLength1;
double tickAlignment1;
Paint tickPaint;
Stroke tickStroke;
Stroke tickStroke1;
if (TickType.MINOR.equals(tick.type)) {
tickLength = renderer.getTickMinorLengthAbsolute();
tickAlignment = renderer.getMinorTickAlignment();
tickLength1 = renderer.getTickMinorLengthAbsolute();
tickAlignment1 = renderer.getMinorTickAlignment();
tickPaint = renderer.getMinorTickColor();
tickStroke = renderer.getMinorTickStroke();
tickStroke1 = renderer.getMinorTickStroke();
} else {
tickLength = getTickLengthAbsolute();
tickAlignment = renderer.getTickAlignment();
tickLength1 = getTickLengthAbsolute();
tickAlignment1 = renderer.getTickAlignment();
tickPaint =
renderer.getTickColor();
tickStroke = renderer.getTickStroke();
tickStroke1 = renderer.getTickStroke();
}
double tickLengthInner = tickLength*tickAlignment;
double tickLengthOuter = tickLength*(1.0 - tickAlignment);
double tickLengthInner = tickLength1*tickAlignment1;
double tickLengthOuter = tickLength1*(1.0 - tickAlignment1);
if ((drawTicksMajor && (tick.type == TickType.MAJOR) ||
tick.type == TickType.CUSTOM) || (drawTicksMinor &&
@@ -284,7 +284,7 @@ public void draw(DrawingContext context) {
tickPoint.getY() + tickNormal.getY()*tickLengthOuter
);
GraphicsUtils.drawPaintedShape(
graphics, tickShape, tickPaint, null, tickStroke);
graphics, tickShape, tickPaint, null, tickStroke1);
}
// Draw label
@@ -298,7 +298,7 @@ public void draw(DrawingContext context) {
tickLabel.setColor(tickPaint);
double labelDist = tickLengthOuter + tickLabelDist;
layoutLabel(tickLabel, tickPoint, tickNormal,
labelDist, isTickLabelOutside, tickLabelRotation);
labelDist, isTickLabelOutside, tickLabelRotation1);
tickLabel.draw(context);
}
}
@@ -308,14 +308,14 @@ public void draw(DrawingContext context) {
// Draw axis label
Label axisLabel = renderer.getLabel();
if (axisLabel != null && !axisLabel.getText().trim().isEmpty()) {
double tickLength = getTickLengthAbsolute();
double tickAlignment = renderer.getTickAlignment();
double tickLengthOuter = tickLength*(1.0 - tickAlignment);
double tickLabelDistance = renderer.getTickLabelDistanceAbsolute();
double tickLength1 = getTickLengthAbsolute();
double tickAlignment1 = renderer.getTickAlignment();
double tickLengthOuter = tickLength1*(1.0 - tickAlignment1);
double tickLabelDistance1 = renderer.getTickLabelDistanceAbsolute();
double labelDistance = renderer.getLabelDistance()*fontSize;
double labelDistance1 = renderer.getLabelDistance()*fontSize;
double labelDist =
tickLengthOuter + tickLabelDistance + fontSize + labelDistance;
tickLengthOuter + tickLabelDistance1 + fontSize + labelDistance1;
double axisLabelPos =
(axis.getMin().doubleValue() + axis.getMax().doubleValue()) * 0.5;
boolean isTickLabelOutside = renderer.isTickLabelsOutside();
@@ -336,15 +336,15 @@ public void draw(DrawingContext context) {
graphics.setTransform(txOrig);
}
private void layoutLabel(Label label, Point2D labelPos, Point2D labelNormal,
double labelDist, boolean isLabelOutside, double rotation) {
Rectangle2D labelSize = label.getTextRectangle();
private void layoutLabel(Label label1, Point2D labelPos, Point2D labelNormal,
double labelDist, boolean isLabelOutside, double rotation) {
Rectangle2D labelSize = label1.getTextRectangle();
Shape marginShape = new Rectangle2D.Double(
0, 0,
labelSize.getWidth() + 2.0*labelDist, labelSize.getHeight() + 2.0*labelDist
);
Rectangle2D marginBounds = marginShape.getBounds2D();
label.setRotation(rotation);
label1.setRotation(rotation);
if ((rotation%360.0) != 0.0) {
marginShape = AffineTransform.getRotateInstance(
Math.toRadians(-rotation),
@@ -373,24 +373,22 @@ private void layoutLabel(Label label, Point2D labelPos, Point2D labelNormal,
double posX = labelPos.getX() - intersX - labelSize.getWidth()/2.0;
double posY = labelPos.getY() - intersY - labelSize.getHeight()/2.0;
label.setBounds(posX, posY, labelSize.getWidth(), labelSize.getHeight());
label1.setBounds(posX, posY, labelSize.getWidth(), labelSize.getHeight());
}
}
@Override
public Dimension2D getPreferredSize() {
AbstractAxisRenderer2D renderer = AbstractAxisRenderer2D.this;
double fontSize = renderer.getTickFont().getSize2D();
double tickLength = getTickLengthAbsolute();
double tickAlignment = renderer.getTickAlignment();
double tickLengthOuter = tickLength*(1.0 - tickAlignment);
double labelDistance = renderer.getTickLabelDistanceAbsolute() + tickLengthOuter;
double minSize = fontSize + labelDistance + tickLengthOuter;
double tickLength1 = getTickLengthAbsolute();
double tickAlignment1 = renderer.getTickAlignment();
double tickLengthOuter = tickLength1*(1.0 - tickAlignment1);
double labelDistance1 = renderer.getTickLabelDistanceAbsolute() + tickLengthOuter;
double minSize = fontSize + labelDistance1 + tickLengthOuter;
return new de.erichseifert.gral.graphics.Dimension2D.Double(minSize, minSize);
}
};
return component;
}
/**
@@ -525,8 +523,7 @@ protected Tick getTick(TickType type, Axis axis, double tickPositionWorld) {
}
}
Tick tick = new Tick(type, tickPoint, tickNormal, null, null, tickLabel);
return tick;
return new Tick(type, tickPoint, tickNormal, null, null, tickLabel);
}
/**
@@ -560,12 +557,11 @@ protected Tick getTick(TickType type, Axis axis, double tickPositionWorld) {
.isShapeNormalOrientationClockwise();
double normalOrientation =
normalOrientationClockwise ? 1.0 : -1.0;
PointND<Double> tickNormal = new PointND<>(
return new PointND<>(
normalOrientation*shapeLineNormals[segmentIndex].getX(),
normalOrientation*shapeLineNormals[segmentIndex].getY()
);
return tickNormal;
}
/**
@@ -176,9 +176,8 @@ public Number getPosition(Number value) {
if (value == null) {
return null;
}
double relativePosition = (value.doubleValue() - getMin().doubleValue()) /
return (value.doubleValue() - getMin().doubleValue()) /
getRange();
return relativePosition;
}
/**
@@ -95,8 +95,7 @@ protected String getLabel(Row row) {
}
// Text to display
String text = (format != null) ? format.format(value) : value.toString();
return text;
return (format != null) ? format.format(value) : value.toString();
}
@Override
@@ -77,8 +77,7 @@ protected Shape stroke(Shape line) {
return null;
}
Stroke stroke = getStroke();
Shape lineShape = stroke.createStrokedShape(line);
return lineShape;
return stroke.createStrokedShape(line);
}
/**
Oops, something went wrong.

0 comments on commit b7ae9c7

Please sign in to comment.