org.adempiere.apps.graph.BarGraph:
* fixed indentation * fixed warnings
This commit is contained in:
parent
9ae07a2192
commit
7ca5ab994f
|
@ -58,8 +58,10 @@ import org.jfree.data.category.DefaultCategoryDataset;
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: BarGraph.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
* @version $Id: BarGraph.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||||
*/
|
*/
|
||||||
public class BarGraph extends CPanel implements ChartMouseListener //, ComponentListener //, ActionListener
|
public class BarGraph extends CPanel implements ChartMouseListener
|
||||||
{
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
|
@ -82,16 +84,16 @@ public class BarGraph extends CPanel implements ChartMouseListener //, Component
|
||||||
loadData();
|
loadData();
|
||||||
//addComponentListener(this);
|
//addComponentListener(this);
|
||||||
} // BarGraph
|
} // BarGraph
|
||||||
|
|
||||||
/** The Goal */
|
/** The Goal */
|
||||||
private MGoal m_goal = null;
|
private MGoal m_goal = null;
|
||||||
/** Graph Size */
|
/** Graph Size */
|
||||||
//private Dimension m_size = null;
|
//private Dimension m_size = null;
|
||||||
/** Zero/Zero Coordibate point */
|
/** Zero/Zero Coordibate point */
|
||||||
private Point m_point0_0 = null;
|
private Point m_point0_0 = null;
|
||||||
/** Layout */
|
// /** Layout */
|
||||||
private BarGraphLayout m_layout = new BarGraphLayout(this);
|
// private BarGraphLayout m_layout = new BarGraphLayout(this);
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static CLogger log = CLogger.getCLogger (BarGraph.class);
|
private static CLogger log = CLogger.getCLogger (BarGraph.class);
|
||||||
|
|
||||||
|
@ -99,16 +101,16 @@ public class BarGraph extends CPanel implements ChartMouseListener //, Component
|
||||||
private String m_X_AxisLabel = "X Axis";
|
private String m_X_AxisLabel = "X Axis";
|
||||||
/** Y Axis Label */
|
/** Y Axis Label */
|
||||||
private String m_Y_AxisLabel = "Y Axis";
|
private String m_Y_AxisLabel = "Y Axis";
|
||||||
/** Y Axis Max */
|
// /** Y Axis Max */
|
||||||
private double m_Y_Max = 0;
|
// private double m_Y_Max = 0;
|
||||||
/** Y Axis Target Line */
|
/** Y Axis Target Line */
|
||||||
private double m_Y_Target = 0;
|
private double m_Y_Target = 0;
|
||||||
/** Y Axis Target Line Label */
|
/** Y Axis Target Line Label */
|
||||||
private String m_Y_TargetLabel = null;
|
private String m_Y_TargetLabel = null;
|
||||||
private static Dimension paneldimension = new Dimension(180, 150);
|
private static Dimension paneldimension = new Dimension(180, 150);
|
||||||
|
|
||||||
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
|
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Performance Data
|
* Load Performance Data
|
||||||
*/
|
*/
|
||||||
|
@ -127,8 +129,8 @@ public class BarGraph extends CPanel implements ChartMouseListener //, Component
|
||||||
{
|
{
|
||||||
MMeasureCalc mc = MMeasureCalc.get(Env.getCtx(), measure.getPA_MeasureCalc_ID());
|
MMeasureCalc mc = MMeasureCalc.get(Env.getCtx(), measure.getPA_MeasureCalc_ID());
|
||||||
String sql = mc.getSqlBarChart(m_goal.getRestrictions(false),
|
String sql = mc.getSqlBarChart(m_goal.getRestrictions(false),
|
||||||
m_goal.getMeasureDisplay(), null,
|
m_goal.getMeasureDisplay(), null,
|
||||||
MRole.getDefault()); // logged in role
|
MRole.getDefault()); // logged in role
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
|
@ -183,13 +185,13 @@ public class BarGraph extends CPanel implements ChartMouseListener //, Component
|
||||||
trunc = "MM";
|
trunc = "MM";
|
||||||
else if (MGoal.MEASUREDISPLAY_Week.equals(MeasureDisplay))
|
else if (MGoal.MEASUREDISPLAY_Week.equals(MeasureDisplay))
|
||||||
trunc = "W";
|
trunc = "W";
|
||||||
// else if (MGoal.MEASUREDISPLAY_Day.equals(MeasureDisplay))
|
// else if (MGoal.MEASUREDISPLAY_Day.equals(MeasureDisplay))
|
||||||
// trunc = "D";
|
// trunc = "D";
|
||||||
trunc = "TRUNC(DateDoc,'" + trunc + "')";
|
trunc = "TRUNC(DateDoc,'" + trunc + "')";
|
||||||
StringBuffer sql = new StringBuffer ("SELECT SUM(ManualActual), ")
|
StringBuffer sql = new StringBuffer ("SELECT SUM(ManualActual), ")
|
||||||
.append(trunc).append(" FROM PA_Achievement WHERE PA_Measure_ID=? AND IsAchieved='Y' ")
|
.append(trunc).append(" FROM PA_Achievement WHERE PA_Measure_ID=? AND IsAchieved='Y' ")
|
||||||
.append("GROUP BY ").append(trunc)
|
.append("GROUP BY ").append(trunc)
|
||||||
.append(" ORDER BY ").append(trunc);
|
.append(" ORDER BY ").append(trunc);
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
|
@ -217,14 +219,14 @@ public class BarGraph extends CPanel implements ChartMouseListener //, Component
|
||||||
}
|
}
|
||||||
} // Achievement in time
|
} // Achievement in time
|
||||||
} // Achievement
|
} // Achievement
|
||||||
|
|
||||||
// Request
|
// Request
|
||||||
else if (MMeasure.MEASURETYPE_Request.equals(measure.getMeasureType()))
|
else if (MMeasure.MEASURETYPE_Request.equals(measure.getMeasureType()))
|
||||||
{
|
{
|
||||||
MRequestType rt = MRequestType.get(Env.getCtx(), measure.getR_RequestType_ID());
|
MRequestType rt = MRequestType.get(Env.getCtx(), measure.getR_RequestType_ID());
|
||||||
String sql = rt.getSqlBarChart(m_goal.getRestrictions(false),
|
String sql = rt.getSqlBarChart(m_goal.getRestrictions(false),
|
||||||
m_goal.getMeasureDisplay(), measure.getMeasureDataType(),
|
m_goal.getMeasureDisplay(), measure.getMeasureDataType(),
|
||||||
null, MRole.getDefault()); // logged in role
|
null, MRole.getDefault()); // logged in role
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
|
@ -259,14 +261,14 @@ public class BarGraph extends CPanel implements ChartMouseListener //, Component
|
||||||
rs = null; pstmt = null;
|
rs = null; pstmt = null;
|
||||||
}
|
}
|
||||||
} // Request
|
} // Request
|
||||||
|
|
||||||
// Project
|
// Project
|
||||||
else if (MMeasure.MEASURETYPE_Project.equals(measure.getMeasureType()))
|
else if (MMeasure.MEASURETYPE_Project.equals(measure.getMeasureType()))
|
||||||
{
|
{
|
||||||
MProjectType pt = MProjectType.get(Env.getCtx(), measure.getC_ProjectType_ID());
|
MProjectType pt = MProjectType.get(Env.getCtx(), measure.getC_ProjectType_ID());
|
||||||
String sql = pt.getSqlBarChart(m_goal.getRestrictions(false),
|
String sql = pt.getSqlBarChart(m_goal.getRestrictions(false),
|
||||||
m_goal.getMeasureDisplay(), measure.getMeasureDataType(),
|
m_goal.getMeasureDisplay(), measure.getMeasureDataType(),
|
||||||
null, MRole.getDefault()); // logged in role
|
null, MRole.getDefault()); // logged in role
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
|
@ -293,7 +295,7 @@ public class BarGraph extends CPanel implements ChartMouseListener //, Component
|
||||||
rs = null; pstmt = null;
|
rs = null; pstmt = null;
|
||||||
}
|
}
|
||||||
} // Project
|
} // Project
|
||||||
|
|
||||||
// Add last 20
|
// Add last 20
|
||||||
int startValue = 0;
|
int startValue = 0;
|
||||||
//if (list.size() > 20) //TODO CHECK
|
//if (list.size() > 20) //TODO CHECK
|
||||||
|
@ -301,42 +303,42 @@ public class BarGraph extends CPanel implements ChartMouseListener //, Component
|
||||||
/*
|
/*
|
||||||
for (int i = startValue; i < list.size(); i++)
|
for (int i = startValue; i < list.size(); i++)
|
||||||
add (list.get(i));
|
add (list.get(i));
|
||||||
*/
|
*/
|
||||||
for (int i = startValue; i < list.size(); i++){
|
for (int i = startValue; i < list.size(); i++){
|
||||||
dataset.addValue(list.get(i).getValue(), list.get(i).getLabel(), list.get(i).getLabel());
|
dataset.addValue(list.get(i).getValue(), list.get(i).getLabel(), list.get(i).getLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the chart...
|
|
||||||
final JFreeChart chart = ChartFactory.createBarChart(
|
|
||||||
measure.getName(), // chart title
|
|
||||||
m_X_AxisLabel, // domain axis label
|
|
||||||
m_Y_AxisLabel, // range axis label
|
|
||||||
dataset, // data
|
|
||||||
PlotOrientation.VERTICAL, // orientation
|
|
||||||
false, // include legend
|
|
||||||
true, // tooltips?
|
|
||||||
true // URLs?
|
|
||||||
);
|
|
||||||
|
|
||||||
CategoryPlot plot = chart.getCategoryPlot();
|
// create the chart...
|
||||||
//plot.setBackgroundPaint(Color.lightGray); //GraphUtil.getForeground(getBackground())
|
final JFreeChart chart = ChartFactory.createBarChart(
|
||||||
BarRenderer renderer = (BarRenderer) plot.getRenderer();
|
measure.getName(), // chart title
|
||||||
chart.getCategoryPlot().setRenderer(renderer);
|
m_X_AxisLabel, // domain axis label
|
||||||
renderer.setSeriesPaint(0, new Color(92/255f, 178/255f, 232/255f));
|
m_Y_AxisLabel, // range axis label
|
||||||
renderer.setSeriesPaint(1, new Color(56/255f, 97/255f, 119/255f));
|
dataset, // data
|
||||||
renderer.setSeriesPaint(2, new Color(242/255f, 70/255f, 78/255f));
|
PlotOrientation.VERTICAL, // orientation
|
||||||
renderer.setSeriesPaint(3, Color.orange);
|
false, // include legend
|
||||||
renderer.setSeriesPaint(4, new Color(147/255f, 196/255f, 51/255f));
|
true, // tooltips?
|
||||||
renderer.setSeriesPaint(5, new Color(210/255f, 247/255f, 91/255f));
|
true // URLs?
|
||||||
renderer.setSeriesPaint(6, new Color(129/255f, 235/255f, 249/255f));
|
);
|
||||||
renderer.setSeriesPaint(7, new Color(60/255f, 84/255f, 8/255f));
|
|
||||||
renderer.setSeriesPaint(8, new Color(0.8f, 0.8f, 0.8f));
|
|
||||||
|
|
||||||
chartPanel = new ChartPanel(chart);
|
CategoryPlot plot = chart.getCategoryPlot();
|
||||||
chartPanel.setSize(getSize());
|
//plot.setBackgroundPaint(Color.lightGray); //GraphUtil.getForeground(getBackground())
|
||||||
chartPanel.addChartMouseListener(this);
|
BarRenderer renderer = (BarRenderer) plot.getRenderer();
|
||||||
add(chartPanel,BorderLayout.CENTER);
|
chart.getCategoryPlot().setRenderer(renderer);
|
||||||
this.setMinimumSize(paneldimension);
|
renderer.setSeriesPaint(0, new Color(92/255f, 178/255f, 232/255f));
|
||||||
|
renderer.setSeriesPaint(1, new Color(56/255f, 97/255f, 119/255f));
|
||||||
|
renderer.setSeriesPaint(2, new Color(242/255f, 70/255f, 78/255f));
|
||||||
|
renderer.setSeriesPaint(3, Color.orange);
|
||||||
|
renderer.setSeriesPaint(4, new Color(147/255f, 196/255f, 51/255f));
|
||||||
|
renderer.setSeriesPaint(5, new Color(210/255f, 247/255f, 91/255f));
|
||||||
|
renderer.setSeriesPaint(6, new Color(129/255f, 235/255f, 249/255f));
|
||||||
|
renderer.setSeriesPaint(7, new Color(60/255f, 84/255f, 8/255f));
|
||||||
|
renderer.setSeriesPaint(8, new Color(0.8f, 0.8f, 0.8f));
|
||||||
|
|
||||||
|
chartPanel = new ChartPanel(chart);
|
||||||
|
chartPanel.setSize(getSize());
|
||||||
|
chartPanel.addChartMouseListener(this);
|
||||||
|
add(chartPanel,BorderLayout.CENTER);
|
||||||
|
this.setMinimumSize(paneldimension);
|
||||||
} // loadData
|
} // loadData
|
||||||
private ChartPanel chartPanel;
|
private ChartPanel chartPanel;
|
||||||
/**
|
/**
|
||||||
|
@ -347,8 +349,8 @@ public class BarGraph extends CPanel implements ChartMouseListener //, Component
|
||||||
{
|
{
|
||||||
return m_point0_0;
|
return m_point0_0;
|
||||||
} // getPoint0_0
|
} // getPoint0_0
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the x_AxisLabel.
|
* @return Returns the x_AxisLabel.
|
||||||
*/
|
*/
|
||||||
|
@ -356,7 +358,7 @@ public class BarGraph extends CPanel implements ChartMouseListener //, Component
|
||||||
{
|
{
|
||||||
return m_X_AxisLabel;
|
return m_X_AxisLabel;
|
||||||
} // getX_AxisLabel
|
} // getX_AxisLabel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param axisLabel The x_AxisLabel to set.
|
* @param axisLabel The x_AxisLabel to set.
|
||||||
*/
|
*/
|
||||||
|
@ -372,7 +374,7 @@ public class BarGraph extends CPanel implements ChartMouseListener //, Component
|
||||||
{
|
{
|
||||||
return m_Y_AxisLabel;
|
return m_Y_AxisLabel;
|
||||||
} // getY_AxisLabel
|
} // getY_AxisLabel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param axisLabel The y_AxisLabel to set.
|
* @param axisLabel The y_AxisLabel to set.
|
||||||
*/
|
*/
|
||||||
|
@ -380,7 +382,7 @@ public class BarGraph extends CPanel implements ChartMouseListener //, Component
|
||||||
{
|
{
|
||||||
m_Y_AxisLabel = axisLabel;
|
m_Y_AxisLabel = axisLabel;
|
||||||
} // setY_AxisLabel
|
} // setY_AxisLabel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the y_TargetLabel.
|
* @return Returns the y_TargetLabel.
|
||||||
*/
|
*/
|
||||||
|
@ -388,7 +390,7 @@ public class BarGraph extends CPanel implements ChartMouseListener //, Component
|
||||||
{
|
{
|
||||||
return m_Y_TargetLabel;
|
return m_Y_TargetLabel;
|
||||||
} // getY_TargetLabel
|
} // getY_TargetLabel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param targetLabel The y_TargetLabel to set.
|
* @param targetLabel The y_TargetLabel to set.
|
||||||
*/
|
*/
|
||||||
|
@ -397,8 +399,8 @@ public class BarGraph extends CPanel implements ChartMouseListener //, Component
|
||||||
m_Y_TargetLabel = targetLabel;
|
m_Y_TargetLabel = targetLabel;
|
||||||
m_Y_Target = target;
|
m_Y_Target = target;
|
||||||
} // setY_TargetLabel
|
} // setY_TargetLabel
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add Column
|
* Add Column
|
||||||
* @param column column
|
* @param column column
|
||||||
|
@ -408,65 +410,65 @@ public class BarGraph extends CPanel implements ChartMouseListener //, Component
|
||||||
super.add (column, "column");
|
super.add (column, "column");
|
||||||
//column.addActionListener(this);
|
//column.addActionListener(this);
|
||||||
} // add
|
} // add
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Paint Component
|
* Paint Component
|
||||||
* @param g graphics
|
* @param g graphics
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void chartMouseClicked(ChartMouseEvent event){
|
public void chartMouseClicked(ChartMouseEvent event){
|
||||||
if ((event.getEntity()!=null) && (event.getTrigger().getClickCount() > 1)) {
|
if ((event.getEntity()!=null) && (event.getTrigger().getClickCount() > 1)) {
|
||||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||||
BarGraphColumn bgc = null;
|
BarGraphColumn bgc = null;
|
||||||
String eventUrl = event.getEntity().toString();
|
String eventUrl = event.getEntity().toString();
|
||||||
for (int i = 0; i < list.size(); i++){
|
for (int i = 0; i < list.size(); i++){
|
||||||
if ( eventUrl.substring(eventUrl.length() - list.get(i).getLabel().length()).equals(list.get(i).getLabel()))
|
if ( eventUrl.substring(eventUrl.length() - list.get(i).getLabel().length()).equals(list.get(i).getLabel()))
|
||||||
bgc = list.get(i);
|
bgc = list.get(i);
|
||||||
}
|
}
|
||||||
if (null==bgc) return;
|
if (null==bgc) return;
|
||||||
log.info(bgc.getName());
|
log.info(bgc.getName());
|
||||||
MQuery query = null;
|
MQuery query = null;
|
||||||
if (bgc.getAchievement() != null) // Single Achievement
|
if (bgc.getAchievement() != null) // Single Achievement
|
||||||
{
|
{
|
||||||
MAchievement a = bgc.getAchievement();
|
MAchievement a = bgc.getAchievement();
|
||||||
query = MQuery.getEqualQuery("PA_Measure_ID", a.getPA_Measure_ID());
|
query = MQuery.getEqualQuery("PA_Measure_ID", a.getPA_Measure_ID());
|
||||||
}
|
}
|
||||||
else if (bgc.getGoal() != null) // Multiple Achievements
|
else if (bgc.getGoal() != null) // Multiple Achievements
|
||||||
{
|
{
|
||||||
MGoal goal = bgc.getGoal();
|
MGoal goal = bgc.getGoal();
|
||||||
query = MQuery.getEqualQuery("PA_Measure_ID", goal.getPA_Measure_ID());
|
query = MQuery.getEqualQuery("PA_Measure_ID", goal.getPA_Measure_ID());
|
||||||
}
|
}
|
||||||
else if (bgc.getMeasureCalc() != null) // Document
|
else if (bgc.getMeasureCalc() != null) // Document
|
||||||
{
|
{
|
||||||
MMeasureCalc mc = bgc.getMeasureCalc();
|
MMeasureCalc mc = bgc.getMeasureCalc();
|
||||||
query = mc.getQuery(m_goal.getRestrictions(false),
|
query = mc.getQuery(m_goal.getRestrictions(false),
|
||||||
bgc.getMeasureDisplay(), bgc.getDate(),
|
bgc.getMeasureDisplay(), bgc.getDate(),
|
||||||
MRole.getDefault()); // logged in role
|
MRole.getDefault()); // logged in role
|
||||||
}
|
}
|
||||||
else if (bgc.getProjectType() != null) // Document
|
else if (bgc.getProjectType() != null) // Document
|
||||||
{
|
{
|
||||||
MProjectType pt = bgc.getProjectType();
|
MProjectType pt = bgc.getProjectType();
|
||||||
query = pt.getQuery(m_goal.getRestrictions(false),
|
query = pt.getQuery(m_goal.getRestrictions(false),
|
||||||
bgc.getMeasureDisplay(), bgc.getDate(), bgc.getID(),
|
bgc.getMeasureDisplay(), bgc.getDate(), bgc.getID(),
|
||||||
MRole.getDefault()); // logged in role
|
MRole.getDefault()); // logged in role
|
||||||
}
|
}
|
||||||
else if (bgc.getRequestType() != null) // Document
|
else if (bgc.getRequestType() != null) // Document
|
||||||
{
|
{
|
||||||
MRequestType rt = bgc.getRequestType();
|
MRequestType rt = bgc.getRequestType();
|
||||||
query = rt.getQuery(m_goal.getRestrictions(false),
|
query = rt.getQuery(m_goal.getRestrictions(false),
|
||||||
bgc.getMeasureDisplay(), bgc.getDate(), bgc.getID(),
|
bgc.getMeasureDisplay(), bgc.getDate(), bgc.getID(),
|
||||||
MRole.getDefault()); // logged in role
|
MRole.getDefault()); // logged in role
|
||||||
}
|
}
|
||||||
if (query != null)
|
if (query != null)
|
||||||
AEnv.zoom(query);
|
AEnv.zoom(query);
|
||||||
else
|
else
|
||||||
log.warning("Nothing to zoom to - " + bgc);
|
log.warning("Nothing to zoom to - " + bgc);
|
||||||
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chartMouseMoved(ChartMouseEvent event) {}
|
public void chartMouseMoved(ChartMouseEvent event) {}
|
||||||
|
|
||||||
public BarGraphColumn[] getBarGraphColumnList() {
|
public BarGraphColumn[] getBarGraphColumnList() {
|
||||||
BarGraphColumn[] array = new BarGraphColumn[list.size()];
|
BarGraphColumn[] array = new BarGraphColumn[list.size()];
|
||||||
|
@ -495,5 +497,5 @@ public class BarGraph extends CPanel implements ChartMouseListener //, Component
|
||||||
}
|
}
|
||||||
public void componentShown(ComponentEvent e) {
|
public void componentShown(ComponentEvent e) {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
} // BarGraph
|
} // BarGraph
|
||||||
|
|
Loading…
Reference in New Issue