Skip to content

Commit

Permalink
Removed redundant local variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
eseifert committed Jul 29, 2017
1 parent 6898779 commit b7ae9c7
Show file tree
Hide file tree
Showing 21 changed files with 74 additions and 105 deletions.
Expand Up @@ -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);
}

/**
Expand Down
Expand Up @@ -166,8 +166,7 @@ public boolean hasNext() {
}

public Comparable<?> next() {
Comparable<?> value = get(i++);
return value;
return get(i++);
}

public void remove() {
Expand Down
Expand Up @@ -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;
}

/**
Expand Down
Expand Up @@ -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) {
Expand Down
Expand Up @@ -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;
}

/**
Expand Down
11 changes: 4 additions & 7 deletions gral-core/src/main/java/de/erichseifert/gral/plots/BarPlot.java
Expand Up @@ -278,9 +278,8 @@ public Shape getPointShape(PointData data) {
barHeight = barHeightMin;
}

Shape shape = getBarShape(
return getBarShape(
barXMin - barX, barY, barWidth, barHeight);
return shape;
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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;
Expand All @@ -329,7 +327,6 @@ public void draw(DrawingContext context) {
}
}
};
return drawable;
}
}

Expand Down
Expand Up @@ -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;
}
}

Expand Down
Expand Up @@ -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;
Expand All @@ -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;
}
}

Expand Down
Expand Up @@ -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;
}
}

Expand Down
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
Expand Up @@ -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.
Expand All @@ -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 =
Expand All @@ -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();

Expand All @@ -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 &&
Expand All @@ -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
Expand All @@ -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);
}
}
Expand All @@ -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();
Expand All @@ -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),
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -560,12 +557,11 @@ public PointND<Double> getNormal(Axis axis, Number value,
.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;
}

/**
Expand Down
Expand Up @@ -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;
}

/**
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit b7ae9c7

Please sign in to comment.