@Test public void testGetSize() { ScalebarAttribute attribute = new ScalebarAttribute(); attribute.setWidth(180); attribute.setHeight(40); ScalebarAttributeValues params = attribute.createValue(null); params.labelDistance = 3; params.barSize = 8; ScaleBarRenderSettings settings = new ScaleBarRenderSettings(); settings.setParams(params); settings.setIntervalLengthInPixels(40); settings.setLeftLabelMargin(3.0f); settings.setRightLabelMargin(4.0f); settings.setMaxSize(new Dimension(180, 40)); settings.setBarSize(8); settings.setPadding(4); settings.setLabelDistance(3); assertEquals( new Dimension(135, 31), ScalebarGraphic.getSize(params, settings, new Dimension(30, 12))); params.orientation = Orientation.HORIZONTAL_LABELS_ABOVE.getLabel(); params.labelDistance = null; params.barSize = null; settings.setBarSize(ScalebarGraphic.getBarSize(settings)); settings.setLabelDistance(ScalebarGraphic.getLabelDistance(settings)); assertEquals( new Dimension(135, 34), ScalebarGraphic.getSize(params, settings, new Dimension(30, 12))); attribute.setWidth(60); attribute.setHeight(180); settings.setMaxSize(new Dimension(60, 180)); params = attribute.createValue(null); settings.setParams(params); params.orientation = Orientation.VERTICAL_LABELS_LEFT.getLabel(); params.labelDistance = 3; params.barSize = 8; settings.setTopLabelMargin(5.0f); settings.setBottomLabelMargin(6.0f); settings.setBarSize(8); settings.setLabelDistance(3); assertEquals( new Dimension(49, 139), ScalebarGraphic.getSize(params, settings, new Dimension(30, 12))); params.labelDistance = null; params.barSize = null; settings.setBarSize(ScalebarGraphic.getBarSize(settings)); settings.setLabelDistance(ScalebarGraphic.getLabelDistance(settings)); assertEquals( new Dimension(57, 139), ScalebarGraphic.getSize(params, settings, new Dimension(30, 12))); }
@VisibleForTesting protected static Dimension getSize( final ScalebarAttributeValues scalebarParams, final ScaleBarRenderSettings settings, final Dimension maxLabelSize) { final float width; final float height; if (scalebarParams.getOrientation().isHorizontal()) { width = 2 * settings.getPadding() + settings.getIntervalLengthInPixels() * scalebarParams.intervals + settings.getLeftLabelMargin() + settings.getRightLabelMargin(); height = 2 * settings.getPadding() + settings.getBarSize() + settings.getLabelDistance() + Label.getRotatedHeight(maxLabelSize, scalebarParams.getLabelRotation()); } else { width = 2 * settings.getPadding() + settings.getLabelDistance() + settings.getBarSize() + Label.getRotatedWidth(maxLabelSize, scalebarParams.getLabelRotation()); height = 2 * settings.getPadding() + settings.getTopLabelMargin() + settings.getIntervalLengthInPixels() * scalebarParams.intervals + settings.getBottomLabelMargin(); } return new Dimension((int) Math.ceil(width), (int) Math.ceil(height)); }
ScalebarGraphic { @VisibleForTesting protected static Dimension getSize( final ScalebarAttributeValues scalebarParams, final ScaleBarRenderSettings settings, final Dimension maxLabelSize) { final float width; final float height; if (scalebarParams.getOrientation().isHorizontal()) { width = 2 * settings.getPadding() + settings.getIntervalLengthInPixels() * scalebarParams.intervals + settings.getLeftLabelMargin() + settings.getRightLabelMargin(); height = 2 * settings.getPadding() + settings.getBarSize() + settings.getLabelDistance() + Label.getRotatedHeight(maxLabelSize, scalebarParams.getLabelRotation()); } else { width = 2 * settings.getPadding() + settings.getLabelDistance() + settings.getBarSize() + Label.getRotatedWidth(maxLabelSize, scalebarParams.getLabelRotation()); height = 2 * settings.getPadding() + settings.getTopLabelMargin() + settings.getIntervalLengthInPixels() * scalebarParams.intervals + settings.getBottomLabelMargin(); } return new Dimension((int) Math.ceil(width), (int) Math.ceil(height)); } }
ScalebarGraphic { @VisibleForTesting protected static Dimension getSize( final ScalebarAttributeValues scalebarParams, final ScaleBarRenderSettings settings, final Dimension maxLabelSize) { final float width; final float height; if (scalebarParams.getOrientation().isHorizontal()) { width = 2 * settings.getPadding() + settings.getIntervalLengthInPixels() * scalebarParams.intervals + settings.getLeftLabelMargin() + settings.getRightLabelMargin(); height = 2 * settings.getPadding() + settings.getBarSize() + settings.getLabelDistance() + Label.getRotatedHeight(maxLabelSize, scalebarParams.getLabelRotation()); } else { width = 2 * settings.getPadding() + settings.getLabelDistance() + settings.getBarSize() + Label.getRotatedWidth(maxLabelSize, scalebarParams.getLabelRotation()); height = 2 * settings.getPadding() + settings.getTopLabelMargin() + settings.getIntervalLengthInPixels() * scalebarParams.intervals + settings.getBottomLabelMargin(); } return new Dimension((int) Math.ceil(width), (int) Math.ceil(height)); }  }
ScalebarGraphic { @VisibleForTesting protected static Dimension getSize( final ScalebarAttributeValues scalebarParams, final ScaleBarRenderSettings settings, final Dimension maxLabelSize) { final float width; final float height; if (scalebarParams.getOrientation().isHorizontal()) { width = 2 * settings.getPadding() + settings.getIntervalLengthInPixels() * scalebarParams.intervals + settings.getLeftLabelMargin() + settings.getRightLabelMargin(); height = 2 * settings.getPadding() + settings.getBarSize() + settings.getLabelDistance() + Label.getRotatedHeight(maxLabelSize, scalebarParams.getLabelRotation()); } else { width = 2 * settings.getPadding() + settings.getLabelDistance() + settings.getBarSize() + Label.getRotatedWidth(maxLabelSize, scalebarParams.getLabelRotation()); height = 2 * settings.getPadding() + settings.getTopLabelMargin() + settings.getIntervalLengthInPixels() * scalebarParams.intervals + settings.getBottomLabelMargin(); } return new Dimension((int) Math.ceil(width), (int) Math.ceil(height)); }  final URI render(
            final MapfishMapContext mapContext,
            final ScalebarAttributeValues scalebarParams,
            final File tempFolder,
            final Template template); }
ScalebarGraphic { @VisibleForTesting protected static Dimension getSize( final ScalebarAttributeValues scalebarParams, final ScaleBarRenderSettings settings, final Dimension maxLabelSize) { final float width; final float height; if (scalebarParams.getOrientation().isHorizontal()) { width = 2 * settings.getPadding() + settings.getIntervalLengthInPixels() * scalebarParams.intervals + settings.getLeftLabelMargin() + settings.getRightLabelMargin(); height = 2 * settings.getPadding() + settings.getBarSize() + settings.getLabelDistance() + Label.getRotatedHeight(maxLabelSize, scalebarParams.getLabelRotation()); } else { width = 2 * settings.getPadding() + settings.getLabelDistance() + settings.getBarSize() + Label.getRotatedWidth(maxLabelSize, scalebarParams.getLabelRotation()); height = 2 * settings.getPadding() + settings.getTopLabelMargin() + settings.getIntervalLengthInPixels() * scalebarParams.intervals + settings.getBottomLabelMargin(); } return new Dimension((int) Math.ceil(width), (int) Math.ceil(height)); }  final URI render(
            final MapfishMapContext mapContext,
            final ScalebarAttributeValues scalebarParams,
            final File tempFolder,
            final Template template);  }