Revision 35164 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/layout/gui/dialogs/FConfigLayoutDialog.java
FConfigLayoutDialog.java | ||
---|---|---|
46 | 46 |
|
47 | 47 |
import java.awt.Dimension; |
48 | 48 |
import java.text.NumberFormat; |
49 |
import java.util.Iterator; |
|
49 | 50 |
|
51 |
import javax.print.attribute.standard.MediaSizeName; |
|
52 |
import javax.swing.JComboBox; |
|
50 | 53 |
import javax.swing.JPanel; |
51 | 54 |
|
55 |
import org.apache.log4j.Logger; |
|
56 |
|
|
52 | 57 |
import com.iver.andami.PluginServices; |
53 | 58 |
import com.iver.andami.ui.mdiManager.IWindow; |
54 | 59 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
55 | 60 |
import com.iver.cit.gvsig.fmap.MapContext; |
61 |
import com.iver.cit.gvsig.printutils.MediaSizeNameWrapper; |
|
62 |
import com.iver.cit.gvsig.printutils.UserMediaSizeName; |
|
56 | 63 |
import com.iver.cit.gvsig.project.documents.layout.Attributes; |
57 | 64 |
import com.iver.cit.gvsig.project.documents.layout.Size; |
58 | 65 |
import com.iver.cit.gvsig.project.documents.layout.gui.Layout; |
... | ... | |
64 | 71 |
* @author Vicente Caballero Navarro |
65 | 72 |
*/ |
66 | 73 |
public class FConfigLayoutDialog extends JPanel implements IWindow { |
74 |
|
|
75 |
private static Logger logger = Logger.getLogger(FConfigLayoutDialog.class); |
|
76 |
|
|
67 | 77 |
private javax.swing.JLabel lTamPag = null; |
68 | 78 |
private javax.swing.JComboBox cbTipoFolio = null; |
69 | 79 |
private javax.swing.JLabel lDistancia = null; |
... | ... | |
181 | 191 |
cbTipoFolio.setSize(175, 20); |
182 | 192 |
cbTipoFolio.setPreferredSize(new java.awt.Dimension(130, 20)); |
183 | 193 |
cbTipoFolio.setLocation(175, 15); |
184 |
cbTipoFolio.addItem(PluginServices.getText(this, |
|
185 |
"Igual_que_la_impresora")); |
|
186 |
cbTipoFolio.addItem(PluginServices.getText(this, "A4")); |
|
187 |
cbTipoFolio.addItem(PluginServices.getText(this, "A3")); |
|
188 |
cbTipoFolio.addItem(PluginServices.getText(this, "A2")); |
|
189 |
cbTipoFolio.addItem(PluginServices.getText(this, "A1")); |
|
190 |
cbTipoFolio.addItem(PluginServices.getText(this, "A0")); |
|
191 |
cbTipoFolio.addItem(PluginServices.getText(this, "Personalizado")); |
|
192 |
|
|
193 |
cbTipoFolio.setSelectedIndex(m_layout.getLayoutContext().getAtributes().getType()); |
|
194 |
|
|
195 |
Iterator iter = Attributes.PAPER_NAMES_LIST.keySet().iterator(); |
|
196 |
while (iter.hasNext()) { |
|
197 |
cbTipoFolio.addItem( |
|
198 |
new MediaSizeNameWrapper( |
|
199 |
(MediaSizeName) Attributes.PAPER_NAMES_LIST.get(iter.next()))); |
|
200 |
} |
|
201 |
|
|
202 |
int curr_type = m_layout.getLayoutContext().getAtributes().getType(); |
|
203 |
int index = getIndexOfWrapperWithId(cbTipoFolio, curr_type); |
|
204 |
cbTipoFolio.setSelectedIndex(index); |
|
205 |
|
|
194 | 206 |
cbTipoFolio.addActionListener(new java.awt.event.ActionListener() { |
195 | 207 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
196 |
type = cbTipoFolio.getSelectedIndex(); |
|
208 |
|
|
209 |
MediaSizeNameWrapper wra = |
|
210 |
(MediaSizeNameWrapper) cbTipoFolio.getSelectedItem(); |
|
211 |
|
|
212 |
type = Attributes.getIdForMediaSizeName(wra.getMediaSizeName()); |
|
197 | 213 |
|
198 | 214 |
Size size = m_layout.getLayoutContext().getAtributes().getSizeinUnits(isLand, |
199 | 215 |
type); |
216 |
|
|
200 | 217 |
getTAlto().setText(String.valueOf(nf.format( |
201 | 218 |
size.getAlto()))); |
202 | 219 |
getTAncho().setText(String.valueOf(nf.format( |
203 | 220 |
size.getAncho()))); |
204 | 221 |
setMargin(margin); |
205 |
if (cbTipoFolio.getSelectedItem().equals(PluginServices.getText(this,"Personalizado"))) { |
|
222 |
if (type == Attributes.PREPARE_PAGE_ID_CUSTOM) { |
|
223 |
// cbTipoFolio.getSelectedItem().equals(PluginServices.getText(this,"Personalizado"))) { |
|
206 | 224 |
getTAlto().setEnabled(true); |
207 | 225 |
getTAncho().setEnabled(true); |
208 | 226 |
getChbVertical().setSelected(true); |
... | ... | |
223 | 241 |
return cbTipoFolio; |
224 | 242 |
} |
225 | 243 |
|
244 |
|
|
245 |
|
|
246 |
private int getIndexOfWrapperWithId(JComboBox combo, int id) { |
|
247 |
|
|
248 |
MediaSizeName msn = Attributes.getMediaSizeNameForId(id); |
|
249 |
|
|
250 |
int cnt = combo.getItemCount(); |
|
251 |
MediaSizeNameWrapper w = null; |
|
252 |
for (int i=0; i<cnt; i++) { |
|
253 |
w = (MediaSizeNameWrapper) combo.getItemAt(i); |
|
254 |
if (w.getMediaSizeName() == msn) { |
|
255 |
return i; |
|
256 |
} |
|
257 |
} |
|
258 |
logger.error("Did not find MSN for ID: " + id + " (returned index 0 for combo)"); |
|
259 |
return 0; |
|
260 |
} |
|
261 |
|
|
226 | 262 |
/** |
227 | 263 |
* This method initializes lDistancia |
228 | 264 |
* |
... | ... | |
262 | 298 |
Size size = m_layout.getLayoutContext().getAtributes().getSizeinUnits(isLand, |
263 | 299 |
type); |
264 | 300 |
getTAlto().setText(String.valueOf(nf.format( |
301 |
size.getAlto()))); |
|
302 |
getTAncho().setText(String.valueOf(nf.format( |
|
265 | 303 |
size.getAncho()))); |
266 |
getTAncho().setText(String.valueOf(nf.format( |
|
267 |
size.getAlto()))); |
|
268 | 304 |
setMargin(margin); |
269 | 305 |
} |
270 | 306 |
}); |
... | ... | |
640 | 676 |
private javax.swing.JButton getBAceptar() { |
641 | 677 |
if (bAceptar == null) { |
642 | 678 |
bAceptar = new javax.swing.JButton(); |
643 |
bAceptar.setSize(84, 23);
|
|
679 |
bAceptar.setSize(84, 26);
|
|
644 | 680 |
bAceptar.setText(PluginServices.getText(this, "Aceptar")); |
645 |
bAceptar.setLocation(130, 245);
|
|
681 |
bAceptar.setLocation(90, 255);
|
|
646 | 682 |
bAceptar.addActionListener(new java.awt.event.ActionListener() { |
647 | 683 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
648 | 684 |
m_layout.getLayoutContext().getAtributes().setUnit(unit); |
... | ... | |
659 | 695 |
|
660 | 696 |
double[] area = { sup, inf, izq, der }; |
661 | 697 |
|
662 |
if (type == Attributes.CUSTOM) { |
|
698 |
if (type == Attributes.PREPARE_PAGE_ID_CUSTOM) {
|
|
663 | 699 |
String width=getTAncho().getText().replace(',','.'); |
664 | 700 |
String height=getTAlto().getText().replace(',','.'); |
665 |
Attributes.CUSTOM_PAPER_SIZE = new Size(Double.valueOf( |
|
666 |
width).doubleValue(), |
|
667 |
Double.valueOf(height) |
|
668 |
.doubleValue()); |
|
701 |
|
|
702 |
double _w = Double.valueOf(width).doubleValue(); |
|
703 |
double _h = Double.valueOf(height).doubleValue(); |
|
704 |
|
|
705 |
_w = m_layout.getLayoutContext().getAtributes().fromUnits(_w); |
|
706 |
_h = m_layout.getLayoutContext().getAtributes().fromUnits(_h); |
|
707 |
|
|
708 |
Attributes.CUSTOM_PAPER_SIZE = new Size(_w, _h); |
|
669 | 709 |
m_layout.getLayoutContext().getAtributes().m_sizePaper=Attributes.CUSTOM_PAPER_SIZE; |
670 | 710 |
} |
671 | 711 |
m_layout.getLayoutContext().getAtributes().setType(type); |
... | ... | |
690 | 730 |
private javax.swing.JButton getBCancelar() { |
691 | 731 |
if (bCancelar == null) { |
692 | 732 |
bCancelar = new javax.swing.JButton(); |
693 |
bCancelar.setSize(85, 23);
|
|
733 |
bCancelar.setSize(85, 26);
|
|
694 | 734 |
bCancelar.setText(PluginServices.getText(this, "Cancelar")); |
695 |
bCancelar.setLocation(245, 245);
|
|
735 |
bCancelar.setLocation(185, 255);
|
|
696 | 736 |
bCancelar.addActionListener(new java.awt.event.ActionListener() { |
697 | 737 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
698 | 738 |
//setVisible(false); |
... | ... | |
736 | 776 |
setMargin(margin); |
737 | 777 |
|
738 | 778 |
//}else{ |
739 |
if (type == Attributes.CUSTOM) { |
|
779 |
if (type == Attributes.PREPARE_PAGE_ID_CUSTOM) {
|
|
740 | 780 |
Attributes.CUSTOM_PAPER_SIZE = new Size(Double.valueOf( |
741 | 781 |
getTAlto().getText()).doubleValue(), |
742 | 782 |
Double.valueOf(getTAncho().getText()) |
... | ... | |
791 | 831 |
setMargin(margin); |
792 | 832 |
|
793 | 833 |
//}else{ |
794 |
if (type == Attributes.CUSTOM) { |
|
834 |
if (type == Attributes.PREPARE_PAGE_ID_CUSTOM) {
|
|
795 | 835 |
Attributes.CUSTOM_PAPER_SIZE = new Size(Double.valueOf( |
796 | 836 |
getTAncho().getText()).doubleValue(), |
797 | 837 |
Double.valueOf(getTAlto().getText()) |
... | ... | |
820 | 860 |
public WindowInfo getWindowInfo() { |
821 | 861 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG); |
822 | 862 |
m_viewinfo.setWidth(371); |
823 |
m_viewinfo.setHeight(300);
|
|
863 |
m_viewinfo.setHeight(260);
|
|
824 | 864 |
m_viewinfo.setTitle(PluginServices.getText(this, "Preparar_pagina")); |
825 | 865 |
|
826 | 866 |
return m_viewinfo; |
... | ... | |
874 | 914 |
return WindowInfo.DIALOG_PROFILE; |
875 | 915 |
} |
876 | 916 |
} |
917 |
|
|
918 |
// [eiel-add-print-formats] |
Also available in: Unified diff