1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-22 21:15:09 +00:00

Delete UScale and related code as it is now unused.

This commit is contained in:
matthew16550 2021-10-04 22:00:11 +11:00
parent 4ac9b7cd90
commit a02ff86cbd
14 changed files with 10 additions and 176 deletions

View File

@ -58,7 +58,6 @@ public abstract class AbstractCommonUGraphic implements UGraphic {
private final ColorMapper colorMapper; private final ColorMapper colorMapper;
private UClip clip; private UClip clip;
private double scale = 1;
private final HColor defaultBackground; private final HColor defaultBackground;
@ -75,7 +74,7 @@ public abstract class AbstractCommonUGraphic implements UGraphic {
Objects.requireNonNull(change); Objects.requireNonNull(change);
final AbstractCommonUGraphic copy = copyUGraphic(); final AbstractCommonUGraphic copy = copyUGraphic();
if (change instanceof UTranslate) { if (change instanceof UTranslate) {
copy.translate = ((UTranslate) change).scaled(scale).compose(copy.translate); copy.translate = ((UTranslate) change).compose(copy.translate);
} else if (change instanceof UClip) { } else if (change instanceof UClip) {
copy.clip = (UClip) change; copy.clip = (UClip) change;
copy.clip = copy.clip.translate(getTranslateX(), getTranslateY()); copy.clip = copy.clip.translate(getTranslateX(), getTranslateY());
@ -91,9 +90,6 @@ public abstract class AbstractCommonUGraphic implements UGraphic {
copy.color = null; copy.color = null;
} else if (change instanceof HColor) { } else if (change instanceof HColor) {
copy.color = (HColor) change; copy.color = (HColor) change;
} else if (change instanceof UScale) {
final double factor = ((UScale) change).getScale();
copy.scale = scale * factor;
} }
return copy; return copy;
} }
@ -128,7 +124,6 @@ public abstract class AbstractCommonUGraphic implements UGraphic {
this.hidden = other.hidden; this.hidden = other.hidden;
this.color = other.color; this.color = other.color;
this.backColor = other.backColor; this.backColor = other.backColor;
this.scale = other.scale;
} }
protected abstract AbstractCommonUGraphic copyUGraphic(); protected abstract AbstractCommonUGraphic copyUGraphic();
@ -155,10 +150,6 @@ public abstract class AbstractCommonUGraphic implements UGraphic {
public UPattern getPattern() { public UPattern getPattern() {
return pattern; return pattern;
} }
public double getScale() {
return scale;
}
}; };
} }

View File

@ -93,13 +93,7 @@ public abstract class AbstractUGraphic<O> extends AbstractCommonUGraphic {
return; return;
} }
beforeDraw(); beforeDraw();
if (shape instanceof Scalable) { driver.draw(shape, getTranslateX(), getTranslateY(), getColorMapper(), getParam(), graphic);
final double scale = getParam().getScale();
shape = ((Scalable) shape).getScaled(scale);
driver.draw(shape, getTranslateX(), getTranslateY(), getColorMapper(), getParam(), graphic);
} else {
driver.draw(shape, getTranslateX(), getTranslateY(), getColorMapper(), getParam(), graphic);
}
afterDraw(); afterDraw();
} }

View File

