package org.skyve.metadata.view.model.map;

import org.locationtech.jts.geom.Geometry;

public class MapFeature {
	private Geometry geometry;
	private boolean zoomable = true;
	private boolean editable = false;
	private String strokeColour;
	private String fillColour;
	private Float fillOpacity;
	private String iconRelativeFilePath;
	private Integer iconAnchorX;
	private Integer iconAnchorY;

	public MapFeature() {
	}

	public MapFeature(Geometry geometry,
			boolean zoomable,
			boolean editable,
			String strokeColour,
			String fillColour,
			Float fillOpacity,
			String iconRelativeFilePath,
			Integer iconAnchorX,
			Integer iconAnchorY) {
		this.geometry = geometry;
		this.zoomable = zoomable;
		this.editable = editable;
		this.strokeColour = strokeColour;
		this.fillColour = fillColour;
		setFillOpacity(fillOpacity);
		this.iconRelativeFilePath = iconRelativeFilePath;
		this.iconAnchorX = iconAnchorX;
		this.iconAnchorY = iconAnchorY;
	}

	public Geometry getGeometry() {
		return geometry;
	}

	public void setGeometry(Geometry geometry) {
		this.geometry = geometry;
	}

	public boolean isZoomable() {
		return zoomable;
	}

	public void setZoomable(boolean zoomable) {
		this.zoomable = zoomable;
	}

	public boolean isEditable() {
		return editable;
	}

	public void setEditable(boolean editable) {
		this.editable = editable;
	}

	public String getStrokeColour() {
		return strokeColour;
	}

	public void setStrokeColour(String strokeColour) {
		this.strokeColour = strokeColour;
	}

	public String getFillColour() {
		return fillColour;
	}

	public void setFillColour(String fillColour) {
		this.fillColour = fillColour;
	}

	public float getFillOpacity() {
		return fillOpacity;
	}

	/**
	 * Set the fill opacity of this map feature. Expects a float between 0.0 (fully transparent) and 1.0 (fully opaque).
	 * 
	 * @param fillOpacity The fill opacity of the feature
	 */
	public void setFillOpacity(Float fillOpacity) {
		if (fillOpacity != null) {
			if (fillOpacity.floatValue() > 1.0) {
				fillOpacity = 1.0f;
			}
			if (fillOpacity.floatValue() < 0.0) {
				fillOpacity = 0.0f;
			}

			this.fillOpacity = fillOpacity;
		}
	}

	public String getIconRelativeFilePath() {
		return iconRelativeFilePath;
	}

	public void setIconRelativeFilePath(String iconRelativeFilePath) {
		this.iconRelativeFilePath = iconRelativeFilePath;
	}

	public Integer getIconAnchorX() {
		return iconAnchorX;
	}

	public void setIconAnchorX(Integer iconAnchorX) {
		this.iconAnchorX = iconAnchorX;
	}

	public Integer getIconAnchorY() {
		return iconAnchorY;
	}

	public void setIconAnchorY(Integer iconAnchorY) {
		this.iconAnchorY = iconAnchorY;
	}
}

@@ -271,17 +271,17 @@
 private 
-F
+f
 loat fil
@@ -288,16 +288,23 @@
 lOpacity
+ = 1.0f
 ;%0A%09priva
@@ -461,16 +461,19 @@
 ometry,%0A
+%09%09%09
 %09%09%09boole
@@ -488,16 +488,19 @@
 ble,%0A%09%09%09
+%09
+%09%09
 boolean 
@@ -508,24 +508,27 @@
 ditable,%0A%09%09%09
+%09
+%09%09
 String strok
@@ -535,24 +535,27 @@
 eColour,%0A%09%09%09
+%09
+%09%09
 String fillC
@@ -564,17 +564,20 @@
 our,%0A%09%09%09
-F
+%09%09%09f
 loat fil
@@ -586,16 +586,19 @@
 pacity,%0A
+%09%09%09
 %09%09%09Strin
@@ -621,16 +621,19 @@
 lePath,%0A
+%09%09%09
 %09%09%09Integ
@@ -648,16 +648,19 @@
 nchorX,%0A
+%09%09%09
 %09%09%09Integ
@@ -1951,17 +1951,17 @@
 Opacity(
-F
+f
 loat fil
@@ -1978,38 +1978,37 @@
 %7B%0A%09%09
-if (fillOpacity != null) %7B
+float value = fillOpacity;
 %0A%09%09
-%09
 if (
@@ -2022,46 +2022,27 @@
 city
-.floatValue()
  %3E 1.0
+f
 ) %7B%0A%09%09%09
-%09fillOpacity
+value
  = 1
@@ -2050,16 +2050,14 @@
 0f;%0A
-%09
 %09%09%7D%0A%09%09
-%09
 if (
@@ -2071,46 +2071,27 @@
 city
-.floatValue()
  %3C 0.0
+f
 ) %7B%0A%09%09%09
-%09fillOpacity
+value
  = 0
@@ -2097,21 +2097,19 @@
 0.0f;%0A%09%09
-%09
 %7D%0A%0A
-%09
 %09%09this.f
@@ -2125,24 +2125,14 @@
 y = 
-fillOpacity;%0A%09%09%7D
+value;
 %0A%09%7D%0A

Fix unboxing in MapFeature.