KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > gulden > framework > amoda > environment > gui > behaviour > CommandExportView


1 /*
2  * Project: AMODA - Abstract Modeled Application
3  * Class: de.gulden.framework.amoda.environment.gui.behaviour.CommandExportView
4  * Version: snapshot-beautyj-1.1
5  *
6  * Date: 2004-09-29
7  *
8  * This is a snapshot version of the AMODA 0.2 development branch,
9  * it is not released as a seperate version.
10  * For AMODA, see http://amoda.berlios.de/.
11  *
12  * This is licensed under the GNU Lesser General Public License (LGPL)
13  * and comes with NO WARRANTY.
14  *
15  * Author: Jens Gulden
16  * Email: amoda@jensgulden.de
17  */

18
19 package de.gulden.framework.amoda.environment.gui.behaviour;
20
21 import de.gulden.framework.amoda.generic.behaviour.GenericCommand;
22 import java.util.*;
23
24 /**
25  * Class CommandExportView.
26  *
27  * @author Jens Gulden
28  * @version snapshot-beautyj-1.1
29  */

30 public class CommandExportView extends GenericCommand {
31
32     // ------------------------------------------------------------------------
33
// --- method ---
34
// ------------------------------------------------------------------------
35

36     public void perform() {
37         de.gulden.framework.amoda.model.document.DocumentView view=getApplication().getWorkspace().getActiveView();
38         if (view!=null) {
39             getApplication().message("*** TO DO ***");
40         /*
41         FileDialogGraphicExport fileDialogGraphicExport=getWorkspace().getEditor().getFileDialogGraphicExport();
42         File file=fileDialogGraphicExport.ask();
43         String suffix=fileDialogGraphicExport.filterSuffix();
44         if (file!=null) {
45           if (suffix!=null) {
46               try {
47                   FileOutputStream out=new FileOutputStream(file);
48                   // create offline image buffer
49
50                   //changed by brieger
51                   //Breite aller visible Actors bestimmen, um das zu exportierende Bild dementsprechend gross zu machen
52                   int width = 0;
53                   Vector actors = visibleWorkflowModel.getVisibleActors();
54                   for (int i=0; i<actors.size(); i++) {
55                     width = width + ((VisibleActor)actors.elementAt(i)).getWidth();
56                   }
57
58                   Image image=panel.createImage(width, panel.getHeight());
59                   // and paint model on it
60                   getVisibleWorkflowModel().paintNoGrid(image.getGraphics());
61                   ParameterBlock pb = new ParameterBlock();
62                   pb.add(image);
63                   PlanarImage img = (PlanarImage)JAI.create("awtImage", pb);
64                   if ( "gif".equalsIgnoreCase(suffix) ) {
65                     GifEncoder encoder = new GifEncoder(image, out);
66                     encoder.encode();
67                   }
68                   else if ( "jpg".equalsIgnoreCase(suffix))
69                     JAI.create("encode", img, out, "JPEG", null);
70                   else if ( "bmp".equalsIgnoreCase(suffix))
71                     JAI.create("encode", img, out, "BMP", null);
72                   else if ( "tif".equalsIgnoreCase(suffix))
73                     JAI.create("encode", img, out, "TIFF", null);
74                   else if ( "png".equalsIgnoreCase(suffix))
75                     JAI.create("encode", img, out, "PNG", null);
76                   out.flush();
77                   out.close();
78                 }
79                 catch (Exception e) {
80                     getWorkspace().getEditor().error("Fehler beim Grafik-Export: "+e.getMessage());
81                 }
82           } else {
83               getWorkspace().getEditor().error("Fehler beim Exportieren: Kein Dateityp gew?hlt.");
84           }
85         }
86         */

87
88         } else {
89             getApplication().message("This requires a currently selected document view.");
90         }
91     }
92
93 } // end CommandExportView
94
Popular Tags