1 23 24 package org.objectweb.fractal.gui.graph.control; 25 26 import org.objectweb.fractal.api.control.BindingController; 27 28 import org.objectweb.fractal.gui.graph.model.Display; 29 import org.objectweb.fractal.gui.graph.model.DisplayListener; 30 import org.objectweb.fractal.gui.graph.model.Rect; 31 import org.objectweb.fractal.swing.AbstractAction; 32 33 import java.awt.event.ActionEvent ; 34 import java.net.URL ; 35 36 import javax.swing.ImageIcon ; 37 import javax.swing.KeyStroke ; 38 39 44 45 public class ChangeDepthAction extends AbstractAction implements 46 DisplayListener, 47 BindingController, 48 ChangeDepthActionAttributes 49 { 50 51 55 56 public final static String DISPLAY_BINDING = "display"; 57 58 61 62 private Display display; 63 64 68 69 private boolean increase; 70 71 74 75 public ChangeDepthAction () { 76 URL url = getClass().getResource( 77 "/org/objectweb/fractal/gui/resources/empty.gif"); 78 putValue(SMALL_ICON, new ImageIcon (url)); 79 } 80 81 85 public String [] listFc () { 86 return new String [] { DISPLAY_BINDING }; 87 } 88 89 public Object lookupFc (final String clientItfName) { 90 if (DISPLAY_BINDING.equals(clientItfName)) { 91 return display; 92 } 93 return null; 94 } 95 96 public void bindFc ( 97 final String clientItfName, 98 final Object serverItf) 99 { 100 if (DISPLAY_BINDING.equals(clientItfName)) { 101 display = (Display)serverItf; 102 } 103 } 104 105 public void unbindFc (final String clientItfName) { 106 if (DISPLAY_BINDING.equals(clientItfName)) { 107 display = null; 108 } 109 } 110 111 115 public boolean getIsIncrease () { 116 return increase; 117 } 118 119 public void setIsIncrease (final boolean isIncrease) { 120 increase = isIncrease; 121 if (increase) { 122 putValue(NAME, "Increase depth"); 123 putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("alt I")); 124 } else { 125 putValue(NAME, "Decrease depth"); 126 putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("alt D")); 127 } 128 } 129 130 134 public void displayedAreaChanged (final Rect oldValue) { 135 } 137 138 public void antialiasingChanged () { 139 } 141 142 public void maxDepthChanged () { 143 if (!increase) { 144 setEnabled(display.getMaxDepth() > 0); 145 } 146 } 147 148 public void itfNameDisplayModeChanged () { 149 } 151 152 156 public void actionPerformed (final ActionEvent e) { 157 if (increase) { 158 display.setMaxDepth(display.getMaxDepth() + 1); 159 } else { 160 display.setMaxDepth(display.getMaxDepth() - 1); 161 } 162 } 163 } 164 | Popular Tags |