📄 gauge.java
字号:
/* * Fire (Flexible Interface Rendering Engine) is a set of graphics widgets for creating GUIs for j2me applications. * Copyright (C) 2006-2008 Bluevibe (www.bluevibe.net) * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * *//** * */package gr.fire.ui;import gr.fire.core.Animation;import gr.fire.core.Component;import gr.fire.core.FireScreen;import javax.microedition.lcdui.Font;import javax.microedition.lcdui.Graphics;/** * @author padeler * */public class Gauge extends Animation{ public static final long MILISECONDS_PER_FRAME=500; private static final int MAX_DOTS=4; private Component owner; private int dots=0; private String str; private boolean running=true; private Font font; private int color; private long lastFrame; public Gauge(String message,int x,int y) { Component c = new Component(); font = FireScreen.getTheme().softKeyFont; c.setX(x); c.setY(y); c.setWidth(font.stringWidth(message)); c.setHeight(font.getHeight()); setup(c,null,message); } public void paint(Graphics g) { g.setFont(font); g.setColor(color); String s = str.substring(0,str.length()-(MAX_DOTS-1-dots)); g.drawString(s,0,0,Graphics.TOP|Graphics.LEFT); } public void showGauge() { FireScreen screen = FireScreen.getScreen(); screen.addComponent(owner); screen.registerAnimation(this); } public void hideGauge() { FireScreen screen = FireScreen.getScreen(); screen.removeComponent(owner); } public Component getOwner() { return owner; } public Object getProperties() { return str; } public Component getTrigger() { return null; } public boolean isRunning() { return running; } public void setup(Component owner, Component trigger, Object properties) { if(!(properties instanceof String)) throw new IllegalArgumentException("Parameter is not a String"); this.owner= owner; this.font = FireScreen.getTheme().softKeyFont; this.color = FireScreen.getTheme().softKeyFgColor; this.str = (String)properties; } public boolean step() { long now = System.currentTimeMillis(); if(now-lastFrame>=MILISECONDS_PER_FRAME) { lastFrame = now; dots++; dots = dots%MAX_DOTS; return running; } return false; } public void stop() { running=false; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -