Revision 469

View differences:

tags/org.gvsig.app.document.layout2.app-2.0.62/org.gvsig.app.document.layout2.app.mainplugin/buildNumber.properties
1
#Sun Dec 06 21:24:33 CET 2015
2
buildNumber=81
0 3

  
tags/org.gvsig.app.document.layout2.app-2.0.62/org.gvsig.app.document.layout2.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml
1
<assembly>
2
  <id>gvsig-plugin-package</id>
3
  <formats>
4
    <format>zip</format>
5
  </formats>
6
  <baseDirectory>${project.artifactId}</baseDirectory>
7
  <includeBaseDirectory>true</includeBaseDirectory>
8
  <files>
9
    <file>
10
      <source>target/${project.artifactId}-${project.version}.jar</source>
11
      <outputDirectory>lib</outputDirectory>
12
    </file>
13
    <file>
14
      <source>target/package.info</source>
15
    </file>
16
  </files>
17

  
18
  <fileSets>
19
    <fileSet>
20
      <directory>src/main/resources-plugin</directory>
21
      <outputDirectory>.</outputDirectory>
22
    </fileSet>
23
  </fileSets>
24

  
25
  <dependencySets>
26
  
27
  <!--
28
    <dependencySet>
29
      <useProjectArtifact>false</useProjectArtifact>
30
      <useTransitiveDependencies>false</useTransitiveDependencies>
31
      <outputDirectory>lib</outputDirectory>
32
      <includes>
33
      </includes>
34
    </dependencySet>
35
    
36
    -->
37
    
38
  </dependencySets>
39

  
40
</assembly>
0 41

  
tags/org.gvsig.app.document.layout2.app-2.0.62/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/math/intervals/IntervalUtils.java
1
package org.gvsig.math.intervals;
2

  
3
public class IntervalUtils {
4

  
5
	/**
6
	 * Calculates an nice round interval division. For instance, for
7
	 * intervalLenght = 1100000 and numberOfDivisions=5,
8
	 * the result would be 250000.
9
	 * 
10
	 * @param intervalLength The full interval to be divided
11
	 * @param numberOfDivisions The exact number of divisions to perform
12
	 * @return A nice round interval division. The calculated result
13
	 * ensures that the whole interval length is covered by the proposed
14
	 * division, so it always fulfills the following formula:
15
	 *  <code>result*numberOfDivisions>=intervalLength</code>
16
	 */
17
	public static double roundIntervalDivision(double intervalLength, int numberOfDivisions) {
18
		if (intervalLength<=0.0d || numberOfDivisions<=0) {
19
			return 0.0d;
20
		}
21

  
22
		double division = intervalLength/numberOfDivisions;
23
		if (division==0.0d) {
24
			return 0.0d;
25
		}
26
		double digitShift = Math.floor((Math.log10(division)));
27
		double scale = Math.pow(10, -digitShift);
28
		double firstSignificatDigit = Math.floor(scale*division);
29
		double result = firstSignificatDigit*Math.pow(10, digitShift);
30
		if (result*numberOfDivisions>=intervalLength) {
31
			return result;
32
		}
33
		else {
34
			result = (0.5+firstSignificatDigit)*Math.pow(10, digitShift);
35
			if (result*numberOfDivisions>=intervalLength) {
36
				return result;
37
			}
38
		}
39
		result = (1+firstSignificatDigit)*Math.pow(10, digitShift);
40
		return result;
41
	}
42
}
tags/org.gvsig.app.document.layout2.app-2.0.62/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutInsertOverViewExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.extension;
23

  
24
import org.gvsig.andami.PluginServices;
25
import org.gvsig.andami.plugins.Extension;
26
import org.gvsig.andami.ui.mdiManager.IWindow;
27
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
28

  
29
/**
30
 * Extensi?n para insertar un localizador sobre el Layout.
31
 * 
32
 * @author Vicente Caballero Navarro
33
 */
34
public class LayoutInsertOverViewExtension extends Extension {
35

  
36
    private LayoutPanel layout = null;
37

  
38
    public void initialize() {
39
        // TODO Auto-generated method stub
40
    }
41

  
42
    public void execute(String s) {
43
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
44

  
45
        if (s.equals("layout-insert-locator")) {
46
            layout.getLayoutControl().setTool("layoutaddoverview");
47
        }
48
    }
49

  
50
    public boolean isEnabled() {
51
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
52

  
53
        if (f == null) {
54
            return false;
55
        }
56

  
57
        if (f instanceof LayoutPanel) {
58
            return ((LayoutPanel) f).getLayoutContext().isEditable();
59
        }
60

  
61
        return false;
62
    }
63

  
64
    public boolean isVisible() {
65
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
66

  
67
        if (f == null) {
68
            return false;
69
        }
70

  
71
        if (f instanceof LayoutPanel) {
72
            return true;
73
        } else {
74
            return false;
75
        }
76
    }
77
}
tags/org.gvsig.app.document.layout2.app-2.0.62/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/FFrameViewPanExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.extension;
23

  
24
import javax.swing.JOptionPane;
25

  
26
import org.gvsig.andami.PluginServices;
27
import org.gvsig.andami.PluginsLocator;
28
import org.gvsig.andami.PluginsManager;
29
import org.gvsig.andami.actioninfo.ActionInfoManager;
30
import org.gvsig.andami.messages.NotificationManager;
31
import org.gvsig.andami.plugins.Extension;
32
import org.gvsig.andami.ui.mdiManager.IWindow;
33
import org.gvsig.app.ApplicationLocator;
34
import org.gvsig.app.ApplicationManager;
35
import org.gvsig.app.project.documents.layout.LayoutDocument;
36
import org.gvsig.app.project.documents.layout.fframes.FFrameOverView;
37
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap;
38
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
39
import org.gvsig.fmap.dal.exception.ReadException;
40
import org.gvsig.tools.ToolsLocator;
41
import org.gvsig.tools.dataTypes.DataTypes;
42
import org.slf4j.Logger;
43
import org.slf4j.LoggerFactory;
44

  
45
/**
46
 * Extensi?n preparada para controlar las opciones que se pueden realizar sobre
47
 * una vista a?adida en el Layout.
48
 * 
49
 * @author Vicente Caballero Navarro
50
 */
51
public class FFrameViewPanExtension extends Extension {
52

  
53
    private LayoutPanel layout = null;
54
    private static Logger logger = LoggerFactory.getLogger(FFrameViewPanExtension.class);
55

  
56
    /**
57
     * @see org.gvsig.andami.plugins.IExtension#initialize()
58
     */
59
    public void initialize() {
60
    	
61
    }
62
    
63
    /**
64
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
65
     */
66
    public void execute(String s) {
67
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
68
        if (s.compareTo("layout-view-navigation-pan") == 0) {
69
        	layout.getLayoutControl().setTool("layoutviewpan");
70
        	layout.getDocument().setModified(true);
71
        }
72
    }
73
    
74

  
75
    /**
76
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
77
     */
78
    public boolean isEnabled() {
79
    	IWindow window = PluginServices.getMDIManager().getActiveWindow();
80
    	if (window instanceof LayoutPanel) {
81
    		LayoutPanel l =
82
    				(LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
83
    		if (!l.getLayoutContext().isEditable()) {
84
    			return false;
85
    		}
86
    		IFFrameUseFMap[] fframes = l.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class);
87
    		if (fframes.length==1 && !(fframes[0] instanceof FFrameOverView)) {
88
    			IFFrameUseFMap fframeview = (IFFrameUseFMap) fframes[0];
89
    			if (fframeview.getScaleType()==IFFrameUseFMap.SCALE_TYPE.NORMAL
90
    					|| fframeview.getScaleType()==IFFrameUseFMap.SCALE_TYPE.FIXED_SCALE) {
91
    				return true;
92
    			}
93
    		}
94
    	}
95
    	return false;
96
    }
97

  
98
    /**
99
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
100
     */
101
    public boolean isVisible() {
102
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
103
        if (f == null) {
104
            return false;
105
        }
106
        if (f instanceof LayoutPanel) {
107
            return true;
108
        } else {
109
            return false;
110
        }
111
    }
112
}
tags/org.gvsig.app.document.layout2.app-2.0.62/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/FFrameViewExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.extension;
23

  
24
import javax.swing.JOptionPane;
25

  
26
import org.gvsig.andami.PluginServices;
27
import org.gvsig.andami.PluginsLocator;
28
import org.gvsig.andami.PluginsManager;
29
import org.gvsig.andami.actioninfo.ActionInfoManager;
30
import org.gvsig.andami.messages.NotificationManager;
31
import org.gvsig.andami.plugins.Extension;
32
import org.gvsig.andami.ui.mdiManager.IWindow;
33
import org.gvsig.app.ApplicationLocator;
34
import org.gvsig.app.ApplicationManager;
35
import org.gvsig.app.project.documents.layout.LayoutDocument;
36
import org.gvsig.app.project.documents.layout.fframes.FFrameOverView;
37
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap;
38
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
39
import org.gvsig.fmap.dal.exception.ReadException;
40
import org.gvsig.tools.ToolsLocator;
41
import org.gvsig.tools.dataTypes.DataTypes;
42
import org.slf4j.Logger;
43
import org.slf4j.LoggerFactory;
44

  
45
/**
46
 * Extensi?n preparada para controlar las opciones que se pueden realizar sobre
47
 * una vista a?adida en el Layout.
48
 * 
49
 * @author Vicente Caballero Navarro
50
 */
