Revision 431

View differences:

org.gvsig.chart/tags/org.gvsig.chart-1.0.74/org.gvsig.chart.main/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
	<modelVersion>4.0.0</modelVersion>
5
	<artifactId>org.gvsig.chart.main</artifactId>
6
	<packaging>jar</packaging>
7
	<name>org.gvsig.chart.main</name>
8
	<parent>
9
		<groupId>org.gvsig</groupId>
10
		<artifactId>org.gvsig.chart</artifactId>
11
		<version>1.0.0-SNAPSHOT</version>
12
	</parent>
13
	<dependencies>
14
		<dependency>
15
			<groupId>org.gvsig</groupId>
16
			<artifactId>org.gvsig.chart.lib.api</artifactId>
17
		</dependency>
18
		<dependency>
19
			<groupId>org.gvsig</groupId>
20
			<artifactId>org.gvsig.chart.lib.api</artifactId>
21
			<type>test-jar</type>
22
		</dependency>
23
		<dependency>
24
			<groupId>org.gvsig</groupId>
25
			<artifactId>org.gvsig.chart.lib.impl</artifactId>
26
			<scope>runtime</scope>
27
		</dependency>
28
		<dependency>
29
			<groupId>org.gvsig</groupId>
30
			<artifactId>org.gvsig.chart.lib.base</artifactId>
31
			<version>1.0.0-SNAPSHOT</version>
32
		</dependency>
33
		<dependency>
34
			<groupId>org.gvsig</groupId>
35
			<artifactId>org.gvsig.chart.swing.api</artifactId>
36
		</dependency>
37
		<dependency>
38
			<groupId>org.gvsig</groupId>
39
			<artifactId>org.gvsig.chart.swing.impl</artifactId>
40
			<scope>runtime</scope>
41
		</dependency>
42
		<dependency>
43
			<groupId>org.gvsig</groupId>
44
			<artifactId>org.gvsig.chart.swing.base</artifactId>
45
		</dependency>
46
		<dependency>
47
			<groupId>org.gvsig</groupId>
48
			<artifactId>org.gvsig.tools.swing.api</artifactId>
49
			<type>jar</type>
50
			<scope>compile</scope>
51
		</dependency>
52
		
53
		<dependency>
54
			<groupId>org.gvsig</groupId>
55
			<artifactId>org.gvsig.fmap.control</artifactId>
56
			<scope>compile</scope>
57
		</dependency>
58
		<dependency>
59
			<groupId>org.gvsig</groupId>
60
			<artifactId>org.gvsig.fmap.dal</artifactId>
61
			<scope>compile</scope>
62
		</dependency>
63
		<dependency>
64
			<groupId>org.gvsig</groupId>
65
			<artifactId>org.gvsig.fmap.geometry</artifactId>
66
			<scope>compile</scope>
67
		</dependency>
68
		<dependency>
69
			<groupId>org.gvsig</groupId>
70
			<artifactId>org.gvsig.fmap.mapcontext</artifactId>
71
			<scope>compile</scope>
72
		</dependency>
73
	</dependencies>
74
</project>
0 75

  
org.gvsig.chart/tags/org.gvsig.chart-1.0.74/org.gvsig.chart.main/src/main/resources/README.txt
1
Put into this folder the resources needed by your classes.
2

  
3
This folder is added to the 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 classes.
0 9

  
org.gvsig.chart/tags/org.gvsig.chart-1.0.74/org.gvsig.chart.main/src/main/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.construc">
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.74/org.gvsig.chart.main/src/main/java/org/gvsig/chart/main/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.construc package documentation</title>
7
</head>
8
<body>
9

  
10
	<p>Construc library testing and demo application.</p>
11

  
12
</body>
13
</html>
0 14

  
org.gvsig.chart/tags/org.gvsig.chart-1.0.74/org.gvsig.chart.main/src/main/java/org/gvsig/chart/main/utils/ChartCellRenderer.java
1
package org.gvsig.chart.main.utils;
2

  
3
import java.awt.Color;
4
import java.awt.Component;
5

  
6
import javax.swing.JLabel;
7
import javax.swing.JList;
8
import javax.swing.JPanel;
9
import javax.swing.JTable;
10
import javax.swing.ListCellRenderer;
11
import javax.swing.table.TableCellRenderer;
12

  
13

  
14
public class ChartCellRenderer extends JLabel implements ListCellRenderer, TableCellRenderer {
15
	  /**
16
	 * 
17
	 */
18
	private static final long serialVersionUID = 1493992436327160367L;
19
	private final Color HIGHLIGHT_COLOR = new Color(195, 212, 232);
20
	private JPanel parentPanel;
21

  
22
	  public ChartCellRenderer(JPanel parentPanel) {
23
	    setOpaque(true);
24
	    setIconTextGap(12);
25
	    this.parentPanel = parentPanel;
26
	  } 
27
	  		  
28
	  public Component getListCellRendererComponent(JList list, Object value,
29
	      int index, boolean isSelected, boolean cellHasFocus) {
30
	    ChartEntry entry = (ChartEntry) value;
31
	    setText(entry.getTitle());
32
	    setIcon(entry.getIcon());
33
	    if (isSelected) {
34
	      setBackground(HIGHLIGHT_COLOR);
35
	      setForeground(Color.black);
36
	    } else {
37
	      setBackground(Color.white);
38
	      setForeground(Color.black);
39
	    }
40
	    return this;
41
	  }
42

  
43
	public JPanel getParentPanel() {
44
		return parentPanel;
45
	}
46

  
47
	public Component getTableCellRendererComponent(JTable table, Object value,
48
			boolean isSelected, boolean arg3, int arg4, int arg5) {
49
		if(value==null)
50
			return null;
51
		ChartEntry entry = (ChartEntry) value;
52
		    setText(entry.getTitle());
53
		    setIcon(entry.getIcon());
54
		    if (isSelected) {
55
		      setBackground(HIGHLIGHT_COLOR);
56
		      setForeground(Color.black);
57
		    } else {
58
		      setBackground(Color.white);
59
		      setForeground(Color.black);
60
		    }
61
		    return this;
62
	}
63
}
0 64

  
org.gvsig.chart/tags/org.gvsig.chart-1.0.74/org.gvsig.chart.main/src/main/java/org/gvsig/chart/main/utils/ChartJDialog.java
1
package org.gvsig.chart.main.utils;
2

  
3
import java.awt.event.ComponentEvent;
4
import java.awt.event.ComponentListener;
5

  
6
import javax.swing.JDialog;
7
import javax.swing.JPanel;
8

  
9
public class ChartJDialog extends JDialog implements ComponentListener{
10

  
11
	/**
12
	 * 
13
	 */
14
	private static final long serialVersionUID = -1850855026936065122L;
15

  
16
	private ChartJPanel panel;
17
	
18
	public ChartJDialog(ChartJPanel panel){
19
		this.panel = panel;
20
		this.panel.setParentWindow(this);
21
		panel.addComponentListener(this);
22
		getContentPane().add(panel);
23
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
24
		setModal(true);
25
		
26
		pack();
27
		setVisible(true);
28
	}
29
	
30
	public void componentHidden(ComponentEvent e) {
31
		this.dispose();
32
	}
33

  
34
	public void componentMoved(ComponentEvent e) {
35
		// TODO Auto-generated method stub
36
		
37
	}
38

  
39
	public void componentResized(ComponentEvent e) {
40
		// TODO Auto-generated method stub
41
		
42
	}
43

  
44
	public void componentShown(ComponentEvent e) {
45
		// TODO Auto-generated method stub
46
		
47
	}
48

  
49
	public JPanel getContentPanel() {
50
		return panel;
51
	}
52

  
53
}
0 54

  
org.gvsig.chart/tags/org.gvsig.chart-1.0.74/org.gvsig.chart.main/src/main/java/org/gvsig/chart/main/utils/ChartJPanel.java
1
package org.gvsig.chart.main.utils;
2

  
3
import javax.swing.JPanel;
4

  
5
public class ChartJPanel extends JPanel{
6

  
7
	/**
8
	 * 
9
	 */
10
	private static final long serialVersionUID = 1L;
11
	private ChartJDialog chartParentWindow;
12

  
13
	public void setParentWindow(ChartJDialog jDialog){
14
		this.chartParentWindow = jDialog;
15
	}
16
	
17
	public ChartJDialog getParentWindow(){
18
		return chartParentWindow;
19
	}
20
}
0 21

  
org.gvsig.chart/tags/org.gvsig.chart-1.0.74/org.gvsig.chart.main/src/main/java/org/gvsig/chart/main/utils/CheckBoxRenderer.java
1
package org.gvsig.chart.main.utils;
2

  
3
import java.awt.Component;
4

  
5
import javax.swing.JCheckBox;
6
import javax.swing.JLabel;
7
import javax.swing.JTable;
8
import javax.swing.table.TableCellRenderer;
9

  
10
public class CheckBoxRenderer extends JCheckBox implements TableCellRenderer {
11

  
12
    /**
13
	 * 
14
	 */
15
	private static final long serialVersionUID = 3586418802127664068L;
16

  
17
	public CheckBoxRenderer() {
18
      setHorizontalAlignment(JLabel.CENTER);
19
    }
20

  
21
    public Component getTableCellRendererComponent(JTable table, Object value,
22
        boolean isSelected, boolean hasFocus, int row, int column) {
23
      if (isSelected) {
24
        setForeground(table.getSelectionForeground());
25
        //super.setBackground(table.getSelectionBackground());
26
        setBackground(table.getSelectionBackground());
27
      } else {
28
        setForeground(table.getForeground());
29
        setBackground(table.getBackground());
30
      }
31
      setSelected((value != null && ((Boolean) value).booleanValue()));
32
      return this;
33
    }
34
}
35

  
0 36

  
org.gvsig.chart/tags/org.gvsig.chart-1.0.74/org.gvsig.chart.main/src/main/java/org/gvsig/chart/main/utils/ChartEntry.java
1
package org.gvsig.chart.main.utils;
2

  
3
import javax.swing.ImageIcon;
4

  
5
import org.gvsig.andami.PluginServices;
6
import org.gvsig.chart.swing.ChartSwingLocator;
7
import org.gvsig.chart.swing.spi.panels.ChartServiceTypePanel;
8
import org.gvsig.fmap.IconThemeHelper;
9

  
10
/**
11
 * Clase que define una entrada de la lista de Charts registrados.
12
 * Contiene el identificador, el nombre, icono y la preview.
13
 */
14
public class ChartEntry {
15
	  private final String id;
16
	  private final String title;
17
	  private ImageIcon icon;
18
	  private ImageIcon image;
19

  
20
	  public ChartEntry(String id, String title) {
21
	    this.id = id;
22
		this.title = title;
23
	  }
24

  
25
	  public String getChartType() {
26
	    return id;
27
	  }
28
	  
29
	  public String getChartPanelType() {
30
	    return id + "Panel";
31
	  }
32
	  
33
	  public String getTitle() {
34
		    return title;
35
	  }
36

  
37
	  public ImageIcon getIcon() {
38
	    if (icon == null) {
39
	    	ChartServiceTypePanel panel = ChartSwingLocator.getSwingManager().getSwingServices().get(this.getChartPanelType());
40
	    	if(panel!=null)
41
	    		icon = panel.getChartIcon();
42
	    }
43
	    if (icon==null)
44
	    	icon = IconThemeHelper.getImageIcon("no-chart-icon");
45
	    return icon;
46
	  }
47
	  
48

  
49
	public String toString() {
50
		    return title;
51
		  }
52
	  
53
	  public ImageIcon getExampleImage() {
54
		    if (image == null) {
55
		    	ChartServiceTypePanel panel = ChartSwingLocator.getSwingManager().getSwingServices().get(this.getChartPanelType());
56
		    	if(panel!=null)
57
		    		image = panel.getChartExample();
58
		    }
59
		    if (image==null)
60
		    	image = IconThemeHelper.getImageIcon("no-chart-example");
61
		    return image;
62
	  }
63
}
0 64

  
org.gvsig.chart/tags/org.gvsig.chart-1.0.74/org.gvsig.chart.main/src/main/java/org/gvsig/chart/main/panels/ChartPropertiesPanel.java
1
package org.gvsig.chart.main.panels;
2

  
3
import java.awt.Dimension;
4
import java.awt.GridBagConstraints;
5
import java.awt.GridBagLayout;
6
import java.awt.Insets;
7
import java.awt.event.ActionEvent;
8
import java.awt.event.ActionListener;
9
import java.awt.event.MouseEvent;
10
import java.util.ArrayList;
11
import java.util.Iterator;
12
import java.util.List;
13

  
14
import javax.swing.DefaultListModel;
15
import javax.swing.ImageIcon;
16
import javax.swing.JButton;
17
import javax.swing.JLabel;
18
import javax.swing.JList;
19
import javax.swing.JPanel;
20
import javax.swing.JScrollPane;
21
import javax.swing.JTable;
22
import javax.swing.ListSelectionModel;
23
import javax.swing.event.ListSelectionEvent;
24
import javax.swing.event.ListSelectionListener;
25
import javax.swing.table.DefaultTableModel;
26

  
27
import org.gvsig.andami.PluginServices;
28
import org.gvsig.andami.ui.mdiManager.IWindow;
29
import org.gvsig.andami.ui.mdiManager.WindowInfo;
30
import org.gvsig.chart.ChartLocator;
31
import org.gvsig.chart.ChartProperties;
32
import org.gvsig.chart.ChartService;
33
import org.gvsig.chart.base.overlay.OverlayChartProperties;
34
import org.gvsig.chart.lib.spi.ChartServiceManager;
35
import org.gvsig.chart.main.MainContext;
36
import org.gvsig.chart.main.utils.ChartCellRenderer;
37
import org.gvsig.chart.main.utils.ChartEntry;
38
import org.gvsig.chart.main.utils.ChartJDialog;
39
import org.gvsig.chart.main.utils.CheckBoxRenderer;
40
import org.gvsig.chart.model.DefaultChartDataSet;
41
import org.gvsig.chart.model.variables.ObservableUsedChartServices;
42
import org.gvsig.chart.swing.ChartSwingLocator;
43
import org.gvsig.chart.swing.ChartSwingPanel;
44
import org.gvsig.chart.swing.ChartWindowManager;
45
import org.gvsig.chart.swing.spi.ChartSwingServiceManager;
46
import org.gvsig.fmap.IconThemeHelper;
47
import org.gvsig.tools.service.ServiceException;
48
import javax.swing.border.LineBorder;
49
import java.awt.Color;
50

  
51
public class ChartPropertiesPanel extends JPanel implements IWindow, ActionListener, ListSelectionListener{
52

  
53
	/**
54
	 * 
55
	 */
56
	private static final long serialVersionUID = -301224990996378683L;
57
    private MainContext chartDocument; 
58
    private JButton accept;
59
	private JButton cancel;
60
    
61
	private String selectedChartType = null;
62

  
63
	private JPanel panel_chartType = null;
64

  
65
	private JLabel previewImageLabel = new JLabel();	
66
	private JLabel chartOptionsLabel;
67
	
68
	private DefaultListModel listModel;
69
	
70
	private JButton addButton;
71
	private JTable table;
72
	private DefaultTableModel tableModel;
73
	private JButton editButton;
74
	private JButton deleteButton;
75
	
76
	private ChartPropertiesPanelObserver<ChartProperties> chartPropertiesObserver;
77
	private JList list;
78
	private ChartSwingServiceManager swingManager;
79
	private ChartServiceManager serviceManager;
80
	private JButton upButton;
81
	private JButton downButton;
82
	private JLabel lblChartPreview;
83
	private JPanel previewPanel;
84
	
85
	public ChartPropertiesPanel(MainContext doc) {
86
		serviceManager = ChartLocator.getServiceManager();
87
		swingManager = ChartSwingLocator.getSwingManager();
88
		
89
		chartDocument = doc;
90
		listModel = getCharts();
91
		
92
		chartPropertiesObserver = new ChartPropertiesPanelObserver<ChartProperties>(this);
93
		doc.getChartProperties().registerObserver(chartPropertiesObserver);
94
		
95
		createMainPanel();
96
		createButtonPanelEvents();
97
        
98
		initializeChartList();
99
		initialize();
100
	}
101
	
102
	private void createMainPanel(){
103
		GridBagLayout gridBagLayout = new GridBagLayout();
104
		gridBagLayout.columnWidths = new int[]{303, 0, 0, 445, 102};
105

  
106
		setLayout(gridBagLayout);
107
		
108
		lblChartPreview = new JLabel("Chart preview");
109
		GridBagConstraints gbc_lblChartPreview = new GridBagConstraints();
110
		gbc_lblChartPreview.gridwidth = 4;
111
		gbc_lblChartPreview.anchor = GridBagConstraints.WEST;
112
		gbc_lblChartPreview.insets = new Insets(0, 0, 5, 5);
113
		gbc_lblChartPreview.gridx = 0;
114
		gbc_lblChartPreview.gridy = 0;
115
		add(lblChartPreview, gbc_lblChartPreview);
116
		
117
		GridBagConstraints gbc_panel_chartType = new GridBagConstraints();
118
		gbc_panel_chartType.gridheight = 2;
119
		gbc_panel_chartType.insets = new Insets(0, 0, 5, 0);
120
		gbc_panel_chartType.gridy = 1;
121
		gbc_panel_chartType.gridwidth = 5;
122
		gbc_panel_chartType.gridx = 0;
123
		add(getTypePanel(), gbc_panel_chartType);
124
		
125
		accept = new JButton("accept");
126
		GridBagConstraints gbc_accept = new GridBagConstraints();
127
		gbc_accept.anchor = GridBagConstraints.EAST;
128
		gbc_accept.insets = new Insets(0, 0, 0, 5);
129
		gbc_accept.gridx = 3;
130
		gbc_accept.gridy = 4;
131
		add(accept, gbc_accept);
132
		
133
		cancel = new JButton("Cancel");
134
		GridBagConstraints gbc_cancel = new GridBagConstraints();
135
		gbc_cancel.anchor = GridBagConstraints.WEST;
136
		gbc_cancel.gridx = 4;
137
		gbc_cancel.gridy = 4;
138
		add(cancel, gbc_cancel);
139
		
140
	}
141
	
142
	private JPanel getTypePanel(){
143
		if (panel_chartType==null){
144
		panel_chartType = new JPanel();
145
		
146
		GridBagLayout gbl_panel_chartType = new GridBagLayout();
147
		gbl_panel_chartType.columnWidths = new int[]{540, 0, 0, 210, 198, 56, 0};
148
		gbl_panel_chartType.rowHeights = new int[]{0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0};
149
		gbl_panel_chartType.columnWeights = new double[]{1.0, 0.0, 0.0, 1.0, 0.0, 0.0, Double.MIN_VALUE};
150
		gbl_panel_chartType.rowWeights = new double[]{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
151
		panel_chartType.setLayout(gbl_panel_chartType);
152
		
153
		previewPanel = new JPanel();
154
		previewPanel.setBackground(Color.WHITE);
155
		previewPanel.setBorder(new LineBorder(new Color(0, 0, 0)));
156
		GridBagConstraints gbc_previewPanel = new GridBagConstraints();
157
		gbc_previewPanel.gridheight = 2;
158
		gbc_previewPanel.gridwidth = 6;
159
		gbc_previewPanel.insets = new Insets(0, 0, 5, 5);
160
		gbc_previewPanel.fill = GridBagConstraints.BOTH;
161
		gbc_previewPanel.gridx = 0;
162
		gbc_previewPanel.gridy = 0;
163
		panel_chartType.add(previewPanel, gbc_previewPanel);
164
		
165
		
166
		chartOptionsLabel= new JLabel("Chart variables");
167
		GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints();
168
		gbc_lblNewLabel_3.anchor = GridBagConstraints.WEST;
169
		gbc_lblNewLabel_3.gridwidth = 4;
170
		gbc_lblNewLabel_3.insets = new Insets(0, 0, 5, 5);
171
		gbc_lblNewLabel_3.gridx = 0;
172
		gbc_lblNewLabel_3.gridy = 3;
173
		panel_chartType.add(chartOptionsLabel, gbc_lblNewLabel_3);
174
		
175
		table = new JTable(){
176
        	/**
177
			 * 
178
			 */
179
			private static final long serialVersionUID = -352323096347454258L;
180
			
181
			public boolean isCellEditable(int rowIndex, int colIndex) {
182
				if(colIndex==0)
183
					return true;
184
				return false; //Disallow the editing of any cell
185
			}
186
			
187
			public String getToolTipText(MouseEvent e) {
188
                String tip = null;
189
                List<ChartProperties> usedFields = getDocument().getChartProperties();
190
            	
191
                java.awt.Point p = e.getPoint();
192
                int rowIndex = rowAtPoint(p);
193
                int colIndex = columnAtPoint(p);
194
                int realColumnIndex = convertColumnIndexToModel(colIndex);
195

  
196
                if (realColumnIndex == 0) { //Sport column
197
                    tip = usedFields.get(rowIndex).getChartName();
198
                }
199
                return tip;
200
            }
201
        };
202
		
203
				GridBagConstraints gbc_table = new GridBagConstraints();
204
				gbc_table.gridheight = 6;
205
				gbc_table.gridwidth = 5;
206
				gbc_table.insets = new Insets(0, 0, 0, 5);
207
				gbc_table.fill = GridBagConstraints.BOTH;
208
				gbc_table.gridx = 0;
209
				gbc_table.gridy = 4;
210
				//panel_chartType.add(table, gbc_table);
211
				JScrollPane scrollPane = new JScrollPane(table);
212
				panel_chartType.add(scrollPane, gbc_table);
213
				table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
214
				
215
				upButton = new JButton("");
216
				upButton.setIcon(new ImageIcon(ChartPropertiesPanel.class.getResource("/icons/arrow_up.png")));
217
				GridBagConstraints gbc_upButton = new GridBagConstraints();
218
				gbc_upButton.insets = new Insets(0, 0, 5, 0);
219
				gbc_upButton.gridx = 5;
220
				gbc_upButton.gridy = 4;
221
				panel_chartType.add(upButton, gbc_upButton);
222
				
223
				downButton = new JButton("");
224
				downButton.setIcon(new ImageIcon(ChartPropertiesPanel.class.getResource("/icons/arrow_down.png")));
225
				GridBagConstraints gbc_downButton = new GridBagConstraints();
226
				gbc_downButton.insets = new Insets(0, 0, 5, 0);
227
				gbc_downButton.gridx = 5;
228
				gbc_downButton.gridy = 5;
229
				panel_chartType.add(downButton, gbc_downButton);
230
		
231
		
232
				addButton = new JButton("");
233
				addButton.setIcon(new ImageIcon(ChartPropertiesPanel.class.getResource("/icons/add.png")));
234
				GridBagConstraints gbc_addButton = new GridBagConstraints();
235
				gbc_addButton.insets = new Insets(0, 0, 5, 0);
236
				gbc_addButton.gridx = 5;
237
				gbc_addButton.gridy = 7;
238
				panel_chartType.add(addButton, gbc_addButton);
239
		
240
		editButton = new JButton("");
241
		editButton.setIcon(new ImageIcon(ChartPropertiesPanel.class.getResource("/icons/edit.png")));
242
		GridBagConstraints gbc_editButton = new GridBagConstraints();
243
		gbc_editButton.insets = new Insets(0, 0, 5, 0);
244
		gbc_editButton.gridx = 5;
245
		gbc_editButton.gridy = 8;
246
		panel_chartType.add(editButton, gbc_editButton);
247
		
248
		deleteButton = new JButton("");
249
		deleteButton.setIcon(new ImageIcon(ChartPropertiesPanel.class.getResource("/icons/delete.png")));
250
		GridBagConstraints gbc_deleteButton = new GridBagConstraints();
251
		gbc_deleteButton.anchor = GridBagConstraints.NORTH;
252
		gbc_deleteButton.gridx = 5;
253
		gbc_deleteButton.gridy = 9;
254
		panel_chartType.add(deleteButton, gbc_deleteButton);
255
		}
256
		return panel_chartType;
257
		
258
	}
259
	
260
	/**
261
	 * 
262
	 * Inicializa los elementos para el manejo de los Chart
263
	 */
264
	private void initialize() {
265
		String[] colName = {"Visible", "Variable (units)", "Chart Type", "Render type" };
266
		    
267
	    tableModel = (DefaultTableModel) table.getModel();
268
	    tableModel.setColumnIdentifiers(colName); 
269
	    
270
	    fillTableData();
271
	    table.getColumnModel().getColumn(0).setPreferredWidth(45);
272
	    table.getColumnModel().getColumn(2).setPreferredWidth(150);
273
	    table.getColumnModel().getColumn(3).setPreferredWidth(150);
274

  
275
	    
276
	    table.getColumnModel().getColumn(0).setCellRenderer(new CheckBoxRenderer());
277
	    table.getColumnModel().getColumn(2).setCellRenderer(new ChartCellRenderer(this));
278

  
279

  
280
	}
281
	
282
	public void fillTableData(){
283
		List<ChartProperties> chartProperties = getDocument().getChartProperties();
284
		removeTable();
285
	    for (int i = 0; i < chartProperties.size(); i++) {
286
	        Object[] data = new Object[4];
287
	        	data[0] = true;
288
	            data[1] = chartProperties.get(i).getChartTitle();
289
	            data[2] = getChartCellType(chartProperties.get(i).getChartType());
290
	            data[3] = chartProperties.get(i).getChartRenderer();
291

  
292
	        ((DefaultTableModel) tableModel).addRow(data);
293
	    }
294
	  //  tableModel.fireTableDataChanged();
295
	    table.revalidate();
296
	    table.repaint();
297
	}
298
	
299
	private ChartEntry getChartCellType(String type){
300
		for(int i=0;i<listModel.getSize(); i++){
301
			ChartEntry entry = (ChartEntry)listModel.get(i);
302
			String entryID = entry.getChartType().toString();
303
			if(entryID.compareToIgnoreCase(type.toString())==0)
304
				return entry;
305
		}
306
		return null;
307
	}
308

  
309
	public void removeTable(){
310
		int numRows = tableModel.getRowCount();
311
		for(int i=numRows-1; i>=0; i--){
312
			tableModel.removeRow(i);
313
		}
314
	}
315
	
316
	public WindowInfo getWindowInfo() {
317
		WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
318
   		m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_grafico"));
319
		m_viewinfo.setWidth(1000);
320
		m_viewinfo.setHeight(460);
321
		return m_viewinfo;
322
	}
323

  
324
	public Object getWindowProfile() {
325
		return WindowInfo.PROPERTIES_PROFILE;
326
	}
327

  
328
	public Object getWindowModel() {
329
		return chartDocument;
330
	}
331

  
332
	public String getSelectedChartType(){
333
		return selectedChartType;
334
	}
335
		
336
	/**
337
	 * Crea el panel de la ChartPropertiesPanel usando un dise?o de Abeille
338
	 */
339
	private void createButtonPanelEvents(){
340
		
341
		addButton.addActionListener(new ActionListener() {
342
			public void actionPerformed(ActionEvent e) {
343
				new ChartJDialog(new ChartUsedFieldPropertiesPanel(getDocument()));
344
			}
345
		});
346
		
347
		editButton.addActionListener(new ActionListener() {
348
			public void actionPerformed(ActionEvent e) {
349
				int index = table.getSelectedRow();
350
				if(index != -1){
351
					ChartProperties variable = getDocument().getChartProperties().get(index);
352
					new ChartJDialog(new ChartUsedFieldPropertiesPanel(getDocument(),variable));
353
				}else{
354
					System.out.println("No row selected");
355
				}
356
			}
357
		});
358
		
359
		deleteButton.addActionListener(new ActionListener() {
360
			public void actionPerformed(ActionEvent e) {
361
				int index = table.getSelectedRow();
362
				if(index != -1){
363
					ObservableUsedChartServices<ChartProperties> usedFields = getDocument().getChartProperties();
364
					usedFields.remove(usedFields.get(index));
365
					refreshTableData();
366
				}else{
367
					System.out.println("No row selected");
368
				}
369
			}
370
		});
371
		
372
		upButton.addActionListener(new ActionListener() {
373
			public void actionPerformed(ActionEvent e) {
374
				int index = table.getSelectedRow();
375
				if(index != -1){
376
					if(index > 0){
377
						ChartProperties variable = getDocument().getChartProperties().get(index);
378
						ChartProperties variable_ant = getDocument().getChartProperties().get(index-1);
379
						getDocument().getChartProperties().set(index - 1, variable);
380
						getDocument().getChartProperties().set(index, variable_ant);
381
					}
382
					
383
				}else{
384
					System.out.println("No row selected");
385
				}
386
			}
387
		});
388
		
389
		downButton.addActionListener(new ActionListener() {
390
			public void actionPerformed(ActionEvent e) {
391
				int index = table.getSelectedRow();
392
				if(index != -1){
393
					if(index < getDocument().getChartProperties().size()-1){
394
						ChartProperties variable = getDocument().getChartProperties().get(index);
395
						ChartProperties variable_pos = getDocument().getChartProperties().get(index+1);
396
						getDocument().getChartProperties().set(index + 1, variable);
397
						getDocument().getChartProperties().set(index, variable_pos);
398
					}
399
					
400
				}else{
401
					System.out.println("No row selected");
402
				}
403
			}
404
		});
405
		
406
		accept.addActionListener(new ActionListener() {
407
			public void actionPerformed(ActionEvent e) {
408
				acceptForm();
409
			}
410
		});
411
		cancel.addActionListener(new ActionListener() {
412
			public void actionPerformed(ActionEvent arg0) {
413
				cancelForm();
414
			}
415
		});
416

  
417
	}
418
	
419
	private void acceptForm(){
420
		System.out.println("Button accept pressed");
421
		
422
		try {
423
			//Create the overlayChart (base chart where the rest is superposed)
424
			ChartProperties props_overlay = swingManager.getChartSwingManager().getServiceManager().getChartManager().createProperties("OverlayChart");
425
			ChartService service_overlay = serviceManager.getChartManager().createChart(props_overlay);
426
        	
427
			ArrayList<ChartService> charts = new ArrayList<ChartService>();
428
        	
429
        	for(int i = 0; i < tableModel.getRowCount(); i++){
430
        		ChartEntry entry = (ChartEntry) tableModel.getValueAt(i, 3);
431
        		String chartType = entry.getChartType();
432
        		
433
				ChartProperties props = swingManager.getChartSwingManager().getServiceManager().getChartManager().createProperties(chartType);
434
				
435
//				//TODO: provisional para cambiar el render
436
//				if(i%2==0){
437
//					((BarsChartProperties)props).setRendererType("BarRenderer");
438
//				}
439
				
440
						
441
				ChartService service= serviceManager.getChartManager().createChart(props);
442
				
443
				// Create new dataset from the selected fields of the main dataset
444
				String keyField = (String) tableModel.getValueAt(i, 4);
445
				String colField = (String) tableModel.getValueAt(i, 5);
446
				String rowField = (String) tableModel.getValueAt(i, 6);
447
				
448
				Iterator<Object> keys = getDocument().getDataset().getValues(keyField);
449
				Iterator<Object> cols = getDocument().getDataset().getValues(colField);
450
				Iterator<Object> rows = getDocument().getDataset().getValues(rowField);
451
				
452
	        	DefaultChartDataSet dataSet = new DefaultChartDataSet();
453
	        	
454
	        	dataSet.setKeyField(keyField);
455
	        	dataSet.setColumnField(colField);
456
	        	dataSet.setRowField(rowField);
457
	        	
458
	        	dataSet.addData(keyField, keys);
459
	        	dataSet.addData(colField, cols);
460
	        	dataSet.addData(rowField, rows);
461
	        	service.setChartDataSet(dataSet);
462
	        	
463
	        	//Para el primer chart, fijar el Background y los ejes para que lo utilicen los siguientes.
464
//				if(i==0){
465
//					JFreeChart chart = (JFreeChart)service.getInnerChart();
466
//					ChartNumberAxis rangeAxis = new ChartNumberAxis(); 
467
//					rangeAxis.setAxis(chart.getCategoryPlot().getRangeAxis());
468
//					service_overlay.setRangeAxis(rangeAxis);
469
//				}else{
470
//					JFreeChart chart = (JFreeChart)service.getInnerChart();
471
//					chart.getCategoryPlot().setRangeAxis((ValueAxis) service_overlay.getRangeAxis());
472
//				}
473
	        	
474
	        	charts.add(service);
475
        	}
476
        	
477
        	((OverlayChartProperties)props_overlay).setCharts(charts);
478
        	ChartSwingPanel panel = swingManager.getChartSwingManager().createPanel(props_overlay);
479
        	panel.setChartService(service_overlay);
480

  
481
            panel.setPreferredSize(new Dimension(800, 400));
482
            swingManager.getChartSwingManager().getWindowManager().showWindow(panel, "Chart window",
483
                ChartWindowManager.MODE_WINDOW);
484
			
485
			
486
		} catch (ServiceException e) {
487
			// TODO Auto-generated catch block
488
			e.printStackTrace();
489
		}
490
	}
491
	
492
	private void cancelForm(){
493
		System.out.println("Button cancel pressed");
494
		setVisible(false);
495
	}
496
		
497
	private void getPreviewPanel(String type) {
498
		if(type == null){
499
			setPreviewImage(IconThemeHelper.getImageIcon("no-chart-example")); 
500
		}else{
501
			if(!list.isSelectionEmpty()){
502
				ChartEntry entry = (ChartEntry)list.getSelectedValue();
503
				setPreviewImage(entry.getExampleImage());
504
			}else{
505
				setPreviewImage(IconThemeHelper.getImageIcon("no-chart-example"));  
506
			}
507
		}
508
	}
509
	
510
	private void setPreviewImage(ImageIcon image){
511
		previewImageLabel.setIcon(image);
512
		previewImageLabel.revalidate();
513
		previewImageLabel.repaint();
514
	}
515

  
516
	public void actionPerformed(ActionEvent e) {	
517
	}
518
	
519
	public MainContext getDocument(){
520
		return this.chartDocument;
521
	}
522

  
523
	public void refreshTableData() {
524
		table.removeAll();
525
		fillTableData();
526
	}
527

  
528

  
529
	
530
	private void initializeChartList() {
531
//		DefaultListModel charts = getCharts();
532
//		list.setModel(charts);
533
//		list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
534
//		list.setCellRenderer(new ChartCellRenderer(this));
535
//        list.addListSelectionListener(this);
536
//		if(!charts.isEmpty()){
537
//			list.setSelectedIndex(0);
538
////			ChartEntry currentEntry = (ChartEntry)list.getSelectedValue();
539
////			this.setSelectedChartType(currentEntry.getChartType());
540
//		}
541

  
542
	}
543
	
544
	/**
545
	 * Obtiene los tipos de chart registrados
546
	 * @return DefaultListModel listModel
547
	 */
548
	private DefaultListModel getCharts() {
549
	    listModel = new DefaultListModel(); 
550
		List<ChartService> registeredServices = this.getDocument().getMainDocument().getServiceManager().getChartServices();
551
	        for(int i=0; i<registeredServices.size();i++){
552
	        	String auxType = registeredServices.get(i).getChartType();
553
	        	String auxName = registeredServices.get(i).getChartName();
554
	        	
555
	        	listModel.addElement(new ChartEntry(auxType, auxName));
556
	        }  
557
				
558
		return listModel;
559
	}
560

  
561
	
562
	/**
563
	 * Manejador de eventos para que cuando se selecciona un tipo de gr?fica
564
	 * actualice la preview y cargue el panel con los subtipos correspondientes
565
	 */
566
	public void valueChanged(ListSelectionEvent evt) {
567
		this.setSelectedChartType(((ChartEntry)list.getSelectedValue()).getChartType());
568
	}
569
	
570
	public void setSelectedChartType(String type){
571
		this.selectedChartType = type;
572
		this.getPreviewPanel(type);
573
		//this.getSubtypePanel(type);
574
	}
575
	
576
}
577

  
0 578

  
org.gvsig.chart/tags/org.gvsig.chart-1.0.74/org.gvsig.chart.main/src/main/java/org/gvsig/chart/main/panels/ChartUsedFieldPropertiesPanel.java
1
package org.gvsig.chart.main.panels;
2

  
3
import java.awt.Color;
4
import java.awt.Dimension;
5
import java.awt.GridBagConstraints;
6
import java.awt.GridBagLayout;
7
import java.awt.Insets;
8
import java.awt.event.ActionEvent;
9
import java.awt.event.ActionListener;
10
import java.util.HashMap;
11
import java.util.List;
12
import java.util.Map;
13

  
14
import javax.swing.DefaultListModel;
15
import javax.swing.JButton;
16
import javax.swing.JLabel;
17
import javax.swing.JList;
18
import javax.swing.JPanel;
19
import javax.swing.JTextField;
20
import javax.swing.JTextPane;
21
import javax.swing.ListSelectionModel;
22
import javax.swing.event.ListSelectionEvent;
23
import javax.swing.event.ListSelectionListener;
24

  
25
import org.gvsig.andami.PluginServices;
26
import org.gvsig.andami.ui.mdiManager.IWindow;
27
import org.gvsig.andami.ui.mdiManager.WindowInfo;
28
import org.gvsig.chart.ChartLocator;
29
import org.gvsig.chart.ChartProperties;
30
import org.gvsig.chart.ChartService;
31
import org.gvsig.chart.lib.spi.ChartServiceManager;
32
import org.gvsig.chart.main.DefaultDataPropertiesPanel;
33
import org.gvsig.chart.main.MainContext;
34
import org.gvsig.chart.main.utils.ChartCellRenderer;
35
import org.gvsig.chart.main.utils.ChartEntry;
36
import org.gvsig.chart.main.utils.ChartJDialog;
37
import org.gvsig.chart.main.utils.ChartJPanel;
38
import org.gvsig.chart.swing.ChartSwingLocator;
39
import org.gvsig.chart.swing.spi.ChartPanel;
40
import org.gvsig.chart.swing.spi.ChartSwingServiceManager;
41
import org.gvsig.tools.service.ServiceException;
42

  
43
public class ChartUsedFieldPropertiesPanel extends ChartJPanel implements IWindow, ActionListener, ListSelectionListener{
44

  
45
	/**
46
	 * 
47
	 */
48
	private static final long serialVersionUID = -301224990996378683L;
49

  
50
	private static final int SUBPANEL_WIDTH = 400;
51
	private static final int SUBPANEL_HEIGHT = 210;
52
	
53
    private JButton accept;
54
	private JButton cancel;
55
    
56
	private String selectedChartType = null;
57
	private ChartPanel currentSubtypePanel = null;
58

  
59
	private JPanel panel_chartType = null;
60
	private JPanel panelSubtype = null;
61
	private Map<String, JPanel> cardPanel = new HashMap<String, JPanel>();
62
	private JList list = null;
63
	private DefaultListModel listModel;
64
	private JLabel chartTypesLabel;
65
	private JLabel chartOptionsLabel;
66

  
67
	private ChartServiceManager serviceManager;
68

  
69
	private ChartSwingServiceManager swingManager;
70
	private JLabel lblName;
71
	private JTextField nameTextField;
72
	private JTextField unitsTextField;
73
	private JLabel lblUnits;
74
	private JLabel lblDescription;
75
	private JTextPane descriptionTextField;
76

  
77
	private MainContext mainContext;
78

  
79
	private ChartJDialog chartJDialog;
80
	
81
	private ChartProperties chartProperties;
82
	private ChartProperties previousChartProperties;
83
	
84
	/**
85
	 * @wbp.parser.constructor
86
	 */
87
	public ChartUsedFieldPropertiesPanel(MainContext mainContext) {
88
		serviceManager = ChartLocator.getServiceManager();
89
		swingManager = ChartSwingLocator.getSwingManager();
90
		
91
		this.mainContext = mainContext;
92
//		this.usedField = usedField;
93
//		this.chartUsedFieldPanel = chartUsedFieldPanel;
94
		
95
		createMainPanel();
96
		createButtonPanelEvents();
97
	}
98
	
99
	public ChartUsedFieldPropertiesPanel(MainContext mainContext, ChartProperties props) {
100
		this(mainContext);
101
		chartProperties = props;
102
		previousChartProperties = props;
103
		this.completeForm();
104
	}
105
	
106
	public void completeForm(){
107
		
108
		// Rellenamos todos los campos
109
		nameTextField.setText(chartProperties.getChartName());
110
		
111
		// Seleccionamos el tipo de gr?fica
112
		for(int i=0;i<listModel.getSize();i++){
113
			ChartEntry entry = (ChartEntry) listModel.get(i);
114
			if(entry.getChartType()==chartProperties.getChartType()){
115
				list.setSelectedIndex(i);
116
			}
117
		}
118
		
119
		// Rellenamos el panel caracter?stico de cada tipo de gr?fica
120
		ChartPanel panel = (ChartPanel) cardPanel.get((String)chartProperties.getChartType());
121
		panel.setChartProperties(chartProperties);
122
		
123
		// TODO ??Refrescar el panel??
124
	}
125
	
126
	public ChartProperties getPreviousChartProperties(){
127
		return previousChartProperties;
128
	}
129
	
130
	private void createMainPanel(){
131
		GridBagLayout gridBagLayout = new GridBagLayout();
132
		gridBagLayout.columnWidths = new int[]{303, 0, 0, 88, 0};
133

  
134
		setLayout(gridBagLayout);
135
		
136
		GridBagConstraints gbc_panel_chartType = new GridBagConstraints();
137
		gbc_panel_chartType.gridheight = 2;
138
		gbc_panel_chartType.insets = new Insets(0, 0, 5, 0);
139
		gbc_panel_chartType.gridy = 0;
140
		gbc_panel_chartType.gridwidth = 5;
141
		gbc_panel_chartType.gridx = 0;
142
		add(getTypePanel(), gbc_panel_chartType);
143
		
144
		accept = new JButton("Next  >");
145
		GridBagConstraints gbc_accept = new GridBagConstraints();
146
		gbc_accept.insets = new Insets(0, 0, 0, 5);
147
		gbc_accept.gridx = 3;
148
		gbc_accept.gridy = 2;
149
		add(accept, gbc_accept);
150
		
151
		cancel = new JButton("Cancel");
152
		GridBagConstraints gbc_cancel = new GridBagConstraints();
153
		gbc_cancel.gridx = 4;
154
		gbc_cancel.gridy = 2;
155
		add(cancel, gbc_cancel);
156
		
157
	}
158
	
159
	private JPanel getTypePanel(){
160
		if (panel_chartType==null){
161
		panel_chartType = new JPanel();
162
		
163
		GridBagLayout gbl_panel_chartType = new GridBagLayout();
164
		gbl_panel_chartType.columnWidths = new int[]{150, 0, 210, 0, 0, 203, 0};
165
		gbl_panel_chartType.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 208, 0, 0};
166
		gbl_panel_chartType.columnWeights = new double[]{1.0, 0.0, 1.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
167
		gbl_panel_chartType.rowWeights = new double[]{0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE};
168
		panel_chartType.setLayout(gbl_panel_chartType);
169
		
170
		lblName = new JLabel("Name");
171
		GridBagConstraints gbc_lblName = new GridBagConstraints();
172
		gbc_lblName.anchor = GridBagConstraints.WEST;
173
		gbc_lblName.insets = new Insets(0, 0, 5, 5);
174
		gbc_lblName.gridx = 0;
175
		gbc_lblName.gridy = 0;
176
		panel_chartType.add(lblName, gbc_lblName);
177
		
178
		nameTextField = new JTextField();
179
		GridBagConstraints gbc_nameTextField = new GridBagConstraints();
180
		gbc_nameTextField.gridwidth = 4;
181
		gbc_nameTextField.insets = new Insets(0, 0, 5, 0);
182
		gbc_nameTextField.fill = GridBagConstraints.HORIZONTAL;
183
		gbc_nameTextField.gridx = 2;
184
		gbc_nameTextField.gridy = 0;
185
		panel_chartType.add(nameTextField, gbc_nameTextField);
186
		nameTextField.setColumns(10);
187
		
188
		lblUnits = new JLabel("Units");
189
		GridBagConstraints gbc_lblUnits = new GridBagConstraints();
190
		gbc_lblUnits.anchor = GridBagConstraints.WEST;
191
		gbc_lblUnits.insets = new Insets(0, 0, 5, 5);
192
		gbc_lblUnits.gridx = 0;
193
		gbc_lblUnits.gridy = 1;
194
		panel_chartType.add(lblUnits, gbc_lblUnits);
195
		
196
		unitsTextField = new JTextField();
197
		GridBagConstraints gbc_unitsTextField = new GridBagConstraints();
198
		gbc_unitsTextField.gridwidth = 4;
199
		gbc_unitsTextField.insets = new Insets(0, 0, 5, 0);
200
		gbc_unitsTextField.fill = GridBagConstraints.HORIZONTAL;
201
		gbc_unitsTextField.gridx = 2;
202
		gbc_unitsTextField.gridy = 1;
203
		panel_chartType.add(unitsTextField, gbc_unitsTextField);
204
		unitsTextField.setColumns(10);
205
		
206
		lblDescription = new JLabel("Description");
207
		GridBagConstraints gbc_lblDescription = new GridBagConstraints();
208
		gbc_lblDescription.anchor = GridBagConstraints.WEST;
209
		gbc_lblDescription.insets = new Insets(0, 0, 5, 5);
210
		gbc_lblDescription.gridx = 0;
211
		gbc_lblDescription.gridy = 2;
212
		panel_chartType.add(lblDescription, gbc_lblDescription);
213
		
214
		descriptionTextField = new JTextPane();
215
		GridBagConstraints gbc_descriptionTextField = new GridBagConstraints();
216
		gbc_descriptionTextField.gridheight = 3;
217
		gbc_descriptionTextField.gridwidth = 4;
218
		gbc_descriptionTextField.insets = new Insets(0, 0, 5, 0);
219
		gbc_descriptionTextField.fill = GridBagConstraints.BOTH;
220
		gbc_descriptionTextField.gridx = 2;
221
		gbc_descriptionTextField.gridy = 2;
222
		panel_chartType.add(descriptionTextField, gbc_descriptionTextField);
223
		
224
		chartTypesLabel = new JLabel("Chart renderer types");
225
		GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
226
		gbc_lblNewLabel_2.anchor = GridBagConstraints.WEST;
227
		gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 5);
228
		gbc_lblNewLabel_2.gridx = 0;
229
		gbc_lblNewLabel_2.gridy = 5;
230
		panel_chartType.add(chartTypesLabel, gbc_lblNewLabel_2);
231
		
232
		chartOptionsLabel= new JLabel("Drawing options");
233
		GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints();
234
		gbc_lblNewLabel_3.anchor = GridBagConstraints.WEST;
235
		gbc_lblNewLabel_3.gridwidth = 4;
236
		gbc_lblNewLabel_3.insets = new Insets(0, 0, 5, 0);
237
		gbc_lblNewLabel_3.gridx = 2;
238
		gbc_lblNewLabel_3.gridy = 5;
239
		panel_chartType.add(chartOptionsLabel, gbc_lblNewLabel_3);
240
		
241
		list = new JList();
242
		GridBagConstraints gbc_list = new GridBagConstraints();
243
		gbc_list.insets = new Insets(0, 0, 5, 5);
244
		gbc_list.fill = GridBagConstraints.BOTH;
245
		gbc_list.gridx = 0;
246
		gbc_list.gridy = 6;
247
		panel_chartType.add(list, gbc_list);
248
		
249
		panelSubtype = new JPanel(); 
250
		GridBagConstraints gbc_panelSubtype = new GridBagConstraints();
251
		gbc_panelSubtype.insets = new Insets(0, 0, 5, 0);
252
		gbc_panelSubtype.gridwidth = 4;
253
		gbc_panelSubtype.fill = GridBagConstraints.BOTH;
254
		gbc_panelSubtype.gridx = 2;
255
		gbc_panelSubtype.gridy = 6;
256
		panelSubtype.setAutoscrolls(true);
257
		Dimension dimension = new Dimension(SUBPANEL_WIDTH, SUBPANEL_HEIGHT);
258
		panelSubtype.setMaximumSize(dimension);
259
		panelSubtype.setMinimumSize(dimension);
260
		panel_chartType.add(panelSubtype, gbc_panelSubtype);
261
		}
262
		return panel_chartType;
263
		
264
	}
265
	
266
	public WindowInfo getWindowInfo() {
267
		WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
268
   		m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_variable"));
269
		m_viewinfo.setWidth(575);
270
		m_viewinfo.setHeight(500);
271
		return m_viewinfo;
272
	}
273

  
274
	public Object getWindowProfile() {
275
		return WindowInfo.PROPERTIES_PROFILE;
276
	}
277

  
278
//	public Object getWindowModel() {
279
//		return chartDocument;
280
//	}
281

  
282
	public String getSelectedChartType(){
283
		return selectedChartType;
284
	}
285
		
286
	/**
287
	 * Crea el panel de la ChartPropertiesPanel usando un dise?o de Abeille
288
	 */
289
	private void createButtonPanelEvents(){
290
		cardPanel.put("empty", new JPanel());
291
		
292
		accept.addActionListener(new ActionListener() {
293
			public void actionPerformed(ActionEvent e) {
294
				acceptForm();
295
			}
296
		});
297
		cancel.addActionListener(new ActionListener() {
298
			public void actionPerformed(ActionEvent arg0) {
299
				cancelForm();
300
			}
301
		});
302
				
303
		//Inicializamos componentes
304
		initializeChartList();
305
	}
306
	
307
	private void acceptForm(){
308
			//chartProperties = serviceManager.getChartManager().createProperties(((ChartEntry)listModel.get(list.getSelectedIndex())).getChartType());
309
//		if(!(chartProperties!=null && !(chartProperties.getChartType().equals(this.currentSubtypePanel.getChartProviderClass().toString()) ))){
310
//			chartProperties = this.currentSubtypePanel.getChartProperties();
311
//		}
312
		
313
		if(this.previousChartProperties != null){
314
			if(this.chartProperties == null &&
315
					previousChartProperties.getChartType().equals(this.currentSubtypePanel.getChartProviderClass().toString())){
316
				chartProperties = previousChartProperties;
317
			}else{
318
				if(this.chartProperties != null &&
319
						!(chartProperties.getChartType().equals(this.currentSubtypePanel.getChartProviderClass().toString()))){
320
					chartProperties = this.currentSubtypePanel.getChartProperties();
321
					//TODO autorrellenar campos en com?n
322
					// this.copyChartProperties();
323
				}
324
			}
325
		}else{
326
			chartProperties = this.currentSubtypePanel.getChartProperties();
327
		}
328
		this.setVisible(false);
329
		this.getParentWindow().setVisible(false);
330
		DefaultDataPropertiesPanel panelProps = new DefaultDataPropertiesPanel(chartProperties, this);
331
		
332
		ChartJDialog dlg = new ChartJDialog(panelProps);
333
		dlg.getContentPane().setPreferredSize(new Dimension(800, 400));
334
		dlg.setSize(new Dimension(350, 75 + (30 * chartProperties.getRequiredFields().size())));
335
		dlg.setVisible(true);
336
	}
337
	
338
	private void cancelForm(){
339
		//Close the window
340
		this.setVisible(false);
341
		this.getParentWindow().setVisible(false);
342
	}
343
		
344
	private void initializeChartList() {
345
		DefaultListModel charts = getCharts();
346
		list.setModel(charts);
347
		list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
348
		list.setCellRenderer(new ChartCellRenderer(this));
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff