Commit a8ecae0a authored by Antoine's avatar Antoine

Added ComponentListener to DefaultView

parent 7c742914
......@@ -36,6 +36,7 @@ import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.awt.event.ComponentListener;
import java.util.ArrayList;
import javax.swing.JFrame;
......@@ -100,7 +101,7 @@ import org.graphstream.ui.swingViewer.util.ShortcutManager;
* graph attribute is the identifier of the view.
* </p>
*/
public class DefaultView extends View implements WindowListener
public class DefaultView extends View implements WindowListener, ComponentListener
{
private static final long serialVersionUID = - 4489484861592064398L;
......@@ -218,12 +219,14 @@ public class DefaultView extends View implements WindowListener
frame.setSize(800, 600);
frame.setVisible(true);
frame.addWindowListener(this);
frame.addComponentListener(this);
frame.addKeyListener(shortcuts);
} else {
frame.setVisible(true);
}
} else {
if (frame != null) {
frame.removeComponentListener(this);
frame.removeWindowListener(this);
frame.removeKeyListener(shortcuts);
frame.remove(this);
......@@ -308,6 +311,23 @@ public class DefaultView extends View implements WindowListener
graph.removeAttribute("ui.viewClosed");
}
void componentHidden(ComponentEvent e) {
repaint();
}
void componentMoved(ComponentEvent e) {
repaint();
}
void componentResized(ComponentEvent e) {
repaint();
}
void componentShown(ComponentEvent e) {
repaint();
}
// Methods deferred to the renderer
@Override
......
......@@ -333,6 +333,8 @@ public class GraphMetrics {
ratioPx2Gu = ratio;
px1 = 0.95f / ratioPx2Gu;
}
else if(ratio == 0) throw new RuntimeException("ratio PX to GU cannot be zero");
else if(ratio < 0) throw new RuntimeException(String.format("ratio PX to GU cannot be negative (%f)",ratio)) ;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment