spring动效引擎怎么用
-
要使用Spring动效引擎,首先需要进行以下几个步骤:
-
引入Spring动效引擎依赖:在项目的pom.xml文件中添加Spring动效引擎的依赖。可以在Maven中央仓库或其他可用的仓库中找到相应的依赖配置。
-
配置Spring动效引擎:在Spring配置文件中声明并配置Spring动效引擎,包括设置动效引擎的属性,如线程池大小、持久化配置等。可以根据具体需求进行适当的配置调整。
-
定义动效:在Spring配置文件中定义具体的动效。可以使用Spring动态语言表达式等方式定义动效的具体实现,比如设置动画效果、动画时长、起始位置、目标位置等。
-
调用动效:在代码中通过注入或获取引擎实例的方式,调用动效引擎来执行具体的动效。可以设置动效参数、启动动效、暂停动效、停止动效等。
-
监听动效事件:可以配置监听器,来监听动效引擎产生的事件,比如动效开始、暂停、完成等事件。可以根据具体需求采取相应的处理方式。
使用Spring动效引擎的示例代码如下:
// 引入Spring动效引擎依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-animation</artifactId> <version>1.0.0</version> </dependency> // 配置Spring动效引擎 <bean id="animationEngine" class="org.springframework.animation.engine.AnimationEngine"> <property name="threadPoolSize" value="10" /> <property name="persistenceConfig" ref="persistenceConfig" /> </bean> // 定义动效 <bean id="fadeAnimation" class="org.springframework.animation.FadeAnimation"> <property name="duration" value="1000" /> <property name="fromValue" value="0" /> <property name="toValue" value="1" /> </bean> // 调用动效 @Autowired private AnimationEngine animationEngine; public void animate() { Animation fadeAnimation = (Animation) applicationContext.getBean("fadeAnimation"); animationEngine.startAnimation(fadeAnimation); } // 监听动效事件 public class AnimationEventListener implements ApplicationListener<AnimationEvent> { public void onApplicationEvent(AnimationEvent event) { if (event instanceof AnimationStartedEvent) { // 动效开始事件处理逻辑 } else if (event instanceof AnimationPausedEvent) { // 动效暂停事件处理逻辑 } else if (event instanceof AnimationCompletedEvent) { // 动效完成事件处理逻辑 } } }通过以上步骤,你就可以在你的项目中使用Spring动效引擎来实现各种动画效果了。当然,具体的使用方式会根据你的项目需求而有所不同,以上仅为一种示例。希望对你有所帮助!
1年前 -
-
使用Spring动效引擎可以为网页和移动应用添加动画效果。下面是使用Spring动效引擎的基本步骤:
-
引入Spring动效引擎库
在项目中引入Spring动效引擎库,可以通过Gradle或Maven方式导入。 -
创建动效场景
使用Spring动效引擎,首先需要创建一个动效场景。动效场景是一个容器,包含了所有的动画效果和控制器。 -
定义动画效果
下一步是定义动画效果。Spring动效引擎提供了多种动画效果,如位移、旋转、缩放等。可以通过代码或者XML方式来定义动画效果。 -
创建控制器
控制器用于触发动画效果的开始和结束,可以根据各种条件来控制。Spring动效引擎支持多种不同的控制器,如点击事件控制器、滚动控制器等。 -
启动动画
最后一步是启动动画,将动效场景中的动画效果与控制器关联起来,并触发动画的开始。
除了上述基本步骤,还可以在动画效果和控制器中设置参数来调整动画的速度、持续时间、延迟等。也可以通过监听器来监听动画的开始和结束事件,执行其他操作。
总之,使用Spring动效引擎可以轻松地为网页和移动应用添加动画效果。需要按照上述步骤引入库、创建场景、定义动画效果、创建控制器并启动动画。
1年前 -
-
Spring动画引擎是一个基于Java的动画库,它可以为网页、桌面应用或移动应用程序添加平滑的动态效果。使用Spring动画引擎可以简化动画的创建和管理,并提供丰富的动态效果来增强用户体验。
以下是使用Spring动画引擎的一般操作流程:
-
添加Spring动画引擎库:首先,您需要将Spring动画引擎库添加到您的项目中。可以通过Maven、Gradle或手动下载jar文件的方式添加引擎库。
-
创建动画对象:使用Spring动画引擎,您可以创建各种类型的动画对象,如移动、缩放、旋转等。可以使用以下代码创建一个简单的平移动画对象:
import com.vaadin.spring.annotation.SpringComponent; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.Assert; import org.vaadin.spring.annotation.VaadinSessionScope; import org.vaadin.spring.sidebar.annotation.SideBarItem; import org.vaadin.spring.sidebar.annotation.VaadinFontIcon; import org.vaadin.spring.sidebar.annotation.VaadinSideBarSection; import org.vaadin.spring.sidebar.annotation.VaadinSideBarSections; import org.w3c.dom.Element; import org.xml.sax.SAXException; import org.yxJxbp.ws_client.api.SoapClientExecutor; import javax.servlet.http.HttpServletRequest; import javax.wsdl.Definition; import javax.wsdl.WSDLException; import javax.wsdl.extensions.ExtensibilityElement; import javax.wsdl.extensions.soap.SOAPBinding; import javax.wsdl.extensions.soap12.SOAP12Binding; import javax.wsdl.factory.WSDLFactory; import javax.wsdl.xml.WSDLReader; import javax.xml.bind.JAXBException; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.xpath.XPathExpressionException; import java.io.IOException; import java.net.URL; import java.rmi.ServerException; import java.util.List; @Component @SpringComponent @VaadinSessionScope @VaadinSideBarSections({ @VaadinSideBarSection(id = Sections.TOOLS, caption = "济南市供水系统自动监控"), @VaadinSideBarSection(id = Sections.OTHER, caption = "其他工具") }) public class JiangningCheckView extends VerticalLayout implements View { public Checkbox selectAction = new Checkbox("记录本次操作到历史", true); public TextArea textAction = new TextArea("本次操作记录"); private SoapClientExecutor soapClientExecutor; private DateField startDateField = new DateField("开始时间: "); private DateField endDateField = new DateField("结束时间: "); private HorizontalLayout selectDate = new HorizontalLayout(); private TextField jn96iDeviceName = new TextField("deviceName"); private Button autoCheckBut = new Button("自动检查运行中的监测设备"); private HorizontalLayout conditionOption = new HorizontalLayout(); private VerticalLayout condition = new VerticalLayout(); private TextField jn96iLicenseKey = new TextField("licenseKey"); private TextField jn96SerialNumberSn = new TextField("sn"); private TextField jn96iUser = new TextField("user"); private TextField jn96iPass = new TextField("pass"); private TextField jn96iPort = new TextField("port"); /** * <xmp> * <tns:plateau_equipment xmlns:tns="http://axis.xxx.wt.abc.cn"> * <tns:device_name>aaron</tns:device_name> * <tns:begin_time>2017-09-06T14:39:00</tns:begin_time> * <tns:end_time> 2017-09-06T15:39:00</tns:end_time> * <tns:user>root</tns:user> * <tns:password>root</tns:password> * <tns:port>22 </tns:port> * </tns:plateau_equipment> * </xmp> */ private Button normalCheckBtn = new Button("检查设备状态"); private synchronized MissDataUpdateResultBean autoCheckDeviceStatus() throws IOException, JAXBException, SAXException, XPathExpressionException, ClassNotFoundException, WSDLException, ParserConfigurationException, TransformerException { String deviceName = jn96iDeviceName.getValue(); String beginTime = startDateField.getValue().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss")); String endTime = endDateField.getValue().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss")); String jn96iUserText = jn96iUser.getValue(); String jn96iPassText = jn96iPass.getValue(); String jn96iPortText = jn96iPort.getValue(); HistoryCheckHistoryRequest hlpiRequest = new HistoryCheckHistoryRequest(); hlpiRequest.setDeviceName(jn96iDeviceName.getValue()); hlpiRequest.setBeginTime(startDateField.getValue().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"))); hlpiRequest.setEndTime(endDateField.getValue().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"))); MissDataUpdateResultBean rs = null; checkponit: { try { rs = soapClientExecutor.invokeWebService("http://233.wt.abc.cn:808/services/JinNingIntService?wsdl", "http://axis.xxx.wt.abc.cn", "queryTemAndPhFromBarByDateTime", hlpiRequest.getRequestMap(), MissDataUpdateResultBean.class); } catch (Exception e) { e.printStackTrace(); throw new ServerException("江宁地区污水厂监控设备状态检查数据接口失败!", e); } } return rs; } /** * 参数: * <xmp> * <tns:plateau_equipment xmlns:tns="http://axis.xxx.wt.abc.cn"> * <tns:device_name>aaron</tns:device_name> * <tns:begin_time>2017-09-06T14:39:00</tns:begin_time> * <tns:end_time> 2017-09-06T15:39:00</tns:end_time> * <tns:user>root</tns:user> * <tns:password>root</tns:password> * <tns:port>22 </tns:port> * </tns:plateau_equipment> * </xmp> */ private TextField jn96iSN = new TextField("JN96-SN"); /** * <xmp> GL8 22 TT * <tns:plateau_equipment xmlns:tns="http://axis.xxx.wt.abc.cn"> * <tns:licenseKey>3.009.0001.01.001.1000..</tns:licenseKey> * <tns:sn>xxx1</tns:sn> * <tns:port>22 </tns:port> * </tns:plateau_equipment> * </xmp> */ private TextField jn96iLicenseKeyQuery = new TextField("licenseKey"); private Button normalQueryBtn = new Button("查询历史数据"); private synchronized MissDataUpdateResultBean queryHistoriesOfDevice() throws IOException, JAXBException, SAXException, XPathExpressionException, ClassNotFoundException, WSDLException, ParserConfigurationException, TransformerException { String jn96iSNText = jn96iSN.getValue(); String jn96iLicenseKeyText = jn96iLicenseKeyQuery.getValue(); String jn96iPortText = jn96iPort.getValue(); QueryHistoryRequest hlpiRequest = new QueryHistoryRequest(); hlpiRequest.setSn(jn96iSN.getValue()); hlpiRequest.setLicenseKey(jn96iLicenseKeyQuery.getValue()); MissDataUpdateResultBean rs = null; checkponit: { try { rs = soapClientExecutor.invokeWebService("http://233.wt.abc.cn:808/services/JinNingIntService?wsdl", "http://axis.xxx.wt.abc.cn", "queryO2AndPHOfJN96ByDateTime", hlpiRequest.getRequestMap(), MissDataUpdateResultBean.class); } catch (Exception e) { e.printStackTrace(); throw new ServerException("江宁地区污水厂监控设备实时数据查询接口失败!", e); } } return rs; } public static interface Sections { public static final String TOOLS = "工具"; public static final String OTHER = "其他"; } @Autowired private HistoryDAO historyDao; @Autowired private HttpServletRequest servletRequest; private static final String SOAP_ACTION_Mapping = "http://axis.xxx.wt.abc.cn"; private static final String SOAP_URI_NS = "http://233.wt.abc.cn:808/services/JinNingIntService?wsdl"; { setMargin(true); setSpacing(true); normalCheckBtn.setWidth("200px"); normalCheckBtn.setEnabled(false); normalCheckBtn.addClickListener((Button.ClickListener) clickEvent -> { try { Date startDate = startDateField.getValue() == null ? now() : Date.from(startDateField.getValue().atStartOfDay(systemDefault()).toInstant()); Date endDate = endDateField.getValue() == null ? now() : Date.from(endDateField.getValue().atStartOfDay(systemDefault()).toInstant()); final DateFormat dateFormat = new SimpleDateFormat("HH:mm"); //{ "03","09","15","21" };//1日四次 String result = ""; //时间的条件 String[] times = { "03", "09", "15", "21" }; for (String t : times) { //对2017-07-26日期下的午时4次,否则两次。如下: String s = "2017-07-26"; boolean equals = format(JSON2Object(s.substring(0, 10), t)).equals(s); int i = equals ? 4 : 2; for (int j = 0; j < i; j++) { final lazy<String> st = format(JSON2Object(s.substring(0, 10), t)); Calendar c = Calendar.getInstance(); c.setTime(startDate); c.add(Calendar.DATE, j);//将开始时间加上多少天,比如1天 startDate = c.getTime(); c.add(Calendar.DATE, 0);//将开始时间加上多少天,比如1天 endDate = c.getTime(); checkIterest("jn96i", startDate, endDate, "run_status_use_to21", "标况", "up_"); Calendar crpm = c; crpm.add(Calendar.MINUTE, -1);//回推在一分钟内,发生的数据。 st.add(crpm.get(YEAR), job(crpm.get(MONTH) + 1), job(crpm.get(DAY_OF_MONTH)), job(crpm.get(HOUR_OF_DAY)), job(crpm.get(MINUTE))); if (selectAction.getValue()) { HttpServletResponse response = ((VaadinServletResponse) VaadinService .getCurrentResponse()).getHttpServletResponse(); this.servletRequest.setAttribute("checkType", "自动检查运行中的监测设备"); this.servletRequest.setAttribute("beginTime", st.get()); this.servletRequest.setAttribute("endTime", st.get()); Object obj0 = servletRequest.getSession().getAttribute("sys.setting.history.realtime"); Object obj1 = null; Object obj2 = null; Object obj3 = null; if (obj0 != null) { obj1 = servletRequest.getSession().getAttribute("sys.setting.history.realtime.value"); obj2 = servletRequest.getSession().getAttribute("sys.setting.history.realtime.name"); obj3 = servletRequest.getSession().getAttribute("sys.setting.history.realtime.checkstatus"); servletRequest.getSession().removeAttribute("sys.setting.history.realtime"); } response.setContentType("application/json"); ((VaadinServletResponse) VaadinService .getCurrentResponse()).getHttpServletResponse().getWriter() .write("{\"message\":\"ok\",\"status\":\"000\",\"value\":\"" + "" + ((obj1 != null) ? obj1.toString() : "") + "\",\"name\":\"" + ((obj1 != null) ? obj2.toString() : "") + "\",\"data\":\"" + ((obj1 != null) ? obj3.toString() : "") + "\"}"); } } } } catch (Exception e) { Notification.show("从WebService获取数据失败!" + e.getMessage(), Type.ERROR_MESSAGE); e.printStackTrace(); } }); } 3. 设置动画属性:通过调整动画对象的属性来实现动画效果。您可以设置持续时间、延迟、重复次数、缓动效果等属性。例如,以下代码设置了一个动画对象的持续时间为1秒,使用缓动效果: ```java import com.vaadin.spring.annotation.SpringComponent; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.Assert; import org.vaadin.spring.annotation.VaadinSessionScope; import o normalCheckBtn.animate().duration(Duration.ofSeconds(1)).easing(Easing.EXPO_OUT);- 启动动画:使用start()方法启动动画。例如,您可以使用以下代码启动动画对象:
normalCheckBtn.animate().start();- 监听动画事件:您可以添加监听器来监听动画的事件,如开始、结束等。例如,以下代码将一个监听器添加到动画对象上,并在动画结束时显示一个提示框:
normalCheckBtn.animate().addListener(new AnimationAdapter() { @Override public void animationEnd(AnimationEvent event) { Notification.show("动画结束", Type.TRAY_NOTIFICATION); } });以上是Spring动画引擎的基本使用方法。您可以根据自己的需求,使用不同的动画对象和属性来创建出各种动画效果。希望对您有所帮助!
1年前 -