Revision 161
org.gvsig.chart/tags/org.gvsig.chart-1.0.22/org.gvsig.chart.app/org.gvsig.chart.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Mon Jan 25 11:46:17 CET 2016 |
|
2 |
buildNumber=37 |
|
0 | 3 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.22/org.gvsig.chart.app/org.gvsig.chart.app.mainplugin/src/test/resources/README.txt | ||
---|---|---|
1 |
Put into this folder the resources needed by your test classes. |
|
2 |
|
|
3 |
This folder is added to the Tests classpath, so you can load any resources |
|
4 |
through the ClassLoader. |
|
5 |
|
|
6 |
By default, in this folder you can find an example of log4j configuration, |
|
7 |
prepared to log messages through the console, so logging works when you |
|
8 |
run your tests classes. |
|
0 | 9 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.22/org.gvsig.chart.app/org.gvsig.chart.app.mainplugin/src/test/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1" ?> |
|
2 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
3 |
|
|
4 |
<!-- |
|
5 |
Log4J configuration file for unit tests execution. |
|
6 |
--> |
|
7 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
8 |
|
|
9 |
<!-- Appender configuration to show logging messages through the console --> |
|
10 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
11 |
<layout class="org.apache.log4j.PatternLayout"> |
|
12 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
13 |
</layout> |
|
14 |
</appender> |
|
15 |
|
|
16 |
<!-- |
|
17 |
Activate logging messages of DEBUG level of higher only for the |
|
18 |
org.gvsig.tools packages. |
|
19 |
You can put full classes names or packages instead, to configure |
|
20 |
logging for all the classes and subpackages of the package. |
|
21 |
--> |
|
22 |
<category name="org.gvsig.tools"> |
|
23 |
<priority value="DEBUG" /> |
|
24 |
</category> |
|
25 |
<category name="org.gvsig.chart"> |
|
26 |
<priority value="DEBUG" /> |
|
27 |
</category> |
|
28 |
|
|
29 |
<!-- |
|
30 |
By default, show only logging messages of INFO level or higher, |
|
31 |
through the previously configured CONSOLE appender. |
|
32 |
--> |
|
33 |
<root> |
|
34 |
<priority value="INFO" /> |
|
35 |
<appender-ref ref="CONSOLE" /> |
|
36 |
</root> |
|
37 |
</log4j:configuration> |
|
0 | 38 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.22/org.gvsig.chart.app/org.gvsig.chart.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 |
<dependencySet> |
|
27 |
<useProjectArtifact>false</useProjectArtifact> |
|
28 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
29 |
<outputDirectory>lib</outputDirectory> |
|
30 |
<includes> |
|
31 |
<include>org.gvsig:org.gvsig.chart.lib.api</include> |
|
32 |
<include>org.gvsig:org.gvsig.chart.swing.api</include> |
|
33 |
<include>org.gvsig:org.gvsig.chart.lib.base</include> |
|
34 |
<include>org.gvsig:org.gvsig.chart.swing.base</include> |
|
35 |
<include>org.gvsig:org.gvsig.chart.lib.impl</include> |
|
36 |
<include>org.gvsig:org.gvsig.chart.swing.impl</include> |
|
37 |
</includes> |
|
38 |
</dependencySet> |
|
39 |
</dependencySets> |
|
40 |
|
|
41 |
</assembly> |
|
0 | 42 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.22/org.gvsig.chart.app/org.gvsig.chart.app.mainplugin/src/main/java/org/gvsig/app/chart/mainplugin/ChartExtension.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.chart.mainplugin; |
|
23 |
|
|
24 |
import java.awt.Dimension; |
|
25 |
import java.awt.Graphics2D; |
|
26 |
import java.awt.Rectangle; |
|
27 |
import java.awt.image.BufferedImage; |
|
28 |
import java.io.File; |
|
29 |
import java.io.IOException; |
|
30 |
|
|
31 |
import javax.imageio.ImageIO; |
|
32 |
import javax.swing.ImageIcon; |
|
33 |
import javax.swing.JComponent; |
|
34 |
import javax.swing.JDialog; |
|
35 |
import javax.swing.JFileChooser; |
|
36 |
import javax.swing.JOptionPane; |
|
37 |
|
|
38 |
import org.gvsig.andami.IconThemeHelper; |
|
39 |
import org.gvsig.andami.PluginServices; |
|
40 |
import org.gvsig.andami.plugins.ExclusiveUIExtension; |
|
41 |
import org.gvsig.andami.plugins.Extension; |
|
42 |
import org.gvsig.andami.plugins.IExtension; |
|
43 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
44 |
import org.gvsig.app.project.documents.chart.ChartDocument; |
|
45 |
import org.gvsig.app.project.documents.chart.ChartDocumentManager; |
|
46 |
import org.gvsig.app.project.documents.chart.gui.DefaultChartDocumentPanel; |
|
47 |
import org.gvsig.app.project.documents.chart.gui.DefaultEditorGroupedChartIWindow; |
|
48 |
import org.gvsig.app.project.documents.chart.gui.EditorChartServiceJDialog; |
|
49 |
import org.gvsig.chart.ChartLocator; |
|
50 |
import org.gvsig.chart.ChartService; |
|
51 |
import org.gvsig.chart.lib.spi.ChartServiceManager; |
|
52 |
import org.gvsig.chart.swing.ChartSwingLocator; |
|
53 |
import org.gvsig.chart.swing.ChartSwingManager; |
|
54 |
import org.gvsig.chart.swing.editors.EditorChartServicePanel; |
|
55 |
import org.gvsig.chart.swing.spi.ChartSwingServiceManager; |
|
56 |
import org.gvsig.tools.library.LibraryException; |
|
57 |
import org.gvsig.tools.util.Caller; |
|
58 |
import org.gvsig.tools.util.impl.DefaultCaller; |
|
59 |
import org.jfree.ui.ExtensionFileFilter; |
|
60 |
import org.slf4j.Logger; |
|
61 |
import org.slf4j.LoggerFactory; |
|
62 |
|
|
63 |
/** |
|
64 |
* Andami extension to show Chart in the application. |
|
65 |
* |
|
66 |
* @author gvSIG Team |
|
67 |
* @version $Id$ |
|
68 |
*/ |
|
69 |
public class ChartExtension extends Extension implements ExclusiveUIExtension { |
|
70 |
static ImageIcon LOGO; |
|
71 |
|
|
72 |
private static final Logger logger = LoggerFactory |
|
73 |
.getLogger(ChartExtension.class); |
|
74 |
|
|
75 |
private static final String MY_VIEW_NAME = "Chart plugin"; |
|
76 |
|
|
77 |
private static final String TOOL_NAME = "Chart.infotool"; |
|
78 |
private static final String ACTION_CREATEPLOT = "chart-create-plot"; |
|
79 |
private static final String ACTION_EDITPLOT = "chart-edit-plot"; |
|
80 |
private static final String ACTION_EXPORTTOPDF = "chart-export-pdf"; |
|
81 |
private static final String ACTION_EXPORTTOPNG = "chart-export-png"; |
|
82 |
|
|
83 |
private ChartServiceManager manager; |
|
84 |
private ChartSwingServiceManager swingServiceManager; |
|
85 |
private ChartSwingManager swingManager; |
|
86 |
|
|
87 |
public void initialize() { |
|
88 |
registerIcons(); |
|
89 |
} |
|
90 |
|
|
91 |
public void postInitialize() { |
|
92 |
manager = ChartLocator.getServiceManager(); |
|
93 |
swingServiceManager = ChartSwingLocator.getSwingManager(); |
|
94 |
swingManager = swingServiceManager.getChartSwingManager(); |
|
95 |
|
|
96 |
// initializeDocumentActionsExtensionPoint(); |
|
97 |
try { |
|
98 |
registerIcons(); |
|
99 |
} |
|
100 |
catch (Exception e) { |
|
101 |
e.printStackTrace(); |
|
102 |
} |
|
103 |
|
|
104 |
ChartDocumentManager.register(); |
|
105 |
// registerContextMenuOptions(); |
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
Caller caller = new DefaultCaller(); |
|
110 |
/* |
|
111 |
* Add registry of persistent styles |
|
112 |
*/ |
|
113 |
caller.add( new ChartDocument.RegisterPersistence() ); |
|
114 |
|
|
115 |
/* |
|
116 |
* Do register of all |
|
117 |
*/ |
|
118 |
if( !caller.call() ) { |
|
119 |
throw new LibraryException(ChartExtension.class, caller.getExceptions()); |
|
120 |
} |
|
121 |
} |
|
122 |
|
|
123 |
|
|
124 |
/** |
|
125 |
* Execute the actions associated to this extension. |
|
126 |
*/ |
|
127 |
public void execute(String actionCommand) { |
|
128 |
if (ACTION_EDITPLOT.equalsIgnoreCase(actionCommand)) { |
|
129 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
130 |
if ((window instanceof DefaultChartDocumentPanel)) { |
|
131 |
// DefaultChartDocumentPanel chartPanel = (DefaultChartDocumentPanel) window; |
|
132 |
// EditorGroupedChartPanel editor = ChartSwingLocator.getSwingManager().getChartSwingManager().createEditorChartPanel( |
|
133 |
// (GroupedCharts)chartPanel.getChartPanel().getOverlayChart()); |
|
134 |
DefaultChartDocumentPanel chartPanel = (DefaultChartDocumentPanel) window; |
|
135 |
ChartDocument document = (ChartDocument)chartPanel.getDocument(); |
|
136 |
DefaultEditorGroupedChartIWindow windowPanel = |
|
137 |
new DefaultEditorGroupedChartIWindow(document); |
|
138 |
JDialog dlg = new JDialog(); |
|
139 |
// dlg.getContentPane().add(editor.getComponent()); |
|
140 |
windowPanel.setParentDialog(dlg); |
|
141 |
dlg.getContentPane().add(windowPanel); |
|
142 |
// dlg.pack(); |
|
143 |
dlg.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); |
|
144 |
|
|
145 |
dlg.setPreferredSize(new Dimension(700, 600)); |
|
146 |
dlg.setModal(true); |
|
147 |
dlg.pack(); |
|
148 |
dlg.setSize(840, 650); |
|
149 |
dlg.setVisible(true); |
|
150 |
|
|
151 |
return; |
|
152 |
} |
|
153 |
} |
|
154 |
if (ACTION_CREATEPLOT.equalsIgnoreCase(actionCommand)) { |
|
155 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
156 |
if ((window instanceof DefaultChartDocumentPanel)) { |
|
157 |
DefaultChartDocumentPanel chartPanel = (DefaultChartDocumentPanel) window; |
|
158 |
ChartDocument document = (ChartDocument)chartPanel.getDocument(); |
|
159 |
DefaultEditorGroupedChartIWindow windowPanel = |
|
160 |
new DefaultEditorGroupedChartIWindow(document); |
|
161 |
|
|
162 |
EditorChartServicePanel editorChartServicePanel = swingManager.createNewChartPanel(windowPanel.getChartDocument().getChartService()); |
|
163 |
editorChartServicePanel.addObserver(windowPanel.getEditorPanel()); |
|
164 |
windowPanel.setEditorChartServicePanel( |
|
165 |
editorChartServicePanel |
|
166 |
); |
|
167 |
|
|
168 |
ChartService service = EditorChartServiceJDialog.showDialog( |
|
169 |
this.swingManager.getTranslation("Add_new_variable"), |
|
170 |
windowPanel.getEditorChartServicePanel()); |
|
171 |
|
|
172 |
if(service != null){ |
|
173 |
document.getChartService().addChartService(service); |
|
174 |
} |
|
175 |
|
|
176 |
windowPanel.setEditorChartServicePanel(null); |
|
177 |
// JDialog dlg = new JDialog(); |
|
178 |
// dlg.setTitle("Add variable to current Chart"); |
|
179 |
//// dlg.setContentPane(new ChartUsedFieldPanel(document)); |
|
180 |
// dlg.pack(); |
|
181 |
// dlg.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); |
|
182 |
// |
|
183 |
// dlg.setVisible(true); |
|
184 |
|
|
185 |
return; |
|
186 |
} |
|
187 |
} |
|
188 |
|
|
189 |
if (ACTION_EXPORTTOPDF.equalsIgnoreCase(actionCommand)) { |
|
190 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
191 |
if ((window instanceof DefaultChartDocumentPanel)) { |
|
192 |
DefaultChartDocumentPanel chartPanel = (DefaultChartDocumentPanel) window; |
|
193 |
ChartDocument document = (ChartDocument)chartPanel.getDocument(); |
|
194 |
JFileChooser chooser = new JFileChooser(); |
|
195 |
|
|
196 |
ExtensionFileFilter filter=new ExtensionFileFilter(this.swingManager.getTranslation("PDF_Image_Files"),".pdf"); |
|
197 |
chooser.addChoosableFileFilter(filter); |
|
198 |
|
|
199 |
chooser.setCurrentDirectory(new File(System.getProperty("user.home"))); |
|
200 |
chooser.setDialogTitle(this.swingManager.getTranslation("SavePDF")); |
|
201 |
|
|
202 |
chooser.setFileSelectionMode( JFileChooser.FILES_AND_DIRECTORIES ); |
|
203 |
// chooser.setAcceptAllFileFilterUsed(true); |
|
204 |
|
|
205 |
if (chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { |
|
206 |
|
|
207 |
// System.out.println("getCurrentDirectory(): " + chooser.getCurrentDirectory()); |
|
208 |
// System.out.println("getSelectedFile() : " + chooser.getSelectedFile().getAbsolutePath()); |
|
209 |
// |
|
210 |
String filename = chooser.getSelectedFile().getAbsolutePath(); |
|
211 |
|
|
212 |
if (!filename.endsWith(".pdf")) { |
|
213 |
filename=filename + ".pdf"; |
|
214 |
} |
|
215 |
|
|
216 |
document.getChartService().exportAsPDF( |
|
217 |
filename, |
|
218 |
chartPanel.getWidth(), |
|
219 |
chartPanel.getHeight() |
|
220 |
); |
|
221 |
|
|
222 |
JOptionPane.showMessageDialog(null, this.swingManager.getTranslation("Document_exported")); |
|
223 |
} else { |
|
224 |
System.out.println("No Selection "); |
|
225 |
} |
|
226 |
|
|
227 |
|
|
228 |
|
|
229 |
return; |
|
230 |
} |
|
231 |
} |
|
232 |
|
|
233 |
if (ACTION_EXPORTTOPNG.equalsIgnoreCase(actionCommand)) { |
|
234 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
235 |
if ((window instanceof DefaultChartDocumentPanel)) { |
|
236 |
DefaultChartDocumentPanel chartPanel = (DefaultChartDocumentPanel) window; |
|
237 |
JFileChooser chooser = new JFileChooser(); |
|
238 |
|
|
239 |
ExtensionFileFilter filter=new ExtensionFileFilter(this.swingManager.getTranslation("PNG_Image_Files"),".png"); |
|
240 |
chooser.addChoosableFileFilter(filter); |
|
241 |
|
|
242 |
chooser.setCurrentDirectory(new File(System.getProperty("user.home"))); |
|
243 |
chooser.setDialogTitle(this.swingManager.getTranslation("SavePNG")); |
|
244 |
|
|
245 |
chooser.setFileSelectionMode( JFileChooser.FILES_AND_DIRECTORIES ); |
|
246 |
// chooser.setAcceptAllFileFilterUsed(true); |
|
247 |
|
|
248 |
if (chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { |
|
249 |
|
|
250 |
// System.out.println("getCurrentDirectory(): " + chooser.getCurrentDirectory()); |
|
251 |
// System.out.println("getSelectedFile() : " + chooser.getSelectedFile().getAbsolutePath()); |
|
252 |
// |
|
253 |
String filename = chooser.getSelectedFile().getAbsolutePath(); |
|
254 |
|
|
255 |
if (!filename.endsWith(".png")) { |
|
256 |
filename=filename + ".png"; |
|
257 |
} |
|
258 |
|
|
259 |
BufferedImage bi = this.createImage(chartPanel, chartPanel.getBounds()); |
|
260 |
this.writeImage(bi, filename); |
|
261 |
|
|
262 |
JOptionPane.showMessageDialog(null, this.swingManager.getTranslation("Document_exported")); |
|
263 |
|
|
264 |
} else { |
|
265 |
System.out.println("No Selection "); |
|
266 |
} |
|
267 |
|
|
268 |
|
|
269 |
|
|
270 |
return; |
|
271 |
} |
|
272 |
} |
|
273 |
} |
|
274 |
|
|
275 |
public void writeImage(BufferedImage image, String fileName){ |
|
276 |
if (fileName == null) return; |
|
277 |
|
|
278 |
int offset = fileName.lastIndexOf( "." ); |
|
279 |
if (offset == -1){ |
|
280 |
return; |
|
281 |
} |
|
282 |
|
|
283 |
String type = fileName.substring(offset + 1); |
|
284 |
try { |
|
285 |
ImageIO.write(image, type, new File( fileName )); |
|
286 |
} catch (IOException e) { |
|
287 |
// TODO Auto-generated catch block |
|
288 |
e.printStackTrace(); |
|
289 |
} |
|
290 |
} |
|
291 |
|
|
292 |
private BufferedImage createImage(JComponent component, Rectangle region) |
|
293 |
{ |
|
294 |
// Make sure the component has a size and has been layed out. |
|
295 |
// (necessary check for components not added to a realized frame) |
|
296 |
|
|
297 |
if (! component.isDisplayable()) |
|
298 |
{ |
|
299 |
Dimension d = component.getSize(); |
|
300 |
|
|
301 |
if (d.width == 0 || d.height == 0) |
|
302 |
{ |
|
303 |
d = component.getPreferredSize(); |
|
304 |
component.setSize( d ); |
|
305 |
} |
|
306 |
|
|
307 |
// layoutComponent( component ); |
|
308 |
} |
|
309 |
|
|
310 |
BufferedImage image = new BufferedImage(region.width, region.height, BufferedImage.TYPE_INT_RGB); |
|
311 |
Graphics2D g2d = image.createGraphics(); |
|
312 |
|
|
313 |
// Paint a background for non-opaque components, |
|
314 |
// otherwise the background will be black |
|
315 |
|
|
316 |
if (! component.isOpaque()) |
|
317 |
{ |
|
318 |
g2d.setColor( component.getBackground() ); |
|
319 |
g2d.fillRect(region.x, region.y, region.width, region.height); |
|
320 |
} |
|
321 |
|
|
322 |
g2d.translate(-region.x, -region.y); |
|
323 |
component.paint( g2d ); |
|
324 |
g2d.dispose(); |
|
325 |
return image; |
|
326 |
} |
|
327 |
|
|
328 |
|
|
329 |
/** |
|
330 |
* Check if tools of this extension are enabled. |
|
331 |
*/ |
|
332 |
public boolean isEnabled() { |
|
333 |
// |
|
334 |
// By default the tool is always enabled |
|
335 |
// |
|
336 |
return true; |
|
337 |
} |
|
338 |
|
|
339 |
/** |
|
340 |
* Check if tools of this extension are visible. |
|
341 |
*/ |
|
342 |
public boolean isVisible() { |
|
343 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
344 |
if (f == null) { |
|
345 |
return false; |
|
346 |
} |
|
347 |
|
|
348 |
if (f instanceof DefaultChartDocumentPanel) { |
|
349 |
return true; |
|
350 |
} |
|
351 |
return false; |
|
352 |
} |
|
353 |
|
|
354 |
/** |
|
355 |
* Check if an extension is enabled. |
|
356 |
*/ |
|
357 |
public boolean isEnabled(IExtension extension) { |
|
358 |
return extension.isEnabled(); |
|
359 |
} |
|
360 |
|
|
361 |
/** |
|
362 |
* Check if an extension is visible. |
|
363 |
*/ |
|
364 |
public boolean isVisible(IExtension extension) { |
|
365 |
return extension.isVisible(); |
|
366 |
} |
|
367 |
|
|
368 |
private void registerIcons() { |
|
369 |
IconThemeHelper.registerIcon("chart", "chart-create-plot", this.getClass()); |
|
370 |
IconThemeHelper.registerIcon("chart", "chart-edit-plot", this.getClass()); |
|
371 |
IconThemeHelper.registerIcon("chart", "chart-export-pdf", this.getClass()); |
|
372 |
IconThemeHelper.registerIcon("chart", "chart-export-png", this.getClass()); |
|
373 |
|
|
374 |
IconThemeHelper.registerIcon("document", "document-chart-unselect", ChartDocumentManager.class); |
|
375 |
IconThemeHelper.registerIcon("document", "document-chart-select", ChartDocumentManager.class); |
|
376 |
|
|
377 |
} |
|
378 |
|
|
379 |
} |
|
0 | 380 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.22/org.gvsig.chart.app/org.gvsig.chart.app.mainplugin/src/main/java/org/gvsig/app/chart/mainplugin/package.html | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
3 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
4 |
<head> |
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
6 |
<title>org.gvsig.landregistryviewer package documentation</title> |
|
7 |
</head> |
|
8 |
<body> |
|
9 |
|
|
10 |
<p>LandRegistryViewer gvSIG extension</p> |
|
11 |
|
|
12 |
<p> |
|
13 |
Shows LandRegistryViewer into gvSIG. |
|
14 |
</p> |
|
15 |
|
|
16 |
</body> |
|
17 |
</html> |
|
0 | 18 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.22/org.gvsig.chart.app/org.gvsig.chart.app.mainplugin/src/main/java/org/gvsig/app/project/documents/chart/events/ChartPropertiesChangeListener.java | ||
---|---|---|
1 |
package org.gvsig.app.project.documents.chart.events; |
|
2 |
|
|
3 |
import java.util.EventListener; |
|
4 |
|
|
5 |
public interface ChartPropertiesChangeListener extends EventListener { |
|
6 |
public void chartPropertiesChange(ChartPropertiesChangeEvent evt); |
|
7 |
} |
|
0 | 8 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.22/org.gvsig.chart.app/org.gvsig.chart.app.mainplugin/src/main/java/org/gvsig/app/project/documents/chart/events/ChartPropertiesChangeEvent.java | ||
---|---|---|
1 |
package org.gvsig.app.project.documents.chart.events; |
|
2 |
|
|
3 |
import java.util.EventObject; |
|
4 |
|
|
5 |
public class ChartPropertiesChangeEvent extends EventObject { |
|
6 |
/** |
|
7 |
* |
|
8 |
*/ |
|
9 |
private static final long serialVersionUID = -1974434668957358782L; |
|
10 |
|
|
11 |
public ChartPropertiesChangeEvent(Object source) { |
|
12 |
super(source); |
|
13 |
} |
|
14 |
} |
|
0 | 15 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.22/org.gvsig.chart.app/org.gvsig.chart.app.mainplugin/src/main/java/org/gvsig/app/project/documents/chart/gui/DefaultEditorChartServiceJDialog.java | ||
---|---|---|
1 |
package org.gvsig.app.project.documents.chart.gui; |
|
2 |
|
|
3 |
import java.awt.Dimension; |
|
4 |
import java.awt.event.ComponentEvent; |
|
5 |
import java.awt.event.ComponentListener; |
|
6 |
|
|
7 |
import javax.swing.JDialog; |
|
8 |
|
|
9 |
import org.gvsig.chart.ChartService; |
|
10 |
import org.gvsig.chart.swing.editors.EditorChartServicePanel; |
|
11 |
|
|
12 |
/** |
|
13 |
* A dialog for choosing a font from the available system fonts. |
|
14 |
* |
|
15 |
* @author Jos? Bad?a |
|
16 |
*/ |
|
17 |
public class DefaultEditorChartServiceJDialog extends JDialog { |
|
18 |
|
|
19 |
/** |
|
20 |
* |
|
21 |
*/ |
|
22 |
private static final long serialVersionUID = 822457766380562414L; |
|
23 |
|
|
24 |
private EditorChartServicePanel editorPanel; |
|
25 |
|
|
26 |
/** |
|
27 |
* Standard constructor - builds a font chooser dialog owned by another dialog. |
|
28 |
* |
|
29 |
* @param owner the dialog that 'owns' this dialog. |
|
30 |
* @param title the title for the dialog. |
|
31 |
* @param modal a boolean that indicates whether or not the dialog is modal. |
|
32 |
* @param font the initial font displayed. |
|
33 |
*/ |
|
34 |
public DefaultEditorChartServiceJDialog(String title, boolean modal, EditorChartServicePanel panel) { |
|
35 |
super(); |
|
36 |
editorPanel = panel; |
|
37 |
setTitle(title); |
|
38 |
setContentPane(panel.getComponent()); |
|
39 |
panel.getComponent().addComponentListener(new ComponentListener() { |
|
40 |
|
|
41 |
public void componentShown(ComponentEvent arg0) { |
|
42 |
// TODO Auto-generated method stub |
|
43 |
|
|
44 |
} |
|
45 |
|
|
46 |
public void componentResized(ComponentEvent arg0) { |
|
47 |
// TODO Auto-generated method stub |
|
48 |
|
|
49 |
} |
|
50 |
|
|
51 |
public void componentMoved(ComponentEvent arg0) { |
|
52 |
// TODO Auto-generated method stub |
|
53 |
|
|
54 |
} |
|
55 |
|
|
56 |
public void componentHidden(ComponentEvent arg0) { |
|
57 |
DefaultEditorChartServiceJDialog.this.dispose(); |
|
58 |
} |
|
59 |
}); |
|
60 |
getContentPane().setVisible(true); |
|
61 |
setPreferredSize(new Dimension(850,500)); |
|
62 |
setModal(true); |
|
63 |
|
|
64 |
pack(); |
|
65 |
setSize(840, 500); |
|
66 |
setVisible(true); |
|
67 |
} |
|
68 |
|
|
69 |
|
|
70 |
public EditorChartServicePanel getMainPanel(){ |
|
71 |
return this.editorPanel; |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* Returns the ChartService |
|
76 |
* |
|
77 |
* @return the ChartService. |
|
78 |
*/ |
|
79 |
public ChartService getChartService() { |
|
80 |
return this.editorPanel.getNewChartService(); |
|
81 |
} |
|
82 |
|
|
83 |
|
|
84 |
} |
|
0 | 85 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.22/org.gvsig.chart.app/org.gvsig.chart.app.mainplugin/src/main/java/org/gvsig/app/project/documents/chart/gui/EditorChartServiceJDialog.java | ||
---|---|---|
1 |
package org.gvsig.app.project.documents.chart.gui; |
|
2 |
|
|
3 |
import org.gvsig.chart.ChartService; |
|
4 |
import org.gvsig.chart.swing.editors.EditorChartServicePanel; |
|
5 |
import org.gvsig.chart.swing.editors.panels.EditorChartPropertiesPanel; |
|
6 |
|
|
7 |
public class EditorChartServiceJDialog { |
|
8 |
|
|
9 |
public static ChartService showDialog(String title, EditorChartServicePanel editorPanel) { |
|
10 |
|
|
11 |
DefaultEditorChartServiceJDialog dlg = new DefaultEditorChartServiceJDialog(title, true, editorPanel); |
|
12 |
if(dlg.getMainPanel().isCancelled()) { |
|
13 |
dlg.setVisible(false); |
|
14 |
return null; |
|
15 |
} |
|
16 |
return dlg.getChartService(); |
|
17 |
} |
|
18 |
|
|
19 |
public static ChartService showDialog(String title, EditorChartPropertiesPanel editorPanel) { |
|
20 |
|
|
21 |
DefaultEditorChartPropertiesJDialog dlg = new DefaultEditorChartPropertiesJDialog(title, true, editorPanel); |
|
22 |
if(dlg.getMainPanel().isCancelled()) { |
|
23 |
dlg.setVisible(false); |
|
24 |
return null; |
|
25 |
} |
|
26 |
return dlg.getChartService(); |
|
27 |
} |
|
28 |
} |
|
0 | 29 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.22/org.gvsig.chart.app/org.gvsig.chart.app.mainplugin/src/main/java/org/gvsig/app/project/documents/chart/gui/DefaultEditorChartPropertiesJDialog.java | ||
---|---|---|
1 |
package org.gvsig.app.project.documents.chart.gui; |
|
2 |
|
|
3 |
import java.awt.Dimension; |
|
4 |
import java.awt.Font; |
|
5 |
import java.awt.event.ComponentEvent; |
|
6 |
import java.awt.event.ComponentListener; |
|
7 |
|
|
8 |
import javax.swing.JDialog; |
|
9 |
|
|
10 |
import org.gvsig.app.gui.utils.FontChooser; |
|
11 |
import org.gvsig.chart.ChartService; |
|
12 |
import org.gvsig.chart.swing.ChartSwingLocator; |
|
13 |
import org.gvsig.chart.swing.ChartSwingManager; |
|
14 |
import org.gvsig.chart.swing.editors.panels.EditorChartPropertiesPanel; |
|
15 |
import org.gvsig.chart.swing.editors.panels.format.chartarea.ChartServiceFormatLegendPanel; |
|
16 |
import org.gvsig.chart.swing.editors.panels.format.chartarea.ChartServiceFormatTitlePanel; |
|
17 |
import org.gvsig.tools.observer.Observable; |
|
18 |
import org.gvsig.tools.observer.Observer; |
|
19 |
|
|
20 |
/** |
|
21 |
* A dialog for choosing a font from the available system fonts. |
|
22 |
* |
|
23 |
* @author Jos? Bad?a |
|
24 |
*/ |
|
25 |
public class DefaultEditorChartPropertiesJDialog extends JDialog implements Observer{ |
|
26 |
|
|
27 |
/** |
|
28 |
* |
|
29 |
*/ |
|
30 |
private static final long serialVersionUID = 822457766380562414L; |
|
31 |
|
|
32 |
private EditorChartPropertiesPanel panel; |
|
33 |
|
|
34 |
private ChartSwingManager swingManager; |
|
35 |
|
|
36 |
/** |
|
37 |
* Standard constructor - builds a font chooser dialog owned by another dialog. |
|
38 |
* |
|
39 |
* @param owner the dialog that 'owns' this dialog. |
|
40 |
* @param title the title for the dialog. |
|
41 |
* @param modal a boolean that indicates whether or not the dialog is modal. |
|
42 |
* @param font the initial font displayed. |
|
43 |
*/ |
|
44 |
public DefaultEditorChartPropertiesJDialog(String title, boolean modal, EditorChartPropertiesPanel panel) { |
|
45 |
super(); |
|
46 |
this.panel = panel; |
|
47 |
this.panel.addObserver(this); |
|
48 |
swingManager = ChartSwingLocator.getSwingManager().getChartSwingManager(); |
|
49 |
setTitle(title); |
|
50 |
setContentPane(panel.getComponent()); |
|
51 |
panel.getComponent().addComponentListener(new ComponentListener() { |
|
52 |
|
|
53 |
public void componentShown(ComponentEvent arg0) { |
|
54 |
// TODO Auto-generated method stub |
|
55 |
|
|
56 |
} |
|
57 |
|
|
58 |
public void componentResized(ComponentEvent arg0) { |
|
59 |
// TODO Auto-generated method stub |
|
60 |
|
|
61 |
} |
|
62 |
|
|
63 |
public void componentMoved(ComponentEvent arg0) { |
|
64 |
// TODO Auto-generated method stub |
|
65 |
|
|
66 |
} |
|
67 |
|
|
68 |
public void componentHidden(ComponentEvent arg0) { |
|
69 |
DefaultEditorChartPropertiesJDialog.this.dispose(); |
|
70 |
} |
|
71 |
}); |
|
72 |
getContentPane().setVisible(true); |
|
73 |
setPreferredSize(new Dimension(850,500)); |
|
74 |
setModal(true); |
|
75 |
|
|
76 |
pack(); |
|
77 |
setSize(700, 500); |
|
78 |
setVisible(true); |
|
79 |
} |
|
80 |
|
|
81 |
|
|
82 |
public ChartService getChartService(){ |
|
83 |
return panel.getChartService(); |
|
84 |
} |
|
85 |
|
|
86 |
|
|
87 |
public EditorChartPropertiesPanel getMainPanel() { |
|
88 |
return this.panel; |
|
89 |
} |
|
90 |
|
|
91 |
|
|
92 |
public void update(Observable observable, Object notification) { |
|
93 |
if(observable instanceof EditorChartPropertiesPanel){ |
|
94 |
|
|
95 |
if(observable instanceof ChartServiceFormatTitlePanel){ |
|
96 |
ChartServiceFormatTitlePanel titlePanel = (ChartServiceFormatTitlePanel)observable; |
|
97 |
Font newFont = null; |
|
98 |
newFont = FontChooser.showDialog(this.swingManager.getTranslation("Pick_Color"), titlePanel.getTitleFont()); |
|
99 |
if (newFont == null) { |
|
100 |
return; |
|
101 |
} |
|
102 |
titlePanel.setTitleFont(newFont); |
|
103 |
} |
|
104 |
if(observable instanceof ChartServiceFormatLegendPanel){ |
|
105 |
ChartServiceFormatLegendPanel titlePanel = (ChartServiceFormatLegendPanel)observable; |
|
106 |
Font newFont = null; |
|
107 |
newFont = FontChooser.showDialog(this.swingManager.getTranslation("Pick_Color"), titlePanel.getLegendTitleFont()); |
|
108 |
if (newFont == null) { |
|
109 |
return; |
|
110 |
} |
|
111 |
titlePanel.setLegendTitleFont(newFont); |
|
112 |
} |
|
113 |
} |
|
114 |
} |
|
115 |
|
|
116 |
} |
|
0 | 117 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.22/org.gvsig.chart.app/org.gvsig.chart.app.mainplugin/src/main/java/org/gvsig/app/project/documents/chart/gui/DefaultEditorGroupedChartIWindow.java | ||
---|---|---|
1 |
package org.gvsig.app.project.documents.chart.gui; |
|
2 |
|
|
3 |
import java.awt.GridBagConstraints; |
|
4 |
import java.awt.GridBagLayout; |
|
5 |
import java.awt.Insets; |
|
6 |
import java.awt.event.ActionEvent; |
|
7 |
import java.awt.event.ActionListener; |
|
8 |
import java.beans.PropertyChangeEvent; |
|
9 |
import java.beans.PropertyChangeListener; |
|
10 |
import java.util.ArrayList; |
|
11 |
import java.util.HashMap; |
|
12 |
import java.util.List; |
|
13 |
import java.util.Map; |
|
14 |
import java.util.Properties; |
|
15 |
|
|
16 |
import javax.swing.JButton; |
|
17 |
import javax.swing.JDialog; |
|
18 |
import javax.swing.JOptionPane; |
|
19 |
import javax.swing.JPanel; |
|
20 |
|
|
21 |
import org.gvsig.andami.PluginServices; |
|
22 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
23 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
24 |
import org.gvsig.app.ApplicationLocator; |
|
25 |
import org.gvsig.app.ApplicationManager; |
|
26 |
import org.gvsig.app.project.Project; |
|
27 |
import org.gvsig.app.project.ProjectManager; |
|
28 |
import org.gvsig.app.project.documents.Document; |
|
29 |
import org.gvsig.app.project.documents.chart.ChartDocument; |
|
30 |
import org.gvsig.app.project.documents.table.TableDocument; |
|
31 |
import org.gvsig.app.project.documents.table.TableManager; |
|
32 |
import org.gvsig.chart.ChartProperties; |
|
33 |
import org.gvsig.chart.ChartService; |
|
34 |
import org.gvsig.chart.GroupedCharts; |
|
35 |
import org.gvsig.chart.model.ChartDataSet; |
|
36 |
import org.gvsig.chart.model.variables.RequiredField; |
|
37 |
import org.gvsig.chart.swing.ChartSwingLocator; |
|
38 |
import org.gvsig.chart.swing.ChartSwingManager; |
|
39 |
import org.gvsig.chart.swing.editors.EditorChartServicePanel; |
|
40 |
import org.gvsig.chart.swing.editors.EditorGroupedChartPanel; |
|
41 |
import org.gvsig.chart.swing.editors.panels.ChartServiceDataPanel; |
|
42 |
import org.gvsig.chart.swing.editors.panels.EditorChartPropertiesPanel; |
|
43 |
import org.gvsig.fmap.dal.exception.DataException; |
|
44 |
import org.gvsig.fmap.dal.feature.Feature; |
|
45 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
46 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
47 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
48 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
49 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
50 |
import org.gvsig.tools.observer.Observable; |
|
51 |
import org.gvsig.tools.observer.Observer; |
|
52 |
|
|
53 |
public class DefaultEditorGroupedChartIWindow extends JPanel implements IWindow, Observer { |
|
54 |
|
|
55 |
/** |
|
56 |
* |
|
57 |
*/ |
|
58 |
private static final long serialVersionUID = -412071853707015402L; |
|
59 |
private static final long ROW_LIMIT = 750; |
|
60 |
private static final long ROW_ALERT_LIMIT = 200; |
|
61 |
private EditorGroupedChartPanel editorPanel; |
|
62 |
private GroupedCharts charts; |
|
63 |
private EditorChartServicePanel editorChartServicePanel = null; |
|
64 |
private ChartSwingManager swingManager; |
|
65 |
private ChartDocument document; |
|
66 |
private boolean isFirstTime = true; |
|
67 |
private boolean allowOnlySelectedRows = false; |
|
68 |
private JDialog dialogParent; |
|
69 |
private HashMap<String, TableDocument> tableDocs; |
|
70 |
|
|
71 |
|
|
72 |
public DefaultEditorGroupedChartIWindow(ChartDocument doc) { |
|
73 |
this.document = doc; |
|
74 |
charts = doc.getChartService().copy(); |
|
75 |
|
|
76 |
swingManager = ChartSwingLocator.getSwingManager().getChartSwingManager(); |
|
77 |
|
|
78 |
editorPanel = ChartSwingLocator.getSwingManager().getChartSwingManager().createEditorChartPanel(charts); |
|
79 |
editorPanel.addObserver(this); |
|
80 |
|
|
81 |
GridBagLayout gridBagLayout = new GridBagLayout(); |
|
82 |
/*gridBagLayout.columnWidths = new int[]{0, 0, 655, 0, 0, 0}; |
|
83 |
/*gridBagLayout.rowHeights = new int[]{0, 0, 0}; |
|
84 |
gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; |
|
85 |
gridBagLayout.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};*/ |
|
86 |
setLayout(gridBagLayout); |
|
87 |
|
|
88 |
JButton acceptButton = new JButton(this.swingManager.getTranslation("accept")); |
|
89 |
acceptButton.addActionListener(new ActionListener() { |
|
90 |
|
|
91 |
public void actionPerformed(ActionEvent arg0) { |
|
92 |
updateDocument(); |
|
93 |
closeMainWindow(); |
|
94 |
|
|
95 |
} |
|
96 |
}); |
|
97 |
acceptButton.setSize(100, acceptButton.getHeight()); |
|
98 |
|
|
99 |
GridBagConstraints gbc_panel = new GridBagConstraints(); |
|
100 |
gbc_panel.gridwidth = 5; |
|
101 |
gbc_panel.insets = new Insets(5, 5, 5, 5); |
|
102 |
gbc_panel.gridx = 0; |
|
103 |
gbc_panel.gridy = 0; |
|
104 |
gbc_panel.fill = GridBagConstraints.BOTH; |
|
105 |
gbc_panel.weightx = 1.0; |
|
106 |
gbc_panel.weighty = 1.0; |
|
107 |
add(editorPanel.getComponent(), gbc_panel); |
|
108 |
|
|
109 |
JButton cancelButton = new JButton(this.swingManager.getTranslation("Cancel")); |
|
110 |
cancelButton.addActionListener(new ActionListener() { |
|
111 |
public void actionPerformed(ActionEvent arg0) { |
|
112 |
closeMainWindow(); |
|
113 |
} |
|
114 |
}); |
|
115 |
|
|
116 |
|
|
117 |
GridBagConstraints gbc_btnNewButton_2 = new GridBagConstraints(); |
|
118 |
gbc_btnNewButton_2.anchor = GridBagConstraints.EAST; |
|
119 |
gbc_btnNewButton_2.insets = new Insets(5, 5, 5, 5); |
|
120 |
gbc_btnNewButton_2.gridx = 4; |
|
121 |
gbc_btnNewButton_2.gridy = 1; |
|
122 |
|
|
123 |
add(acceptButton, gbc_btnNewButton_2); |
|
124 |
|
|
125 |
cancelButton.setSize(100, cancelButton.getHeight()); |
|
126 |
GridBagConstraints gbc_btnNewButton_1 = new GridBagConstraints(); |
|
127 |
gbc_btnNewButton_1.anchor = GridBagConstraints.EAST; |
|
128 |
gbc_btnNewButton_1.insets = new Insets(5, 5, 5, 75); |
|
129 |
gbc_panel.fill = GridBagConstraints.BOTH; |
|
130 |
gbc_panel.weightx = 1.0; |
|
131 |
gbc_panel.weighty = 0.0; |
|
132 |
gbc_btnNewButton_1.gridx = 4; |
|
133 |
gbc_btnNewButton_1.gridy = 1; |
|
134 |
add(cancelButton, gbc_btnNewButton_1); |
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
} |
|
139 |
|
|
140 |
protected void closeMainWindow() { |
|
141 |
if(this.dialogParent!=null){ |
|
142 |
this.dialogParent.dispose(); |
|
143 |
}else{ |
|
144 |
PluginServices.getMDIManager().closeWindow(this); |
|
145 |
} |
|
146 |
} |
|
147 |
|
|
148 |
public void setParentDialog(JDialog parent){ |
|
149 |
this.dialogParent = parent; |
|
150 |
} |
|
151 |
|
|
152 |
public EditorChartServicePanel getEditorChartServicePanel(){ |
|
153 |
return this.editorChartServicePanel; |
|
154 |
} |
|
155 |
|
|
156 |
public TableDocument getDocument(String name){ |
|
157 |
if(tableDocs != null && !tableDocs.isEmpty()){ |
|
158 |
return tableDocs.get(name); |
|
159 |
} |
|
160 |
return null; |
|
161 |
} |
|
162 |
|
|
163 |
public WindowInfo getWindowInfo() { |
|
164 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG |
|
165 |
| WindowInfo.RESIZABLE); |
|
166 |
m_viewinfo |
|
167 |
.setTitle(PluginServices.getText(this, this.swingManager.getTranslation("propiedades_grafico"))); |
|
168 |
m_viewinfo.setWidth(830); |
|
169 |
m_viewinfo.setHeight(545); |
|
170 |
return m_viewinfo; |
|
171 |
} |
|
172 |
|
|
173 |
public Object getWindowProfile() { |
|
174 |
return WindowInfo.PROPERTIES_PROFILE; |
|
175 |
} |
|
176 |
|
|
177 |
public EditorGroupedChartPanel getEditorPanel() { |
|
178 |
return editorPanel; |
|
179 |
} |
|
180 |
|
|
181 |
private void initializeDataSource(ChartServiceDataPanel panel) { |
|
182 |
ApplicationManager appManager = ApplicationLocator.getManager(); |
|
183 |
final Project project = appManager.getCurrentProject(); |
|
184 |
ProjectManager projectManager = appManager.getProjectManager(); |
|
185 |
|
|
186 |
List<Document> tableDocuments = project |
|
187 |
.getDocuments(TableManager.TYPENAME); |
|
188 |
TableDocument[] pts = tableDocuments |
|
189 |
.toArray(new TableDocument[tableDocuments.size()]); |
|
190 |
|
|
191 |
Properties extendedProps = new Properties(); |
|
192 |
tableDocs = new HashMap<String, TableDocument>(); |
|
193 |
List<String> tableNames = new ArrayList<String>(); |
|
194 |
|
|
195 |
for (TableDocument t : pts) { |
|
196 |
tableDocs.put(t.getName(), t); |
|
197 |
tableNames.add(t.getName()); |
|
198 |
} |
|
199 |
|
|
200 |
//props.setDataTableModel(tableNames); |
|
201 |
panel.setTableNameModel(tableNames); |
|
202 |
|
|
203 |
if(tableNames.size() > 0){ |
|
204 |
String tableName = panel.getPreviousChartProperties().getChartTableName(); |
|
205 |
if(tableName != null && tableName != ""){ |
|
206 |
panel.setSelectedTableName(tableName); |
|
207 |
setFieldsForTable(panel, tableName); |
|
208 |
}else{ |
|
209 |
panel.setSelectedTableName(tableNames.get(0)); |
|
210 |
setFieldsForTable(panel, tableNames.get(0)); |
|
211 |
} |
|
212 |
} |
|
213 |
|
|
214 |
panel.fillTableData(); |
|
215 |
|
|
216 |
} |
|
217 |
|
|
218 |
private boolean isActivatedPanel(ChartServiceDataPanel panel, long total, long selected){ |
|
219 |
if(total>ROW_LIMIT && (selected>ROW_LIMIT || selected ==0)){ |
|
220 |
editorChartServicePanel.setDisableChartCreation(false); |
|
221 |
return false; |
|
222 |
} |
|
223 |
return true; |
|
224 |
} |
|
225 |
|
|
226 |
private void getAlertMessages(ChartServiceDataPanel panel, String tableName){ |
|
227 |
ApplicationManager appManager = ApplicationLocator.getManager(); |
|
228 |
final Project project = appManager.getCurrentProject(); |
|
229 |
|
|
230 |
TableDocument selDoc = (TableDocument) project.getDocument(tableName, |
|
231 |
TableManager.TYPENAME); |
|
232 |
if (selDoc != null) { |
|
233 |
try { |
|
234 |
long total = selDoc.getStore().getFeatureCount(); |
|
235 |
long selected = selDoc.getStore().getFeatureSelection().getSize(); |
|
236 |
this.allowOnlySelectedRows=false; |
|
237 |
editorChartServicePanel.setDisableChartCreation(true); |
|
238 |
String text=""; |
|
239 |
int messageType = JOptionPane.PLAIN_MESSAGE; |
|
240 |
if(total>ROW_LIMIT && (selected>ROW_LIMIT || selected == 0)){ |
|
241 |
// alert |
|
242 |
text += this.swingManager.getTranslation("chart_data_limit_exceeded"); |
|
243 |
text += "\n"; |
|
244 |
text += this.swingManager.getTranslation("chart_data_more_info"); |
|
245 |
text += "\n"; |
|
246 |
messageType = JOptionPane.ERROR_MESSAGE; |
|
247 |
this.allowOnlySelectedRows=true; |
|
248 |
editorChartServicePanel.setDisableChartCreation(false); |
|
249 |
} |
|
250 |
if(total>ROW_LIMIT && selected<ROW_LIMIT && selected>ROW_ALERT_LIMIT){ |
|
251 |
if(!panel.getOnlySelectedRows()){ |
|
252 |
// alert for that |
|
253 |
text += this.swingManager.getTranslation("chart_data_using_selected_rows"); |
|
254 |
text += "\n"; |
|
255 |
text += this.swingManager.getTranslation("chart_data_more_info"); |
|
256 |
text += "\n"; |
|
257 |
} |
|
258 |
this.allowOnlySelectedRows=true; |
|
259 |
// alert for too time |
|
260 |
text += this.swingManager.getTranslation("chart_data_operation_seconds"); |
|
261 |
text += "\n"; |
|
262 |
messageType = JOptionPane.WARNING_MESSAGE; |
|
263 |
} |
|
264 |
if(total>ROW_LIMIT && selected<=ROW_ALERT_LIMIT && selected > 0){ |
|
265 |
if(!panel.getOnlySelectedRows()){ |
|
266 |
// alert for that |
|
267 |
text += this.swingManager.getTranslation("chart_data_using_selected_rows"); |
|
268 |
text += "\n"; |
|
269 |
text += this.swingManager.getTranslation("chart_data_more_info"); |
|
270 |
text += "\n"; |
|
271 |
messageType = JOptionPane.WARNING_MESSAGE; |
|
272 |
} |
|
273 |
this.allowOnlySelectedRows=true; |
|
274 |
} |
|
275 |
if(total>ROW_ALERT_LIMIT && total<=ROW_LIMIT && (selected == 0 || selected > ROW_ALERT_LIMIT)){ |
|
276 |
// alert for too time |
|
277 |
text += this.swingManager.getTranslation("chart_data_operation_seconds"); |
|
278 |
text += "\n"; |
|
279 |
messageType = JOptionPane.INFORMATION_MESSAGE; |
|
280 |
} |
|
281 |
if(selected == 0 && panel.getOnlySelectedRows()){ |
|
282 |
text += this.swingManager.getTranslation("chart_data_no_rows_selected"); |
|
283 |
messageType = JOptionPane.WARNING_MESSAGE; |
|
284 |
} |
|
285 |
|
|
286 |
panel.setOnlySelectedRows(this.allowOnlySelectedRows); |
|
287 |
|
|
288 |
if(!text.equals("") && !isFirstTime){ |
|
289 |
JOptionPane.showConfirmDialog(this, text, |
|
290 |
"Chart data limit exceeded", |
|
291 |
JOptionPane.DEFAULT_OPTION, |
|
292 |
messageType); |
|
293 |
} |
|
294 |
} catch (DataException e) { |
|
295 |
// TODO Auto-generated catch block |
|
296 |
e.printStackTrace(); |
|
297 |
} |
|
298 |
} |
|
299 |
} |
|
300 |
|
|
301 |
private void setFieldsForTable(ChartServiceDataPanel panel, String tableName) { |
|
302 |
ApplicationManager appManager = ApplicationLocator.getManager(); |
|
303 |
final Project project = appManager.getCurrentProject(); |
|
304 |
|
|
305 |
TableDocument selDoc = (TableDocument) project.getDocument(tableName, |
|
306 |
TableManager.TYPENAME); |
|
307 |
if (selDoc != null) { |
|
308 |
// We get the fields of this table and put them to lstFields |
|
309 |
try { |
|
310 |
long total_rows = selDoc.getStore().getFeatureCount(); |
|
311 |
long selected_rows = selDoc.getStore().getFeatureSelection().getSize(); |
|
312 |
|
|
313 |
boolean activated = isActivatedPanel(panel, total_rows, selected_rows); |
|
314 |
|
|
315 |
FeatureType featType = selDoc.getStore() |
|
316 |
.getDefaultFeatureType(); |
|
317 |
FeatureAttributeDescriptor[] atts = featType |
|
318 |
.getAttributeDescriptors(); |
|
319 |
List<String> newFields = new ArrayList<String>(); |
|
320 |
List<RequiredField> rFields = null; |
|
321 |
if(panel.getPreviousChartProperties().getChartType().equals(panel.getChartProperties().getChartType())){ |
|
322 |
rFields = panel.getPreviousChartProperties().getRequiredFields(); |
|
323 |
} |
|
324 |
else{ |
|
325 |
rFields = panel.getChartProperties().getRequiredFields(); |
|
326 |
} |
|
327 |
int j=0; |
|
328 |
for (RequiredField rf : rFields) { |
|
329 |
if (rf.isOptional()) |
|
330 |
newFields.add(""); |
|
331 |
|
|
332 |
for (int i = 0; i < atts.length; i++) { |
|
333 |
if(rf.isNumeric()){ |
|
334 |
if (atts[i].getDataType().isNumeric()) { |
|
335 |
newFields.add(atts[i].getName()); |
|
336 |
} |
|
337 |
}else{ |
|
338 |
newFields.add(atts[i].getName()); |
|
339 |
} |
|
340 |
} |
|
341 |
|
|
342 |
panel.setRequiredFieldModel(rFields, rf, newFields, activated); |
|
343 |
|
|
344 |
// Seleccionamos el valor previo |
|
345 |
if(rf.getValue()!=null){ |
|
346 |
panel.setSelectedRequiredField(rFields, rf, rf.getValue(), activated); |
|
347 |
} |
|
348 |
|
|
349 |
|
|
350 |
|
|
351 |
newFields = new ArrayList<String>(); |
|
352 |
j++; |
|
353 |
} |
|
354 |
// Properties props = ((ChartPanel) panelProps).getExtendedData(); |
|
355 |
// props.put("fieldsCombo", newFields); |
|
356 |
// ((ChartPanel) panelProps).setExtendedData(props); |
|
357 |
} catch (DataException e) { |
|
358 |
// TODO Auto-generated catch block |
|
359 |
e.printStackTrace(); |
|
360 |
} |
|
361 |
} |
|
362 |
} |
|
363 |
|
|
364 |
public void update(Observable observable, Object notification) { |
|
365 |
if(observable instanceof EditorGroupedChartPanel){ |
|
366 |
EditorGroupedChartPanel editorPanel = (EditorGroupedChartPanel)observable; |
|
367 |
if(notification instanceof GroupedCharts){ |
|
368 |
EditorChartPropertiesPanel editorPropertiesPanel = ChartSwingLocator.getSwingManager().getChartSwingManager().createEditorChartPropertiesPanel( |
|
369 |
(ChartService)editorPanel.getGroupedChart(), |
|
370 |
editorPanel.getGroupedChart()); |
|
371 |
ChartService service = EditorChartServiceJDialog.showDialog( |
|
372 |
this.swingManager.getTranslation("General_options"), |
|
373 |
editorPropertiesPanel |
|
374 |
); |
|
375 |
if(service != null){ |
|
376 |
editorPanel.refreshInformation(); |
|
377 |
} |
|
378 |
} |
|
379 |
if(notification == null){ |
|
380 |
ChartSwingManager swingManager = ChartSwingLocator.getSwingManager().getChartSwingManager(); |
|
381 |
editorChartServicePanel = swingManager.createNewChartPanel(this.charts); |
|
382 |
editorChartServicePanel.addObserver(getEditorPanel()); |
|
383 |
ChartService service = EditorChartServiceJDialog.showDialog( |
|
384 |
this.swingManager.getTranslation("Add_new_variable"), |
|
385 |
editorChartServicePanel); |
|
386 |
if(service != null){ |
|
387 |
getEditorPanel().getGroupedChart().addChartService(service); |
|
388 |
getEditorPanel().notifyObservers(getEditorPanel().getGroupedChart(), service); |
|
389 |
int services = getEditorPanel().getGroupedChart().getChartServices().size(); |
|
390 |
if(services > 1){ |
|
391 |
for(int x=services; x>1; x--){ |
|
392 |
ChartService prev_service = getEditorPanel().getGroupedChart().getChartServices().get(x-2); |
|
393 |
service = getEditorPanel().getGroupedChart().getChartServices().get(x-1); |
|
394 |
getEditorPanel().getGroupedChart().updateChartService(x-2, service); |
|
395 |
getEditorPanel().getGroupedChart().updateChartService(x-1, prev_service); |
|
396 |
} |
|
397 |
getEditorPanel().getGroupedChart().refreshCharts(); |
|
398 |
getEditorPanel().getGroupedChart().redrawCharts(); |
|
399 |
getEditorPanel().getGroupedChart().notifyChange( |
|
400 |
getEditorPanel().getGroupedChart()); |
|
401 |
|
|
402 |
} |
|
403 |
} |
|
404 |
editorChartServicePanel = null; |
|
405 |
} |
|
406 |
if(!(notification instanceof GroupedCharts) && |
|
407 |
notification instanceof ChartService){ |
|
408 |
int index = getEditorPanel().getGroupedChart().getChartServices().indexOf((ChartService)notification); |
|
409 |
createNewChartVariable(index); |
|
410 |
} |
|
411 |
getEditorPanel().getGroupedChart().refreshCharts(); |
|
412 |
} |
|
413 |
if(observable instanceof ChartServiceDataPanel){ |
|
414 |
if(notification != null && notification instanceof String){ |
|
415 |
setFieldsForTable(((ChartServiceDataPanel)observable), (String) notification); |
|
416 |
getAlertMessages(((ChartServiceDataPanel)observable), (String) notification); |
|
417 |
isFirstTime=false; |
|
418 |
} |
|
419 |
if(notification != null && notification instanceof ChartService){ |
|
420 |
try { |
|
421 |
if(editorChartServicePanel != null){ |
|
422 |
if(editorChartServicePanel.isEditing()){ |
|
423 |
getEditorPanel().getGroupedChart().updateChartService( |
|
424 |
editorChartServicePanel.getChartServiceIndexEdited(), |
|
425 |
editorChartServicePanel.getNewChartService()); |
|
426 |
ChartServiceDataPanel dataPanel = (ChartServiceDataPanel)observable; |
|
427 |
dataPanel.fillTableData(); |
|
428 |
getEditorPanel().getGroupedChart().updateChartService( |
|
429 |
editorChartServicePanel.getChartServiceIndexEdited(), |
|
430 |
editorChartServicePanel.getPreviousChartService()); |
|
431 |
}else{ |
|
432 |
getEditorPanel().getGroupedChart().addChartService(editorChartServicePanel.getNewChartService()); |
|
433 |
getEditorPanel().notifyObservers(getEditorPanel().getGroupedChart(), editorChartServicePanel.getNewChartService()); |
|
434 |
// ChartServiceDataPanel dataPanel = (ChartServiceDataPanel)observable; |
|
435 |
// editorChartServicePanel.getNewChartService().createChartLegendItems(); |
|
436 |
// dataPanel.fillTableData(); |
|
437 |
getEditorPanel().getGroupedChart().deleteChartService(editorChartServicePanel.getNewChartService()); |
|
438 |
} |
|
439 |
} |
|
440 |
|
|
441 |
|
|
442 |
refreshChartServiceData((ChartService)notification); |
|
443 |
} catch (DataException e) { |
|
444 |
// TODO Auto-generated catch block |
|
445 |
e.printStackTrace(); |
|
446 |
} |
|
447 |
} |
|
448 |
if(notification == null){ |
|
449 |
initializeDataSource(((ChartServiceDataPanel)observable)); |
|
450 |
} |
|
451 |
} |
|
452 |
if(observable instanceof GroupedCharts){ |
|
453 |
// if(notification != null && notification instanceof ChartService){ |
|
454 |
// try { |
|
455 |
// refreshChartServiceData((ChartService)notification); |
|
456 |
// } catch (DataException e) { |
|
457 |
// // TODO Auto-generated catch block |
|
458 |
// e.printStackTrace(); |
|
459 |
// } |
|
460 |
// }else{ |
|
461 |
refreshGroupedChartsData(); |
|
462 |
// } |
|
463 |
} |
|
464 |
} |
|
465 |
|
|
466 |
public void createNewChartVariable(int index) { |
|
467 |
|
|
468 |
ChartSwingManager swingManager = ChartSwingLocator.getSwingManager().getChartSwingManager(); |
|
469 |
editorChartServicePanel = swingManager.createEditorChartPanel(index, this.charts); |
|
470 |
editorChartServicePanel.addObserver(getEditorPanel()); |
|
471 |
ChartService service = EditorChartServiceJDialog.showDialog( |
|
472 |
this.swingManager.getTranslation("Edit_a_variable"), |
|
473 |
editorChartServicePanel); |
|
474 |
if(service != null){ |
|
475 |
getEditorPanel().getGroupedChart().updateChartService(index, service); |
|
476 |
getEditorPanel().getGroupedChart().refreshCharts(); |
|
477 |
getEditorPanel().getGroupedChart().redrawCharts(); |
|
478 |
getEditorPanel().getGroupedChart().notifyChange( |
|
479 |
getEditorPanel().getGroupedChart()); |
|
480 |
getEditorPanel().notifyObservers(getEditorPanel().getGroupedChart(), service); |
|
481 |
|
|
482 |
} |
|
483 |
editorChartServicePanel = null; |
|
484 |
} |
|
485 |
|
|
486 |
public ChartDocument getChartDocument(){ |
|
487 |
return this.document; |
|
488 |
} |
|
489 |
|
|
490 |
private void updateDocument(){ |
|
491 |
getChartDocument().setChartService(this.charts); |
|
492 |
} |
|
493 |
|
|
494 |
/** |
|
495 |
* We read the actual data and create the ChartDataSet |
|
496 |
* @param cs |
|
497 |
* @throws DataException |
|
498 |
*/ |
|
499 |
public void refreshChartServiceData(ChartService cs) throws DataException{ |
|
500 |
ApplicationManager appManager = ApplicationLocator.getManager(); |
|
501 |
Project project = appManager.getCurrentProject(); |
|
502 |
|
|
503 |
ChartProperties cp = cs.getChartProperties(); |
|
504 |
|
|
505 |
FeatureSet fs; |
|
506 |
String tableName = cs.getChartProperties().getChartTableName(); |
|
507 |
if(tableName != null){ |
|
508 |
TableDocument table = (TableDocument) project.getDocument( |
|
509 |
tableName, TableManager.TYPENAME); |
|
510 |
|
|
511 |
if (table == null) { |
|
512 |
throw new RuntimeException("No se encuentra la tabla " |
|
513 |
+ tableName); |
|
514 |
} |
|
515 |
ChartDataSet dataSet = cs.getChartDataSet(); |
|
516 |
FeatureSelection fsel = table.getStore().getFeatureSelection(); |
|
517 |
fs = table.getStore().getFeatureSet(); |
|
518 |
|
|
519 |
DisposableIterator it = null; |
|
520 |
|
|
521 |
if (cp.getUseSelectedFeatures()) { |
|
522 |
it = fsel.fastIterator(); |
|
523 |
} |
|
524 |
else { |
|
525 |
it = fs.fastIterator(); |
|
526 |
} |
|
527 |
|
|
528 |
int[] fieldIDs = new int[cp.getRequiredFields().size()]; |
|
529 |
ArrayList[] data = new ArrayList[cp.getRequiredFields().size()]; |
|
530 |
|
|
531 |
// Buscamos los ID de los campos que vamos a usar. |
|
532 |
for (int j = 0; j < cp.getRequiredFields().size(); j++) { |
|
533 |
RequiredField rq = cp.getRequiredFields().get(j); |
|
534 |
|
|
535 |
if (fs.getDefaultFeatureType() |
|
536 |
.getAttributeDescriptor(rq.getValue()) == null) |
|
537 |
fieldIDs[j] = -1; |
|
538 |
else{ |
|
539 |
fieldIDs[j] = fs.getDefaultFeatureType() |
|
540 |
.getAttributeDescriptor(rq.getValue()).getIndex(); |
|
541 |
} |
|
542 |
|
|
543 |
ArrayList<Object> aux = new ArrayList<Object>(); |
|
544 |
data[j] = aux; |
|
545 |
} |
|
546 |
|
|
547 |
// if onlyRecordsSelected is set, we should iterate by selected features only |
|
548 |
while (it.hasNext()) { |
|
549 |
Feature f = (Feature) it.next(); |
|
550 |
for (int j = 0; j < fieldIDs.length; j++) { |
|
551 |
if (fieldIDs[j] != -1) |
|
552 |
data[j].add(f.get(fieldIDs[j])); |
|
553 |
} |
|
554 |
} |
|
555 |
for (int j = 0; j < fieldIDs.length; j++) { |
|
556 |
RequiredField rq = cp.getRequiredFields().get(j); |
|
557 |
if (fieldIDs[j] != -1) |
|
558 |
dataSet.addData(rq.getName(), |
|
559 |
data[j]); |
|
560 |
} |
|
561 |
it.dispose(); |
|
562 |
cs.setChartDataSet(dataSet); |
|
563 |
} |
|
564 |
} |
|
565 |
|
|
566 |
public void refreshGroupedChartsData() { |
|
567 |
List<ChartService> chartServices = charts.getChartServices(); |
|
568 |
for (int i = 0; i < chartServices.size(); i++) { |
|
569 |
try { |
|
570 |
ChartService cs = chartServices.get(i); |
|
571 |
refreshChartServiceData(cs); |
|
572 |
} catch (DataException e) { |
|
573 |
// TODO Auto-generated catch block |
|
574 |
e.printStackTrace(); |
|
575 |
} |
|
576 |
} |
|
577 |
|
|
578 |
// try { |
|
579 |
// overlay = this.chartDocumentContext.getMainChart(); |
|
580 |
// |
|
581 |
// if(overlay instanceof GroupedCharts){ |
|
582 |
// GroupedCharts oc = (GroupedCharts)overlay; |
|
583 |
// oc.setChartServices(chartServices); |
|
584 |
// |
|
585 |
// this.previewPanel.setChartService(overlay); |
|
586 |
// } |
|
587 |
// |
|
588 |
// } catch (ServiceException e) { |
|
589 |
// // TODO Auto-generated catch block |
|
590 |
// e.printStackTrace(); |
|
591 |
// } |
|
592 |
|
|
593 |
} |
|
594 |
|
|
595 |
public void setEditorChartServicePanel( |
|
596 |
EditorChartServicePanel createNewChartPanel) { |
|
597 |
this.editorChartServicePanel = createNewChartPanel; |
|
598 |
} |
|
599 |
|
|
600 |
} |
|
601 |
|
|
0 | 602 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.22/org.gvsig.chart.app/org.gvsig.chart.app.mainplugin/src/main/java/org/gvsig/app/project/documents/chart/gui/DefaultChartDocumentPanel.java | ||
---|---|---|
1 |
package org.gvsig.app.project.documents.chart.gui; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Dimension; |
|
5 |
import java.beans.PropertyChangeEvent; |
|
6 |
import java.beans.PropertyChangeListener; |
|
7 |
|
|
8 |
import javax.swing.JPanel; |
|
9 |
|
|
10 |
import org.gvsig.andami.PluginServices; |
|
11 |
import org.gvsig.andami.ui.mdiManager.IWindowListener; |
|
12 |
import org.gvsig.andami.ui.mdiManager.IWindowTransform; |
|
13 |
import org.gvsig.andami.ui.mdiManager.SingletonWindow; |
|
14 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
15 |
import org.gvsig.app.project.documents.Document; |
|
16 |
import org.gvsig.app.project.documents.chart.ChartDocument; |
|
17 |
import org.gvsig.app.project.documents.chart.events.ChartPropertiesChangeEvent; |
|
18 |
import org.gvsig.app.project.documents.chart.events.ChartPropertiesChangeListener; |
|
19 |
import org.gvsig.app.project.documents.gui.IDocumentWindow; |
|
20 |
import org.gvsig.app.project.documents.gui.WindowLayout; |
|
21 |
import org.gvsig.chart.swing.ChartSwingLocator; |
|
22 |
import org.gvsig.chart.swing.ViewChartPanel; |
|
23 |
|
|
24 |
public class DefaultChartDocumentPanel extends JPanel |
|
25 |
implements ChartPropertiesChangeListener,IDocumentWindow, IWindowListener, IWindowTransform, SingletonWindow { |
|
26 |
/** |
|
27 |
* |
Also available in: Unified diff