Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r4888 - branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels

Subject: perfsonar development work

List archive

perfsonar: r4888 - branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r4888 - branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels
  • Date: Sat, 17 Jan 2009 06:26:25 -0500

Author: nina
Date: 2009-01-17 06:26:25 -0500 (Sat, 17 Jan 2009)
New Revision: 4888

Modified:

branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels/ResponseChartPanel.java
Log:
allow zooming by mouse wheel for all charts

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels/ResponseChartPanel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels/ResponseChartPanel.java
2009-01-17 11:25:32 UTC (rev 4887)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels/ResponseChartPanel.java
2009-01-17 11:26:25 UTC (rev 4888)
@@ -27,6 +27,8 @@
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.LayoutManager;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.BreakIterator;
@@ -37,6 +39,7 @@
import java.util.ResourceBundle;

import javax.swing.AbstractAction;
+import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
@@ -131,6 +134,7 @@
chart = createChart(psModel,ifDataset.getDatasets());
chart.setAntiAlias(true);
chartPanel = new ChartPanel(chart);
+ addListener(chartPanel);

chartPanel.setDomainZoomable(true);
chartPanel.setRangeZoomable(false);
@@ -217,5 +221,37 @@
this.title = title;
chart.setTitle(title);
}
+
+ public void addListener(ChartPanel chartPanel) {
+ chartPanel.addMouseWheelListener(new MouseWheelListener() {

+ public void mouseWheelMoved(MouseWheelEvent e) {
+ if (e.getScrollType() !=
MouseWheelEvent.WHEEL_UNIT_SCROLL) return;
+ if (e.getWheelRotation()< 0)
increaseZoom((ChartPanel)e.getComponent(), true);
+ else
decreaseZoom((ChartPanel)e.getComponent(), true);
+ }
+
+ public synchronized void increaseZoom(JComponent chart,
boolean saveAction){
+ ChartPanel ch = (ChartPanel)chart;
+ zoomChartAxis(ch, true);
+ }
+
+ public synchronized void decreaseZoom(JComponent chart,
boolean saveAction){
+ ChartPanel ch = (ChartPanel)chart;
+ zoomChartAxis(ch, false);
+ }
+
+ private void zoomChartAxis(ChartPanel chartP, boolean
increase){
+ int width = chartP.getMaximumDrawWidth() -
chartP.getMinimumDrawWidth();
+ int height = chartP.getMaximumDrawHeight() -
chartP.getMinimumDrawWidth();
+ if(increase){
+ chartP.zoomInBoth(width/2, height/2);
+ }else{
+ chartP.zoomOutBoth(width/2, height/2);
+ }
+
+ }
+ });
+ }
+
}



  • perfsonar: r4888 - branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels, svnlog, 01/17/2009

Archive powered by MHonArc 2.6.16.

Top of Page