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.ChartMouseListener;
|
||||||
import org.jfree.chart.ChartPanel;
|
import org.jfree.chart.ChartPanel;
|
||||||
import org.jfree.chart.JFreeChart;
|
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.CategoryPlot;
|
||||||
import org.jfree.chart.plot.PlotOrientation;
|
import org.jfree.chart.plot.PlotOrientation;
|
||||||
import org.jfree.chart.renderer.category.BarRenderer;
|
import org.jfree.chart.renderer.category.BarRenderer;
|
||||||
|
@ -57,6 +59,9 @@ 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 $
|
||||||
|
*
|
||||||
|
* @author Teo Sarca, www.arhipac.ro
|
||||||
|
* <li>BF [ 2507325 ] BarGraph zoom not working
|
||||||
*/
|
*/
|
||||||
public class BarGraph extends CPanel implements ChartMouseListener
|
public class BarGraph extends CPanel implements ChartMouseListener
|
||||||
{
|
{
|
||||||
|
@ -411,22 +416,51 @@ public class BarGraph extends CPanel implements ChartMouseListener
|
||||||
//column.addActionListener(this);
|
//column.addActionListener(this);
|
||||||
} // add
|
} // add
|
||||||
|
|
||||||
|
/**
|
||||||
/**************************************************************************
|
* Get BarGraphColumn for ChartEntity
|
||||||
* Paint Component
|
* @param event
|
||||||
* @param g graphics
|
* @return BarGraphColumn or null if not found
|
||||||
*/
|
*/
|
||||||
|
private BarGraphColumn getBarGraphColumn(ChartMouseEvent event)
|
||||||
public void chartMouseClicked(ChartMouseEvent event){
|
{
|
||||||
if ((event.getEntity()!=null) && (event.getTrigger().getClickCount() > 1)) {
|
ChartEntity entity = event.getEntity();
|
||||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
String key = null;
|
||||||
BarGraphColumn bgc = null;
|
if (entity instanceof CategoryItemEntity)
|
||||||
String eventUrl = event.getEntity().toString();
|
{
|
||||||
for (int i = 0; i < list.size(); i++){
|
Comparable<?> rowKey = ((CategoryItemEntity)entity).getRowKey();
|
||||||
if ( eventUrl.substring(eventUrl.length() - list.get(i).getLabel().length()).equals(list.get(i).getLabel()))
|
if (rowKey != null)
|
||||||
bgc = list.get(i);
|
{
|
||||||
|
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());
|
log.info(bgc.getName());
|
||||||
MQuery query = null;
|
MQuery query = null;
|
||||||
if (bgc.getAchievement() != null) // Single Achievement
|
if (bgc.getAchievement() != null) // Single Achievement
|
||||||
|
@ -464,38 +498,20 @@ public class BarGraph extends CPanel implements ChartMouseListener
|
||||||
AEnv.zoom(query);
|
AEnv.zoom(query);
|
||||||
else
|
else
|
||||||
log.warning("Nothing to zoom to - " + bgc);
|
log.warning("Nothing to zoom to - " + bgc);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
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 chartMouseMoved(ChartMouseEvent event)
|
||||||
public void componentHidden(ComponentEvent e) {
|
{
|
||||||
}
|
}
|
||||||
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
|
} // BarGraph
|
||||||
|
|
Loading…
Reference in New Issue