From 80b6cbfc9c861469146318d0b3dd5f8b8b525b8a Mon Sep 17 00:00:00 2001 From: xiejun <xiejun@vci-tech.com> Date: 星期五, 01 十一月 2024 15:11:19 +0800 Subject: [PATCH] Revert "集成获取mdm分发通用数据格式接口集成" --- Source/BladeX-Tool/blade-core-tool/src/main/java/org/springblade/core/tool/support/ImagePosition.java | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 150 insertions(+), 0 deletions(-) diff --git a/Source/BladeX-Tool/blade-core-tool/src/main/java/org/springblade/core/tool/support/ImagePosition.java b/Source/BladeX-Tool/blade-core-tool/src/main/java/org/springblade/core/tool/support/ImagePosition.java new file mode 100644 index 0000000..f96211e --- /dev/null +++ b/Source/BladeX-Tool/blade-core-tool/src/main/java/org/springblade/core/tool/support/ImagePosition.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package org.springblade.core.tool.support; + +/** + * 鍥剧墖鎿嶄綔绫� + * + * @author Chill + */ +public class ImagePosition { + + /** + * 鍥剧墖椤堕儴. + */ + public static final int TOP = 32; + + /** + * 鍥剧墖涓儴. + */ + public static final int MIDDLE = 16; + + /** + * 鍥剧墖搴曢儴. + */ + public static final int BOTTOM = 8; + + /** + * 鍥剧墖宸︿晶. + */ + public static final int LEFT = 4; + + /** + * 鍥剧墖灞呬腑. + */ + public static final int CENTER = 2; + + /** + * 鍥剧墖鍙充晶. + */ + public static final int RIGHT = 1; + + /** + * 妯悜杈硅窛锛岄潬宸︽垨闈犲彸鏃跺拰杈圭晫鐨勮窛绂�. + */ + private static final int PADDING_HORI = 6; + + /** + * 绾靛悜杈硅窛锛岄潬涓婃垨闈犲簳鏃跺拰杈圭晫鐨勮窛绂�. + */ + private static final int PADDING_VERT = 6; + + + /** + * 鍥剧墖涓洅[宸︿笂瑙抅鐨剎鍧愭爣. + */ + private int boxPosX; + + /** + * 鍥剧墖涓洅[宸︿笂瑙抅鐨剏鍧愭爣. + */ + private int boxPosY; + + /** + * Instantiates a new image position. + * + * @param width the width + * @param height the height + * @param boxWidth the box width + * @param boxHeight the box height + * @param style the style + */ + public ImagePosition(int width, int height, int boxWidth, int boxHeight, int style) { + switch (style & 7) { + case LEFT: + boxPosX = PADDING_HORI; + break; + case RIGHT: + boxPosX = width - boxWidth - PADDING_HORI; + break; + case CENTER: + default: + boxPosX = (width - boxWidth) / 2; + } + switch (style >> 3 << 3) { + case TOP: + boxPosY = PADDING_VERT; + break; + case MIDDLE: + boxPosY = (height - boxHeight) / 2; + break; + case BOTTOM: + default: + boxPosY = height - boxHeight - PADDING_VERT; + } + } + + + /** + * Gets the x. + * + * @return the x + */ + public int getX() { + return getX(0); + } + + /** + * Gets the x. + * + * @param x 妯悜鍋忕Щ + * @return the x + */ + public int getX(int x) { + return this.boxPosX + x; + } + + /** + * Gets the y. + * + * @return the y + */ + public int getY() { + return getY(0); + } + + /** + * Gets the y. + * + * @param y 绾靛悜鍋忕Щ + * @return the y + */ + public int getY(int y) { + return this.boxPosY + y; + } + +} -- Gitblit v1.9.3