Flex3.权威指南.第二讲源代码

1.EComm.mxml

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
  creationComplete="prodHandler(groceryInventory)"    >
    <mx:Model id="groceryInventory" source="assets/inventory.xml"/>
   
    <mx:Script>
        <![CDATA[
            import mx.messaging.Producer;
           
            import valueObjects.ShoppingCart;
            import valueObjects.ShoppingCartItem;
            import valueObjects.Product;
           
            [Bindable]
            private var theProduct:Product;
           
            [Bindable]
            public var cart:ShoppingCart=new ShoppingCart();
           
           
           
            private function prodHandler(theItem:Object):void{
                 theProduct=Product.buildProduct(theItem);
                 trace(theProduct);
            }
           
            private function addToCart(product:Product):void{
                var sci:ShoppingCartItem=new ShoppingCartItem(product);
                cart.addItem(sci);
            }
        ]]>
    </mx:Script>
      
    <mx:states>
        <mx:State name="cartView">
            <mx:SetProperty target="{products}" name="width" value="0"/>
            <mx:SetProperty target="{products}" name="height" value="0"/>
            <mx:SetProperty target="{cartBox}" name="width" value="100%"/>
            <mx:AddChild relativeTo="{cartBox}" position="lastChild">
                <mx:DataGrid id="dgCart" width="100%">
                    <mx:columns>
                        <mx:DataGridColumn headerText="Column 1" dataField="col1"/>
                        <mx:DataGridColumn headerText="Column 2" dataField="col2"/>
                        <mx:DataGridColumn headerText="Column 3" dataField="col3"/>
                    </mx:columns>
                </mx:DataGrid>
            </mx:AddChild>
            <mx:AddChild relativeTo="{cartBox}" position="lastChild">
                <mx:LinkButton label="Continue Shopping" click="this.currentState=''"/>
            </mx:AddChild>
            <mx:RemoveChild target="{linkbutton1}"/>
        </mx:State>
        <mx:State name="expanded">
              <mx:AddChild>
                  <mx:VBox x="200" width="100%">
                      <mx:Text text="{groceryInventory.description}" width="50%"/>
                      <mx:Label text="Certified Organic" visible="{theProduct.isOrganic}"/>
                      <mx:Label text="Low Fat" visible="{theProduct.isLowFat}"/>
                     
                  </mx:VBox>
              </mx:AddChild>
        </mx:State>
    </mx:states>
    <mx:ApplicationControlBar dock="true" width="100%" height="90">
        <mx:Canvas width="100%" height="100%">
            <mx:Label x="0" y="0" text="Flex"/>
            <mx:Label x="0" y="41" text="GROCER"/>
            <mx:Button label="View Cart" id="btnViewCart" right="90" y="0"/>
            <mx:Button label="Checkout" id="btnCheckout" right="10" y="0"/>
        </mx:Canvas>
    </mx:ApplicationControlBar>
    <mx:Label text="(c) 2006, FlexGrocer" bottom="10" right="10"/>
    <mx:HBox x="0" y="0" width="100%" height="100%" id="bodyBox">
        <mx:VBox width="100%" height="100%" id="products">
            <mx:Label text="Milk" id="prodName"/>
            <mx:Image source="@Embed('assets/dairy_milk.jpg')" scaleContent="true"
             mouseOver="this.currentState='expanded'"
             mouseOut="this.currentState=''"    />
            <mx:Label text="$1.99" id="price"/>
            <mx:Button label="Add To Cart" id="add"
             click="addToCart(theProduct)"    />
        </mx:VBox>
        <mx:VBox height="100%" id="cartBox">
            <mx:Label text="Your Cart Total: $"/>
            <mx:LinkButton label="View Cart" click="this.currentState='cartView'" id="linkbutton1"/>
        </mx:VBox>
    </mx:HBox>
   
</mx:Application>

 

