From c442cba2a1cbd307b4de30932df917ee6c92b83f Mon Sep 17 00:00:00 2001 From: "yonghwan82.jeon" Date: Thu, 24 Apr 2014 18:00:21 +0900 Subject: [PATCH] NSCREEN: Add new Model. Add new Model. Change-Id: Ib56aaf04b76fd99231021ca3a683199b741677e6 Signed-off-by: yonghwan82.jeon --- .../ui/views/nscreen2/NScreenModel.java | 216 +++++++++++++++++++++ 1 file changed, 216 insertions(+) create mode 100644 org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen2/NScreenModel.java diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen2/NScreenModel.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen2/NScreenModel.java new file mode 100644 index 0000000..e7f7410 --- /dev/null +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen2/NScreenModel.java @@ -0,0 +1,216 @@ +/* + * UI Builder + * + * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + + +package org.tizen.webuibuilder.ui.views.nscreen2; + +public class NScreenModel { + + public enum Orientation { + LANDSCAPE, PORTRAIT + } + + public enum Scan { + PROGRESSIVE, INTERLACE + } + + private String title; + + private int width; + private int height; + private int color; + private int colorIndex; + private int deviceHeight; + private int deviceWidth; + private Orientation orientation; + private int monochrome; + private String resolution; + private Scan scan; + private int grid; + + private String fileName; + + NScreenModel link; + + public NScreenModel(String title, int width, int height, String fileName) { + this.title = title; + this.width = width; + this.height = height; + this.fileName = fileName; + } + + public NScreenModel() { + this("Basic", 0, 0, ""); + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public int getWidth() { + return width; + } + + public void setWidth(int width) { + this.width = width; + } + + public int getHeight() { + return height; + } + + public void setHeight(int height) { + this.height = height; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public int getColor() { + return color; + } + + public void setColor(int color) { + this.color = color; + } + + public int getColorIndex() { + return colorIndex; + } + + public void setColorIndex(int colorIndex) { + this.colorIndex = colorIndex; + } + + public int getDeviceHeight() { + return deviceHeight; + } + + public void setDeviceHeight(int deviceHeight) { + this.deviceHeight = deviceHeight; + } + + public int getDeviceWidth() { + return deviceWidth; + } + + public void setDeviceWidth(int deviceWidth) { + this.deviceWidth = deviceWidth; + } + + public Orientation getOrientation() { + return orientation; + } + + public void setOrientation(Orientation orientation) { + this.orientation = orientation; + } + + public int getMonochrome() { + return monochrome; + } + + public void setMonochrome(int monochrome) { + this.monochrome = monochrome; + } + + public String getResolution() { + return resolution; + } + + public void setResolution(String resolution) { + this.resolution = resolution; + } + + public Scan getScan() { + return scan; + } + + public void setScan(Scan scan) { + this.scan = scan; + } + + public int getGrid() { + return grid; + } + + public void setGrid(int grid) { + this.grid = grid; + } + + public String getOriginFileName() { + return fileName; + } + + public String getAspectRatio() { + return reduceRatio(width, height); + } + + public String getDeviceAspectRatio() { + return reduceRatio(deviceWidth, deviceHeight); + } + + public String reduceRatio(int numerator, int denominator) { + int temp = 0; + + if (numerator == denominator) + return "1:1"; + + if (+numerator < +denominator) { + temp = numerator; + numerator = denominator; + denominator = temp; + } + + int divisor = gcd(+numerator, +denominator); + + return (numerator / divisor) + "/" + (denominator / divisor); + } + + private static int gcd(int a, int b) { + if (b == 0) + return a; + + return gcd(b, a % b); + } + + public void linkTo(NScreenModel nScreenModel) { + link = nScreenModel; + } + + public boolean isLink() { + if (link == null) + return false; + else + return true; + + } +} -- 2.7.4