1 23 24 package org.objectweb.fractal.gui.menu.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.model.Component; 30 import org.objectweb.fractal.gui.model.Configuration; 31 import org.objectweb.fractal.gui.graph.view.Printer; 32 import org.objectweb.fractal.gui.selection.model.Selection; 33 import org.objectweb.fractal.swing.AbstractAction; 34 35 import java.awt.event.ActionEvent ; 36 import java.net.URL ; 37 38 import javax.swing.ImageIcon ; 39 import javax.swing.KeyStroke ; 40 41 44 45 public class ExportSVGAction extends AbstractAction implements 46 BindingController 47 { 48 49 public final static String CONFIGURATION_BINDING = "configuration"; 50 51 public final static String SELECTION_BINDING = "selection"; 52 53 public final static String DISPLAY_BINDING = "display"; 54 55 public final static String PRINT_BINDING = "print"; 56 57 private Configuration configuration; 58 59 private Selection selection; 60 61 private Display display; 62 63 private Printer printer; 64 65 68 69 public ExportSVGAction () { 70 putValue(NAME, "ExportSVG"); 71 putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("control 2")); 72 putValue(SHORT_DESCRIPTION, "Export to SVG"); 73 URL url = getClass().getResource( 74 "/org/objectweb/fractal/gui/resources/export.gif"); 75 putValue(SMALL_ICON, new ImageIcon (url)); 76 setEnabled(true); 77 } 78 79 83 public String [] listFc () { 84 return new String [] { 85 CONFIGURATION_BINDING, 86 SELECTION_BINDING, 87 DISPLAY_BINDING, 88 PRINT_BINDING 89 }; 90 } 91 92 public Object lookupFc (final String clientItfName) { 93 if (CONFIGURATION_BINDING.equals(clientItfName)) { 94 return configuration; 95 } else if (SELECTION_BINDING.equals(clientItfName)) { 96 return selection; 97 } else if (DISPLAY_BINDING.equals(clientItfName)) { 98 return display; 99 } else if (PRINT_BINDING.equals(clientItfName)) { 100 return printer; 101 } 102 return null; 103 } 104 105 public void bindFc (final String clientItfName, final Object serverItf) { 106 if (CONFIGURATION_BINDING.equals(clientItfName)) { 107 configuration = (Configuration)serverItf; 108 } else if (SELECTION_BINDING.equals(clientItfName)) { 109 selection = (Selection)serverItf; 110 } else if (DISPLAY_BINDING.equals(clientItfName)) { 111 display = (Display)serverItf; 112 } else if (PRINT_BINDING.equals(clientItfName)) { 113 printer = (Printer)serverItf; 114 } 115 } 116 117 public void unbindFc (final String clientItfName) { 118 if (CONFIGURATION_BINDING.equals(clientItfName)) { 119 configuration = null; 120 } else if (SELECTION_BINDING.equals(clientItfName)) { 121 selection = null; 122 } else if (DISPLAY_BINDING.equals(clientItfName)) { 123 display = null; 124 } else if (PRINT_BINDING.equals(clientItfName)) { 125 printer = null; 126 } 127 } 128 129 133 public void actionPerformed (final ActionEvent e) { 134 Object o = selection.getSelection(); 135 if (o instanceof Component) { 136 Component c = (Component)o; 137 printer.setType(Printer.TYPE_EXPORT); 138 printer.print(true, c); 139 } 140 } 141 } 142 | Popular Tags |