All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jwebmp.plugins.radialsvgslider.RadialSVGSlider Maven / Gradle / Ivy

There is a newer version: 0.66.0.1
Show newest version
/*
 * Copyright (C) 2017 GedMarc
 *
 * This program 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.
 *
 * This program is 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 program.  If not, see .
 */
package com.jwebmp.plugins.radialsvgslider;

import com.jwebmp.core.base.ComponentHierarchyBase;
import com.jwebmp.core.base.html.Div;
import com.jwebmp.core.base.html.attributes.GlobalAttributes;
import com.jwebmp.core.htmlbuilder.css.lists.ListCSS;
import com.jwebmp.core.htmlbuilder.css.lists.ListStyleType;
import com.jwebmp.core.plugins.ComponentInformation;

import javax.validation.constraints.NotNull;

/**
 * An implementation of the Radial SVG Slider.
 * 

* Customized to be generic. https://codyhouse.co/gem/radial-svg-slider/ *

* * @author GedMarc * @version 1.0 * @since 29 Aug 2015 */ @ComponentInformation(name = "Radial SVG Slider Gem", description = "A carousel-like slider that animates the screen changes in a radial fashion", url = "https://codyhouse.co/demo/radial-svg-slider/index.html") public class RadialSVGSlider extends Div { private RadialSVGSliderFeature feature; @ListCSS(ListStyleType = ListStyleType.none) private RadialSVGSliderList radialSliderList; public RadialSVGSlider() { addFeature(getFeature()); addClass("cd-radial-slider-wrapper"); addAttribute(GlobalAttributes.Style, "margin-top: 0px;margin-bottom: 0px;"); } public final RadialSVGSliderFeature getFeature() { if (feature == null) { feature = new RadialSVGSliderFeature(this); } return feature; } /** * Sets the classes correctly on the children */ @Override public void preConfigure() { if (!isConfigured()) { int size = getRadialSliderList().getChildren() .size(); if (size > 0) { getRadialSliderList().getChildren() .stream() .findFirst() .get() .addClass("visible"); } if (size > 1) { getRadialSliderList().getChildren() .iterator() .next() .addClass("next-slide"); getRadialSliderList().getChildren() .toArray(new ComponentHierarchyBase[getRadialSliderList().getChildren() .size()])[getRadialSliderList().getChildren() .size() - 1].addClass("prev-slide"); } } super.preConfigure(); } /** * Renders the default stuff that doesn't need to be built * * @return */ @Override protected StringBuilder renderAfterChildren() { return new StringBuilder( getNewLine() + getNewLine() + getCurrentTabIndentString() + "\t" + "

    " + getNewLine() + getCurrentTabIndentString() + "\t" + "\t" + "
  • Next
  • " + getNewLine() + getCurrentTabIndentString() + "\t" + "\t" + "
  • Prev
  • " + getNewLine() + getCurrentTabIndentString() + "\t" + "
" + getNewLine() + getCurrentTabIndentString() + "\t" + "" + getNewLine() + getCurrentTabIndentString() + "\t" + "
" + getNewLine() + getCurrentTabIndentString() + "\t" + "\t" + "" + getNewLine() + getCurrentTabIndentString() + "\t" + "\t" + "\t" + "" + getNewLine() + getCurrentTabIndentString() + "\t" + "\t" + "\t" + "\t" + "" + getNewLine() + getCurrentTabIndentString() + "\t" + "\t" + "\t" + "\t" + "\t" + "" + getNewLine() + getCurrentTabIndentString() + "\t" + "\t" + "\t" + "\t" + "" + getNewLine() + getCurrentTabIndentString() + "\t" + "" + getNewLine() + getCurrentTabIndentString() + "\t" + "\t" + "\t" + "\t" + "" + getNewLine() + getCurrentTabIndentString() + "\t" + "\t" + "\t" + "\t" + "\t" + "" + getNewLine() + getCurrentTabIndentString() + "\t" + "\t" + "\t" + "\t" + "" + getNewLine() + getCurrentTabIndentString() + "\t" + "\t" + "\t" + "" + getNewLine() + getCurrentTabIndentString() + "\t" + "\t" + "" + getNewLine() + getCurrentTabIndentString() + "\t" + "
"); } /** * Returns the radial slider list * * @return */ @NotNull public RadialSVGSliderList getRadialSliderList() { if (radialSliderList == null) { setRadialSliderList(new RadialSVGSliderList()); } return radialSliderList; } /** * Sets the radial slider list * * @param radialSliderList */ public void setRadialSliderList(RadialSVGSliderList radialSliderList) { remove(this.radialSliderList); this.radialSliderList = radialSliderList; if (this.radialSliderList != null) { this.radialSliderList.addClass("cd-radial-slider"); this.radialSliderList.addAttribute(RadialSVGSliderListAttributes.Radius1, 60); this.radialSliderList.addAttribute(RadialSVGSliderListAttributes.Radius2, 1364); this.radialSliderList.addAttribute(RadialSVGSliderListAttributes.CenterX1, 110); this.radialSliderList.addAttribute(RadialSVGSliderListAttributes.CenterX2, 1290); this.radialSliderList.addAttribute(GlobalAttributes.Style, "margin-top: 0px;margin-bottom: 0px;padding-left:0"); add(this.radialSliderList); } } /** * Adds a face to this * * @param content * The content div to add * * @return */ public RadialSVGSliderListItem addFace(Div content) { return addFace(content, ""); } /** * Adds a face to this * * @param content * The content div to add * @param backgroundUrl * The background image URL to apply * * @return */ public RadialSVGSliderListItem addFace(Div content, String backgroundUrl) { RadialSVGSliderListItem li = new RadialSVGSliderListItem(); li.setContent(content); if (backgroundUrl != null) { li.setFaceBackgroundImageUrl(backgroundUrl); } getRadialSliderList().add(li); return li; } @Override public RadialSVGSliderOptions getOptions() { return getFeature().getOptions(); } @Override public int hashCode() { int result = super.hashCode(); result = 31 * result + getFeature().hashCode(); result = 31 * result + getRadialSliderList().hashCode(); return result; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof RadialSVGSlider)) { return false; } if (!super.equals(o)) { return false; } RadialSVGSlider that = (RadialSVGSlider) o; if (!getFeature().equals(that.getFeature())) { return false; } return getRadialSliderList().equals(that.getRadialSliderList()); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy