BF [ 2507325 ] BarGraph zoom not working
https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2507325&group_id=176962
This commit is contained in:
parent
f15351e309
commit
3277f5967c
|
@ -47,6 +47,8 @@ import org.jfree.chart.ChartMouseEvent;
|
|||
import org.jfree.chart.ChartMouseListener;
|
||||
import org.jfree.chart.ChartPanel;
|
||||
import org.jfree.chart.JFreeChart;
|
||||
import org.jfree.chart.entity.CategoryItemEntity;
|
||||
import org.jfree.chart.entity.ChartEntity;
|
||||
import org.jfree.chart.plot.CategoryPlot;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.chart.renderer.category.BarRenderer;
|
||||
|
@ -57,6 +59,9 @@ import org.jfree.data.category.DefaultCategoryDataset;
|
|||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: BarGraph.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||
*
|
||||
* @author Teo Sarca, www.arhipac.ro
|
||||
* <li>BF [ 2507325 ] BarGraph zoom not working
|
||||
*/
|
||||
public class BarGraph extends CPanel implements ChartMouseListener
|
||||
{
|
||||
|
@ -411,22 +416,51 @@ public class BarGraph extends CPanel implements ChartMouseListener
|
|||
//column.addActionListener(this);
|
||||
} // add
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Paint Component
|
||||
* @param g graphics
|
||||
/**
|
||||
* Get BarGraphColumn for ChartEntity
|
||||
* @param event
|
||||
* @return BarGraphColumn or null if not found
|
||||
*/
|
||||
|
||||
public void chartMouseClicked(ChartMouseEvent event){
|
||||
if ((event.getEntity()!=null) && (event.getTrigger().getClickCount() > 1)) {
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
BarGraphColumn bgc = null;
|
||||
String eventUrl = event.getEntity().toString();
|
||||
for (int i = 0; i < list.size(); i++){
|
||||
if ( eventUrl.substring(eventUrl.length() - list.get(i).getLabel().length()).equals(list.get(i).getLabel()))
|
||||
bgc = list.get(i);
|
||||
private BarGraphColumn getBarGraphColumn(ChartMouseEvent event)
|
||||
{
|
||||
ChartEntity entity = event.getEntity();
|
||||
String key = null;
|
||||
if (entity instanceof CategoryItemEntity)
|
||||
{
|
||||
Comparable<?> rowKey = ((CategoryItemEntity)entity).getRowKey();
|
||||
if (rowKey != null)
|
||||
{
|
||||
key = rowKey.toString();
|
||||
}
|
||||
}
|
||||
if (key == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < list.size(); i++)
|
||||
{
|
||||
final String label = list.get(i).getLabel();
|
||||
if (key.equals(label))
|
||||
{
|
||||
return list.get(i);
|
||||
}
|
||||
}
|
||||
//
|
||||
return null;
|
||||
}
|
||||
|
||||
public void chartMouseClicked(ChartMouseEvent event)
|
||||
{
|
||||
if ((event.getEntity()!=null) && (event.getTrigger().getClickCount() > 1))
|
||||
{
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
try
|
||||
{
|
||||
BarGraphColumn bgc = getBarGraphColumn(event);
|
||||
if (bgc == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (null==bgc) return;
|
||||
log.info(bgc.getName());
|
||||
MQuery query = null;
|
||||
if (bgc.getAchievement() != null) // Single Achievement
|
||||
|
@ -464,38 +498,20 @@ public class BarGraph extends CPanel implements ChartMouseListener
|
|||
AEnv.zoom(query);
|
||||
else
|
||||
log.warning("Nothing to zoom to - " + bgc);
|
||||
}
|
||||
finally
|
||||
{
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
|
||||
public void chartMouseMoved(ChartMouseEvent event) {}
|
||||
|
||||
public BarGraphColumn[] getBarGraphColumnList() {
|
||||
BarGraphColumn[] array = new BarGraphColumn[list.size()];
|
||||
for (int i = 0; i < list.size(); i++){
|
||||
array[i] = list.get(i);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
/*
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
public void chartMouseMoved(ChartMouseEvent event)
|
||||
{
|
||||
}
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
|
||||
public BarGraphColumn[] getBarGraphColumnList()
|
||||
{
|
||||
return list.toArray(new BarGraphColumn[list.size()]);
|
||||
}
|
||||
public void componentResized(ComponentEvent e) {
|
||||
float aspectRatio = 1.6f;
|
||||
Dimension size = getSize();
|
||||
if (size.width > size.height * aspectRatio)
|
||||
chartPanel.setSize( new Dimension(
|
||||
java.lang.Math.round(size.height*aspectRatio),
|
||||
size.height));
|
||||
else
|
||||
chartPanel.setSize(new Dimension(
|
||||
size.width,
|
||||
java.lang.Math.round(size.width / aspectRatio)));
|
||||
}
|
||||
public void componentShown(ComponentEvent e) {
|
||||
}
|
||||
*/
|
||||
} // BarGraph
|
||||
|
|
Loading…
Reference in New Issue