Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use anchor to realize clip window in J2ME

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you the "J2ME clip window can use anchor how to achieve", the content is easy to understand, clear, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn "J2ME clip window can use anchor how to achieve" this article.

/ * drawClip draw part of a picture. The clip window can use anchor. * * @ param g * Graphics * @ param x * int position x * @ param y * int position to be drawn y * @ param image * Image picture * @ param clipX * int clip coordinates in the picture x * @ param clipY * int clip coordinates in the picture y * @ param clipWidth * width of int clip in picture * @ param clipHeight * height of int clip in picture * @ param anchor * int link anchor * / public static void drawClip (Graphics g Int x, int y, Image image, int clipX, int clipY, int clipWidth, int clipHeight, int anchor) {int [] old = {g.getClipX (), g.getClipY (), g.getClipWidth (), g.getClipHeight ()} / / Store the original initial Clip size and coordinates int offsetX = 0, offsetY = 0 Switch (anchor) {/ / the processing of various anchor is the relative offset of Graphics.TOP | Graphics.LEFT / / take the relative offset of Graphics.LEFT relative to Graphics.TOP | Graphics.LEFT, and finally / / draw the figure case Graphics.HCENTER with Graphics.TOP | Graphics.LEFT anchor | Graphics.TOP: offsetX = clipWidth / 2; break Case Graphics.RIGHT | Graphics.TOP: offsetX= clipWidth; break; case Graphics.LEFT | Graphics.VCENTER: offsetY = clipHeight / 2; break; case Graphics.HCENTER | Graphics.VCENTER: offsetX= clipWidth / 2; offsetY = clipHeight / 2; break; case Graphics.RIGHT | Graphics.VCENTER: offsetX= clipWidth; offsetY = clipHeight / 2 Break; case Graphics.LEFT | Graphics.BOTTOM: offsetY = clipHeight; break; case Graphics.HCENTER | Graphics.BOTTOM: offsetX = clipWidth / 2; offsetY = clipHeight; break; case Graphics.RIGHT | Graphics.BOTTOM: offsetX = clipWidth; offsetY = clipHeight; break } g.setClip (x-offsetX, y-offsetY, clipWidth, clipHeight); g.drawImage (image, x-clipX-offsetX, y-clipY-offsetY, Graphics.TOP | Graphics.LEFT); g.setClip (old [0], old [1], old [2], old [3]) / / restore CLIP size position after painting} the above is all the contents of the article "how can clip windows in J2ME be implemented using anchor?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report