51
public class FFrameViewExtension extends Extension {
52

  
53
    private static Logger logger = LoggerFactory.getLogger(FFrameViewExtension.class);
54

  
55
    /**
56
     * @see org.gvsig.andami.plugins.IExtension#initialize()
57
     */
58
    public void initialize() {
59
    	
60
    }
61

  
62
    /**
63
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String, Object[])
64
     */
65
    public void execute(String command, Object[] args) {
66
    	if (command.endsWith("view-change-scale")) {
67
    		ApplicationManager manager = ApplicationLocator.getManager();
68
    		IWindow window = manager.getActiveWindow();
69
    		if (!(window instanceof LayoutPanel)) {
70
    			return;
71
    		}
72
    		LayoutPanel layout = (LayoutPanel) window;
73
    		try {
74
    			if (args.length>0) {
75
    				Long scale = (Long) ToolsLocator.getDataTypesManager().coerce(DataTypes.LONG, args[0]);
76
    				if (layout!=null &&
77
    						layout.getLayoutControl()!=null &&
78
    						layout.getLayoutControl().getLayoutFunctions()!=null) {
79
    					layout.getLayoutControl().getLayoutFunctions().setScale(scale);
80
    				}
81
    			}
82
    		} catch (Throwable ex) {
83
    			logger.info("Can't change scale of view.", ex);
84
    			ApplicationLocator.getManager().message("Can't change scale of view.", JOptionPane.ERROR_MESSAGE);
85
    		}
86
    	}
87
    	else {
88
    		execute(command);	
89
    	}
90
    }
91
    
92
    /**
93
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
94
     */
95
    public void execute(String s) {
96
        LayoutPanel layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
97

  
98
        if (s.compareTo("layout-view-navigation-zoom-in-topoint") == 0) {
99
        	layout.getLayoutControl().setTool("layoutviewzoomin");
100
        } else if (s.compareTo("layout-view-navigation-zoom-out-topoint") == 0) {
101
        	layout.getLayoutControl().setTool("layoutviewzoomout");
102
        } else if (s.compareTo("layout-view-navigation-zoom-all") == 0) {
103
        	try {
104
        		layout.getLayoutControl().viewFull();
105
        	} catch (ReadException e) {
106
        		NotificationManager.addError("Error de Driver", e);
107
        	}
108
        }
109
        else {
110
        	return;
111
        }
112
        layout.getDocument().setModified(true);
113
    }
114
    
115

  
116
    /**
117
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
118
     */
119
    public boolean isEnabled() {
120
    	IWindow window = PluginServices.getMDIManager().getActiveWindow();
121
    	if (window instanceof LayoutPanel) {
122
    		LayoutPanel l =
123
    				(LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
124
    		if (!l.getLayoutContext().isEditable()) {
125
    			return false;
126
    		}
127
    		IFFrameUseFMap[] fframes = l.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class);
128
    		if (fframes.length==1 && !(fframes[0] instanceof FFrameOverView)) {
129
    			IFFrameUseFMap fframeview = (IFFrameUseFMap) fframes[0];
130
    			if (fframeview.getScaleType()==IFFrameUseFMap.SCALE_TYPE.NORMAL) {
131
    				return true;
132
    			}
133
    		}
134
    	}
135
    	return false;
136
    }
137

  
138
    /**
139
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
140
     */
141
    public boolean isVisible() {
142
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
143

  
144
        if (f == null) {
145
            return false;
146
        }
147

  
148
        if (f instanceof LayoutPanel) {
149
            return true;
150
        } else {
151
            return false;
152
        }
153
    }
154
}
tags/org.gvsig.app.document.layout2.app-2.0.62/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutEditableControls.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.extension;
23

  
24
import java.awt.event.KeyEvent;
25

  
26
import javax.swing.KeyStroke;
27

  
28
import org.gvsig.andami.PluginServices;
29
import org.gvsig.andami.plugins.Extension;
30
import org.gvsig.andami.ui.mdiManager.IWindow;
31
import org.gvsig.app.project.documents.layout.LayoutKeyEvent;
32
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
33

  
34
/**
35
 * Extensi?n para controlar las operaciones basicas de edici?n sobre el Layout.
36
 * 
37
 * @author Vicente Caballero Navarro
38
 */