2.DataEntry.mxml

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute">
    <mx:Model id="prodModel">
        <groceries>
            <catName>Dairy</catName>
            <prodName>Milk</prodName>
            <imageName>assets/dairy_milk.jpg</imageName>
            <cost>1.20</cost>
            <listPrice>1.99</listPrice>
            <isOrganic>true</isOrganic>
            <isLowFat>true</isLowFat>
            <description>Direct from California where cows are happiest!</description>
        </groceries>
    </mx:Model>
   
    <mx:Script>
        <![CDATA[
            import flash.net.FileReferenceList;
           
            public function fileBrowse():void{
                   var myFileRef:FileReferenceList=new FileReferenceList();
                   myFileRef.browse();
            }
        ]]>
    </mx:Script>
   
    <mx:Form>
        <mx:FormHeading label="{prodModel.catName}"/>
        <mx:FormItem label="Product Name">
            <mx:TextInput id="product" text="{prodModel.prodName}"/>
        </mx:FormItem>
        <mx:FormItem label="ProductNameUnit" direction="horizontal">
             <mx:ComboBox/>
             <mx:TextInput/>
        </mx:FormItem>
        <mx:FormItem label="Cost">
            <mx:TextInput id="cost" text="{prodModel.cost}"/>
        </mx:FormItem>
            <mx:FormItem label="List Price">
            <mx:TextInput id="listPrice" text="{prodModel.listPrice}"/>
        </mx:FormItem>
            <mx:FormItem label="Description">
            <mx:TextInput id="description" text="{prodModel.description}"/>
        </mx:FormItem>
       
        <mx:FormItem label="Organic">
            <mx:CheckBox id="isOrganic" selected="{prodModel.isOrganic}"/>
        </mx:FormItem>
        <mx:FormItem label="Is Low Fat">
            <mx:CheckBox id="isLowFat" selected="{prodModel.isLowFat}"/>
        </mx:FormItem>
        <mx:FormItem label="Image Path">
            <mx:TextInput id="imageName" text="{prodModel.imageName}"/>
            <mx:Button label="Browse" click="fileBrowse()"/>
        </mx:FormItem>
        <mx:FormItem>
             <mx:HBox>
                 <mx:Button label="Update"/>
                 <mx:Button label="Delete"/>
             </mx:HBox>
        </mx:FormItem>
       
    </mx:Form>
</mx:Application>

 

3.Dashboard.mxml

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
    <mx:ApplicationControlBar dock="true">
        <mx:LinkButton label="All"
            click="this.currentState=''"/>
        <mx:LinkButton label="Sales"
            click="this.currentState='fullSales'"/>
        <mx:LinkButton label="Categories"
            click="this.currentState='fullType'"/>
        <mx:LinkButton label="Comparison"
            click="this.currentState='fullComp'"/>
        <mx:Spacer width="100%"/>
        <mx:Label text="Start Date"/>
        <mx:DateField id="startDate"/>
        <mx:Label text="End Date"/>
        <mx:DateField id="endDate"/>
        <mx:RadioButtonGroup id="grossOrNetGroup"/>
        <mx:RadioButton id="gross" groupName="grossOrNetGroup"
            label="Gross Sales" data="GROSS" selected="true"/>
        <mx:RadioButton id="net" groupName="grossOrNetGroup"
            label="Net Sales" data="NET"/>   
    </mx:ApplicationControlBar>

    <mx:states>
        <mx:State name="fullSales">
            <mx:SetProperty target="{rightCharts}"
                name="width" value="0"/>
            <mx:SetProperty target="{rightCharts}"
                name="height" value="0"/>
        </mx:State>

        <mx:State name="fullType">
            <mx:SetProperty target="{sales}"
                name="width"
                value="0"/>
            <mx:SetProperty target="{sales}"
                name="height"
                value="0"/>
            <mx:SetProperty target="{comp}"
                name="width"
                value="0"/>
            <mx:SetProperty target="{comp}"
                name="height"
                value="0"/>
        </mx:State>
        <mx:State name="fullComp">
            <mx:SetProperty target="{sales}"
                name="width"
                value="0"/>
            <mx:SetProperty target="{sales}"
                name="height"
                value="0"/>
            <mx:SetProperty target="{type}"
                name="width"
                value="0"/>
            <mx:SetProperty target="{type}"
                name="height"
                value="0"/>
        </mx:State>
    </mx:states>

    <mx:Panel id="sales"
        width="100%" height="100%"
        title="Sales Chart">
        <mx:ControlBar>
        </mx:ControlBar>
    </mx:Panel>
    <mx:VBox id="rightCharts"
        width="100%" height="100%" >
        <mx:Panel id="type"
            width="100%" height="100%"
            title="Category Chart">
            <mx:ControlBar>
            </mx:ControlBar>
        </mx:Panel>
        <mx:Panel id="comp"
            width="100%" height="100%"
            title="Comparison Chart">
            <mx:ControlBar>
            </mx:ControlBar>
        </mx:Panel>
    </mx:VBox>
</mx:Application>

【顶级EI完整复现】【DRCC】考虑N-1准则的分布鲁棒机会约束低碳经济调度(Matlab代码实现)内容概要:本文介绍了名为《【顶级EI完整复现】【DRCC】考虑N-1准则的分布鲁棒机会约束低碳经济调度(Matlab代码实现)》的技术资源,聚焦于电力系统中低碳经济调度问题,结合N-1安全准则与分布鲁棒机会约束(DRCC)方法,提升调度模型在不确定性环境下的鲁棒性和可行性。该资源提供了完整的Matlab代码实现,涵盖建模、优化求解及仿真分析全过程,适用于复杂电力系统调度场景的科研复现与算法验证。文中还列举了大量相关领域的研究主题与代码资源,涉及智能优化算法、机器学习、电力系统管理、路径规划等多个方向,展示了广泛的科研应用支持能力。; 适合人群:具备一定电力系统、优化理论和Matlab编程基础的研究生、科研人员及从事能源调度、智能电网相关工作的工程师。; 使用场景及目标:①复现高水平期刊(如EI/SCI)关于低碳经济调度的研究成果;②深入理解N-1安全约束与分布鲁棒优化在电力调度中的建模方法;③开展含新能源接入的电力系统不确定性优化研究;④为科研项目、论文撰写或工程应用提供可运行的算法原型和技术支撑。; 阅读建议:建议读者结合文档提供的网盘资源,下载完整代码与案例数据,按照目录顺序逐步学习,并重点理解DRCC建模思想与Matlab/YALMIP/CPLEX等工具的集成使用方式,同时可参考文中列出的同类研究方向拓展研究思路。
内容概要:本文详细介绍了一个基于MATLAB实现的电力负荷预测项目,采用K近邻回归(KNN)算法进行建模。项目从背景意义出发,阐述了电力负荷预测在提升系统效率、优化能源配置、支撑智能电网和智慧城市建设等方面的重要作用。针对负荷预测中影响因素多样、时序性强、数据质量差等挑战,提出了包括特征工程、滑动窗口构造、数据清洗与标准化、K值与距离度量优化在内的系统性解决方案。模型架构涵盖数据采集、预处理、KNN回归原理、参数调优、性能评估及工程部署全流程,并支持多算法集成与可视化反馈。文中还提供了MATLAB环境下完整的代码实现流程,包括数据加载、归一化、样本划分、K值选择、模型训练预测、误差分析与结果可视化等关键步骤,增强了模型的可解释性与实用性。; 适合人群:具备一定MATLAB编程基础和机器学习基础知识,从事电力系统分析、能源管理、智能电网或相关领域研究的研发人员、工程师及高校师生;适合工作1-3年希望提升实际项目开发能力的技术人员; 使用场景及目标:①应用于短期电力负荷预测,辅助电网调度与发电计划制定;②作为教学案例帮助理解KNN回归在实际工程中的应用;③为新能源接入、需求响应、智慧能源系统提供数据支持;④搭建可解释性强、易于部署的轻量级预测模型原型; 阅读建议:建议结合MATLAB代码实践操作,重点关注特征构造、参数调优与结果可视化部分,深入理解KNN在时序数据中的适应性改进方法,并可进一步拓展至集成学习或多模型融合方向进行研究与优化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值