Revision 5556

View differences:

org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.10/org.gvsig.legend.urbanhorizontalsignage.app/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
  <modelVersion>4.0.0</modelVersion>
3
  <parent>
4
    <groupId>org.gvsig</groupId>
5
    <artifactId>org.gvsig.legend.urbanhorizontalsignage</artifactId>
6
    <version>1.0.10</version>
7
  </parent>
8
  <groupId>org.gvsig</groupId>
9
  <artifactId>org.gvsig.legend.urbanhorizontalsignage.app</artifactId>
10
  <packaging>pom</packaging>
11
  <name>org.gvsig.legend.urbanhorizontalsignage.app</name>
12

  
13
  <modules>
14
    <module>org.gvsig.legend.urbanhorizontalsignage.app.mainplugin</module>
15
  </modules>
16

  
17
</project>
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.10/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/buildNumber.properties
1
#Tue Sep 28 09:02:17 CEST 2021
2
buildNumber=99
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.10/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/src/main/resources-plugin/plugin-persistence.def
1
<?xml version="1.0"?>
2
<!--
3
Definitions of plugin persistence org.gvsig.aggregatelegend.app.mainplugin
4
 -->
5
<definitions>
6
  <version>1.0.0</version>
7
  <classes>
8
    <class name="org.gvsig.legend.urbanhorizontalsignage.app.mainplugin">
9
      <extends>
10
      </extends>
11
      <description>Persistence of the legend of urban horizontal signage</description>
12
      <fields>
13
      </fields>
14
    </class>
15
  </classes>
16
</definitions>  
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.10/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/src/main/resources-plugin/i18n/text.properties
1
_Urban_horizontal_signage_legend_description=Leyenda para la se\u00f1alizaci\u00f3n urbana horizontal
2
_Urban_horizontal_signage_legend=Se\u00f1alizaci\u00f3n urbana horizontal
3
_Width_field=Campo para la anchura
4
_Continuity_field=Campo para la continuidad
5
_Segments_color_field=Campo para el color de los segmentos
6
_Segments_length_field=Campo para la longitud de los segmentos
7
_Paint_holes_field=Campo para el pintado de los huecos
8
_Holes_color_field=Campo para el color de los huecos
9
_Holes_length_field=Campo para la longitud de los huecos
10
_Round_vertex_field=Campo para el redondeo de los v\u00e9rtices
11
_Gap_width_between_lines=Separaci\u00f3n entre l\u00edneas
12
_Copy_selected_features_as_polygons_to_clipboard=Copiar elementos seleccionados como pol\u00edgonos al portapapeles
13
_Number_of_geometries_to_be_copied_to_the_clipboard=N\u00famero de geometr\u00edas a ser copiadas al portapapeles
14
_Do_you_want_to_continue=\u00bfDesea continuar?
15
_Copy_as_polygons=Copiar como pol\u00edgonos
16
_Target_Color_field=Campo de destino para el color
17
_Target_Length_field=Campo de destino para la longitud
18
_Target_Area_field=Campo de destino para el \u00e1rea
19
# ---------------------------------------
20
# Picture marker symbol table legend
21
#
22
_Picture_marker_symbol_table_legend=Valores \u00fanicos de marcador de imagen en tabla
23
_Legend_table_fields=Campos de la tabla de la leyenda
24
_Images_table_fields=Campos de la tabla de las imagenes
25
_Unit=Unidad
26
_Line_to_offset_color=Color de la linea al offset
27
_Draw_line_to_offset=Pinta la linea al offset
28
_Classifying_field=Campo para clasificar
29
_OffsetX_field=Campo para el offset X
30
_OffsetY_field=Campo para el offset Y
31
_Rotation_field=Campo para la rotaci\u00f3n
32
_Line_to_offset_color_field=Campo para el color de la linea al offset
33
_Table_name=Nombre de tabla
34
_Image_field=Campo de la imagen
35
_Image_selected_field=Campo de la imagen seleccionada
36
# ---------------------------------------
37
_Convert_lines_to_polygons=Convertir lineas a poligonos
38
_Convert_Urban_signage_lines_to_polygons=Convertir lineas de se\u00e1lizaci\u00f2n urbana a poligonos
39
_Convert=Converir
40
_Target_layer=Capa destino
41
_Elements_to_process=Elementos a procesar
42
_Delete_lines_at_finish=Eliminar lineas al terminar
43
_Urban_signage=Se\u00f1alizaci\u00f3n urbana
44

  
45

  
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.10/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties
1
_Urban_horizontal_signage_legend_description=Urban horizontal signage legend
2
_Urban_horizontal_signage_legend=Urban horizontal signage
3
_Width_field=Width field
4
_Continuity_field=Continuity field
5
_Segments_color_field=Segments color field
6
_Segments_length_field=Segments length field
7
_Paint_holes_field=Paint holes field
8
_Holes_color_field=Holes color field
9
_Holes_length_field=Holes length field
10
_Round_vertex_field=Round vertex field
11
_Gap_width_between_lines=Gap width between lines
12
_Copy_selected_features_as_polygons_to_clipboard=Copy selected features as polygons to clipboard
13
_Number_of_geometries_to_be_copied_to_the_clipboard=Number of geometries to be copied to the clipboard
14
_Do_you_want_to_continue=Do you want to continue?
15
_Copy_as_polygons=Copy as polygons
16
_Target_Color_field=Target color field
17
_Target_Length_field=Target length field
18
_Target_Area_field=Target area field
19
# ---------------------------------------
20
# Picture marker symbol table legend
21
#
22
_Picture_marker_symbol_table_legend=Picture marker unique values in table
23
_Legend_table_fields=Legend table fields
24
_Images_table_fields=Images table fields
25
_Unit=Unit
26
_Line_to_offset_color=Line to offset color
27
_Draw_line_to_offset=Draw line to offset
28
_Classifying_field=Classifying field
29
_OffsetX_field=OffsetX field
30
_OffsetY_field=OffsetY field
31
_Rotation_field=Rotation field
32
_Line_to_offset_color_field=Line to offset color field
33
_Table_name=Table name
34
_Image_field=Image field
35
_Image_selected_field=Image selected field
36
# ---------------------------------------
37
_Convert_lines_to_polygons=Convert lines to polygons
38
_Convert_Urban_signage_lines_to_polygons=Convert urban signage lines to polygons
39
_Convert=Convert
40
_Target_layer=Target layer
41
_Elements_to_process=Elements to process
42
_Delete_lines_at_finish=Delete lines at finish
43
_Urban_signage=Urban signage
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.10/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/src/main/resources-plugin/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!-- gvSIG. Desktop Geographic Information System. Copyright (C) 2007-2013 gvSIG
3
  Association. This program is free software; you can redistribute it and/or modify
4
  it under the terms of the GNU General Public License as published by the Free Software
5
  Foundation; either version 3 of the License, or (at your option) any later version.
6
  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
7
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8
  PURPOSE. See the GNU General Public License for more details. You should have received
9
  a copy of the GNU General Public License along with this program; if not, write to
10
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
11
  USA. For any additional information, do not hesitate to contact us at info AT gvsig.com,
12
  or visit our website www.gvsig.com. -->
13
<plugin-config>
14
  <depends plugin-name="org.gvsig.app.mainplugin" />
15
  <resourceBundle name="text" />
16
  <libraries library-dir="lib" />
17
  <extensions>
18
      <extension class-name="org.gvsig.legend.urbanhorizontalsignage.app.UrbanHorizontalSignageExtension"
19
                 description="" active="true" priority="1">
20
        
21
          <action
22
              name="layer-modify-clipboard-copy-as-polygons"
23
              label="_Copy_selected_features_as_polygons_to_clipboard"
24
              tooltip="_Copy_selected_features_as_polygons_to_clipboard"
25
              position="601105001"
26
              action-command="layer-modify-clipboard-copy-as-polygons"
27
              icon="layer-modify-clipboard-copy-as-polygons"
28
              accelerator=""
29
          />
30

  
31
          <action
32
              name="tools-urbanSignage-linesToPolygons"
33
              label="_Convert_lines_to_polygons"
34
              tooltip="_Copy_selected_lines_to_polygons"
35
              position="900500000"
36
              action-command="tools-urbanSignage-linesToPolygons"
37
              icon="tools-urbanSignage-linesToPolygons"
38
              accelerator=""
39
          />
40

  
41
          <menu
42
              name="layer-modify-clipboard-copy-as-polygons"
43
              text="Layer/Modify/_Copy_selected_features_as_polygons_to_clipboard"
44
          />
45

  
46
          <menu
47
              name="tools-urbanSignage-linesToPolygons"
48
              text="tools/_Urban_signage/_Convert_lines_to_polygons"
49
          />
50

  
51
<!--          
52
          <tool-bar name="edit">
53
              <action-tool
54
                  name="layer-modify-clipboard-copy-as-polygons"
55
              />
56
          </tool-bar>
57
-->
58

  
59

  
60
      </extension>
61
      <extension class-name="org.gvsig.legend.urbanhorizontalsignage.app.rotate.RotatePointExtension"
62
                 description="" active="false" priority="1">
63
        
64
          <action
65
              name="layer-modify-rotatepoint"
66
              label="_Rotate_point"
67
              tooltip="_Rotate_point"
68
              position="601105001"
69
              action-command="layer-modify-rotatepoint"
70
              icon="layer-modify-rotatepoint"
71
              accelerator=""
72
          />
73

  
74
          <menu
75
              name="layer-modify-rotatepoint"
76
              text="Layer/Modify/_Rotate_point"
77
          />
78

  
79
      </extension>
80

  
81
  </extensions>
82
</plugin-config>
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.10/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml
1
<!-- gvSIG. Desktop Geographic Information System. Copyright (C) 2007-2013 gvSIG
2
  Association. This program is free software; you can redistribute it and/or modify
3
  it under the terms of the GNU General Public License as published by the Free Software
4
  Foundation; either version 3 of the License, or (at your option) any later version.
5
  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
6
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
7
  PURPOSE. See the GNU General Public License for more details. You should have received
8
  a copy of the GNU General Public License along with this program; if not, write to
9
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
10
  USA. For any additional information, do not hesitate to contact us at info AT gvsig.com,
11
  or visit our website www.gvsig.com. -->
12
<assembly>
13
  <id>gvsig-plugin-package</id>
14
  <formats>
15
    <format>zip</format>
16
  </formats>
17
  <baseDirectory>${project.artifactId}</baseDirectory>
18
  <includeBaseDirectory>true</includeBaseDirectory>
19
  <files>
20
    <file>
21
      <source>target/${project.artifactId}-${project.version}.jar</source>
22
      <outputDirectory>lib</outputDirectory>
23
    </file>
24
    <file>
25
      <source>target/package.info</source>
26
    </file>
27
  </files>
28

  
29
  <fileSets>
30
    <fileSet>
31
      <directory>src/main/resources-plugin</directory>
32
      <outputDirectory>.</outputDirectory>
33
    </fileSet>
34
  </fileSets>
35

  
36

  
37
  <dependencySets>
38
    <dependencySet>
39
      <useProjectArtifact>false</useProjectArtifact>
40
      <useTransitiveDependencies>false</useTransitiveDependencies>
41
      <outputDirectory>lib</outputDirectory>
42
      <includes>
43
        <include>org.gvsig:org.gvsig.legend.urbanhorizontalsignage.lib.api</include>
44
        <include>org.gvsig:org.gvsig.legend.urbanhorizontalsignage.lib.impl</include>
45
        <include>org.gvsig:org.gvsig.legend.urbanhorizontalsignage.swing.api</include>
46
        <include>org.gvsig:org.gvsig.legend.urbanhorizontalsignage.swing.impl</include>
47
      </includes>
48
    </dependencySet>
49
  </dependencySets>
50

  
51
</assembly>
52

  
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.10/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/src/main/java/org/gvsig/legend/urbanhorizontalsignage/app/UrbanHorizontalSignageConfigForCopyPanel.java
1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.legend.urbanhorizontalsignage.app;
7

  
8
import javax.swing.JComponent;
9
import org.gvsig.fmap.dal.DataTypes;
10
import org.gvsig.fmap.dal.feature.FeatureType;
11
import org.gvsig.fmap.dal.swing.DALSwingLocator;
12
import org.gvsig.fmap.dal.swing.DataSwingManager;
13
import org.gvsig.fmap.dal.swing.featuretype.AttributeDescriptorPickerController;
14
import org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageConfig;
15
import org.gvsig.legend.urbanhorizontalsignage.swing.api.linelegend.UrbanHorizontalSignageConfigPanel;
16
import org.gvsig.tools.swing.api.Component;
17
import org.gvsig.tools.swing.api.ToolsSwingLocator;
18
import org.gvsig.tools.swing.api.ToolsSwingManager;
19

  
20
/**
21
 *
22
 * @author fdiaz
23
 */
24
public class UrbanHorizontalSignageConfigForCopyPanel extends UrbanHorizontalSignageConfigForCopyPanelView implements  UrbanHorizontalSignageConfigPanel, Component {
25

  
26
    private AttributeDescriptorPickerController targetColorFieldController;
27
    private AttributeDescriptorPickerController targetLengthFieldController;
28
    private AttributeDescriptorPickerController targetAreaFieldController;
29

  
30
    public UrbanHorizontalSignageConfigForCopyPanel() {
31
        
32
        initComponents();
33
        
34
    }
35
    
36
    
37

  
38
    private void initComponents(){
39
        ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager();
40
        DataSwingManager dataSwingManager = DALSwingLocator.getDataSwingManager();
41
        
42
        targetColorFieldController = dataSwingManager.createAttributeDescriptorPickerController(cboTargetColorFields, (t) -> {
43
            return t.getDataType().isNumeric() || t.getType() == DataTypes.STRING;
44
        });
45
        targetColorFieldController.setEditable(true);
46
        
47
        targetLengthFieldController = dataSwingManager.createAttributeDescriptorPickerController(cboTargetLengthFields, (t) -> {
48
            return t.getDataType().isNumeric();
49
        });
50
        targetLengthFieldController.setEditable(true);
51
        
52
        targetAreaFieldController = dataSwingManager.createAttributeDescriptorPickerController(cboTargetAreaFields, (t) -> {
53
            return t.getDataType().isNumeric();
54
        });
55
        targetAreaFieldController.setEditable(true);
56
        
57
        translateAll();
58
    }
59
    
60
    private void translateAll() {
61
        ToolsSwingManager toolsSwingmanager = ToolsSwingLocator.getToolsSwingManager();
62
        toolsSwingmanager.translate(this.lblTargetColorField);
63
        toolsSwingmanager.translate(this.lblTargetLengthField);
64
        toolsSwingmanager.translate(this.lblTargetAreaField);
65
    }
66

  
67
    @Override
68
    public void fetch(UrbanHorizontalSignageConfig config) {
69
        config.setTargetColorFieldName((String) this.targetColorFieldController.getName());
70
        config.setTargetLenghtFieldName((String) this.targetLengthFieldController.getName());
71
        config.setTargetAreaFieldName((String) this.targetAreaFieldController.getName());
72
    }
73

  
74
    @Override
75
    public void put(UrbanHorizontalSignageConfig config) {
76
        this.targetColorFieldController.set(config.getTargetColorFieldName());
77
        this.targetLengthFieldController.set(config.getTargetLenghtFieldName());
78
        this.targetAreaFieldController.set(config.getTargetAreaFieldName());
79
    }
80

  
81
    @Override
82
    public void setFeatureType(FeatureType type) {
83
        this.targetColorFieldController.setFeatureType(type);
84
        this.targetAreaFieldController.setFeatureType(type);
85
        this.targetLengthFieldController.setFeatureType(type);
86
    }
87

  
88
    @Override
89
    public JComponent asJComponent() {
90
        return this;
91
    }
92
    
93
}
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.10/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/src/main/java/org/gvsig/legend/urbanhorizontalsignage/app/UrbanHorizontalSignageExtension.java
1
package org.gvsig.legend.urbanhorizontalsignage.app;
2

  
3
import java.awt.event.ActionEvent;
4
import java.util.function.Predicate;
5
import javax.swing.Icon;
6
import javax.swing.JOptionPane;
7
import javax.swing.SwingConstants;
8
import javax.swing.event.TreeModelListener;
9
import javax.swing.tree.TreePath;
10
import org.gvsig.andami.IconThemeHelper;
11
import org.gvsig.andami.plugins.Extension;
12
import org.gvsig.app.ApplicationLocator;
13
import org.gvsig.app.ApplicationManager;
14
import org.gvsig.app.project.documents.view.ViewDocument;
15
import org.gvsig.app.project.documents.view.ViewManager;
16
import org.gvsig.fmap.dal.DALLocator;
17
import org.gvsig.fmap.dal.DataManager;
18
import org.gvsig.fmap.dal.DataStore;
19
import org.gvsig.fmap.dal.feature.FeatureSelection;
20
import org.gvsig.fmap.dal.feature.FeatureSet;
21
import org.gvsig.fmap.dal.feature.FeatureStore;
22
import org.gvsig.fmap.dal.feature.FeatureType;
23
import org.gvsig.fmap.mapcontext.MapContext;
24
import org.gvsig.fmap.mapcontext.MapContextLocator;
25
import org.gvsig.fmap.mapcontext.layers.FLayers;
26
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
27
import org.gvsig.fmap.mapcontrol.CompoundStoresTreeModel;
28
import org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageLegend;
29
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageLocator;
30
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageManager;
31
import org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageConfig;
32
import org.gvsig.legend.urbanhorizontalsignage.swing.api.ConvertLinesToPolygonsPanel;
33
import org.gvsig.legend.urbanhorizontalsignage.swing.api.UrbanHorizontalSignageSwingLocator;
34
import org.gvsig.legend.urbanhorizontalsignage.swing.api.UrbanHorizontalSignageSwingManager;
35
import org.gvsig.tools.ToolsLocator;
36
import org.gvsig.tools.dispose.DisposeUtils;
37
import org.gvsig.tools.i18n.I18nManager;
38
import org.gvsig.tools.swing.api.ToolsSwingLocator;
39
import org.gvsig.tools.swing.api.windowmanager.Dialog;
40
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
41
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2;
42
import org.gvsig.tools.util.LabeledValue;
43
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
45

  
46
@SuppressWarnings("UseSpecificCatch")
47
public class UrbanHorizontalSignageExtension extends Extension {
48

  
49
    private static final Logger LOGGER = LoggerFactory.getLogger(UrbanHorizontalSignageExtension.class);
50

  
51
    @Override
52
    public void initialize() {
53
        IconThemeHelper.registerIcon("legend", "legend-overview-vectorial-urbanhorizontalsignage", this);
54
        IconThemeHelper.registerIcon("legend", "legend-overview-vectorial-picturemarkersymboltable", this);
55
        IconThemeHelper.registerIcon("action", "layer-modify-clipboard-copy-as-polygons", this);
56

  
57
    }
58

  
59
    @Override
60
    public void execute(String actionCommand) {
61
        ApplicationManager application = ApplicationLocator.getManager();
62

  
63
        if ("layer-modify-clipboard-copy-as-polygons".equalsIgnoreCase(actionCommand) ) {
64
            ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
65
            if (viewdoc == null) {
66
                return;
67
            }
68
            MapContext mapContext = viewdoc.getMapContext();
69
            FLyrVect layer = mapContext.getLayers().getFirstActiveVectorLayer();
70
            if (layer == null) {
71
                return;
72
            }
73
            copySelecctionAsPolygons(layer);
74
            
75
        } else if ("tools-urbanSignage-linesToPolygons".equalsIgnoreCase(actionCommand) ) {
76
            ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
77
            if (viewdoc == null) {
78
                return;
79
            }
80
            MapContext mapContext = viewdoc.getMapContext();
81
            FLyrVect layer = mapContext.getLayers().getFirstActiveVectorLayer();
82
            if (layer == null) {
83
                return;
84
            }
85
            if( !(layer.getLegend() instanceof UrbanHorizontalSignageLegend) ) {
86
                //FIXME mensaje al usuario?
87
                return;
88
            }
89
            UrbanHorizontalSignageLegend legend = (UrbanHorizontalSignageLegend) layer.getLegend();
90
            UrbanHorizontalSignageConfig config = legend.getConfig(); // FIXME: clone
91
            FeatureSet lines;
92
            try {
93
                lines = layer.getFeatureStore().getFeatureSelection();
94
            } catch(Exception ex) {
95
                //FIXME mensaje al usuario?
96
                return;
97
            }
98
            convertLinesAsPolygons(config, lines);
99
        }
100
        
101
    }
102
    
103
    private void copySelecctionAsPolygons(FLyrVect sourceLayer) {
104
//        UrbanHorizontalSignageManager uhsManager = UrbanHorizontalSignageLocator.getUrbanHorizontalSignageManager();
105

  
106
        UrbanHorizontalSignageConfigForCopyPanel panel = new UrbanHorizontalSignageConfigForCopyPanel();
107
        panel.setFeatureType(sourceLayer.getFeatureStore().getDefaultFeatureTypeQuietly());
108
        UrbanHorizontalSignageLegend legend = (UrbanHorizontalSignageLegend) sourceLayer.getLegend();
109
        panel.put(legend.getConfig());
110

  
111
        I18nManager i18n = ToolsLocator.getI18nManager();
112
        WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager();
113

  
114
        Dialog theDialog = winManager.createDialog(
115
                panel.asJComponent(),
116
                i18n.getTranslation("_Copy_as_polygons"),
117
                i18n.getTranslation("_Copy_as_polygons"),
118
                WindowManager_v2.BUTTONS_OK_CANCEL
119
        );
120
        theDialog.setAutoclose(false);
121

  
122
        theDialog.setButtonLabel(
123
                WindowManager_v2.BUTTON_OK,
124
                i18n.getTranslation("_Accept")
125
        );
126
        theDialog.setButtonLabel(
127
                WindowManager_v2.BUTTON_CANCEL,
128
                i18n.getTranslation("_Cancel")
129
        );
130

  
131
        theDialog.addActionListener((ActionEvent e) -> {
132
            switch (theDialog.getAction()) {
133
                case WindowManager_v2.BUTTON_OK:
134
                    Thread task = new Thread(() -> {
135
                        panel.fetch(legend.getConfig());
136
                        performCopyAsPolygons(sourceLayer);
137
                        theDialog.asJComponent().setVisible(false);
138
                    }, "UHS_CopyAsPolygons");
139
                    task.start();
140
                    break;
141
                case WindowManager_v2.BUTTON_CANCEL:
142
                    theDialog.asJComponent().setVisible(false);
143
                    break;
144
            }
145
        });
146

  
147
        theDialog.show(WindowManager.MODE.DIALOG);
148
    }
149
    
150
    private void performCopyAsPolygons(FLyrVect sourceLayer) {
151
        I18nManager i18n = ToolsLocator.getI18nManager();
152
        UrbanHorizontalSignageManager uhsManager = UrbanHorizontalSignageLocator.getUrbanHorizontalSignageManager();
153
        ApplicationManager application = ApplicationLocator.getManager();
154
        DataManager dataManager = DALLocator.getDataManager();
155

  
156
        UrbanHorizontalSignageLegend legend = (UrbanHorizontalSignageLegend) sourceLayer.getLegend();
157
        FeatureStore tempTargetStore = null;
158
        FeatureSet tempFeatureSet = null;
159
        try {
160

  
161
            FeatureSet sourceFeatureSet = sourceLayer.getFeatureStore().getFeatureSelection();
162
            tempTargetStore = uhsManager.createTemporaryPolygonsFromLines(legend.getConfig(), sourceFeatureSet, null);
163
            tempFeatureSet = tempTargetStore.getFeatureSet();
164

  
165
            int n = application.confirmDialog(
166
                    "_Number_of_geometries_to_be_copied_to_the_clipboard" + " " + tempFeatureSet.getSize() + "\n" + "_Do_you_want_to_continue",
167
                    i18n.getTranslation("_Copy_selected_features_as_polygons_to_clipboard"),
168
                    JOptionPane.YES_NO_OPTION,
169
                    JOptionPane.QUESTION_MESSAGE);
170
            if (n == JOptionPane.YES_OPTION) {
171
                dataManager.putFeaturesInClipboard(tempFeatureSet);
172
            }
173

  
174
        } catch (Exception e) {
175
            LOGGER.warn("Can't get the selection as JSON.", e);
176
        } finally {
177
            DisposeUtils.disposeQuietly(tempTargetStore);
178
            DisposeUtils.disposeQuietly(tempFeatureSet);
179
        }
180

  
181
    }
182
    
183
    private void convertLinesAsPolygons(UrbanHorizontalSignageConfig config, FeatureSet source) {
184
        I18nManager i18n = ToolsLocator.getI18nManager();
185
        WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager();
186
        ApplicationManager application = ApplicationLocator.getManager();
187
        UrbanHorizontalSignageManager uhsManager = UrbanHorizontalSignageLocator.getUrbanHorizontalSignageManager();
188
        UrbanHorizontalSignageSwingManager uhsSwingManager = UrbanHorizontalSignageSwingLocator.getUrbanHorizontalSignageSwingManager();
189

  
190
        
191
        final ConvertLinesToPolygonsPanel panel = uhsSwingManager.createConvertLinesToPolygonsPanel();       
192
        panel.setSource(source);
193
        panel.setStores(new StoresWithLayerTypeIcon());
194
        panel.put(config);
195

  
196
        Dialog theDialog = winManager.createDialog(
197
                panel.asJComponent(),
198
                i18n.getTranslation("_Convert_lines_to_polygons"),
199
                i18n.getTranslation("_Convert_Urban_signage_lines_to_polygons"),
200
                WindowManager_v2.BUTTONS_OK_CANCEL
201
        );
202
        theDialog.setButtonLabel(WindowManager_v2.BUTTON_OK, i18n.getTranslation("_Convert"));
203
        theDialog.setButtonLabel(WindowManager_v2.BUTTON_CANCEL, i18n.getTranslation("_Close"));
204
        theDialog.setAutoclose(false);
205

  
206
        theDialog.addActionListener((ActionEvent e) -> {
207
            switch (theDialog.getAction()) {
208
                case WindowManager_v2.BUTTON_OK:
209
                    Thread task = new Thread(() -> {
210
                        try {
211
                            theDialog.setButtonEnabled(WindowManager_v2.BUTTON_OK, false);
212
                            panel.setTaskStatusVisible(true);
213
                            uhsManager.convertLinesToPolygons(
214
                                    panel.getConfig(), 
215
                                    panel.getSource(), 
216
                                    panel.getTargetStore(), 
217
                                    panel.getDeleteSourceAtFinish(),
218
                                    panel.getTaskStatus()
219
                            );
220
                            theDialog.asJComponent().setVisible(false);
221
                        } catch(Exception ex) {
222
                            LOGGER.warn("Can't convert lines to polygons", ex);
223
                        }
224
                    }, "UHS_ConvertLinesToPolygons");
225
                    task.start();
226
                    break;
227
                case WindowManager_v2.BUTTON_CANCEL:
228
                    theDialog.asJComponent().setVisible(false);
229
                    break;
230
            }
231
        });
232

  
233
        theDialog.show(WindowManager.MODE.WINDOW);
234
    }
235

  
236
    @Override
237
    public boolean isEnabled() {
238
        // it's enabled if there is exactly one vector layer in the active view
239
        // and it has a selection
240

  
241
        ApplicationManager application = ApplicationLocator.getManager();
242
        ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
243
        if (viewdoc == null) {
244
            return false;
245
        }
246
        MapContext mapContext = viewdoc.getMapContext();
247
        FLyrVect layer = mapContext.getLayers().getFirstActiveVectorLayer();
248
        if (layer == null) {
249
            return false;
250
        }
251
        if (!layer.isAvailable()) {
252
            // This can happen when opening a persisted project
253
            // and there is a "slow" layer (GeoDB)
254
            return false;
255
        }
256
        try {
257
            FeatureStore store = layer.getFeatureStore();
258
            FeatureSelection selection = store.getFeatureSelection();
259
            if (selection.isEmpty()) {
260
                return false;
261
            }
262
            return (layer.getLegend() instanceof UrbanHorizontalSignageLegend);
263
//            return !selection.isEmpty();
264
        } catch (Exception ex) {
265
            LOGGER.warn("Can't get selection from layer '" + layer.getName() + "'.", ex);
266
            return false;
267
        }
268
    }
269

  
270
    @Override
271
    public boolean isVisible() {
272
        ApplicationManager application = ApplicationLocator.getManager();
273
        return application.getActiveDocument(ViewManager.TYPENAME) != null;
274
    }
275
    
276
    private static class StoresWithLayerTypeIcon implements CompoundStoresTreeModel {
277

  
278
        private final CompoundStoresTreeModel delegated;
279

  
280
        public StoresWithLayerTypeIcon() {
281
            ApplicationManager application = ApplicationLocator.getManager();
282
            this.delegated = (CompoundStoresTreeModel) application.createProjectStoresTreeModel();
283
        }
284
        
285
        @Override
286
        public void setFilter(Predicate<DataStore> filter) {
287
            this.delegated.setFilter(filter);
288
        }
289

  
290
        @Override
291
        public void addLayers(FLayers layers) {
292
            this.delegated.addLayers(layers);
293
        }
294

  
295
        @Override
296
        public Icon getIcon(Object item) {
297
            Icon icon = this.delegated.getIcon(item);
298
            if( item instanceof LabeledValue ) {
299
                item = ((LabeledValue)item).getValue();
300
            }
301
            if (item instanceof FeatureStore) {
302
                try {
303
                    FeatureStore store = (FeatureStore) item;
304
                    FeatureType ft = store.getDefaultFeatureTypeQuietly();
305
                    int type = ft.getDefaultGeometryAttribute().getGeomType().getType();
306
                    Icon icon2 = MapContextLocator.getMapContextManager().getIcon(
307
                            type, 
308
                            !store.getFeatureSelection().isEmpty()
309
                    );
310
                    if( icon2!=null ) {
311
                        icon = ToolsSwingLocator.getToolsSwingManager().createCompoundIcon(
312
                               SwingConstants.HORIZONTAL, 2, icon, icon2
313
                        );
314
                    }
315
                } catch(Exception ex) {
316
                    LOGGER.trace("Can't get geometry type from store.", ex);
317
                }
318
            }
319
            return icon;
320
        }
321

  
322
        @Override
323
        public Object getRoot() {
324
            return this.delegated.getRoot();
325
        }
326

  
327
        @Override
328
        public Object getChild(Object parent, int index) {
329
            return this.delegated.getChild(parent, index);
330
        }
331

  
332
        @Override
333
        public int getChildCount(Object parent) {
334
            return this.delegated.getChildCount(parent);
335
        }
336

  
337
        @Override
338
        public boolean isLeaf(Object node) {
339
            return this.delegated.isLeaf(node);
340
        }
341

  
342
        @Override
343
        public void valueForPathChanged(TreePath path, Object newValue) {
344
            this.delegated.valueForPathChanged(path, newValue);
345
        }
346

  
347
        @Override
348
        public int getIndexOfChild(Object parent, Object child) {
349
            return this.delegated.getIndexOfChild(parent, child);
350
        }
351

  
352
        @Override
353
        public void addTreeModelListener(TreeModelListener l) {
354
            this.delegated.addTreeModelListener(l);
355
        }
356

  
357
        @Override
358
        public void removeTreeModelListener(TreeModelListener l) {
359
            this.delegated.removeTreeModelListener(l);
360
        }
361
        
362
    }
363

  
364
}
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.10/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/src/main/java/org/gvsig/legend/urbanhorizontalsignage/app/rotate/RotatePointListener.java
1
package org.gvsig.legend.urbanhorizontalsignage.app.rotate;
2

  
3
import org.gvsig.fmap.dal.feature.Feature;
4
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
5
import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
6

  
7
/**
8
 *
9
 * @author gvSIG Team
10
 */
11
public interface RotatePointListener extends ToolListener {
12

  
13
    public void rotate(Feature feature, String fieldName, double angle) throws BehaviorException;
14
}
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.10/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/src/main/java/org/gvsig/legend/urbanhorizontalsignage/app/rotate/RotatePointListenerImpl.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2014 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23

  
24
package org.gvsig.legend.urbanhorizontalsignage.app.rotate;
25

  
26
import org.gvsig.fmap.dal.exception.DataException;
27
import org.gvsig.fmap.dal.feature.EditableFeature;
28
import org.gvsig.fmap.dal.feature.Feature;
29

  
30
import org.slf4j.Logger;
31
import org.slf4j.LoggerFactory;
32

  
33
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
34
import org.gvsig.fmap.mapcontrol.tools.Listeners.AbstractToolListener;
35

  
36
/**
37
 * @author gvSIG Team
38
 *
39
 */
40
@SuppressWarnings("UseSpecificCatch")
41
public class RotatePointListenerImpl 
42
        extends AbstractToolListener
43
        implements RotatePointListener  
44
    {
45

  
46
    private static final Logger LOGGER = LoggerFactory.getLogger(RotatePointListenerImpl.class);
47

  
48
    public static final String ROTATE_TOOL_NAME = "RotatePoint";
49
    
50
    
51
    public RotatePointListenerImpl() {
52
        super();
53
    }
54

  
55
    @Override
56
    public void rotate(Feature feature, String fieldName, double angle) throws BehaviorException {
57
        try {
58
            EditableFeature ef = feature.getEditable();
59
            ef.set(fieldName, angle);
60
            feature.getStore().update(ef);
61
        } catch (DataException ex) {
62
            LOGGER.debug("Can't save rotation to feature", ex);
63
                    
64
        }
65
    }
66
    
67
}
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.10/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/src/main/java/org/gvsig/legend/urbanhorizontalsignage/app/rotate/RotatePointExtension.java
1
package org.gvsig.legend.urbanhorizontalsignage.app.rotate;
2

  
3
import org.gvsig.andami.plugins.Extension;
4
import org.gvsig.app.ApplicationLocator;
5
import org.gvsig.app.ApplicationManager;
6
import org.gvsig.app.project.documents.view.ViewDocument;
7
import org.gvsig.app.project.documents.view.ViewManager;
8
import org.gvsig.app.project.documents.view.gui.IView;
9
import org.gvsig.fmap.dal.feature.FeatureSelection;
10
import org.gvsig.fmap.dal.feature.FeatureStore;
11
import org.gvsig.fmap.mapcontext.MapContext;
12
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
13
import org.gvsig.fmap.mapcontrol.MapControl;
14
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
15
import org.gvsig.legend.urbanverticalsignage.lib.api.PictureMarkerSymbolTableLegend;
16
import org.slf4j.Logger;
17
import org.slf4j.LoggerFactory;
18

  
19
@SuppressWarnings("UseSpecificCatch")
20
public class RotatePointExtension extends Extension {
21

  
22
    private static final Logger LOGGER = LoggerFactory.getLogger(RotatePointExtension.class);
23

  
24
    @Override
25
    public void initialize() {
26
//        IconThemeHelper.registerIcon("legend", "legend-overview-vectorial-urbanhorizontalsignage", this);
27
//        IconThemeHelper.registerIcon("legend", "legend-overview-vectorial-picturemarkersymboltable", this);
28
//        IconThemeHelper.registerIcon("action", "layer-modify-clipboard-copy-as-polygons", this);
29

  
30
    }
31

  
32
    @Override
33
    public void execute(String actionCommand) {
34

  
35
        if (actionCommand.compareToIgnoreCase("layer-modify-rotatepoint") != 0) {
36
            return;
37
        }
38

  
39
        ApplicationManager application = ApplicationLocator.getManager();
40
        IView view = (IView) application.getActiveComponent(ViewDocument.class);
41
        if (view == null) {
42
            return;
43
        }
44
        MapControl mapControl = view.getMapControl();
45
        if (mapControl == null) {
46
            return;
47
        }
48
        MapContext mapContext = mapControl.getMapContext();
49
        if (mapContext == null) {
50
            return;
51
        }
52
        FLyrVect layer = mapContext.getLayers().getFirstActiveVectorLayer();
53
        if (layer == null) {
54
            return;
55
        }
56
        if (!mapControl.hasTool(RotatePointListenerImpl.ROTATE_TOOL_NAME)) {
57
            RotatePointListenerImpl listener = new RotatePointListenerImpl();
58
            Behavior behavior = new RotatePointBehavior(listener);
59
            mapControl.addBehavior(RotatePointListenerImpl.ROTATE_TOOL_NAME, behavior);
60
        }
61
        mapControl.setTool(RotatePointListenerImpl.ROTATE_TOOL_NAME);
62
    }
63
    
64
       
65
    @Override
66
    public boolean isEnabled() {
67
        ApplicationManager application = ApplicationLocator.getManager();
68
        ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
69
        if (viewdoc == null) {
70
            return false;
71
        }
72
        MapContext mapContext = viewdoc.getMapContext();
73
        FLyrVect layer = mapContext.getLayers().getFirstActiveVectorLayer();
74
        if (layer == null) {
75
            return false;
76
        }
77
        if (!layer.isAvailable()) {
78
            // This can happen when opening a persisted project
79
            // and there is a "slow" layer (GeoDB)
80
            return false;
81
        }
82
        try {
83
            FeatureStore store = layer.getFeatureStore();
84
            FeatureSelection selection = store.getFeatureSelection();
85
            if (selection.isEmpty()) {
86
                return false;
87
            }
88
            return (layer.getLegend() instanceof PictureMarkerSymbolTableLegend);
89
        } catch (Exception ex) {
90
            LOGGER.warn("Can't get selection from layer '" + layer.getName() + "'.", ex);
91
            return false;
92
        }
93
    }
94

  
95
    @Override
96
    public boolean isVisible() {
97
        ApplicationManager application = ApplicationLocator.getManager();
98
        return application.getActiveDocument(ViewManager.TYPENAME) != null;
99
    }
100

  
101
}
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.10/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/src/main/java/org/gvsig/legend/urbanhorizontalsignage/app/rotate/RotatePointBehavior.java
1
package org.gvsig.legend.urbanhorizontalsignage.app.rotate;
2

  
3
import java.awt.event.InputEvent;
4
import java.awt.event.MouseEvent;
5
import java.awt.geom.AffineTransform;
6
import java.awt.geom.Point2D;
7
import javax.swing.SwingUtilities;
8
import org.gvsig.euclidean.EuclideanLine2D;
9
import org.gvsig.euclidean.EuclideanManager;
10
import org.gvsig.fmap.dal.feature.Feature;
11
import org.gvsig.fmap.dal.feature.FeatureSelection;
12
import org.gvsig.fmap.geom.Geometry;
13
import org.gvsig.fmap.geom.primitive.Point;
14
import org.gvsig.fmap.mapcontext.ViewPort;
15
import org.gvsig.fmap.mapcontext.layers.FLayer;
16
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
17
import org.gvsig.fmap.mapcontrol.MapControl;
18
import org.gvsig.fmap.mapcontrol.MapControlDrawer;
19
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
20
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
21
import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
22
import org.gvsig.legend.urbanverticalsignage.lib.api.PictureMarkerSymbolTableLegend;
23
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol;
24
import org.gvsig.tools.util.ToolsUtilLocator;
25
import org.slf4j.Logger;
26
import org.slf4j.LoggerFactory;
27

  
28
/**
29
 *
30
 * @author gvSIG Team
31
 */
32
@SuppressWarnings("UseSpecificCatch")
33
public class RotatePointBehavior extends Behavior {
34

  
35
    protected static final Logger LOGGER = LoggerFactory.getLogger(RotatePointBehavior.class);
36

  
37
    protected RotatePointListener listener;
38

  
39
    private double angle;
40
    private Point2D currentPoint;
41
    private Point2D centerPoint;
42
    private IMarkerSymbol symbol;
43
    private Feature feature;
44
    private String layerName;
45
    private PictureMarkerSymbolTableLegend legend;
46

  
47
    public RotatePointBehavior(RotatePointListener listener) {
48
        this.listener = listener;
49
    }
50

  
51
    @Override
52
    public void setMapControl(MapControl mc) {
53
        super.setMapControl(mc);
54
        updateCurrentValues();
55
    }
56

  
57
    @Override
58
    public void paintComponent(MapControlDrawer drawer) {
59
        if (this.feature == null || this.symbol == null || this.currentPoint==null) {
60
            return;
61
        }
62
        Geometry geom = this.feature.getDefaultGeometry();
63
        if (geom == null) {
64
            return;
65
        }
66
        this.symbol.setRotation(angle);
67
        drawer.draw(geom, this.symbol);
68

  
69
        EuclideanManager euclideanManager = ToolsUtilLocator.getEuclideanManager();
70
        double d = distance(this.centerPoint, this.currentPoint);
71
        drawer.drawLine(
72
                (int) this.centerPoint.getX(), (int) this.centerPoint.getY(),
73
                (int) this.currentPoint.getX(), (int) this.currentPoint.getY()
74
        );
75
        drawer.drawLine(
76
                (int) this.centerPoint.getX(), (int) this.centerPoint.getY(),
77
                (int) (this.centerPoint.getX()+d), (int) this.centerPoint.getY()
78
        );
79
    }
80

  
81
    private void updateCurrentValues() {
82
        this.angle = 0;
83
        this.centerPoint = null;
84
        this.currentPoint = null;
85

  
86
        this.feature = null;
87
        this.layerName = null;
88
        this.legend = null;
89
        this.symbol = null;
90
        try {
91
            FLayer[] layers = this.getMapControl().getMapContext().getLayers().getActives();
92
            if (layers == null || layers.length != 1) {
93
                return;
94
            }
95
            FLyrVect layer = (FLyrVect) layers[0];
96
            FeatureSelection selection = layer.getFeatureStore().getFeatureSelection();
97
            feature = selection.first();
98
            if (symbol == null && feature != null) {
99
                this.legend = (PictureMarkerSymbolTableLegend) layer.getLegend();
100
                symbol = (IMarkerSymbol) legend.getSymbolByFeature(feature);
101
            }
102
            Point point = (Point) feature.getDefaultGeometry();
103
            ViewPort vp = this.getMapControl().getViewPort();
104
            this.centerPoint = vp.fromMapPoint(point.getX(), point.getY());
105
        } catch (Exception ex) {
106
            this.angle = 0;
107
            this.currentPoint = null;
108

  
109
            this.centerPoint = null;
110
            this.legend = null;
111
            this.feature = null;
112
            this.layerName = null;
113
            this.symbol = null;
114
        }
115
    }
116

  
117
    @Override
118
    public void mouseMoved(MouseEvent mouseEvent) throws BehaviorException {
119

  
120
        if (((mouseEvent.getModifiersEx() & (InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK
121
                | InputEvent.ALT_DOWN_MASK | InputEvent.ALT_GRAPH_DOWN_MASK | InputEvent.META_DOWN_MASK)) != 0)
122
                || SwingUtilities.isLeftMouseButton(mouseEvent)) {
123
            return;
124
        }
125
        try {
126
            if (mouseEvent.getClickCount() == 1) {
127
                listener.rotate(feature, legend.getRotationFieldName(), angle);
128
                return;
129
            }
130
            this.currentPoint = mouseEvent.getPoint();
131

  
132
            EuclideanManager euclideanManager = ToolsUtilLocator.getEuclideanManager();
133
            double d = distance(this.centerPoint, this.currentPoint);
134
            EuclideanLine2D line = euclideanManager.createLine2D(
135
                    this.centerPoint.getX(), this.centerPoint.getY(),
136
                    this.currentPoint.getX(), this.currentPoint.getY()
137
            );
138
//            EuclideanLine2D line0 = euclideanManager.createLine2D(
139
//                    this.centerPoint.getX(), this.centerPoint.getY(),
140
//                    this.centerPoint.getX()+d, this.centerPoint.getY()
141
//            );
142
//            Point2D.Double p = new Point2D.Double(this.centerPoint.getX()+d, this.centerPoint.getY()-1);
143
            this.angle = Math.toDegrees(line.getAngle());
144
            LOGGER.info("Angulo: " + angle);
145

  
146
        } catch (Exception ex) {
147
            LOGGER.warn("Can't rotate from point of the layer " + layerName, ex);
148
        }
149
    }
150

  
151
    @Override
152
    public void mouseDragged(MouseEvent e) throws BehaviorException {
153
        mouseMoved(e);
154
    }
155

  
156
    public void setListener(ToolListener listener) {
157
        this.listener = (RotatePointListener) listener;
158
    }
159

  
160
    @Override
161
    public ToolListener getListener() {
162
        return listener;
163
    }
164

  
165
    public double distance(Point2D p1, Point2D p2) {
166
        double x = Math.sqrt( Math.pow(p2.getX()-p1.getX(), 2)+Math.pow(p2.getY()-p1.getY(), 2));
167
        return x;
168
    }
169
}
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.10/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/src/main/java/org/gvsig/legend/urbanhorizontalsignage/app/UrbanHorizontalSignageConfigForCopyPanelView.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<object classname="com.jeta.forms.store.memento.FormPackage">
4
 <at name="fileversion">
5
  <object classname="com.jeta.forms.store.memento.FormsVersion2">
6
   <at name="major">2</at>
7
   <at name="minor">0</at>
8
   <at name="sub">0</at>
9
  </object>
10
 </at>
11
 <at name="form">
12
  <object classname="com.jeta.forms.store.memento.FormMemento">
13
   <super classname="com.jeta.forms.store.memento.ComponentMemento">
14
    <at name="cellconstraints">
15
     <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
16
      <at name="column">1</at>
17
      <at name="row">1</at>
18
      <at name="colspan">1</at>
19
      <at name="rowspan">1</at>
20
      <at name="halign">default</at>
21
      <at name="valign">default</at>
22
      <at name="insets" object="insets">0,0,0,0</at>
23
     </object>
24
    </at>
25
    <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
26
   </super>
27
   <at name="id">/home/fdiaz/projects/gvSIG/org.gvsig.legend.urbanhorizontalsignage/org.gvsig.legend.urbanhorizontalsignage.app/org.gvsig.legend.urbanhorizontalsignage.app.mainplugin/src/main/java/org/gvsig/legend/urbanhorizontalsignage/app/UrbanHorizontalSignageConfigForCopyPanelView.xml</at>
28
   <at name="rowspecs">CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE</at>
29
   <at name="colspecs">FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE</at>
30
   <at name="components">
31
    <object classname="java.util.LinkedList">
32
     <item >
33
      <at name="value">
34
       <object classname="com.jeta.forms.store.memento.BeanMemento">
35
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
36
         <at name="cellconstraints">
37
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
38
           <at name="column">2</at>
39
           <at name="row">2</at>
40
           <at name="colspan">1</at>
41
           <at name="rowspan">1</at>
42
           <at name="halign">default</at>
43
           <at name="valign">default</at>
44
           <at name="insets" object="insets">0,0,0,0</at>
45
          </object>
46
         </at>
47
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
48
        </super>
49
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
50
        <at name="beanclass">com.jeta.forms.components.label.JETALabel</at>
51
        <at name="beanproperties">
52
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
53
          <at name="classname">com.jeta.forms.components.label.JETALabel</at>
54
          <at name="properties">
55
           <object classname="com.jeta.forms.store.support.PropertyMap">
56
            <at name="border">
57
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
58
              <super classname="com.jeta.forms.store.properties.BorderProperty">
59
               <at name="name">border</at>
60
              </super>
61
              <at name="borders">
62
               <object classname="java.util.LinkedList">
63
                <item >
64
                 <at name="value">
65
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
66
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
67
                    <at name="name">border</at>
68
                   </super>
69
                  </object>
70
                 </at>
71
                </item>
72
               </object>
73
              </at>
74
             </object>
75
            </at>
76
            <at name="name">lblTargetColorField</at>
77
            <at name="width">117</at>
78
            <at name="text">_Target_Color_field</at>
79
            <at name="fill">
80
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
81
              <at name="name">fill</at>
82
             </object>
83
            </at>
84
            <at name="height">14</at>
85
           </object>
86
          </at>
87
         </object>
88
        </at>
89
       </object>
90
      </at>
91
     </item>
92
     <item >
93
      <at name="value">
94
       <object classname="com.jeta.forms.store.memento.BeanMemento">
95
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
96
         <at name="cellconstraints">
97
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
98
           <at name="column">2</at>
99
           <at name="row">4</at>
100
           <at name="colspan">1</at>
101
           <at name="rowspan">1</at>
102
           <at name="halign">default</at>
103
           <at name="valign">default</at>
104
           <at name="insets" object="insets">0,0,0,0</at>
105
          </object>
106
         </at>
107
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
108
        </super>
109
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
110
        <at name="beanclass">com.jeta.forms.components.label.JETALabel</at>
111
        <at name="beanproperties">
112
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
113
          <at name="classname">com.jeta.forms.components.label.JETALabel</at>
114
          <at name="properties">
115
           <object classname="com.jeta.forms.store.support.PropertyMap">
116
            <at name="border">
117
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
118
              <super classname="com.jeta.forms.store.properties.BorderProperty">
119
               <at name="name">border</at>
120
              </super>
121
              <at name="borders">
122
               <object classname="java.util.LinkedList">
123
                <item >
124
                 <at name="value">
125
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
126
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
127
                    <at name="name">border</at>
128
                   </super>
129
                  </object>
130
                 </at>
131
                </item>
132
               </object>
133
              </at>
134
             </object>
135
            </at>
136
            <at name="name">lblTargetLengthField</at>
137
            <at name="width">117</at>
138
            <at name="text">_Target_Length_field</at>
139
            <at name="fill">
140
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
141
              <at name="name">fill</at>
142
             </object>
143
            </at>
144
            <at name="height">14</at>
145
           </object>
146
          </at>
147
         </object>
148
        </at>
149
       </object>
150
      </at>
151
     </item>
152
     <item >
153
      <at name="value">
154
       <object classname="com.jeta.forms.store.memento.BeanMemento">
155
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
156
         <at name="cellconstraints">
157
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
158
           <at name="column">2</at>
159
           <at name="row">6</at>
160
           <at name="colspan">1</at>
161
           <at name="rowspan">1</at>
162
           <at name="halign">default</at>
163
           <at name="valign">default</at>
164
           <at name="insets" object="insets">0,0,0,0</at>
165
          </object>
166
         </at>
167
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
168
        </super>
169
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
170
        <at name="beanclass">com.jeta.forms.components.label.JETALabel</at>
171
        <at name="beanproperties">
172
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
173
          <at name="classname">com.jeta.forms.components.label.JETALabel</at>
174
          <at name="properties">
175
           <object classname="com.jeta.forms.store.support.PropertyMap">
176
            <at name="border">
177
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
178
              <super classname="com.jeta.forms.store.properties.BorderProperty">
179
               <at name="name">border</at>
180
              </super>
181
              <at name="borders">
182
               <object classname="java.util.LinkedList">
183
                <item >
184
                 <at name="value">
185
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
186
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
187
                    <at name="name">border</at>
188
                   </super>
189
                  </object>
190
                 </at>
191
                </item>
192
               </object>
193
              </at>
194
             </object>
195
            </at>
196
            <at name="name">lblTargetAreaField</at>
197
            <at name="width">117</at>
198
            <at name="text">_Target_Area_field</at>
199
            <at name="fill">
200
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
201
              <at name="name">fill</at>
202
             </object>
203
            </at>
204
            <at name="height">14</at>
205
           </object>
206
          </at>
207
         </object>
208
        </at>
209
       </object>
210
      </at>
211
     </item>
212
     <item >
213
      <at name="value">
214
       <object classname="com.jeta.forms.store.memento.BeanMemento">
215
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
216
         <at name="cellconstraints">
217
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
218
           <at name="column">4</at>
219
           <at name="row">2</at>
220
           <at name="colspan">3</at>
221
           <at name="rowspan">1</at>
222
           <at name="halign">default</at>
223
           <at name="valign">default</at>
224
           <at name="insets" object="insets">0,0,0,0</at>
225
          </object>
226
         </at>
227
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
228
        </super>
229
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
230
        <at name="beanclass">javax.swing.JComboBox</at>
231
        <at name="beanproperties">
232
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
233
          <at name="classname">javax.swing.JComboBox</at>
234
          <at name="properties">
235
           <object classname="com.jeta.forms.store.support.PropertyMap">
236
            <at name="border">
237
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
238
              <super classname="com.jeta.forms.store.properties.BorderProperty">
239
               <at name="name">border</at>
240
              </super>
241
              <at name="borders">
242
               <object classname="java.util.LinkedList">
243
                <item >
244
                 <at name="value">
245
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
246
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
247
                    <at name="name">border</at>
248
                   </super>
249
                  </object>
250
                 </at>
251
                </item>
252
               </object>
253
              </at>
254
             </object>
255
            </at>
256
            <at name="componentCount">3</at>
257
            <at name="editable">true</at>
258
            <at name="requestFocusEnabled">false</at>
259
            <at name="name">cboTargetColorFields</at>
260
            <at name="width">1155</at>
261
            <at name="items">
262
             <object classname="com.jeta.forms.store.properties.ItemsProperty">
263
              <at name="name">items</at>
264
             </object>
265
            </at>
266
            <at name="height">20</at>
267
           </object>
268
          </at>
269
         </object>
270
        </at>
271
       </object>
272
      </at>
273
     </item>
274
     <item >
275
      <at name="value">
276
       <object classname="com.jeta.forms.store.memento.BeanMemento">
277
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
278
         <at name="cellconstraints">
279
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
280
           <at name="column">4</at>
281
           <at name="row">6</at>
282
           <at name="colspan">3</at>
283
           <at name="rowspan">1</at>
284
           <at name="halign">default</at>
285
           <at name="valign">default</at>
286
           <at name="insets" object="insets">0,0,0,0</at>
287
          </object>
288
         </at>
289
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
290
        </super>
291
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
292
        <at name="beanclass">javax.swing.JComboBox</at>
293
        <at name="beanproperties">
294
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
295
          <at name="classname">javax.swing.JComboBox</at>
296
          <at name="properties">
297
           <object classname="com.jeta.forms.store.support.PropertyMap">
298
            <at name="border">
299
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
300
              <super classname="com.jeta.forms.store.properties.BorderProperty">
301
               <at name="name">border</at>
302
              </super>
303
              <at name="borders">
304
               <object classname="java.util.LinkedList">
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff