?? kpiattachment.java
字號(hào):
/* * This source code is part of TWaver 1.3.1 * * SERVA Software PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * Copyright 2000-2005 SERVA Software, Inc. All rights reserved. */package demo.network.customui;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import javax.swing.Icon;
import twaver.Element;
import twaver.TWaverConst;
import twaver.network.ui.ElementUI;
import twaver.network.ui.LayoutedIconAttachment;
public class KPIAttachment extends LayoutedIconAttachment {
public final static double WIDTH = 20;
public final static double HEIGHT = 25;
public final static String[] KYES = new String[]{"PM-01", "PM-02", "PM-03", "PM-04", "PM-05"};
public final static Color[] COLORS = new Color[]{Color.GREEN, Color.BLUE, Color.YELLOW, Color.RED, Color.CYAN};
public KPIAttachment(String name, ElementUI ui) {
super(name, ui, new Icon(){
public int getIconHeight() {
return (int)HEIGHT;
}
public int getIconWidth() {
return (int)WIDTH;
}
public void paintIcon(Component c, Graphics g, int x, int y) {
}
});
}
public void paint(Graphics2D g2d) {
final int count = KYES.length;
final Point location = this.getLocation();
final double width = WIDTH / count;
Element element = getElementUI().getElement();
for(int i=0; i<count; i++){
double proportion = 0;
String valueText = (String)element.getClientProperty(KYES[i]);
if(valueText != null){
proportion = Double.parseDouble(valueText.substring(KYES[i].length() + 1));
}
g2d.setColor(COLORS[i]);
double x = location.x + i * width;
double height = HEIGHT * proportion;
double y = location.y + HEIGHT - height;
g2d.fillRect((int)x, (int)y, (int)width, (int)height);
}
g2d.setColor(Color.GRAY);
g2d.setStroke(TWaverConst.BASIC_STROKE);
g2d.drawRect(location.x, location.y-1, (int)WIDTH, (int)HEIGHT);
}
};
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -