svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / layout / mapbox / panel / FFrameMapBoxPanel.java @ 1714
History | View | Annotate | Download (3.93 KB)
1 | 1714 | fdiaz | /*
|
---|---|---|---|
2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||
3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||
4 | */
|
||
5 | package org.gvsig.layout.mapbox.panel; |
||
6 | |||
7 | import java.awt.geom.Dimension2D; |
||
8 | import java.awt.geom.Rectangle2D; |
||
9 | import javax.swing.SpinnerNumberModel; |
||
10 | import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
||
11 | import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
||
12 | import org.gvsig.layout.mapbox.fframe.FFrameMapBox; |
||
13 | import org.gvsig.layout.mapbox.model.Dimension2DDouble; |
||
14 | import org.gvsig.layout.mapbox.model.MapBoxModel; |
||
15 | import org.gvsig.tools.ToolsLocator; |
||
16 | import org.gvsig.tools.i18n.I18nManager; |
||
17 | import org.gvsig.tools.lang.CloneableUtils; |
||
18 | import org.gvsig.tools.swing.api.ToolsSwingLocator; |
||
19 | import org.gvsig.tools.swing.api.ToolsSwingManager; |
||
20 | |||
21 | /**
|
||
22 | *
|
||
23 | * @author fdiaz
|
||
24 | */
|
||
25 | public class FFrameMapBoxPanel extends FFrameMapBoxPanelView { |
||
26 | /*
|
||
27 | La clase FFrameMapBoxPanelView debe extender de AbstractFFramePanel y ser abstract
|
||
28 | public abstract class FFrameMapBoxPanelView extends AbstractFFramePanel
|
||
29 | */
|
||
30 | |||
31 | // private Dimension dimension;
|
||
32 | private MapBoxModel model;
|
||
33 | private Rectangle2D rectangle; |
||
34 | private FFrameMapBox baseFrame;
|
||
35 | private Rectangle2D.Double fframebbox; |
||
36 | |||
37 | public FFrameMapBoxPanel(LayoutPanel layoutPanel, IFFrame fframe) {
|
||
38 | initComponents(); |
||
39 | translate(); |
||
40 | put((FFrameMapBox)fframe); |
||
41 | } |
||
42 | |||
43 | private void initComponents() { |
||
44 | this.spnColumns.setModel(new SpinnerNumberModel(3, 1, Integer.MAX_VALUE, 1)); |
||
45 | this.spnRows.setModel(new SpinnerNumberModel(3, 1, Integer.MAX_VALUE, 1)); |
||
46 | this.spnDegrees.setModel(new SpinnerNumberModel(0d, -179d, +180d, 1d)); |
||
47 | } |
||
48 | |||
49 | private void translate() { |
||
50 | ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
||
51 | |||
52 | toolsSwingManager.translate(this.lblRows);
|
||
53 | toolsSwingManager.translate(this.lblColumns);
|
||
54 | toolsSwingManager.translate(this.lblDegrees);
|
||
55 | toolsSwingManager.translate(this.lblPreview);
|
||
56 | } |
||
57 | |||
58 | public FFrameMapBox fetch(FFrameMapBox output) {
|
||
59 | //FIXME: Este rectangle no es bueno para crear el frame
|
||
60 | //porque ya est? pasado por la AT
|
||
61 | if (output == null) { |
||
62 | output = (FFrameMapBox) CloneableUtils.cloneQuietly(this.baseFrame);
|
||
63 | if(output == null){ |
||
64 | return null; |
||
65 | } |
||
66 | output.setBoundBox(fframebbox); |
||
67 | } |
||
68 | output.setRotation((double) this.spnDegrees.getValue()); |
||
69 | if (this.model == null || this.model.isEmpty()) { |
||
70 | Dimension2D dimension = new Dimension2DDouble( |
||
71 | fframebbox.getWidth(), |
||
72 | fframebbox.getHeight()); |
||
73 | this.model = new MapBoxModel( |
||
74 | dimension, |
||
75 | (int) this.spnColumns.getValue(), |
||
76 | (int) this.spnRows.getValue()); |
||
77 | } |
||
78 | output.setModel(model); |
||
79 | return output;
|
||
80 | } |
||
81 | |||
82 | public void put(FFrameMapBox fframeMapBox) { |
||
83 | if(fframeMapBox != null) { |
||
84 | this.baseFrame = fframeMapBox;
|
||
85 | this.model = fframeMapBox.getModel();
|
||
86 | this.spnDegrees.setValue(fframeMapBox.getRotation());
|
||
87 | |||
88 | boolean enabled =(this.model == null || this.model.isEmpty()); |
||
89 | this.spnColumns.setEnabled(enabled);
|
||
90 | this.spnRows.setEnabled(enabled);
|
||
91 | this.fframebbox = fframeMapBox.getBoundBox();
|
||
92 | // this.rectangle = fframeMapBox.getBoundBox();
|
||
93 | } |
||
94 | } |
||
95 | |||
96 | @Override
|
||
97 | public IFFrame getFFrame() {
|
||
98 | return fetch(null); |
||
99 | } |
||
100 | |||
101 | @Override
|
||
102 | public void setRectangle(Rectangle2D r) { |
||
103 | this.rectangle = r;
|
||
104 | } |
||
105 | |||
106 | @Override
|
||
107 | public String getTitle() { |
||
108 | I18nManager i18n = ToolsLocator.getI18nManager(); |
||
109 | return i18n.getTranslation("_Mapbox_properties"); |
||
110 | } |
||
111 | |||
112 | |||
113 | |||
114 | } |