@ -72,7 +72,6 @@ public class LimitFinder extends UGraphicNo {
UClip.class, UClip.class,
HColor.class, HColor.class,
UHidden.class, UHidden.class,
UScale.class,
UStroke.class, UStroke.class,
UTranslate.class UTranslate.class
)) { )) {

View File

@ -1,41 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.ugraphic;
public interface Scalable {
public UShape getScaled(double scale);
}

View File

@ -40,22 +40,13 @@ import java.awt.geom.Point2D;
import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Dimension2DDouble;
public class UEllipse extends AbstractShadowable implements Scalable, UShapeSized { public class UEllipse extends AbstractShadowable implements UShapeSized {
private final double width; private final double width;
private final double height; private final double height;
private final double start; private final double start;
private final double extend; private final double extend;
public UShape getScaled(double scale) {
if (scale == 1) {
return this;
}
final AbstractShadowable result = new UEllipse(width * scale, height * scale, start, extend);
result.setDeltaShadow(this.getDeltaShadow());
return result;
}
public UEllipse(double width, double height) { public UEllipse(double width, double height) {
this(width, height, 0, 0); this(width, height, 0, 0);
} }

View File

@ -116,14 +116,6 @@ public class UFont {
return font; return font;
} }
public UFont scaled(double scale) {
if (scale == 1) {
return this;
}
final float current = font.getSize2D();
return withSize((float) (current * scale));
}
public UFont withSize(float size) { public UFont withSize(float size) {
return new UFont(font.deriveFont(size), family); return new UFont(font.deriveFont(size), family);
} }

View File

@ -37,20 +37,11 @@ package net.sourceforge.plantuml.ugraphic;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
public class ULine extends AbstractShadowable implements Scalable, UShapeSized { public class ULine extends AbstractShadowable implements UShapeSized {
private final double dx; private final double dx;
private final double dy; private final double dy;
public UShape getScaled(double scale) {
if (scale == 1) {
return this;
}
final AbstractShadowable result = new ULine(dx * scale, dy * scale);
result.setDeltaShadow(this.getDeltaShadow());
return result;
}
public ULine(Point2D p1, Point2D p2) { public ULine(Point2D p1, Point2D p2) {
this(p2.getX() - p1.getX(), p2.getY() - p1.getY()); this(p2.getX() - p1.getX(), p2.getY() - p1.getY());
} }

View File

@ -48,6 +48,4 @@ public interface UParam {
public boolean isHidden(); public boolean isHidden();
public UPattern getPattern(); public UPattern getPattern();
public double getScale();
} }

View File

@ -58,10 +58,4 @@ public class UParamNull implements UParam {
public UPattern getPattern() { public UPattern getPattern() {
return UPattern.FULL; return UPattern.FULL;
} }
public double getScale() {
return 1;
}
} }

View File

@ -39,7 +39,7 @@ import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ugraphic.comp.CompressionMode; import net.sourceforge.plantuml.ugraphic.comp.CompressionMode;
public class URectangle extends AbstractShadowable implements Scalable, UShapeSized, UShapeIgnorableForCompression { public class URectangle extends AbstractShadowable implements UShapeSized, UShapeIgnorableForCompression {
private final double width; private final double width;
private final double height; private final double height;
@ -102,16 +102,6 @@ public class URectangle extends AbstractShadowable implements Scalable, UShapeSi
return new URectangle(width, height, rx, ry, comment, ignoreForCompressionOnX, true, codeLine); return new URectangle(width, height, rx, ry, comment, ignoreForCompressionOnX, true, codeLine);
} }
public UShape getScaled(double scale) {
if (scale == 1) {
return this;
}
final AbstractShadowable result = new URectangle(width * scale, height * scale, rx * scale, ry * scale, comment,
ignoreForCompressionOnX, ignoreForCompressionOnY, codeLine);
result.setDeltaShadow(this.getDeltaShadow());
return result;
}
public URectangle(double width, double height) { public URectangle(double width, double height) {
this(width, height, 0, 0, null, false, false, null); this(width, height, 0, 0, null, false, false, null);
} }

View File

@ -1,63 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.ugraphic;
public class UScale implements UChange {
private final double scale;
@Override
public String toString() {
return "scale scale=" + scale;
}
public UScale(double scale) {
this.scale = scale;
}
public double getScale() {
return scale;
}
// public Point2D getTranslated(Point2D p) {
// if (p == null) {
// return null;
// }
// return new Point2D.Double(p.getX() + dx, p.getY() + dy);
// }
}

View File

@ -73,7 +73,7 @@ public class DriverLineG2d extends DriverShadowedG2d implements UDriver<Graphics
static void manageStroke(UParam param, Graphics2D g2d) { static void manageStroke(UParam param, Graphics2D g2d) {
final UStroke stroke = param.getStroke(); final UStroke stroke = param.getStroke();
final float thickness = (float) (stroke.getThickness() * param.getScale()); final float thickness = (float) stroke.getThickness();
if (stroke.getDashVisible() == 0) { if (stroke.getDashVisible() == 0) {
g2d.setStroke(new BasicStroke(thickness)); g2d.setStroke(new BasicStroke(thickness));
} else { } else {

View File

@ -83,7 +83,7 @@ public class DriverTextAsPathG2d implements UDriver<Graphics2D> {
final UText shape = (UText) ushape; final UText shape = (UText) ushape;
final FontConfiguration fontConfiguration = shape.getFontConfiguration(); final FontConfiguration fontConfiguration = shape.getFontConfiguration();
final UFont font = fontConfiguration.getFont().scaled(param.getScale()); final UFont font = fontConfiguration.getFont();
final Dimension2D dimBack = calculateDimension(font, shape.getText()); final Dimension2D dimBack = calculateDimension(font, shape.getText());
if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) { if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) {
final Color extended = mapper.toColor(fontConfiguration.getExtendedColor()); final Color extended = mapper.toColor(fontConfiguration.getExtendedColor());

View File

@ -83,20 +83,18 @@ public class DriverTextG2d implements UDriver<Graphics2D> {
final List<StyledString> strings = StyledString.build(text); final List<StyledString> strings = StyledString.build(text);
final UFont font = fontConfiguration.getFont().scaled(param.getScale());
for (StyledString styledString : strings) { for (StyledString styledString : strings) {
final FontConfiguration fc = styledString.getStyle() == FontStyle.BOLD ? fontConfiguration.bold() final FontConfiguration fc = styledString.getStyle() == FontStyle.BOLD ? fontConfiguration.bold()
: fontConfiguration; : fontConfiguration;
final Dimension2D dim = calculateDimension(fc.getFont(), styledString.getText()); final Dimension2D dim = calculateDimension(fc.getFont(), styledString.getText());
printSingleText(g2d, fc, styledString.getText(), x, y, mapper, param); printSingleText(g2d, fc, styledString.getText(), x, y, mapper);
x += dim.getWidth(); x += dim.getWidth();
} }
} }
private void printSingleText(Graphics2D g2d, final FontConfiguration fontConfiguration, final String text, double x, private void printSingleText(Graphics2D g2d, final FontConfiguration fontConfiguration, final String text, double x,
double y, ColorMapper mapper, UParam param) { double y, ColorMapper mapper) {
final UFont font = fontConfiguration.getFont().scaled(param.getScale()); final UFont font = fontConfiguration.getFont();
final HColor extended = fontConfiguration.getExtendedColor(); final HColor extended = fontConfiguration.getExtendedColor();
final int orientation = 0; final int orientation = 0;