39
public class LayoutEditableControls extends Extension {
40

  
41
    private static LayoutKeyEvent lke = new LayoutKeyEvent();
42
    private static KeyStroke copyLayout = KeyStroke.getKeyStroke(KeyEvent.VK_C,
43
        KeyEvent.CTRL_MASK);
44
    private static KeyStroke cutLayout = KeyStroke.getKeyStroke(KeyEvent.VK_X,
45
        KeyEvent.CTRL_MASK);
46
    private static KeyStroke pasteLayout = KeyStroke.getKeyStroke(
47
        KeyEvent.VK_V, KeyEvent.CTRL_MASK);
48
    private static KeyStroke leftLayout = KeyStroke.getKeyStroke(
49
        KeyEvent.VK_LEFT, 0);
50
    private static KeyStroke rightLayout = KeyStroke.getKeyStroke(
51
        KeyEvent.VK_RIGHT, 0);
52
    private static KeyStroke upLayout = KeyStroke.getKeyStroke(KeyEvent.VK_UP,
53
        0);
54
    private static KeyStroke downLayout = KeyStroke.getKeyStroke(
55
        KeyEvent.VK_DOWN, 0);
56
    private static KeyStroke undoLayout = KeyStroke.getKeyStroke(KeyEvent.VK_Z,
57
        KeyEvent.CTRL_MASK);
58
    private static KeyStroke redoLayout = KeyStroke.getKeyStroke(KeyEvent.VK_Y,
59
        KeyEvent.CTRL_MASK);
60
    private static KeyStroke del1Layout = KeyStroke.getKeyStroke(
61
        KeyEvent.VK_DELETE, 0);
62
    private static KeyStroke del2Layout = KeyStroke.getKeyStroke(
63
        KeyEvent.VK_BACK_SPACE, 0);
64

  
65
    /**
66
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
67
     */
68
    public void execute(String s) {
69
        LayoutPanel layout =
70
            (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
71
        if (s.equals("layout-properties")) {
72
            if (layout.showFProperties()) {
73
                layout.getDocument().setModified(true);
74
            }
75
        }
76
    }
77

  
78
    /**
79
     * @see com.iver.mdiApp.plugins.IExtension#isVisible()
80
     */
81
    public boolean isVisible() {
82
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
83

  
84
        if (f == null) {
85
            return false;
86
        }
87

  
88
        if (f instanceof LayoutPanel) {
89
            return true;
90
        }
91
        return false;
92
    }
93

  
94
    /**
95
     * @see org.gvsig.andami.plugins.IExtension#initialize()
96
     */
97
    public void initialize() {
98
        registerKeys();
99
    }
100

  
101
    private static void registerKeys() {
102
        PluginServices.registerKeyStroke(copyLayout, lke);
103
        PluginServices.registerKeyStroke(cutLayout, lke);
104
        PluginServices.registerKeyStroke(pasteLayout, lke);
105
        PluginServices.registerKeyStroke(leftLayout, lke);
106
        PluginServices.registerKeyStroke(rightLayout, lke);
107
        PluginServices.registerKeyStroke(upLayout, lke);
108
        PluginServices.registerKeyStroke(downLayout, lke);
109
        PluginServices.registerKeyStroke(undoLayout, lke);
110
        PluginServices.registerKeyStroke(redoLayout, lke);
111
        PluginServices.registerKeyStroke(del1Layout, lke);
112
        PluginServices.registerKeyStroke(del2Layout, lke);
113
    }
114

  
115
    /**
116
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
117
     */
118
    public boolean isEnabled() {
119
        return true;
120
    }
121
}
tags/org.gvsig.app.document.layout2.app-2.0.62/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/Print.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.extension;
23

  
24
import java.awt.Graphics;
25
import java.awt.Graphics2D;
26
import java.awt.geom.AffineTransform;
27
import java.awt.geom.Rectangle2D;
28
import java.awt.print.PageFormat;
29
import java.awt.print.Printable;
30
import java.awt.print.PrinterException;
31
import java.awt.print.PrinterJob;
32

  
33
import javax.print.Doc;
34
import javax.print.DocFlavor;
35
import javax.print.DocPrintJob;
36
import javax.print.PrintException;
37
import javax.print.PrintService;
38
import javax.print.PrintServiceLookup;
39
import javax.print.ServiceUI;
40
import javax.print.SimpleDoc;
41
import javax.print.attribute.PrintRequestAttributeSet;
42
import javax.print.event.PrintJobAdapter;
43
import javax.print.event.PrintJobEvent;
44
import javax.print.event.PrintJobListener;
45
import javax.swing.JOptionPane;
46

  
47
import org.slf4j.Logger;
48
import org.slf4j.LoggerFactory;
49

  
50
import org.gvsig.andami.IconThemeHelper;
51
import org.gvsig.andami.PluginServices;
52
import org.gvsig.andami.plugins.Extension;
53
import org.gvsig.andami.ui.mdiManager.IWindow;
54
import org.gvsig.app.ApplicationLocator;
55
import org.gvsig.app.project.documents.layout.Attributes;
56
import org.gvsig.app.project.documents.layout.FLayoutUtilities;
57
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
58
import org.gvsig.i18n.Messages;
59

  
60
/**
61
 * Extensi?n desde la que se imprime.
62
 * 
63
 * @author Vicente Caballero Navarro
64
 */
65
public class Print extends Extension implements Printable {
66

  
67
    private static Logger logger = LoggerFactory.getLogger(Print.class);
68
    
69
    public static PrinterJob printerJob = PrinterJob.getPrinterJob();
70

  
71
    // private Paper paper;
72
    Rectangle2D.Double aux = null;   
73
    private PrintService[] m_cachePrintServices = null;
74
    private PrintService m_cachePrintService = null;
75
    
76
    private static LayoutPanel theLayoutPanel = null;
77

  
78
    public void execute(String s) {
79
        if (s.compareTo("application-print-layout") == 0) {
80
            doPrint((LayoutPanel) PluginServices.getMDIManager().getActiveWindow());
81
        }
82
    }
83

  
84
    public void doPrint(final LayoutPanel layoutPanel) {
85
        
86
        theLayoutPanel = layoutPanel;
87
        
88
        try {
89
            PluginServices.backgroundExecution(new Runnable() {
90

  
91
                public void run() {
92
                    if (layoutPanel.getLayoutContext().getAttributes().getType() == Attributes.CUSTOM) {
93
                        layoutPanel.showPrintDialog(printerJob);
94
                    } else {
95
                        layoutPanel.showPrintDialog(null);
96
                    }
97
                }
98
            });
99

  
100
        } catch (Exception e) {
101
            
102
            logger.info("Error while showing print dialog.", e);
103
            ApplicationLocator.getManager().messageDialog(
104
                Messages.getText("_Error_while_showing_print_dialog"),
105
                Messages.getText("Imprimir"),
106
                JOptionPane.ERROR_MESSAGE);
107
        }
108
    }
109
    
110
    public void setLayout(LayoutPanel layoutp){
111
        theLayoutPanel = layoutp;
112
    }
113
    
114
    
115
    public boolean isVisible() {
116
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
117

  
118
        if (f == null) {
119
            return false;
120
        }
121

  
122
        return (f instanceof LayoutPanel);
123
    }
124

  
125
    public boolean isEnabled() {
126
        LayoutPanel f =
127
            (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
128

  
129
        if (f == null) {
130
            return false;
131
        }
132

  
133
        return true;
134
    }
135

  
136
   
137
    public void initialize() {
138
        registerIcons();
139
    }
140

  
141
    private void registerIcons() {
142
        IconThemeHelper.registerIcon("action", "application-print", this);
143
    }
144

  
145
    /**
146
     * Abre un di?logo para imprimir.
147
     * 
148
     * @param layout
149
     *            Layout a imprimir.
150
     */
151
    public void openDialogToPrint(LayoutPanel layoutPanel) {
152
      
153
        theLayoutPanel = layoutPanel;
154
        
155
        try {
156
            if (layoutPanel.getLayoutContext().getAttributes().getType() == Attributes.CUSTOM) {
157
                layoutPanel.showPrintDialog(printerJob);
158
            } else {
159
                layoutPanel.showPrintDialog(null);
160
            }
161
        } catch (Exception e) {
162
            System.out.println("Excepci?n al abrir el di?logo de impresi?n: "
163
                + e);
164
            e.printStackTrace();
165
        }
166
    }
167

  
168
    /**
169
     * Imprime el Layout que se pasa como par?metro.
170
     * 
171
     * @param layout
172
     *            Layout a imprimir.
173
     */
174
    public void printLayout(LayoutPanel layoutPanel) {
175

  
176
        theLayoutPanel = layoutPanel;
177
        
178
        try {
179
            printerJob.setPrintable((Printable) PluginServices
180
                .getExtension(org.gvsig.app.extension.Print.class));
181

  
182
            // Actualizar attributes
183
            PrintRequestAttributeSet att =
184
                layoutPanel.getLayoutContext().getAttributes()
185
                    .toPrintRequestAttributeSet();
186
            DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
187

  
188
            if (m_cachePrintServices == null) {
189
                m_cachePrintServices =
190
                    PrintServiceLookup.lookupPrintServices(flavor, null);
191
            }
192

  
193
            PrintService defaultService = null;
194

  
195
            if (m_cachePrintService == null) {
196
                defaultService = PrintServiceLookup.lookupDefaultPrintService();
197
            }
198

  
199
            if (m_cachePrintService == null) {
200
                m_cachePrintService =
201
                    ServiceUI.printDialog(null, 200, 200, m_cachePrintServices,
202
                        defaultService, flavor, att);
203
            }
204

  
205
            if (m_cachePrintService != null) {
206
                DocPrintJob jobNuevo = m_cachePrintService.createPrintJob();
207
                PrintJobListener pjlistener = new PrintJobAdapter() {
208

  
209
                    public void printDataTransferCompleted(PrintJobEvent e) {
210
                        System.out.println("Fin de impresi?n");
211
                    }
212
                };
213

  
214
                jobNuevo.addPrintJobListener(pjlistener);
215

  
216
                Doc doc =
217
                    new SimpleDoc(
218
                        PluginServices
219
                            .getExtension(org.gvsig.app.extension.Print.class),
220
                        flavor, null);
221
                jobNuevo.print(doc, att);
222
            }
223
        } catch (PrintException pe) {
224
            pe.printStackTrace();
225
        }
226
    }
227
    
228
    /**
229
     * Se dibuja sobre el graphics el Layout.
230
     *
231
     * @param g2 graphics sobre el que se dibuja.
232
     */
233
    public void drawShapes(Graphics2D g2) {
234
        theLayoutPanel.drawLayoutPrint(g2);
235
    }
236
    
237
    
238
    public int print(Graphics g, PageFormat format, int pi)
239
        throws PrinterException {
240
        
241
        if (pi >= 1) {
242
            return Printable.NO_SUCH_PAGE;
243
        }
244

  
245
        Graphics2D g2d = (Graphics2D) g;
246

  
247

  
248
        AffineTransform at = g2d.getTransform();
249
        g2d.translate(0, 0);
250
        theLayoutPanel.obtainRect(true);
251

  
252
        g2d.scale((double) 72 / (double) (Attributes.DPI),
253
            (double) 72 / (double) (Attributes.DPI));
254

  
255
        if (theLayoutPanel.getLayoutContext().getAttributes().isMargin()) {
256
            g2d.setClip((int) (theLayoutPanel.getLayoutControl().getRect().getMinX() +
257
                FLayoutUtilities.fromSheetDistance(theLayoutPanel.getLayoutContext().getAttributes().getAreaInsets()[2],
258
                    theLayoutPanel.getLayoutControl().getAT())),
259
                (int) (theLayoutPanel.getLayoutControl().getRect().getMinY() +
260
                FLayoutUtilities.fromSheetDistance(theLayoutPanel.getLayoutContext().getAttributes().getAreaInsets()[0],
261
                    theLayoutPanel.getLayoutControl().getAT())),
262
                (int) (theLayoutPanel.getLayoutControl().getRect().getWidth() -
263
                FLayoutUtilities.fromSheetDistance(theLayoutPanel.getLayoutContext().getAttributes().getAreaInsets()[2] +
264
                    theLayoutPanel.getLayoutContext().getAttributes().getAreaInsets()[3], theLayoutPanel.getLayoutControl().getAT())),
265
                (int) (theLayoutPanel.getLayoutControl().getRect().getHeight() -
266
                FLayoutUtilities.fromSheetDistance(theLayoutPanel.getLayoutContext().getAttributes().getAreaInsets()[0] +
267
                    theLayoutPanel.getLayoutContext().getAttributes().getAreaInsets()[1], theLayoutPanel.getLayoutControl().getAT())));
268
        }
269

  
270
        drawShapes(g2d);
271
        g2d.setTransform(at);
272

  
273
        return Printable.PAGE_EXISTS;
274
    }
275
}
tags/org.gvsig.app.document.layout2.app-2.0.62/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/FFrameViewZoomPrev.java
1
package org.gvsig.app.extension;
2

  
3
import org.gvsig.andami.IconThemeHelper;
4
import org.gvsig.andami.PluginServices;
5
import org.gvsig.andami.plugins.Extension;
6
import org.gvsig.andami.ui.mdiManager.IWindow;
7
import org.gvsig.app.project.documents.layout.fframes.FFrameOverView;
8
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap;
9
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
10
import org.gvsig.fmap.mapcontext.ExtentHistory;
11
import org.gvsig.fmap.mapcontext.MapContext;
12
import org.gvsig.fmap.mapcontext.ViewPort;
13

  
14

  
15

  
16
public class FFrameViewZoomPrev extends Extension {
17

  
18
    public void postInitialize() {
19
    }
20

  
21
    public void initialize() {
22
        IconThemeHelper.registerIcon("action", "layout-view-navigation-zoom-back", this);
23
    }
24

  
25
    
26
    public boolean isEnabled() {
27
    	IWindow window = PluginServices.getMDIManager().getActiveWindow();
28
    	if (window instanceof LayoutPanel) {
29
    		LayoutPanel l =
30
    				(LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
31
    		IFFrameUseFMap[] fframes = l.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class);
32
    		if (fframes.length==1 && !(fframes[0] instanceof FFrameOverView)) {
33
    			IFFrameUseFMap fframeView = (IFFrameUseFMap) fframes[0];
34
    			MapContext mc = fframeView.getMapContext();
35
    			if (mc!=null) {
36
    				ExtentHistory history = mc.getViewPort().getEnvelopes();
37
    				if (history.hasPrevious()&&fframeView.getScaleType()==IFFrameUseFMap.SCALE_TYPE.NORMAL) {
38
    					return true;
39
    				}
40
    			}
41
    		}
42
    	}
43
    	return false;
44
    }
45

  
46
    /**
47
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
48
     */
49
    public boolean isVisible() {
50
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
51

  
52
        if (f == null || !(f instanceof LayoutPanel)) {
53
            return false;
54
        }
55
        return true;
56
    }
57

  
58
    public void execute(String arg0) {
59
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
60

  
61
        if (f == null || !(f instanceof LayoutPanel)) {
62
            return;
63
        }
64
		LayoutPanel l =
65
				(LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
66
   		IFFrameUseFMap[] fframes = l.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class);
67
		if (fframes.length==1 && !(fframes[0] instanceof FFrameOverView)) {
68
			IFFrameUseFMap fframeView = (IFFrameUseFMap) fframes[0];
69
			ViewPort vp = fframeView.getMapContext().getViewPort();
70
	        vp.setPreviousEnvelope();
71
	        l.getDocument().setModified(true);
72
		}
73
    }
74

  
75
}
tags/org.gvsig.app.document.layout2.app-2.0.62/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/FFrameViewAddLayerExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.extension;
23

  
24
import org.gvsig.andami.PluginServices;
25
import org.gvsig.andami.PluginsLocator;
26
import org.gvsig.andami.PluginsManager;
27
import org.gvsig.andami.plugins.Extension;
28
import org.gvsig.andami.ui.mdiManager.IWindow;
29
import org.gvsig.app.project.documents.layout.fframes.FFrameOverView;
30
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap;
31
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
32
import org.slf4j.Logger;
33
import org.slf4j.LoggerFactory;
34

  
35
/**
36
 * Extension to control the options that can be done on a view added to layout
37
 * 
38
 * @author Cesar Martinez Izquierdo
39
 */
40
public class FFrameViewAddLayerExtension extends Extension {
41

  
42
    private static Logger logger = LoggerFactory.getLogger(FFrameViewAddLayerExtension.class);
43
    //.info("Can't change scale of view.", ex);
44

  
45
    /**
46
     * @see org.gvsig.andami.plugins.IExtension#initialize()
47
     */
48
    public void initialize() {
49
    	
50
    }
51
    
52
    /**
53
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
54
     */
55
    public void execute(String s) {
56
        LayoutPanel layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
57
    	if (s.compareTo("layout-view-add-layer") == 0) {
58
        	PluginsManager manager = PluginsLocator.getManager();
59
        	AddLayer plugin = (AddLayer) manager.getExtension(AddLayer.class);
60
        	IFFrameUseFMap[] fframes = layout.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class);
61
        	if (fframes.length>0) {
62
        		if (fframes[0].getMapContext()!=null) {
63
        			plugin.addLayers(fframes[0].getMapContext());
64
        			fframes[0].refresh();
65
        			layout.getDocument().setModified(true);
66
        		}
67
        	}
68
        }
69
    }
70
    
71

  
72
    /**
73
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
74
     */
75
    public boolean isEnabled() {
76
    	IWindow window = PluginServices.getMDIManager().getActiveWindow();
77
    	if (window instanceof LayoutPanel) {
78
    		LayoutPanel l =
79
    				(LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
80
    		if (!l.getLayoutContext().isEditable()) {
81
    			return false;
82
    		}
83
    		IFFrameUseFMap[] fframes = l.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class);
84
    		if (fframes.length==1 && !(fframes[0] instanceof FFrameOverView) && ((IFFrameUseFMap)fframes[0]).getMapContext()!=null) {
85
    			return true;
86
    		}
87
    	}
88
    	return false;
89
    }
90

  
91
    /**
92
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
93
     */
94
    public boolean isVisible() {
95
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
96

  
97
        if (f == null) {
98
            return false;
99
        }
100

  
101
        if (f instanceof LayoutPanel) {
102
            return true;
103
        } else {
104
            return false;
105
        }
106
    }
107
}
tags/org.gvsig.app.document.layout2.app-2.0.62/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutCommandStackExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.extension;
23

  
24
import org.gvsig.andami.IconThemeHelper;
25
import org.gvsig.andami.PluginServices;
26
import org.gvsig.andami.plugins.Extension;
27
import org.gvsig.app.gui.command.CommandStackDialog;
28
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
29

  
30
public class LayoutCommandStackExtension extends Extension {
31

  
32
    private LayoutPanel layout = null;
33

  
34
    public void initialize() {
35
        registerIcons();
36
    }
37

  
38
    private void registerIcons() {
39
        IconThemeHelper.registerIcon("action", "edit-undo-redo-actions", this);
40
    }
41

  
42
    public void execute(String s) {
43
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
44
        if (s.equals("edit-undo-redo-actions-layout")) {
45
            CommandStackDialog csd = new CommandStackDialog();
46
            csd.setModel(layout.getLayoutContext().getFrameCommandsRecord());
47
            layout.getLayoutContext().getFrameCommandsRecord()
48
                .addObserver(layout);
49
            PluginServices.getMDIManager().addWindow(csd);
50
            layout.getDocument().setModified(true);
51
        }
52
    }
53

  
54
    public boolean isEnabled() {
55
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
56
        if (layout.getLayoutContext().isEditable())
57
            return true;
58
        return false;
59
    }
60

  
61
    public boolean isVisible() {
62
        if (PluginServices.getMDIManager().getActiveWindow() instanceof LayoutPanel) {
63
            return true;
64
        }
65
        return false;
66
    }
67

  
68
}
tags/org.gvsig.app.document.layout2.app-2.0.62/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutGraphicControls.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.extension;
23

  
24
import org.slf4j.Logger;
25
import org.slf4j.LoggerFactory;
26
import org.gvsig.andami.IconThemeHelper;
27
import org.gvsig.andami.PluginServices;
28
import org.gvsig.andami.plugins.Extension;
29
import org.gvsig.andami.ui.mdiManager.IWindow;
30
import org.gvsig.app.project.documents.layout.FLayoutGraphics;
31
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameDialogNotification;
32
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
33
import org.gvsig.tools.observer.Observable;
34
import org.gvsig.tools.observer.Observer;
35

  
36
/**
37
 * Extensi?n que actua sobre el Layout para controlas las diferentes
38
 * operaciones sobre los gr?ficos.
39
 * 
40
 * @author Vicente Caballero Navarro
41
 */
42
public class LayoutGraphicControls extends Extension {
43

  
44
    private static final Logger logger = LoggerFactory
45
        .getLogger(LayoutGraphicControls.class);
46
    private LayoutPanel layout = null;
47

  
48
    /**
49
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
50
     */
51
    public void execute(String s) {
52
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
53
        FLayoutGraphics lg = new FLayoutGraphics(layout);
54
        logger.debug("Comand : " + s);
55

  
56
        if (s.compareTo("layout-graphic-group") == 0) {
57
            layout.getLayoutContext().getFrameCommandsRecord()
58
                .startComplex(PluginServices.getText(this, "group"));
59
            lg.grouping();
60
            layout.getLayoutContext().getFrameCommandsRecord().endComplex();
61
            layout.getDocument().setModified(true);
62
        } else
63
            if (s.compareTo("layout-graphic-ungroup") == 0) {
64
                lg.ungrouping();
65
                layout.getDocument().setModified(true);
66
            } else
67
                if (s.compareTo("layout-graphic-properties") == 0) {
68
                	lg.openFrameDialog(new Observer() {
69
						public void update(Observable observable,
70
								Object notification) {
71
							if (notification instanceof FFrameDialogNotification &&
72
									((FFrameDialogNotification)notification).getType()==FFrameDialogNotification.FRAME_CREATED) {
73
								getLayout().getDocument().setModified(true);
74
							}
75
						}
76
                	});
77
                } else
78
                    if (s.compareTo("layout-graphic-align") == 0) {
79
                        lg.aligning();
80
                        layout.getDocument().setModified(true);
81
                    } else
82
                        if (s.compareTo("layout-graphic-send-back") == 0) {
83
                            lg.behind();
84
                            layout.getDocument().setModified(true);
85
                        } else
86
                            if (s.compareTo("layout-graphic-bring-to-front") == 0) {
87
                                lg.before();
88
                                layout.getDocument().setModified(true);
89
                            } else
90
                                if (s.compareTo("layout-graphic-add-border") == 0) {
91
                                    if (lg.border()) {
92
                                        layout.getDocument().setModified(true);
93
                                    }
94
                                } else
95
                                    if (s.compareTo("layout-graphic-position") == 0) {
96
                                        lg.position();
97
                                        layout.getDocument().setModified(true);
98
                                    }
99
    }
100

  
101
    /**
102
     * @see com.iver.mdiApp.plugins.IExtension#isVisible()
103
     */
104
    public boolean isVisible() {
105
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
106

  
107
        if (f == null) {
108
            return false;
109
        }
110

  
111
        if (f instanceof LayoutPanel) {
112
            return true;
113
        }
114
        return false;
115
    }
116

  
117
    /**
118
     * @see org.gvsig.andami.plugins.IExtension#initialize()
119
     */
120
    public void initialize() {
121
        registerIcons();
122
    }
123

  
124
    private void registerIcons() {
125
        
126
        IconThemeHelper.registerIcon("action", "layout-graphic-group", this);
127
        IconThemeHelper.registerIcon("action", "layout-graphic-ungroup", this);
128
        IconThemeHelper.registerIcon("action", "layout-graphic-bring-to-front", this);
129
        IconThemeHelper.registerIcon("action", "layout-graphic-send-back", this);
130
        IconThemeHelper.registerIcon("action", "layout-graphic-position", this);
131
        IconThemeHelper.registerIcon("action", "layout-graphic-add-border", this);
132
    }
133

  
134
    /**
135
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
136
     */
137
    public boolean isEnabled() {
138
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
139
        if (!layout.getLayoutContext().isEditable())
140
            return false;
141
        return true;
142
    }
143
    
144
	protected LayoutPanel getLayout() {
145
		return layout;
146
	}
147
}
tags/org.gvsig.app.document.layout2.app-2.0.62/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutUndoExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.extension;
23

  
24
import org.gvsig.andami.IconThemeHelper;
25
import org.gvsig.andami.PluginServices;
26
import org.gvsig.andami.messages.NotificationManager;
27
import org.gvsig.andami.plugins.Extension;
28
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
29
import org.gvsig.tools.undo.UndoException;
30

  
31
public class LayoutUndoExtension extends Extension {
32

  
33
    public void initialize() {
34
        registerIcons();
35
    }
36

  
37
    private void registerIcons() {
38
        
39
        IconThemeHelper.registerIcon("action", "edit-undo", this);
40
    }
41

  
42
    public void execute(String actionCommand) {
43
        LayoutPanel layout =
44
            (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
45
        if (actionCommand.equals("edit-undo-layout")) {
46
            try {
47
                layout.getLayoutContext().getFrameCommandsRecord().undo();
48
            } catch (UndoException e) {
49
                NotificationManager.showMessageError("Undo layout", e);
50
            }
51
            layout.getLayoutContext().updateFFrames();
52
            layout.getLayoutControl().refresh();
53
            layout.getDocument().setModified(true);
54
        }
55
    }
56

  
57
    public boolean isEnabled() {
58
        if (PluginServices.getMDIManager().getActiveWindow() instanceof LayoutPanel) {
59
            LayoutPanel layout =
60
                (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
61
            if (layout.getLayoutContext().getFrameCommandsRecord().canUndo()
62
                && layout.getLayoutContext().isEditable())
63
                return true;
64
        }
65
        return false;
66
    }
67

  
68
    public boolean isVisible() {
69
        if (PluginServices.getMDIManager().getActiveWindow() instanceof LayoutPanel) {
70
            return true;
71
        }
72
        return false;
73
    }
74

  
75
}
tags/org.gvsig.app.document.layout2.app-2.0.62/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/TagExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.extension;
23

  
24
import java.awt.Component;
25

  
26
import javax.swing.JOptionPane;
27

  
28
import org.gvsig.andami.IconThemeHelper;
29
import org.gvsig.andami.PluginServices;
30
import org.gvsig.andami.plugins.Extension;
31
import org.gvsig.andami.ui.mdiManager.IWindow;
32
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
33
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
34

  
35
public class TagExtension extends Extension {
36

  
37
    private LayoutPanel layout = null;
38

  
39
    /**
40
     * @see org.gvsig.andami.plugins.IExtension#initialize()
41
     */
42
    public void initialize() {
43
        registerIcons();
44
    }
45

  
46
    private void registerIcons() {
47

  
48
        IconThemeHelper.registerIcon("action", "layout-graphic-show-tags", this);
49
        IconThemeHelper.registerIcon("action", "layout-insert-tag", this);
50

  
51
    }
52

  
53
    /**
54
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
55
     */
56
    public void execute(String s) {
57

  
58
        /*
59
         * FLayoutZooms zooms = new FLayoutZooms(layout);
60
         * logger.debug("Comand : " + s);
61
         * if (s.compareTo("SET_TAG") == 0) {
62
         * layout.setTool(Layout.SET_TAG);
63
         * }
64
         */
65

  
66
        // FJP: Cambio: abrimos la ventana de tag para
67
        // asignar el tag a los elementos seleccionados
68
        if (s.equals("layout-insert-tag")) {
69
            IFFrame[] selectedFrames =
70
                layout.getLayoutContext().getSelectedFFrames();
71
            if (selectedFrames.length > 0) {
72
                String defaultStr = "";
73
                if (selectedFrames.length == 1)
74
                    defaultStr = selectedFrames[0].getTag();
75
                String theTag =
76
                    JOptionPane.showInputDialog(
77
                        (Component) PluginServices.getMainFrame(),
78
                        "Introduzca el tag:", defaultStr);
79
                if (theTag != null) {
80
                    for (int i = 0; i < selectedFrames.length; i++)
81
                        selectedFrames[i].setTag(theTag);
82
                }
83
                layout.getDocument().setModified(true);
84
            }
85
        } else
86
            if (s.equals("layout-graphic-show-tags")) {
87
                // IFFrame[] frames = layout.getFFrames();
88
                // for (int i=0; i< frames.length; i++)
89
                // {
90
                // IFFrame f = frames[i];
91
                // if (f instanceof FFrameText)
92
                // {
93
                // FFrameText txt = (FFrameText) f;
94
                // if (f.getTag() != null)
95
                // {
96
                // txt.clearText();
97
                // txt.addText(f.getTag());
98
                // }
99
                // }
100
                // }
101
                layout.setShowIconTag(true);
102
                layout.getLayoutControl().refresh();
103
            }
104
    }
105

  
106
    /**
107
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
108
     */
109
    public boolean isEnabled() {
110
        IFFrame[] selectedFrames =
111
            layout.getLayoutContext().getSelectedFFrames();
112
        if (selectedFrames == null)
113
            return false;
114
        return (selectedFrames.length > 0);
115
    }
116

  
117
    /**
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff