*remove unuse code
*fixed license header *minor presentation touch up
This commit is contained in:
parent
698ac42bc2
commit
0434ec9644
|
@ -1,3 +1,16 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Copyright (C) 2008 Low Heng Sin *
|
||||||
|
* Copyright (C) 2008 Idalica Corporation *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. This program 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 General Public License for more details. *
|
||||||
|
* You should have received a copy of the GNU General Public License along *
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
*****************************************************************************/
|
||||||
package org.adempiere.webui.apps.graph;
|
package org.adempiere.webui.apps.graph;
|
||||||
|
|
||||||
import java.awt.BasicStroke;
|
import java.awt.BasicStroke;
|
||||||
|
@ -32,14 +45,13 @@ import org.zkoss.zul.Menupopup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performance Indicator
|
* Performance Indicator
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author hengsin
|
||||||
* @version $Id: PerformanceIndicator.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
|
||||||
*/
|
*/
|
||||||
public class WPerformanceIndicator extends Panel implements EventListener
|
public class WPerformanceIndicator extends Panel implements EventListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 3580494126343850939L;
|
private static final long serialVersionUID = 3580494126343850939L;
|
||||||
|
|
||||||
|
@ -50,43 +62,29 @@ public class WPerformanceIndicator extends Panel implements EventListener
|
||||||
public WPerformanceIndicator(MGoal goal)
|
public WPerformanceIndicator(MGoal goal)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
m_goal = goal;
|
m_goal = goal;
|
||||||
// setName(m_goal.getName());
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
mRefresh.addEventListener(Events.ON_CLICK, this);
|
mRefresh.addEventListener(Events.ON_CLICK, this);
|
||||||
popupMenu.appendChild(mRefresh);
|
popupMenu.appendChild(mRefresh);
|
||||||
|
|
||||||
addEventListener(Events.ON_DOUBLE_CLICK, this);
|
addEventListener(Events.ON_DOUBLE_CLICK, this);
|
||||||
addEventListener(Events.ON_CLICK, this);
|
addEventListener(Events.ON_CLICK, this);
|
||||||
} // PerformanceIndicator
|
} // PerformanceIndicator
|
||||||
|
|
||||||
private MGoal m_goal = null;
|
private MGoal m_goal = null;
|
||||||
/** The Performance Name */
|
/** The Performance Name */
|
||||||
private String m_text = null;
|
private String m_text = null;
|
||||||
/** Performance Line */
|
/** Performance Line */
|
||||||
// private double m_line = 0;
|
|
||||||
|
|
||||||
/** Height */
|
|
||||||
// private static double s_height = 45;
|
|
||||||
/** 100% width */
|
|
||||||
// private static double s_width100 = 150;
|
|
||||||
/** Max width */
|
|
||||||
// private static double s_widthMax = 250;
|
|
||||||
/** Integer Number Format */
|
/** Integer Number Format */
|
||||||
private static DecimalFormat s_format = DisplayType.getNumberFormat(DisplayType.Integer);
|
private static DecimalFormat s_format = DisplayType.getNumberFormat(DisplayType.Integer);
|
||||||
|
|
||||||
Menupopup popupMenu = new Menupopup();
|
Menupopup popupMenu = new Menupopup();
|
||||||
private Menuitem mRefresh = new Menuitem(Msg.getMsg(Env.getCtx(), "Refresh"), "/images/Refresh16.png");
|
private Menuitem mRefresh = new Menuitem(Msg.getMsg(Env.getCtx(), "Refresh"), "/images/Refresh16.png");
|
||||||
|
|
||||||
//Insert Pie Graph Kinamo (pelgrim)
|
|
||||||
// private static Color colorOK = Color.magenta;
|
|
||||||
// private static Color colorNotOK = Color.lightGray;
|
|
||||||
// private static Dimension indicatordimension = new Dimension(170,120);
|
|
||||||
// private static Dimension paneldimension = new Dimension(180, 150);
|
|
||||||
ChartPanel chartPanel;
|
ChartPanel chartPanel;
|
||||||
//private static Dimension
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Goal
|
* Get Goal
|
||||||
|
@ -96,18 +94,18 @@ public class WPerformanceIndicator extends Panel implements EventListener
|
||||||
{
|
{
|
||||||
return m_goal;
|
return m_goal;
|
||||||
} // getGoal
|
} // getGoal
|
||||||
|
|
||||||
private JFreeChart createChart()
|
private JFreeChart createChart()
|
||||||
{
|
{
|
||||||
JFreeChart chart = null;
|
JFreeChart chart = null;
|
||||||
|
|
||||||
// Set Text
|
// Set Text
|
||||||
StringBuffer text = new StringBuffer(m_goal.getName());
|
StringBuffer text = new StringBuffer(m_goal.getName());
|
||||||
if (m_goal.isTarget())
|
if (m_goal.isTarget())
|
||||||
text.append(": ").append(m_goal.getPercent()).append("%");
|
text.append(": ").append(m_goal.getPercent()).append("%");
|
||||||
else
|
else
|
||||||
text.append(": ").append(s_format.format(m_goal.getMeasureActual()));
|
text.append(": ").append(s_format.format(m_goal.getMeasureActual()));
|
||||||
|
|
||||||
m_text = text.toString();
|
m_text = text.toString();
|
||||||
|
|
||||||
// ToolTip
|
// ToolTip
|
||||||
|
@ -120,21 +118,10 @@ public class WPerformanceIndicator extends Panel implements EventListener
|
||||||
.append(s_format.format(m_goal.getMeasureTarget()));
|
.append(s_format.format(m_goal.getMeasureTarget()));
|
||||||
setTooltiptext(text.toString());
|
setTooltiptext(text.toString());
|
||||||
//
|
//
|
||||||
//setBackground(m_goal.getColor());
|
|
||||||
// setForeground(GraphUtil.getForeground(getBackground()));
|
|
||||||
// Performance Line
|
|
||||||
// int percent = m_goal.getPercent();
|
|
||||||
// if (percent > 100) // draw 100% line
|
|
||||||
// m_line = s_width100;
|
|
||||||
// else // draw Performance Line
|
|
||||||
// m_line = s_width100 * m_goal.getGoalPerformanceDouble();
|
|
||||||
|
|
||||||
|
|
||||||
// String title = m_text;
|
|
||||||
DefaultValueDataset data = new DefaultValueDataset((float)m_goal.getPercent());
|
DefaultValueDataset data = new DefaultValueDataset((float)m_goal.getPercent());
|
||||||
MeterPlot plot = new MeterPlot(data);
|
MeterPlot plot = new MeterPlot(data);
|
||||||
|
|
||||||
MColorSchema colorSchema = m_goal.getColorSchema();
|
MColorSchema colorSchema = m_goal.getColorSchema();
|
||||||
int rangeLo = 0; int rangeHi=0;
|
int rangeLo = 0; int rangeHi=0;
|
||||||
for (int i=1; i<=4; i++){
|
for (int i=1; i<=4; i++){
|
||||||
switch (i) {
|
switch (i) {
|
||||||
|
@ -150,50 +137,50 @@ public class WPerformanceIndicator extends Panel implements EventListener
|
||||||
new Range(rangeLo, rangeHi), //range
|
new Range(rangeLo, rangeHi), //range
|
||||||
colorSchema.getColor(rangeHi),
|
colorSchema.getColor(rangeHi),
|
||||||
new BasicStroke(7.0f),
|
new BasicStroke(7.0f),
|
||||||
//Color.lightGray
|
|
||||||
new Color(-13091716)
|
new Color(-13091716)
|
||||||
//Color.gray
|
|
||||||
));
|
));
|
||||||
rangeLo = rangeHi;
|
rangeLo = rangeHi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plot.setRange(new Range(0,rangeLo));
|
plot.setRange(new Range(0,rangeLo));
|
||||||
|
|
||||||
plot.setDialBackgroundPaint(new Color(-13091716));//Color.GRAY);
|
|
||||||
plot.setUnits(m_goal.getName());
|
|
||||||
plot.setDialShape(DialShape.CHORD);//CIRCLE);
|
|
||||||
//plot.setDialBackgroundPaint(new GradientPaint(0, 0, m_goal.getColor(), 0, 1000, Color.black));
|
|
||||||
plot.setNeedlePaint(Color.white);
|
|
||||||
plot.setTickSize(2000);
|
|
||||||
plot.setTickLabelFont(new Font("SansSerif", Font.BOLD, 11));
|
|
||||||
plot.setValueFont(new Font("SansSerif", Font.BOLD, 11));
|
|
||||||
plot.setNoDataMessageFont(new Font("SansSerif", Font.BOLD, 11));
|
|
||||||
plot.setTickLabelPaint(Color.white);
|
|
||||||
plot.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
|
|
||||||
|
|
||||||
chart = new JFreeChart( m_text, new Font("SansSerif", Font.BOLD, 11), plot,false);
|
plot.setDialBackgroundPaint(new Color(-13091716));
|
||||||
|
plot.setUnits("");
|
||||||
|
plot.setDialShape(DialShape.CHORD);//CIRCLE);
|
||||||
|
plot.setNeedlePaint(Color.white);
|
||||||
|
plot.setTickSize(2000);
|
||||||
|
plot.setTickLabelFont(new Font("SansSerif", Font.BOLD, 8));
|
||||||
|
plot.setValueFont(new Font("SansSerif", Font.BOLD, 8));
|
||||||
|
plot.setNoDataMessageFont(new Font("SansSerif", Font.BOLD, 8));
|
||||||
|
plot.setTickLabelPaint(Color.white);
|
||||||
|
plot.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
|
||||||
|
|
||||||
|
chart = new JFreeChart( m_text, new Font("SansSerif", Font.BOLD, 9), plot,false);
|
||||||
|
|
||||||
return chart;
|
return chart;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init Graph Display
|
* Init Graph Display
|
||||||
* Kinamo (pelgrim)
|
* Kinamo (pelgrim)
|
||||||
*/
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
JFreeChart chart = createChart();
|
JFreeChart chart = createChart();
|
||||||
|
chart.setBackgroundPaint(Color.WHITE);
|
||||||
BufferedImage bi = chart.createBufferedImage(200, 120, BufferedImage.TRANSLUCENT , null);
|
chart.setBorderVisible(true);
|
||||||
|
chart.setBorderPaint(Color.LIGHT_GRAY);
|
||||||
|
chart.setAntiAlias(true);
|
||||||
|
BufferedImage bi = chart.createBufferedImage(200, 120, BufferedImage.TRANSLUCENT , null);
|
||||||
try {
|
try {
|
||||||
byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);
|
byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);
|
||||||
|
|
||||||
AImage image = new AImage("", bytes);
|
AImage image = new AImage("", bytes);
|
||||||
Image myImage = new Image();
|
Image myImage = new Image();
|
||||||
myImage.setContent(image);
|
myImage.setContent(image);
|
||||||
appendChild(myImage);
|
appendChild(myImage);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
}
|
}
|
||||||
|
@ -210,119 +197,8 @@ public class WPerformanceIndicator extends Panel implements EventListener
|
||||||
chartPanel.setChart(createChart());
|
chartPanel.setChart(createChart());
|
||||||
invalidate();
|
invalidate();
|
||||||
} // updateData
|
} // updateData
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
* Adds an <code>ActionListener</code> to the indicator.
|
|
||||||
* @param l the <code>ActionListener</code> to be added
|
|
||||||
*/
|
|
||||||
/* public void addActionListener(ActionListener l)
|
|
||||||
{
|
|
||||||
if (l != null)
|
|
||||||
listenerList.add(ActionListener.class, l);
|
|
||||||
} // addActionListener
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Removes an <code>ActionListener</code> from the indicator.
|
|
||||||
* @param l the listener to be removed
|
|
||||||
*/
|
|
||||||
/* public void removeActionListener(ActionListener l)
|
|
||||||
{
|
|
||||||
if (l != null)
|
|
||||||
listenerList.remove(ActionListener.class, l);
|
|
||||||
} // removeActionListener
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Returns an array of all the <code>ActionListener</code>s added
|
|
||||||
* to this indicator with addActionListener().
|
|
||||||
*
|
|
||||||
* @return all of the <code>ActionListener</code>s added or an empty
|
|
||||||
* array if no listeners have been added
|
|
||||||
*/
|
|
||||||
/* public ActionListener[] getActionListeners()
|
|
||||||
{
|
|
||||||
return (ActionListener[])(listenerList.getListeners(ActionListener.class));
|
|
||||||
} // getActionListeners
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Notifies all listeners that have registered interest for
|
|
||||||
* notification on this event type. The event instance
|
|
||||||
* is lazily created using the <code>event</code>
|
|
||||||
* parameter.
|
|
||||||
*
|
|
||||||
* @param event the <code>ActionEvent</code> object
|
|
||||||
* @see EventListenerList
|
|
||||||
*/
|
|
||||||
/* protected void fireActionPerformed(MouseEvent event)
|
|
||||||
{
|
|
||||||
// Guaranteed to return a non-null array
|
|
||||||
ActionListener[] listeners = getActionListeners();
|
|
||||||
ActionEvent e = null;
|
|
||||||
// Process the listeners first to last
|
|
||||||
for (int i = 0; i < listeners.length; i++)
|
|
||||||
{
|
|
||||||
// Lazily create the event:
|
|
||||||
if (e == null)
|
|
||||||
e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
|
|
||||||
"pi", event.getWhen(), event.getModifiers());
|
|
||||||
listeners[i].actionPerformed(e);
|
|
||||||
}
|
|
||||||
} // fireActionPerformed
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
* Mouse Clicked
|
|
||||||
* @param e mouse event
|
|
||||||
*/
|
|
||||||
/* public void mouseClicked (MouseEvent e)
|
|
||||||
{
|
|
||||||
if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() > 1)
|
|
||||||
fireActionPerformed(e);
|
|
||||||
if (SwingUtilities.isRightMouseButton(e))
|
|
||||||
popupMenu.show((Component)e.getSource(), e.getX(), e.getY());
|
|
||||||
} // mouseClicked
|
|
||||||
|
|
||||||
public void mousePressed (MouseEvent e)
|
public void onEvent(Event event) throws Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseReleased (MouseEvent e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void mouseEntered (MouseEvent e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void mouseExited (MouseEvent e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Action Listener.
|
|
||||||
* Update Display
|
|
||||||
* @param e event
|
|
||||||
*/
|
|
||||||
/* public void actionPerformed (ActionEvent e)
|
|
||||||
{
|
|
||||||
if (e.getSource() == mRefresh)
|
|
||||||
{
|
|
||||||
m_goal.updateGoal(true);
|
|
||||||
updateDisplay();
|
|
||||||
//
|
|
||||||
Container parent = getParent();
|
|
||||||
if (parent != null)
|
|
||||||
parent.invalidate();
|
|
||||||
invalidate();
|
|
||||||
if (parent != null)
|
|
||||||
parent.repaint();
|
|
||||||
else
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
} // actionPerformed
|
|
||||||
*/
|
|
||||||
public void onEvent(Event event) throws Exception
|
|
||||||
{
|
|
||||||
// Component comp = event.getTarget();
|
|
||||||
// String eventName = event.getName();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue