org.wicketstuff.openlayers3.component.Marker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wicketstuff-openlayers3-bootstrap Show documentation
Show all versions of wicketstuff-openlayers3-bootstrap Show documentation
Openlayer3 components that leverage Wicket Bootstrap
The newest version!
package org.wicketstuff.openlayers3.component;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.panel.GenericPanel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.request.resource.CssResourceReference;
import org.wicketstuff.openlayers3.api.util.Color;
/**
* Provides a marker that may be placed on a amp.
*/
public class Marker extends GenericPanel {
private static final long serialVersionUID = 1L;
/**
* Creates a new instance.
*
* @param id
* Wicket element ID for the marker
* @param color
* Model with the color of the marker
*/
public Marker(final String id, final IModel color) {
super(id, color);
}
@Override
protected void onInitialize() {
super.onInitialize();
add(new WebMarkupContainer("pin")
.add(new AttributeAppender("style", getBackgroundColorModel())));
}
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
response.render(CssHeaderItem.forReference(new CssResourceReference(Marker.class,
"Marker.css")));
}
/**
* Returns a model with the CSS for specifying the marker color.
*
* @return Model with the CSS marker color
*/
private IModel getBackgroundColorModel() {
return new IModel() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return "background-color: " + getModelObject() + ";";
}
};
}
}