diff --git a/client/src/org/compiere/apps/graph/BarGraph.java b/client/src/org/compiere/apps/graph/BarGraph.java deleted file mode 100644 index 36defe9fcd..0000000000 --- a/client/src/org/compiere/apps/graph/BarGraph.java +++ /dev/null @@ -1,486 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * 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. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.graph; - -import java.awt.*; -import java.awt.event.*; -import java.awt.geom.*; -import java.util.*; -import java.util.logging.*; -import java.math.*; -import java.sql.*; - -import org.compiere.apps.*; -import org.compiere.model.*; -import org.compiere.swing.*; -import org.compiere.util.*; - -/** - * Bar Graph - * - * @author Jorg Janke - * @version $Id: BarGraph.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class BarGraph extends CPanel implements ActionListener -{ - /** - * Constructor - */ - public BarGraph() - { - super(); - setLayout(m_layout); - // Size - m_size = new Dimension (500,300); - setPreferredSize(m_size); - setMinimumSize(m_size); - setMaximumSize(m_size); - // 0/0 point - FontMetrics fm = getFontMetrics(getFont()); - int fontHeight = fm.getHeight(); - int yAxis_X = fontHeight+10; // | - int xAxis_Y = m_size.height-fontHeight-10; // - - m_point0_0 = new Point(yAxis_X, xAxis_Y); - } // BarGraph - - /** - * Constructor - * @param goal goal - */ - public BarGraph(MGoal goal) - { - this(); - m_goal = goal; - m_Y_AxisLabel = goal.getName(); - m_X_AxisLabel = goal.getXAxisText(); - loadData(); - /** test - add (new BarGraphColumn("Column 1", 100)); - add (new BarGraphColumn("Column 2", 200)); - add (new BarGraphColumn("Column 3", 300)); - add (new BarGraphColumn("Column 4", 400)); - add (new BarGraphColumn("Column 5", 500)); - add (new BarGraphColumn("Column 6", 400)); - add (new BarGraphColumn("Column 7", 300)); - add (new BarGraphColumn("Column 8", 200)); - add (new BarGraphColumn("Column 9", 100)); - add (new BarGraphColumn("Column 10", 200)); - add (new BarGraphColumn("Column 11", 300)); - add (new BarGraphColumn("Column 12", 400)); - add (new BarGraphColumn("Column 13", 500)); - add (new BarGraphColumn("Column 14", 100)); - **/ - } // BarGraph - - /** The Goal */ - private MGoal m_goal = null; - /** Graph Size */ - private Dimension m_size = null; - /** Zero/Zero Coordibate point */ - private Point m_point0_0 = null; - /** Layout */ - private BarGraphLayout m_layout = new BarGraphLayout(this); - - /** Logger */ - private static CLogger log = CLogger.getCLogger (BarGraph.class); - - /** X Axis Label */ - private String m_X_AxisLabel = "X Axis"; - /** Y Axis Label */ - private String m_Y_AxisLabel = "Y Axis"; - /** Y Axis Max */ - private double m_Y_Max = 0; - /** Y Axis Target Line */ - private double m_Y_Target = 0; - /** Y Axis Target Line Label */ - private String m_Y_TargetLabel = null; - - /** - * Load Performance Data - */ - private void loadData() - { - ArrayList list = new ArrayList(); - // Calculated - MMeasure measure = m_goal.getMeasure(); - if (measure == null) - { - log.warning("No Measure for " + m_goal); - return; - } - if (MMeasure.MEASURETYPE_Calculated.equals(measure.getMeasureType())) - { - MMeasureCalc mc = MMeasureCalc.get(Env.getCtx(), measure.getPA_MeasureCalc_ID()); - String sql = mc.getSqlBarChart(m_goal.getRestrictions(false), - m_goal.getMeasureDisplay(), null, - MRole.getDefault()); // logged in role - PreparedStatement pstmt = null; - try - { - pstmt = DB.prepareStatement (sql, null); - ResultSet rs = pstmt.executeQuery (); - while (rs.next ()) - { - BigDecimal data = rs.getBigDecimal(1); - Timestamp date = rs.getTimestamp(2); - BarGraphColumn bgc = new BarGraphColumn(mc, data); - bgc.setLabel(date, m_goal.getMeasureDisplay()); - list.add(bgc); - } - rs.close (); - pstmt.close (); - pstmt = null; - } - catch (Exception e) - { - log.log (Level.SEVERE, sql, e); - } - try - { - if (pstmt != null) - pstmt.close (); - pstmt = null; - } - catch (Exception e) - { - pstmt = null; - } - } - else if (MMeasure.MEASURETYPE_Achievements.equals(measure.getMeasureType())) - { - if (MMeasure.MEASUREDATATYPE_StatusQtyAmount.equals(measure.getMeasureDataType())) - { - MAchievement[] achievements = MAchievement.get(measure); - for (int i = 0; i < achievements.length; i++) - { - MAchievement achievement = achievements[i]; - BarGraphColumn bgc = new BarGraphColumn(achievement); - list.add(bgc); - } - } - else // MMeasure.MEASUREDATATYPE_QtyAmountInTime - { - String MeasureDisplay = m_goal.getMeasureDisplay(); - String trunc = "D"; - if (MGoal.MEASUREDISPLAY_Year.equals(MeasureDisplay)) - trunc = "Y"; - else if (MGoal.MEASUREDISPLAY_Quarter.equals(MeasureDisplay)) - trunc = "Q"; - else if (MGoal.MEASUREDISPLAY_Month.equals(MeasureDisplay)) - trunc = "MM"; - else if (MGoal.MEASUREDISPLAY_Week.equals(MeasureDisplay)) - trunc = "W"; - // else if (MGoal.MEASUREDISPLAY_Day.equals(MeasureDisplay)) - // trunc = "D"; - trunc = "TRUNC(DateDoc,'" + trunc + "')"; - StringBuffer sql = new StringBuffer ("SELECT SUM(ManualActual), ") - .append(trunc).append(" FROM PA_Achievement WHERE PA_Measure_ID=? AND IsAchieved='Y' ") - .append("GROUP BY ").append(trunc) - .append(" ORDER BY ").append(trunc); - PreparedStatement pstmt = null; - try - { - pstmt = DB.prepareStatement (sql.toString(), null); - pstmt.setInt(1, measure.getPA_Measure_ID()); - ResultSet rs = pstmt.executeQuery (); - while (rs.next ()) - { - BigDecimal data = rs.getBigDecimal(1); - Timestamp date = rs.getTimestamp(2); - BarGraphColumn bgc = new BarGraphColumn(m_goal, data); - bgc.setLabel(date, m_goal.getMeasureDisplay()); - list.add(bgc); - } - rs.close (); - pstmt.close (); - pstmt = null; - } - catch (Exception e) - { - log.log (Level.SEVERE, sql.toString(), e); - } - try - { - if (pstmt != null) - pstmt.close (); - pstmt = null; - } - catch (Exception e) - { - pstmt = null; - } - } // Achievement in time - } // Achievement - - // Request - else if (MMeasure.MEASURETYPE_Request.equals(measure.getMeasureType())) - { - MRequestType rt = MRequestType.get(Env.getCtx(), measure.getR_RequestType_ID()); - String sql = rt.getSqlBarChart(m_goal.getRestrictions(false), - m_goal.getMeasureDisplay(), measure.getMeasureDataType(), - null, MRole.getDefault()); // logged in role - PreparedStatement pstmt = null; - try - { - pstmt = DB.prepareStatement (sql, null); - ResultSet rs = pstmt.executeQuery (); - while (rs.next ()) - { - BigDecimal data = rs.getBigDecimal(1); - int R_Status_ID = rs.getInt(3); - BarGraphColumn bgc = new BarGraphColumn(rt, data, R_Status_ID); - if (R_Status_ID == 0) - { - Timestamp date = rs.getTimestamp(2); - bgc.setLabel(date, m_goal.getMeasureDisplay()); - } - else - { - MStatus status = MStatus.get(Env.getCtx(), R_Status_ID); - bgc.setLabel(status.getName()); - } - list.add(bgc); - } - rs.close (); - pstmt.close (); - pstmt = null; - } - catch (Exception e) - { - log.log (Level.SEVERE, sql, e); - } - try - { - if (pstmt != null) - pstmt.close (); - pstmt = null; - } - catch (Exception e) - { - pstmt = null; - } - } // Request - - // Project - else if (MMeasure.MEASURETYPE_Project.equals(measure.getMeasureType())) - { - MProjectType pt = MProjectType.get(Env.getCtx(), measure.getC_ProjectType_ID()); - String sql = pt.getSqlBarChart(m_goal.getRestrictions(false), - m_goal.getMeasureDisplay(), measure.getMeasureDataType(), - null, MRole.getDefault()); // logged in role - PreparedStatement pstmt = null; - try - { - pstmt = DB.prepareStatement (sql, null); - ResultSet rs = pstmt.executeQuery (); - while (rs.next ()) - { - BigDecimal data = rs.getBigDecimal(1); - Timestamp date = rs.getTimestamp(2); - int id = rs.getInt(3); - BarGraphColumn bgc = new BarGraphColumn(pt, data, id); - bgc.setLabel(date, m_goal.getMeasureDisplay()); - list.add(bgc); - } - rs.close (); - pstmt.close (); - pstmt = null; - } - catch (Exception e) - { - log.log (Level.SEVERE, sql, e); - } - try - { - if (pstmt != null) - pstmt.close (); - pstmt = null; - } - catch (Exception e) - { - pstmt = null; - } - } // Project - - // Add last 20 - int startValue = 0; - if (list.size() > 20) - startValue = list.size()-20; - for (int i = startValue; i < list.size(); i++) - add (list.get(i)); - } // loadData - - /** - * Get Point 0_0 - * @return point - */ - public Point getPoint0_0() - { - return m_point0_0; - } // getPoint0_0 - - - /** - * @return Returns the x_AxisLabel. - */ - public String getX_AxisLabel () - { - return m_X_AxisLabel; - } // getX_AxisLabel - - /** - * @param axisLabel The x_AxisLabel to set. - */ - public void setX_AxisLabel (String axisLabel) - { - m_X_AxisLabel = axisLabel; - } // setX_AxisLabel - - /** - * @return Returns the y_AxisLabel. - */ - public String getY_AxisLabel () - { - return m_Y_AxisLabel; - } // getY_AxisLabel - - /** - * @param axisLabel The y_AxisLabel to set. - */ - public void setY_AxisLabel (String axisLabel) - { - m_Y_AxisLabel = axisLabel; - } // setY_AxisLabel - - /** - * @return Returns the y_TargetLabel. - */ - public String getY_TargetLabel () - { - return m_Y_TargetLabel; - } // getY_TargetLabel - - /** - * @param targetLabel The y_TargetLabel to set. - */ - public void setY_TargetLabel (String targetLabel, double target) - { - m_Y_TargetLabel = targetLabel; - m_Y_Target = target; - } // setY_TargetLabel - - - /** - * Add Column - * @param column column - */ - public void add (BarGraphColumn column) - { - super.add (column, "column"); - column.addActionListener(this); - } // add - - - /************************************************************************** - * Paint Component - * @param g graphics - */ - protected void paintComponent (Graphics g) - { - Graphics2D g2D = (Graphics2D)g; - Rectangle bounds = getBounds(); - // Background - // g2D.setColor(Color.white); - Dimension size = getPreferredSize(); - // g2D.fill3DRect(0, 0, size.width, size.height, true); - - Font font = getFont(); - FontMetrics fm = g2D.getFontMetrics(font); - int fontHeight = fm.getHeight(); - // - int yAxis_X = m_point0_0.x; // fontHeight+10; // | - int xAxis_Y = m_point0_0.y; // size.height-fontHeight-10; // - - - // Paint X axis - g2D.setColor(Color.black); - g2D.drawLine(yAxis_X, xAxis_Y, size.width-5, xAxis_Y); - g2D.setFont(font); - g2D.drawString(m_X_AxisLabel, yAxis_X, xAxis_Y+fontHeight); - - // Paint Y axis - g2D.drawLine(yAxis_X, 5, yAxis_X, xAxis_Y); - AffineTransform transform = AffineTransform.getRotateInstance(Math.PI*3/2); - font = font.deriveFont(transform); - g2D.setFont(font); - g2D.drawString(m_Y_AxisLabel, yAxis_X-fontHeight+10, xAxis_Y); - - // Columns - super.paintComponent(g2D); - } // paintComponent - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (e.getSource() instanceof BarGraphColumn) - { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - BarGraphColumn bgc = (BarGraphColumn)e.getSource(); - log.info(bgc.getName()); - MQuery query = null; - if (bgc.getAchievement() != null) // Single Achievement - { - MAchievement a = bgc.getAchievement(); - query = MQuery.getEqualQuery("PA_Measure_ID", a.getPA_Measure_ID()); - } - else if (bgc.getGoal() != null) // Multiple Achievements - { - MGoal goal = bgc.getGoal(); - query = MQuery.getEqualQuery("PA_Measure_ID", goal.getPA_Measure_ID()); - } - else if (bgc.getMeasureCalc() != null) // Document - { - MMeasureCalc mc = bgc.getMeasureCalc(); - query = mc.getQuery(m_goal.getRestrictions(false), - bgc.getMeasureDisplay(), bgc.getDate(), - MRole.getDefault()); // logged in role - } - else if (bgc.getProjectType() != null) // Document - { - MProjectType pt = bgc.getProjectType(); - query = pt.getQuery(m_goal.getRestrictions(false), - bgc.getMeasureDisplay(), bgc.getDate(), bgc.getID(), - MRole.getDefault()); // logged in role - } - else if (bgc.getRequestType() != null) // Document - { - MRequestType rt = bgc.getRequestType(); - query = rt.getQuery(m_goal.getRestrictions(false), - bgc.getMeasureDisplay(), bgc.getDate(), bgc.getID(), - MRole.getDefault()); // logged in role - } - if (query != null) - AEnv.zoom(query); - else - log.warning("Nothing to zoom to - " + bgc); - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - } - } // actionPerformed - -} // BarGraph diff --git a/client/src/org/compiere/apps/graph/BarGraphColumn.java b/client/src/org/compiere/apps/graph/BarGraphColumn.java deleted file mode 100644 index 1572577d27..0000000000 --- a/client/src/org/compiere/apps/graph/BarGraphColumn.java +++ /dev/null @@ -1,485 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * 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. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.graph; - -import java.awt.*; -import java.awt.event.*; -import java.awt.geom.*; -import javax.swing.*; -import javax.swing.event.*; -import java.math.*; -import java.sql.*; -import java.text.*; - -import org.compiere.model.*; -import org.compiere.util.*; - -/** - * Bar Graph Column - * - * @author Jorg Janke - * @version $Id: BarGraphColumn.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class BarGraphColumn extends JComponent implements MouseListener -{ - /** - * Base Constructor - * @param label label - * @param value value - */ - public BarGraphColumn (String label, double value) - { - m_label = label; - setValue(value); - addMouseListener(this); - } // BarGraphColumn - - /** - * Single Achievement Constructor - * @param achievement achievement - */ - public BarGraphColumn (MAchievement achievement) - { - this (achievement.getName(), achievement.getManualActual().doubleValue()); - m_achievement = achievement; - } // BarGraphColumn - - /** - * Achievement Goal Constructor - * @param goal goal - * @param data count - */ - public BarGraphColumn (MGoal goal, BigDecimal data) - { - this ("", data == null ? 0 : data.doubleValue()); - m_goal = goal; - } // BarGraphColumn - - /** - * Measure Calc Constructor - * @param mc MeasureCalc - */ - public BarGraphColumn (MMeasureCalc mc, BigDecimal data) - { - this ("", data == null ? 0 : data.doubleValue()); - m_mc = mc; - } // BarGraphColumn - - /** - * Request Type Constructor - * @param rt Request Type - */ - public BarGraphColumn (MRequestType rt, BigDecimal data, int id) - { - this ("", data == null ? 0 : data.doubleValue()); - m_rt = rt; - m_id = id; - } // BarGraphColumn - - /** - * Project Type Constructor - * @param pt Procet Type - */ - public BarGraphColumn (MProjectType pt, BigDecimal data, int id) - { - this ("", data == null ? 0 : data.doubleValue()); - m_pt = pt; - m_id = id; - } // BarGraphColumn - - /** Optional Achievement */ - private MAchievement m_achievement = null; - /** Measure Calc */ - private MMeasureCalc m_mc = null; - /** Goal */ - private MGoal m_goal = null; - - private MRequestType m_rt = null; - private MProjectType m_pt = null; - private int m_id = 0; - - /** Display */ - private String m_measureDisplay = null; - private Timestamp m_date = null; - - /** Column Label */ - private String m_label = null; - /** Column Data Value */ - private double m_value = 0; - /** Column Label Value */ - private String m_labelValue = ""; - /** Column Data Target Value */ - private double m_targetValue = 0; - /** Column Width in pixles */ - private double m_width = 0; - /** Column Height in pixles */ - private double m_height = 0; - - /** Logger */ - private static CLogger log = CLogger.getCLogger (BarGraphColumn.class); - /** Integer Number Format */ - private static DecimalFormat s_format = DisplayType.getNumberFormat(DisplayType.Integer); - - /** - * Get Achievement Goal - * @return achievement or null - */ - public MGoal getGoal() - { - return m_goal; - } // getGoal - - - /** - * Get Single Achievement - * @return achievement or null - */ - public MAchievement getAchievement() - { - return m_achievement; - } // getAchievement - - /** - * Get MeasureCalc - * @return measure - */ - public MMeasureCalc getMeasureCalc() - { - return m_mc; - } // getMeasureCalc - - public MRequestType getRequestType() - { - return m_rt; - } - - public MProjectType getProjectType() - { - return m_pt; - } - - public String getMeasureDisplay() - { - return m_measureDisplay; - } // getMeasureDisplay - - public Timestamp getDate() - { - return m_date; - } // getDate - - public int getID() - { - return m_id; - } - - /** - * Set Background and matching Foreground - * @param bg background - */ - public void setBackground (Color bg) - { - super.setBackground (bg); - setForeground(GraphUtil.getForeground(bg)); - } // setBackground - - /** - * @return Returns the label. - */ - public String getLabel () - { - return m_label; - } // getLabel - - /** - * @param label The label to set. - */ - public void setLabel (String label) - { - m_label = label; - if (m_label != null) - m_labelValue = s_format.format(m_value) + " - " + m_label; - else - m_labelValue = s_format.format(m_value); - setToolTipText(m_labelValue); - setName(m_labelValue); - } // setLabel - - /** - * @param date for label. - * @param MeasureDisplay measure display - */ - public void setLabel (Timestamp date, String MeasureDisplay) - { - if (date == null) - return; - m_date = date; - m_measureDisplay = MeasureDisplay; - // - SimpleDateFormat format = DisplayType.getDateFormat(DisplayType.Date); - String text = format.format(date); - // Month only - if (MGoal.MEASUREDISPLAY_Month.equals(MeasureDisplay) - || MGoal.MEASUREDISPLAY_Quarter.equals(MeasureDisplay)) - { - String pattern = format.toPattern(); - String mmText = text; - int index = pattern.indexOf("dd"); - if (index == 0) // dd.MM.yyyy - mmText = text.substring(3); - else if (index > 0) // MM/dd/yyyy - { - mmText = text.substring(0, index-1); - if (text.length() > index+2) - mmText += text.substring(index+2); - } - setLabel(mmText); - } - else // Day - setLabel(text); - } // setLabel - - /** - * @return Returns the targetValue. - */ - public double getTargetValue () - { - return m_targetValue; - } // getTargetValue - - /** - * @param targetValue The targetValue to set. - */ - public void setTargetValue (double targetValue) - { - m_targetValue = targetValue; - } // setTargetValue - - /** - * @return Returns the data value. - */ - public double getValue () - { - return m_value; - } // getValue - - /** - * @param value The data value to set. - */ - public void setValue (double value) - { - m_value = value; - if (m_label != null) - m_labelValue = s_format.format(m_value) + " - " + m_label; - else - m_labelValue = s_format.format(m_value); - setToolTipText(m_labelValue); - setName(m_labelValue); - } // setValue - - /** - * @return Returns the column width in pixles. - */ - public double getColWidth () - { - return m_width; - } // getColWidth - - /** - * @param width The column width in pixles. - */ - public void setColWidth (double width) - { - m_width = width; - if (isPreferredSizeSet()) - setPreferredSize(null); - } // getColWidth - - /** - * @return Returns the height in pixles. - */ - public double getColHeight() - { - return m_height; - } // getHeight - - /** - * @param height The hight in pixles. - */ - public void setColHeight (double height) - { - m_height = height; - if (isPreferredSizeSet()) - setPreferredSize(null); - } // setHeight - - /** - * Get Maximum Size - * @return size - */ - public Dimension getMaximumSize () - { - return getPreferredSize(); - } // getMaximumSize - - /** - * Get Minimum Size - * @return size - */ - public Dimension getMinimumSize () - { - return getPreferredSize(); - } // getMinimumSize - - /** - * Get Preferred Size - * @return size - */ - public Dimension getPreferredSize () - { - if (!isPreferredSizeSet()) - { - Dimension size = new Dimension((int)m_width, (int)m_height); - setPreferredSize(size); - } - return super.getPreferredSize (); - } // getPreferredSize - - - /** - * Paint Component - * @param g graphics - */ - protected void paintComponent (Graphics g) - { - Graphics2D g2D = (Graphics2D)g; - Rectangle bounds = getBounds(); - // Background - g2D.setColor(getBackground()); - Dimension size = getPreferredSize(); - g2D.fill3DRect(0, 0, size.width, size.height, true); - - // Paint Label & Value - Color color = getForeground(); - g2D.setPaint(color); - // - Font font = getFont(); - FontMetrics fm = g2D.getFontMetrics(font); - int fontHeight = fm.getHeight(); - AffineTransform transform = AffineTransform.getRotateInstance(Math.PI*3/2); - font = font.deriveFont(transform); - g2D.setFont(font); - // - int x = (int)(size.width/2)+((fontHeight-2)/2); - if (x < fontHeight) - x = fontHeight-2; - int y = (int)(size.height-3); - g2D.drawString(m_labelValue, x, y); - log.finest("x=" + x + ",fontHeight=" + fontHeight + ", y=" + y + " - " + m_labelValue); - // Paint Target - if (m_targetValue != 0) - { - - } - } // paintComponent - - - /************************************************************************** - * Adds an ActionListener to the indicator. - * @param l the ActionListener to be added - */ - public void addActionListener(ActionListener l) - { - if (l != null) - listenerList.add(ActionListener.class, l); - } // addActionListener - - /** - * Removes an ActionListener 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 ActionListeners added - * to this indicator with addActionListener(). - * - * @return all of the ActionListeners 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 event - * parameter. - * - * @param event the ActionEvent 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, - "column"+m_label, 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); - } // mouseClicked - - public void mousePressed (MouseEvent e) - { - } - - public void mouseReleased (MouseEvent e) - { - } - - public void mouseEntered (MouseEvent e) - { - } - - public void mouseExited (MouseEvent e) - { - } - -} // BarGraphColumn diff --git a/client/src/org/compiere/apps/graph/BarGraphLayout.java b/client/src/org/compiere/apps/graph/BarGraphLayout.java deleted file mode 100644 index 14be9a5500..0000000000 --- a/client/src/org/compiere/apps/graph/BarGraphLayout.java +++ /dev/null @@ -1,153 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * 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. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.graph; - -import java.awt.*; -import java.util.*; - -import org.compiere.util.*; - -/** - * Bar Graph Layout - * - * @author Jorg Janke - * @version $Id: BarGraphLayout.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class BarGraphLayout - implements LayoutManager -{ - /** - * Bar Graph Layout - * @param parent parenr - */ - public BarGraphLayout (BarGraph parent) - { - m_parent = parent; - } // BarGraphLayout - - /** Parent Container */ - private BarGraph m_parent; - /** List of Components */ - private ArrayList m_list = new ArrayList(); - /** Layout Complete */ - private boolean m_layoutComplete = false; - /** Gap between columns */ - private static int XGAP = 2; - /** Gap to Axix */ - private static int YGAP = 1; - - /** Logger */ - private static CLogger log = CLogger.getCLogger (BarGraphLayout.class); - - /** - * Add Layout Component - * @param name name - * @param comp component - */ - public void addLayoutComponent (String name, Component comp) - { - if (comp instanceof BarGraphColumn) - m_list.add((BarGraphColumn)comp); - else - log.severe("Invalid Class: " + comp); - m_layoutComplete = false; - } // addLayoutComponent - - /** - * Remove Layout Component - * @param comp component - */ - public void removeLayoutComponent (Component comp) - { - m_list.remove(comp); - m_layoutComplete = false; - } // removeLayoutComponent - - /** - * Preferred Layout Size - * @param parent parent - * @return size - */ - public Dimension preferredLayoutSize (Container parent) - { - return parent.getPreferredSize(); - } // preferredLayoutSize - - /** - * Minimum Layout Size - * @param parent parent - * @return size - */ - public Dimension minimumLayoutSize (Container parent) - { - return parent.getMinimumSize(); - } // minimumLayoutSize - - - /** - * Layout Container - * @param parent - */ - public void layoutContainer (Container parent) - { - if (m_layoutComplete) - return; - - // Find Max - double maxValue = 0; - for (int i = 0; i < m_list.size(); i++) - { - BarGraphColumn column = m_list.get(i); - maxValue = Math.max(maxValue, column.getValue()); - } - // - Dimension size = m_parent.getPreferredSize(); - Point point0_0 = m_parent.getPoint0_0(); - - double graphHeight = size.height - (size.height-point0_0.y) - (2*YGAP); - double graphWidth = size.width - point0_0.x - XGAP; - double columnWidth = (graphWidth - (XGAP*m_list.size())) / m_list.size(); - columnWidth = Math.min(30, columnWidth); - FontMetrics fm = m_parent.getFontMetrics(m_parent.getFont()); - int fontHeight = fm.getHeight(); - columnWidth = Math.max(fontHeight, columnWidth); - - log.fine("Height=" + graphHeight + ", MaxValue=" + maxValue - + ", Width=" + graphWidth + ", ColumnWidth=" + columnWidth); - - int x = point0_0.x + (2*XGAP); - // Set Values - for (int i = 0; i < m_list.size(); i++) - { - BarGraphColumn column = m_list.get(i); - double multiplier = column.getValue() / maxValue; - double height = graphHeight * multiplier; - column.setColHeight(height); - column.setColWidth(columnWidth); - Dimension ps = column.getPreferredSize(); - column.setBackground(GraphUtil.getBackground(i)); - // - int y = point0_0.y - ps.height - YGAP; - column.setLocation(x, y); - column.setBounds(x, y, ps.width, ps.height); - x += ps.width + XGAP; - log.finer(i + " - " + ((int)(multiplier*100)) + "% - " + column.getBounds()); - } - m_layoutComplete = true; - } // layoutContainer - -} // BarGraphLayout diff --git a/client/src/org/compiere/apps/graph/GraphUtil.java b/client/src/org/compiere/apps/graph/GraphUtil.java deleted file mode 100644 index 596eea8fcd..0000000000 --- a/client/src/org/compiere/apps/graph/GraphUtil.java +++ /dev/null @@ -1,168 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * 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. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.graph; - -import java.awt.*; -import java.util.*; -import org.compiere.util.*; - -/** - * Graphic Utilities - * - * @author Jorg Janke - * @version $Id: GraphUtil.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $ - */ -public class GraphUtil -{ - /** Logger */ - private static CLogger log = CLogger.getCLogger (GraphUtil.class); - - /** - * Get Foreground for back - * @param background back - * @return while or black - */ - public static Color getForeground (Color background) - { - if (background != null && isDark(background)) - return Color.white; - return Color.black; - } // getForeground - - /** - * Get Column Background - * @param index index - * @return random color - */ - public static Color getBackground (int index) - { - while (s_colors.size() <= index) - { - int rr = (index+1) * 47; - int gg = 100; - while (rr > 255) - { - rr -= 255; - gg += 50; - } - while (gg > 255) - gg -= 255; - s_colors.add(new Color(255-rr, gg, rr)); - } - return s_colors.get(index); - } // getBackGround - - /** List of Colors */ - private static ArrayList s_colors = new ArrayList(); - - - /** - * Is the Color dark? - * @param color color - * @return true if dark - */ - public static boolean isDark (Color color) - { - float r = color.getRed() / 255.0f; - float g = color.getGreen() / 255.0f; - float b = color.getBlue() / 255.0f; - double whiteDistance = colorDistance (r, g, b, 1.0, 1.0, 1.0); - double blackDistance = colorDistance (r, g, b, 0.0, 0.0, 0.0); - boolean dark = blackDistance < whiteDistance; - if (r+g+b == 1.0) - dark = false; - // log.info("r=" + r + ",g=" + g + ",b=" + b + " - black=" + blackDistance - // + (dark ? " ") + "white=" + whiteDistance - // + " - Alpha=" + color.getAlpha() + ", Trans=" + color.getTransparency()); - return dark; - } // isDark - - /** - * Is Color more white or black? - * @param r red - * @param g green - * @param b blue - * @return true if dark - */ - public static boolean isDark (double r, double g, double b) - { - double whiteDistance = colorDistance (r, g, b, 1.0, 1.0, 1.0); - double blackDistance = colorDistance (r, g, b, 0.0, 0.0, 0.0); - boolean dark = blackDistance < whiteDistance; - // log.finest("r=" + r + ",g=" + g + ",b=" + b + " - white=" + whiteDistance + ",black=" + blackDistance); - return dark; - } // isDark - - /** - * Simple Color Distance. - * (3d point distance) - * @param r1 first red - * @param g1 first green - * @param b1 first blue - * @param r2 second red - * @param g2 second green - * @param b2 second blue - * @return 3d distance for relative comparison - */ - public static double colorDistance (double r1, double g1, double b1, - double r2, double g2, double b2) - { - double a = (r2 - r1) + 0.1; - double b = (g2 - g1) + 0.1; - double c = (b2 - b1) + 0.1; - return Math.sqrt (a*a + b*b + c*c); - } // colorDistance - - - /** - * Get darker color - * @param color color - * @param factor factor 0..1 (AWT 0.7) the smaller, the darker - * @return darker color - */ - public static Color darker(Color color, double factor) - { - if (factor < 0.0) - factor = 0.7; - else if (factor > 1.0) - factor = 0.7; - return new Color( - Math.max((int)(color.getRed() * factor), 0), - Math.max((int)(color.getGreen() * factor), 0), - Math.max((int)(color.getBlue() * factor), 0)); - } // darker - - /** - * Get brighter color - * @param color color - * @param factor factor 0..1 (AWT 0.7) the smaller, the lighter - * @return brighter color - */ - public static Color brighter (Color color, double factor) - { - if (factor < 0.0) - factor = 0.7; - else if (factor > 1.0) - factor = 0.7; - - return new Color( - Math.min((int)(color.getRed() / factor), 255), - Math.min((int)(color.getGreen() / factor), 255), - Math.min((int)(color.getBlue() / factor), 255)); - } // brighter - -} // GraphUtil diff --git a/client/src/org/compiere/apps/graph/PAPanel.java b/client/src/org/compiere/apps/graph/PAPanel.java deleted file mode 100644 index 4cddc1195a..0000000000 --- a/client/src/org/compiere/apps/graph/PAPanel.java +++ /dev/null @@ -1,166 +0,0 @@ -/********************************************************************** - * This file is part of Adempiere ERP Bazaar * - * http://www.adempiere.org * - * * - * Copyright (C) 1999 - 2006 Compiere Inc. * - * Copyright (C) Contributors * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License * - * as published by the Free Software Foundation; either version 2 * - * of the License, or (at your option) any later version. * - * * - * 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., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301, USA. * - * * - * Contributors: * - * - Bahman Movaqar (bmovaqar@users.sf.net) * - **********************************************************************/ -package org.compiere.apps.graph; - -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; - -import javax.swing.JPopupMenu; -import javax.swing.SwingUtilities; - -import org.compiere.model.MGoal; -import org.compiere.swing.CMenuItem; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.Env; - -/** - * Performance Analysis Panel. Key Performace Indicators - * - * @author Jorg Janke - * @version $Id: PAPanel.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class PAPanel extends CPanel implements MouseListener, ActionListener { - /** - * Serial version UID - */ - private static final long serialVersionUID = 900002328486L; - - /** - * Get Panel if User has Perfpormance Goals - * - * @return panel pr null - */ - public static PAPanel get() { - int AD_User_ID = Env.getAD_User_ID(Env.getCtx()); - MGoal[] goals = MGoal.getUserGoals(Env.getCtx(), AD_User_ID); - if (goals.length == 0) - return null; - return new PAPanel(goals); - } // get - - /*************************************************************************** - * Constructor - * - * @param goals - */ - private PAPanel(MGoal[] goals) { - super(); - m_goals = goals; - init(); - } // PAPanel - - /** Goals */ - private MGoal[] m_goals = null; - - /** Logger */ - private static CLogger log = CLogger.getCLogger(PAPanel.class); - - /** Popup menu */ - JPopupMenu pmenu = new JPopupMenu(); - - /** Update menu item */ - CMenuItem menuUpdate = new CMenuItem(); - - /** - * Static/Dynamic Init - */ - private void init() { - for (int i = 0; i < m_goals.length; i++) { - PerformanceIndicator pi = new PerformanceIndicator(m_goals[i]); - pi.addActionListener(this); - add(pi); - } - // Setup the popup menu - menuUpdate.setText("Update Indicators"); - menuUpdate.setActionCommand("update"); - menuUpdate.addActionListener(this); - pmenu.setLightWeightPopupEnabled(false); - pmenu.add(menuUpdate); - - this.addMouseListener(this); - } // init - - /** - * Action Listener for Drill Down - * - * @param e - * event - */ - public void actionPerformed(ActionEvent e) { - if (e.getSource() instanceof PerformanceIndicator) { - PerformanceIndicator pi = (PerformanceIndicator) e.getSource(); - log.info(pi.getName()); - MGoal goal = pi.getGoal(); - if (goal.getMeasure() != null) - new PerformanceDetail(goal); - } else if (e.getActionCommand().equals("update")) - updateInidcators(); - } // actionPerformed - - /** - * Updates indicators. - */ - private void updateInidcators() { - for (int i = 0; i < m_goals.length; i++) { - log.info("Updating indicator \"" + m_goals[i].getName() + "\"..."); - remove(i); - PerformanceIndicator pi = new PerformanceIndicator(m_goals[i]); - pi.addActionListener(this); - add(pi, i); - log.info("done."); - } - } // updateIndicators - - public void mouseClicked(MouseEvent e) { - if (SwingUtilities.isRightMouseButton(e)) - pmenu.show((Component) e.getSource(), e.getX(), e.getY()); - } - - public void mouseEntered(MouseEvent e) { - // TODO Auto-generated method stub - - } - - public void mouseExited(MouseEvent e) { - // TODO Auto-generated method stub - - } - - public void mousePressed(MouseEvent e) { - // TODO Auto-generated method stub - - } - - public void mouseReleased(MouseEvent e) { - // TODO Auto-generated method stub - - } - -} // PAPanel diff --git a/client/src/org/compiere/apps/graph/PerformanceDetail.java b/client/src/org/compiere/apps/graph/PerformanceDetail.java deleted file mode 100644 index 56d0995102..0000000000 --- a/client/src/org/compiere/apps/graph/PerformanceDetail.java +++ /dev/null @@ -1,76 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * 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. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.graph; - -import java.awt.*; -import java.awt.event.*; - -import org.compiere.*; -import org.compiere.apps.*; -import org.compiere.swing.*; -import org.compiere.model.*; - - -/** - * Performance Detail Frame. - * BarPanel for Drill-Down - * - * @author Jorg Janke - * @version $Id: PerformanceDetail.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class PerformanceDetail extends CFrame - implements ActionListener -{ - /** - * Constructor. - * Called from PAPanel, ViewPI (Performance Indicator) - * @param goal goal - */ - public PerformanceDetail (MGoal goal) - { - super (goal.getName()); - setIconImage(Adempiere.getImage16()); - barPanel = new BarGraph(goal); - init(); - AEnv.showCenterScreen(this); - } // PerformanceDetail - - BarGraph barPanel = null; - ConfirmPanel confirmPanel = new ConfirmPanel(); - - /** - * Static init - */ - private void init() - { - getContentPane().add(barPanel, BorderLayout.NORTH); - - getContentPane().add(confirmPanel, BorderLayout.SOUTH); - confirmPanel.addActionListener(this); - } // init - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - dispose(); - } // actionPerformed - -} // PerformanceDetail diff --git a/client/src/org/compiere/apps/graph/PerformanceIndicator.java b/client/src/org/compiere/apps/graph/PerformanceIndicator.java deleted file mode 100644 index 7560dab7dc..0000000000 --- a/client/src/org/compiere/apps/graph/PerformanceIndicator.java +++ /dev/null @@ -1,456 +0,0 @@ -/********************************************************************** - * This file is part of Adempiere ERP Bazaar * - * http://www.adempiere.org * - * * - * Copyright (C) 1999 - 2006 Compiere Inc. * - * Copyright (C) Contributors * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License * - * as published by the Free Software Foundation; either version 2 * - * of the License, or (at your option) any later version. * - * * - * 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., 51 Franklin Street, Fifth Floor, Boston, * - * MA 02110-1301, USA. * - * * - * Contributors: * - * - Bahman Movaqar (bmovaqar@users.sf.net) * - **********************************************************************/ -package org.compiere.apps.graph; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.text.DecimalFormat; - -import javax.swing.BorderFactory; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.SwingUtilities; -import javax.swing.border.BevelBorder; -import javax.swing.event.EventListenerList; - -import org.compiere.model.MGoal; -import org.compiere.swing.CMenuItem; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.jfree.chart.ChartPanel; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.DialShape; -import org.jfree.chart.plot.MeterInterval; -import org.jfree.chart.plot.MeterPlot; -import org.jfree.data.Range; -import org.jfree.data.general.DefaultValueDataset; -import org.jfree.ui.RectangleInsets; - -/** - * Performance Indicator - * - * @author Jorg Janke - * @version $Id: PerformanceIndicator.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -// vpj-cd e-evolution public class PerformanceIndicator extends JComponent -public class PerformanceIndicator extends JPanel implements MouseListener, - ActionListener { - /** - * Serial version UID - */ - private static final long serialVersionUID = -3988387418888L; - - /** - * Constructor - * - * @param goal - * goal model - */ - public PerformanceIndicator(MGoal goal) { - super(); - m_goal = goal; - setName(m_goal.getName()); - // vpj-cd e-evolution getPreferredSize(); // calculate size - init(); - // - setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); - setOpaque(true); - // vpj-cd e-evolution updateDisplay(); - - // - mRefresh.addActionListener(this); - popupMenu.add(mRefresh); - // - addMouseListener(this); - } // PerformanceIndicator - - private MGoal m_goal = null; - - /** The Performance Name */ - private String m_text = null; - - /** 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 */ - private static DecimalFormat s_format = DisplayType - .getNumberFormat(DisplayType.Integer); - - JPopupMenu popupMenu = new JPopupMenu(); - - private CMenuItem mRefresh = new CMenuItem(Msg.getMsg(Env.getCtx(), - "Refresh"), Env.getImageIcon("Refresh16.gif")); - - // Insert Pie Graph Kinamo (pelgrim) - private static Color colorOK = Color.magenta; - - private static Color colorNotOK = Color.lightGray; - - // private static Dimension indicatordimension = new Dimension(150, 150); - private static Dimension indicatordimension = new Dimension(190, 130); - - private static Dimension paneldimension = new Dimension(200, 200); - - // private static Dimension - - /** - * Get Goal - * - * @return goal - */ - public MGoal getGoal() { - return m_goal; - } // getGoal - - /** - * Init Graph Display Kinamo (pelgrim) - */ - private void init() { - // Set Text - StringBuffer text = new StringBuffer(m_goal.getName()); - if (m_goal.isTarget()) - text.append(": ").append(m_goal.getPercent()).append("%"); - else - text.append(": ") - .append(s_format.format(m_goal.getMeasureActual())); - m_text = text.toString(); - - // ToolTip - text = new StringBuffer(); - if (m_goal.getDescription() != null) - text.append(m_goal.getDescription()).append(": "); - text.append(s_format.format(m_goal.getMeasureActual())); - if (m_goal.isTarget()) - text.append(" ").append(Msg.getMsg(Env.getCtx(), "of")).append(" ") - .append(s_format.format(m_goal.getMeasureTarget())); - 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(); - - // vpj-cd e-evolution Plot Meter ----------------------------------- - JFreeChart chart = null; - - String title = m_text; - DefaultValueDataset data = new DefaultValueDataset((float) m_goal - .getPercent()); - MeterPlot plot = new MeterPlot(data); - plot.addInterval(new MeterInterval("Normal", new Range(0.0, 100.0))); - - plot.setUnits(m_goal.getName()); - plot.setRange(new Range(0, 100)); - plot.setDialShape(DialShape.CIRCLE); - plot.setDialBackgroundPaint(m_goal.getColor()); - plot.setNeedlePaint(Color.white); - plot.setTickSize(10); - plot.setTickLabelFont(new Font("SansSerif", Font.BOLD, 8)); - plot.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); - - chart = new JFreeChart(m_text, new Font("SansSerif", Font.BOLD, 12), - plot, false); - // chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, - // 1000, Color.ORANGE)); - ChartPanel chartPanel = new ChartPanel(chart); - chartPanel.setPreferredSize(indicatordimension); - - chartPanel - .addChartMouseListener(new org.jfree.chart.ChartMouseListener() { - public void chartMouseClicked( - org.jfree.chart.ChartMouseEvent e) { - // plot p = (MeterPlot) e.getSource(); - MouseEvent me = e.getTrigger(); - - if (SwingUtilities.isLeftMouseButton(me) - && me.getClickCount() > 1) - fireActionPerformed(me); - // if (SwingUtilities.isRightMouseButton(me)) - // popupMenu.show((Component)me.getSource(), me.getX(), - // me.getY()); - } - - public void chartMouseMoved( - org.jfree.chart.ChartMouseEvent e) { - - } - - }); - - this.add(chartPanel, BorderLayout.NORTH); - // --------------------------------------------- - - invalidate(); - } - - /** - * Update Display Data - */ - protected void updateDisplay() { - // Set Text - /* - * begin vpj-cd e-evolution StringBuffer text = new - * StringBuffer(m_goal.getName()); if (m_goal.isTarget()) text.append(": - * ").append(m_goal.getPercent()).append("%"); else text.append(": - * ").append(s_format.format(m_goal.getMeasureActual())); m_text = - * text.toString(); // ToolTip text = new StringBuffer(); if - * (m_goal.getDescription() != null) - * text.append(m_goal.getDescription()).append(": "); - * text.append(s_format.format(m_goal.getMeasureActual())); if - * (m_goal.isTarget()) text.append(" ").append(Msg.getMsg(Env.getCtx(), - * "of")).append(" ") - * .append(s_format.format(m_goal.getMeasureTarget())); - * 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(); - */ - JFreeChart chart = null; - - String title = m_text; - DefaultValueDataset data = new DefaultValueDataset((float) m_goal - .getPercent()); - MeterPlot plot = new MeterPlot(data); - plot.addInterval(new MeterInterval("Normal", new Range(0.0, 100.0))); - - plot.setUnits(m_goal.getName()); - plot.setRange(new Range(0, 100)); - plot.setDialShape(DialShape.CIRCLE); - plot.setDialBackgroundPaint(m_goal.getColor()); - plot.setNeedlePaint(Color.white); - plot.setTickSize(10); - plot.setTickLabelFont(new Font("SansSerif", Font.BOLD, 8)); - plot.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); - - chart = new JFreeChart(m_text, new Font("SansSerif", Font.BOLD, 12), - plot, false); - // chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, - // 1000, Color.ORANGE)); - ChartPanel chartPanel = new ChartPanel(chart); - chartPanel.setPreferredSize(indicatordimension); - - chartPanel - .addChartMouseListener(new org.jfree.chart.ChartMouseListener() { - public void chartMouseClicked( - org.jfree.chart.ChartMouseEvent e) { - // plot p = (MeterPlot) e.getSource(); - System.out.println("evento" + e.getSource()); - System.out.println("evento" + e.getTrigger()); - System.out.println("evento" + e.getChart().getTitle()); - - MouseEvent me = e.getTrigger(); - - if (SwingUtilities.isLeftMouseButton(me) - && me.getClickCount() > 1) - fireActionPerformed(me); - if (SwingUtilities.isRightMouseButton(me)) - popupMenu.show((Component) me.getSource(), me - .getX(), me.getY()); - } - - public void chartMouseMoved( - org.jfree.chart.ChartMouseEvent e) { - - } - - }); - - this.add(chartPanel, BorderLayout.NORTH); - // vpj-cd e-evolution getPreferredSize(); - invalidate(); - } // updateData - - /*************************************************************************** - * Get Preferred Size - * - * @return size - */ - /* - * vpj-cd e-evolution public Dimension getPreferredSize() { if - * (!isPreferredSizeSet()) { double width = s_width100; if - * (m_goal.getPercent() > 100) { width = width * - * m_goal.getGoalPerformanceDouble(); width = Math.min(width, s_widthMax); } - * Dimension size = new Dimension(); size.setSize(width, s_height); - * setPreferredSize(size); setMinimumSize(size); setMaximumSize(size); } - * return super.getPreferredSize(); } // getPreferredSize // end vpj-cd - * - * /** Paint Component @param g Graphics - */ - /* - * vpj-cd e-evolution protected void paintComponent (Graphics g) { - * Graphics2D g2D = (Graphics2D)g; Rectangle bounds = getBounds(); Insets - * insets = getInsets(); // Background // - * g2D.setColor(GraphUtil.darker(getBackground(), 0.85)); - * g2D.setColor(getBackground()); Dimension size = getPreferredSize(); - * g2D.fill3DRect(0+insets.right, 0+insets.top, - * size.width-insets.right-insets.left, - * size.height-insets.top-insets.bottom, true); - * // Paint Text Color color = getForeground(); g2D.setPaint(color); Font - * font = getFont(); // Bold +1 font = new Font(font.getName(), Font.BOLD, - * font.getSize()+1); // AttributedString aString = new - * AttributedString(m_text); aString.addAttribute(TextAttribute.FONT, font); - * aString.addAttribute(TextAttribute.FOREGROUND, color); - * AttributedCharacterIterator iter = aString.getIterator(); // - * LineBreakMeasurer measurer = new LineBreakMeasurer(iter, - * g2D.getFontRenderContext()); float width = getPreferredSize().width - 8; // - * 4 pt ; float xPos = 4; float yPos = 2; while (measurer.getPosition() < - * iter.getEndIndex()) { TextLayout layout = measurer.nextLayout(width); - * yPos += layout.getAscent() + layout.getDescent() + layout.getLeading(); - * layout.draw(g2D, xPos, yPos); } - * // Paint Performance Line int x = (int)(m_line); int y = - * (int)(size.height-insets.bottom); g2D.setPaint(Color.black); - * g2D.drawLine(x, insets.top, x, y); } // paintComponent - */ - // end vpj-cd e-evolution - /*************************************************************************** - * Adds an ActionListener to the indicator. - * - * @param l - * the ActionListener to be added - */ - public void addActionListener(ActionListener l) { - if (l != null) - listenerList.add(ActionListener.class, l); - } // addActionListener - - /** - * Removes an ActionListener 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 ActionListeners added to this - * indicator with addActionListener(). - * - * @return all of the ActionListeners 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 - * event parameter. - * - * @param event - * the ActionEvent 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 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 - -} // PerformanceIndicator diff --git a/client/src/org/compiere/apps/graph/ViewPI.java b/client/src/org/compiere/apps/graph/ViewPI.java deleted file mode 100644 index 174bcd39d3..0000000000 --- a/client/src/org/compiere/apps/graph/ViewPI.java +++ /dev/null @@ -1,135 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * 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. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.graph; - -import java.awt.*; -import java.awt.event.*; -import java.util.logging.*; -import javax.swing.*; - -import org.compiere.apps.*; -import org.compiere.apps.form.*; -import org.compiere.model.*; -import org.compiere.swing.*; -import org.compiere.util.*; - -/** - * View Performance Indicators - * - * @author Jorg Janke - * @version $Id: ViewPI.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class ViewPI extends CPanel - implements FormPanel, ActionListener -{ - /** - * Init - * @param WindowNo - * @param frame - */ - public void init (int WindowNo, FormFrame frame) - { - log.fine(""); - m_WindowNo = WindowNo; - m_frame = frame; - try - { - // Top Selection Panel - // m_frame.getContentPane().add(selectionPanel, BorderLayout.NORTH); - // Center - initPanel(); - CScrollPane scroll = new CScrollPane (this); - m_frame.getContentPane().add(scroll, BorderLayout.CENTER); - // South - confirmPanel.addActionListener(this); - m_frame.getContentPane().add(confirmPanel, BorderLayout.SOUTH); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - } - sizeIt(); - } // init - - /** - * Size Window - */ - private void sizeIt() - { - // Frame - m_frame.pack(); - // Dimension size = m_frame.getPreferredSize(); - // size.width = WINDOW_WIDTH; - // m_frame.setSize(size); - } // size - - /** - * Dispose - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - removeAll(); - } // dispose - - /** Window No */ - private int m_WindowNo = 0; - /** FormFrame */ - private FormFrame m_frame; - /** Logger */ - private static CLogger log = CLogger.getCLogger (ViewPI.class); - /** Confirmation Panel */ - private ConfirmPanel confirmPanel = new ConfirmPanel(); - - - /** - * Init Panel - */ - private void initPanel() - { - BoxLayout layout = new BoxLayout(this, BoxLayout.PAGE_AXIS); - MGoal[] goals = MGoal.getGoals(Env.getCtx()); - for (int i = 0; i < goals.length; i++) - { - PerformanceIndicator pi = new PerformanceIndicator(goals[i]); - pi.addActionListener(this); - add (pi); - } - } // initPanel - - - /** - * Action Listener for Drill Down - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - dispose(); - else if (e.getSource() instanceof PerformanceIndicator) - { - PerformanceIndicator pi = (PerformanceIndicator)e.getSource(); - log.info(pi.getName()); - MGoal goal = pi.getGoal(); - if (goal.getMeasure() != null) - new PerformanceDetail(goal); - } - } // actionPerformed - -} // ViewPI diff --git a/client/src/org/compiere/apps/graph/package.html b/client/src/org/compiere/apps/graph/package.html deleted file mode 100644 index 8cba21fff4..0000000000 --- a/client/src/org/compiere/apps/graph/package.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - -

Package org.compiere.apps.graph

- -Performance dashboard - -

Related Documentation

- -For overviews, tutorials, examples, guides, and tool documentation, please see: - - - - - - diff --git a/client/src/org/compiere/grid/ed/VCellRenderer.java b/client/src/org/compiere/grid/ed/VCellRenderer.java index 299cf27ee6..246abaf040 100644 --- a/client/src/org/compiere/grid/ed/VCellRenderer.java +++ b/client/src/org/compiere/grid/ed/VCellRenderer.java @@ -148,7 +148,7 @@ public final class VCellRenderer extends DefaultTableCellRenderer bg = table.getSelectionBackground(); fg = table.getSelectionForeground(); if (hasFocus) - bg = GraphUtil.brighter(bg, .9); + bg = org.adempiere.apps.graph.GraphUtil.brighter(bg, .9); } // Set Color