1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "bridge/declarative_frontend/jsview/models/line_model_impl.h" 17 #include "bridge/declarative_frontend/view_stack_processor.h" 18 19 namespace OHOS::Ace::Framework { 20 Create()21void LineModelImpl::Create() 22 { 23 RefPtr<ShapeComponent> lineComponent = AceType::MakeRefPtr<OHOS::Ace::ShapeComponent>(ShapeType::LINE); 24 ViewStackProcessor::GetInstance()->ClaimElementId(lineComponent); 25 lineComponent->SetStroke(Color::BLACK); 26 ViewStackProcessor::GetInstance()->Push(lineComponent); 27 } 28 StartPoint(const ShapePoint & value)29void LineModelImpl::StartPoint(const ShapePoint &value) 30 { 31 auto line = AceType::DynamicCast<ShapeComponent>(ViewStackProcessor::GetInstance()->GetMainComponent()); 32 if (!line) { 33 LOGE("startPointComponent is null."); 34 return; 35 } 36 line->SetStart(value); 37 } 38 EndPoint(const ShapePoint & value)39void LineModelImpl::EndPoint(const ShapePoint &value) 40 { 41 auto line = AceType::DynamicCast<ShapeComponent>(ViewStackProcessor::GetInstance()->GetMainComponent()); 42 if (!line) { 43 LOGE("startPointComponent is null."); 44 return; 45 } 46 line->SetEnd(value); 47 } 48 49 } // namespace OHOS::Ace::Framework