Commit ee493ab8 authored by Nico Mack's avatar Nico Mack

Added ellipse shape to ShapeFactory

Fixed minor bug in style lookup for Font nodes
parent cf5898cb
...@@ -1009,7 +1009,7 @@ public class BootstrappingUtils { ...@@ -1009,7 +1009,7 @@ public class BootstrappingUtils {
if (!AVAILABLE_FONTS.contains(fontName)) { if (!AVAILABLE_FONTS.contains(fontName)) {
logAndThrowBuildException(new BuildException(StringUtils.build("Specified font {} is unknown!", fontName)), rootElement, childName); //$NON-NLS-1$ logAndThrowBuildException(new BuildException(StringUtils.build("Specified font {} is unknown!", fontName)), rootElement, childName); //$NON-NLS-1$
} }
if (!FONT_STYLES.containsKey(fontStyle)) { if (!FONT_STYLES.containsKey(fontStyle.toLowerCase())) {
logAndThrowBuildException(new BuildException(StringUtils.build("Specified font style {} does match accepted values. Accepted values are {}!", fontStyle, FONT_STYLES.keySet())), rootElement, childName); //$NON-NLS-1$ logAndThrowBuildException(new BuildException(StringUtils.build("Specified font style {} does match accepted values. Accepted values are {}!", fontStyle, FONT_STYLES.keySet())), rootElement, childName); //$NON-NLS-1$
} }
......
...@@ -48,8 +48,8 @@ import java.awt.geom.AffineTransform; ...@@ -48,8 +48,8 @@ import java.awt.geom.AffineTransform;
public class ShapeBootstrapper { public class ShapeBootstrapper {
/** /**
* Method used to build a {@link Shape} instance given an archetype. The method will delegate * Method used to build a {@link Shape} instance given an archetype. The method will delegate the
* the construction of the shape to the given public static non-arg build method found in the * construction of the shape to the given public static non-arg build method found in the
* {@link ShapeFactory}. * {@link ShapeFactory}.
* *
* @param shapeNode * @param shapeNode
...@@ -110,6 +110,10 @@ public class ShapeBootstrapper { ...@@ -110,6 +110,10 @@ public class ShapeBootstrapper {
dimensions.setLocation(circleSize, circleSize); dimensions.setLocation(circleSize, circleSize);
dimensions.toCoordinates(ScreenCoordinates.class); dimensions.toCoordinates(ScreenCoordinates.class);
return ShapeFactory.buildCircle((int) dimensions.getX()); return ShapeFactory.buildCircle((int) dimensions.getX());
case "ellipse": //$NON-NLS-1$
dimensions.setLocation(width, height);
dimensions.toCoordinates(ScreenCoordinates.class);
return ShapeFactory.buildEllipse((int) dimensions.getX(), (int) dimensions.getY());
case "square": //$NON-NLS-1$ case "square": //$NON-NLS-1$
dimensions.setLocation(squareSize, squareSize); dimensions.setLocation(squareSize, squareSize);
dimensions.toCoordinates(ScreenCoordinates.class); dimensions.toCoordinates(ScreenCoordinates.class);
......
...@@ -55,13 +55,35 @@ public class ShapeFactory { ...@@ -55,13 +55,35 @@ public class ShapeFactory {
private static final Logger LOGGER = LoggerFactory.getLogger(ShapeFactory.class.getSimpleName()); private static final Logger LOGGER = LoggerFactory.getLogger(ShapeFactory.class.getSimpleName());
/**
* Method for building a circle.
*
* @param circleSize
* The diameter of the circle to build.
* @return An instance of {@link java.awt.geom.Ellipse2D.Float}.
*/
public static Ellipse2D.Float buildCircle(float circleSize) { public static Ellipse2D.Float buildCircle(float circleSize) {
return new Ellipse2D.Float(-circleSize / 2f, -circleSize / 2f, circleSize, circleSize); return new Ellipse2D.Float(-circleSize / 2f, -circleSize / 2f, circleSize, circleSize);
} }
/** /**
* Method for building a circle and setting it for the shape field. The size will de defaulted * Method for building a ellipse.
* to the calibration's default size. *
* @param horizontalSize
* The width of the ellipse to build.
* @param verticalSize
* The height of the ellipse to build.
* @return An instance of {@link java.awt.geom.Ellipse2D.Float}.
*/
public static Ellipse2D.Float buildEllipse(float horizontalSize, float verticalSize) {
return new Ellipse2D.Float(-horizontalSize / 2f, -verticalSize / 2f, horizontalSize, verticalSize);
}
/**
* Method for building a circle and setting it for the shape field. The size will de defaulted to
* the calibration's default size.
* *
* @return An instance of {@link java.awt.geom.Ellipse2D.Float}. * @return An instance of {@link java.awt.geom.Ellipse2D.Float}.
*/ */
...@@ -212,15 +234,15 @@ public class ShapeFactory { ...@@ -212,15 +234,15 @@ public class ShapeFactory {
} }
/** /**
* Method for building an arc taking a ratio for the base bounding rectangle from the default * Method for building an arc taking a ratio for the base bounding rectangle from the default square
* square size given by the calibration and with a standard round form. The arc type can be * size given by the calibration and with a standard round form. The arc type can be specified to
* specified to either give only an arc or build, for example, a pie. * either give only an arc or build, for example, a pie.
* *
* @param radius * @param radius
* The ratio of the bounding rectangle to draw the arc in. * The ratio of the bounding rectangle to draw the arc in.
* @param arcStart * @param arcStart
* The angle at which the arc will commence. <b>Note</b>: The 0 angle is horizontal. See * The angle at which the arc will commence. <b>Note</b>: The 0 angle is horizontal. See here
* here http://kodejava.org/how-do-i-draw-an-arc-in-java-2d/. * http://kodejava.org/how-do-i-draw-an-arc-in-java-2d/.
* @param arcLength * @param arcLength
* The length of the arc as given by degrees. * The length of the arc as given by degrees.
* @param arcType * @param arcType
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment