|
|
|
@ -3,14 +3,17 @@ package com.fr.van.chart.map.designer.type;
|
|
|
|
|
import com.fr.base.Utils; |
|
|
|
|
import com.fr.design.event.UIObserver; |
|
|
|
|
import com.fr.design.event.UIObserverListener; |
|
|
|
|
import com.fr.design.file.HistoryTemplateListCache; |
|
|
|
|
import com.fr.design.gui.ibutton.UIButtonGroup; |
|
|
|
|
import com.fr.design.gui.icombobox.UIComboBox; |
|
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
|
import com.fr.design.mainframe.JTemplate; |
|
|
|
|
import com.fr.design.mainframe.chart.mode.ChartEditContext; |
|
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
|
import com.fr.general.GeneralContext; |
|
|
|
|
import com.fr.plugin.chart.base.GisLayer; |
|
|
|
|
import com.fr.plugin.chart.map.VanChartMapPlot; |
|
|
|
|
import com.fr.plugin.chart.map.server.MapLayerConfigManager; |
|
|
|
@ -29,6 +32,7 @@ import java.awt.CardLayout;
|
|
|
|
|
import java.awt.Component; |
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
import java.awt.event.ItemEvent; |
|
|
|
|
import java.util.Locale; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author Bjorn |
|
|
|
@ -39,8 +43,16 @@ public class GisLayerPane extends JPanel implements UIObserver {
|
|
|
|
|
|
|
|
|
|
private UIButtonGroup gisButton; |
|
|
|
|
private JPanel layerPaneCheckPane; |
|
|
|
|
private UIComboBox gisGaoDeLayer; |
|
|
|
|
private UIComboBox gisLayer; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 标准图层 |
|
|
|
|
*/ |
|
|
|
|
private UIComboBox standardLayers; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 自定义图层 |
|
|
|
|
*/ |
|
|
|
|
private UIComboBox customLayers; |
|
|
|
|
private JPanel layerCardPane; |
|
|
|
|
|
|
|
|
|
private WMSLayerPane wmsLayerPane; |
|
|
|
@ -48,7 +60,7 @@ public class GisLayerPane extends JPanel implements UIObserver {
|
|
|
|
|
|
|
|
|
|
private UIComboBox zoomLevel; |
|
|
|
|
|
|
|
|
|
private String[] layers = MapLayerConfigManager.getLayerItems(); |
|
|
|
|
private String[] layers = MapLayerConfigManager.getCustomLayerItems(); |
|
|
|
|
|
|
|
|
|
public GisLayerPane() { |
|
|
|
|
initComps(); |
|
|
|
@ -86,15 +98,12 @@ public class GisLayerPane extends JPanel implements UIObserver {
|
|
|
|
|
gisButton = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Mode_Auto"), |
|
|
|
|
Toolkit.i18nText("Fine-Design_Form_Widget_Style_Standard"), Toolkit.i18nText("Fine-Design_Chart_Custom")}); |
|
|
|
|
gisButton.setSelectedIndex(ChartEditContext.supportTheme() ? 0 : 1); |
|
|
|
|
gisGaoDeLayer = new UIComboBox(MapLayerConfigManager.getGaoDeLayerItems()); |
|
|
|
|
gisButton.addActionListener(event -> { |
|
|
|
|
refreshZoomLevel(); |
|
|
|
|
checkLayerCardPane(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
gisGaoDeLayer.addItemListener(event -> refreshZoomLevel()); |
|
|
|
|
|
|
|
|
|
initCustomGISLayerPane(); |
|
|
|
|
initLayer(); |
|
|
|
|
initLayerCardPane(); |
|
|
|
|
|
|
|
|
|
layerPaneCheckPane = new JPanel(new CardLayout()) { |
|
|
|
@ -104,15 +113,15 @@ public class GisLayerPane extends JPanel implements UIObserver {
|
|
|
|
|
return new Dimension(0, 0); |
|
|
|
|
} |
|
|
|
|
if (isStandardGis()) { |
|
|
|
|
return gisGaoDeLayer.getPreferredSize(); |
|
|
|
|
return standardLayers.getPreferredSize(); |
|
|
|
|
} else { |
|
|
|
|
return gisLayer.getPreferredSize(); |
|
|
|
|
return customLayers.getPreferredSize(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
layerPaneCheckPane.add(new JPanel(), "auto"); |
|
|
|
|
layerPaneCheckPane.add(gisGaoDeLayer, "standard"); |
|
|
|
|
layerPaneCheckPane.add(gisLayer, "custom"); |
|
|
|
|
layerPaneCheckPane.add(standardLayers, "standard"); |
|
|
|
|
layerPaneCheckPane.add(customLayers, "custom"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double p = TableLayout.PREFERRED; |
|
|
|
@ -142,7 +151,7 @@ public class GisLayerPane extends JPanel implements UIObserver {
|
|
|
|
|
if (isStandardGis() || isAuto()) { |
|
|
|
|
return new Dimension(0, 0); |
|
|
|
|
} |
|
|
|
|
String itemName = Utils.objectToString(gisLayer.getSelectedItem()); |
|
|
|
|
String itemName = Utils.objectToString(customLayers.getSelectedItem()); |
|
|
|
|
if (MapLayerConfigManager.isCustomLayer(itemName)) { |
|
|
|
|
return tileLayerPane.getPreferredSize(); |
|
|
|
|
} else if (MapLayerConfigManager.isCustomWmsLayer(itemName)) { |
|
|
|
@ -163,10 +172,12 @@ public class GisLayerPane extends JPanel implements UIObserver {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initCustomGISLayerPane() { |
|
|
|
|
gisLayer = new UIComboBox(layers); |
|
|
|
|
private void initLayer() { |
|
|
|
|
standardLayers = new UIComboBox(MapLayerConfigManager.getStandardLayerItems()); |
|
|
|
|
customLayers = new UIComboBox(layers); |
|
|
|
|
|
|
|
|
|
gisLayer.addItemListener(e -> |
|
|
|
|
standardLayers.addItemListener(event -> refreshZoomLevel()); |
|
|
|
|
customLayers.addItemListener(e -> |
|
|
|
|
{ |
|
|
|
|
if (e.getStateChange() == ItemEvent.SELECTED) { |
|
|
|
|
checkCustomLayerCardPane(); |
|
|
|
@ -175,7 +186,7 @@ public class GisLayerPane extends JPanel implements UIObserver {
|
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
gisLayer.addPopupMenuListener(new PopupMenuListener() { |
|
|
|
|
customLayers.addPopupMenuListener(new PopupMenuListener() { |
|
|
|
|
public void popupMenuCanceled(PopupMenuEvent e) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -184,12 +195,12 @@ public class GisLayerPane extends JPanel implements UIObserver {
|
|
|
|
|
|
|
|
|
|
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { |
|
|
|
|
|
|
|
|
|
String selected = Utils.objectToString(gisLayer.getSelectedItem()); |
|
|
|
|
String selected = Utils.objectToString(customLayers.getSelectedItem()); |
|
|
|
|
ZoomLevel zoomSelected = (ZoomLevel) zoomLevel.getSelectedItem(); |
|
|
|
|
|
|
|
|
|
gisLayer.setModel(new DefaultComboBoxModel(MapLayerConfigManager.getLayerItems())); |
|
|
|
|
customLayers.setModel(new DefaultComboBoxModel(MapLayerConfigManager.getCustomLayerItems())); |
|
|
|
|
|
|
|
|
|
gisLayer.setSelectedItem(selected); |
|
|
|
|
customLayers.setSelectedItem(selected); |
|
|
|
|
zoomLevel.setSelectedItem(zoomSelected); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -201,15 +212,15 @@ public class GisLayerPane extends JPanel implements UIObserver {
|
|
|
|
|
if (isAuto()) { |
|
|
|
|
levels = MapStatusPane.ZOOM_LEVELS; |
|
|
|
|
} else if (isStandardGis()) { |
|
|
|
|
if (gisGaoDeLayer.getSelectedIndex() == gisGaoDeLayer.getItemCount() - 1) { |
|
|
|
|
if (standardLayers.getSelectedIndex() == standardLayers.getItemCount() - 1) { |
|
|
|
|
levels = MapStatusPane.ZOOM_LEVELS; |
|
|
|
|
} else { |
|
|
|
|
levels = MapStatusPane.GAODE_ZOOM_LEVELS; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (ComparatorUtils.equals(gisLayer.getSelectedItem(), Toolkit.i18nText("Fine-Design_Chart_Layer_Blue"))) { |
|
|
|
|
if (ComparatorUtils.equals(customLayers.getSelectedItem(), Toolkit.i18nText("Fine-Design_Chart_Layer_Blue"))) { |
|
|
|
|
levels = MapStatusPane.BLUE_ZOOM_LEVELS; |
|
|
|
|
} else if (ComparatorUtils.equals(gisLayer.getSelectedItem(), Toolkit.i18nText("Fine-Design_Chart_Layer_GaoDe"))) { |
|
|
|
|
} else if (ComparatorUtils.equals(customLayers.getSelectedItem(), Toolkit.i18nText("Fine-Design_Chart_Layer_GaoDe"))) { |
|
|
|
|
levels = MapStatusPane.GAODE_ZOOM_LEVELS; |
|
|
|
|
} else { |
|
|
|
|
levels = MapStatusPane.ZOOM_LEVELS; |
|
|
|
@ -233,7 +244,7 @@ public class GisLayerPane extends JPanel implements UIObserver {
|
|
|
|
|
|
|
|
|
|
private void checkCustomLayerCardPane() { |
|
|
|
|
CardLayout cardLayout = (CardLayout) layerCardPane.getLayout(); |
|
|
|
|
cardLayout.show(layerCardPane, Utils.objectToString(gisLayer.getSelectedItem())); |
|
|
|
|
cardLayout.show(layerCardPane, Utils.objectToString(customLayers.getSelectedItem())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void resetGisLayer(VanChartMapPlot mapPlot) { |
|
|
|
@ -256,8 +267,12 @@ public class GisLayerPane extends JPanel implements UIObserver {
|
|
|
|
|
switch (layer.getGisLayerType()) { |
|
|
|
|
case AUTO: |
|
|
|
|
gisButton.setSelectedIndex(0); |
|
|
|
|
layer.setGisLayerType(GISLayerType.AUTO); |
|
|
|
|
layer.setLayerName(GISLayerType.getLocString(GISLayerType.AUTO)); |
|
|
|
|
//dealWithTemplateTheme(layer);
|
|
|
|
|
break; |
|
|
|
|
case GAO_DE_API: |
|
|
|
|
populateStandardGis(layer); |
|
|
|
|
case LAYER_NULL: |
|
|
|
|
populateStandardGis(layer); |
|
|
|
|
break; |
|
|
|
@ -272,16 +287,22 @@ public class GisLayerPane extends JPanel implements UIObserver {
|
|
|
|
|
|
|
|
|
|
private void populateStandardGis(GisLayer layer) { |
|
|
|
|
gisButton.setSelectedIndex(1); |
|
|
|
|
String layerName = layer.getLayerName(); |
|
|
|
|
if (layer.getGisLayerType() == GISLayerType.LAYER_NULL) { |
|
|
|
|
gisGaoDeLayer.setSelectedIndex(gisGaoDeLayer.getItemCount() - 1); |
|
|
|
|
standardLayers.setSelectedIndex(standardLayers.getItemCount() - 1); |
|
|
|
|
} else { |
|
|
|
|
if(Locale.CHINA.equals(GeneralContext.getLocale())) { |
|
|
|
|
standardLayers.setSelectedItem(layerName); |
|
|
|
|
layer.setGaoDeGisType(GaoDeGisType.parseByLocaleName(layerName)); |
|
|
|
|
} else { |
|
|
|
|
gisGaoDeLayer.setSelectedItem(layer.getGaoDeGisType().getTypeName()); |
|
|
|
|
standardLayers.setSelectedItem(layerName); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void populateCustomGis(GisLayer layer) { |
|
|
|
|
gisButton.setSelectedIndex(2); |
|
|
|
|
gisLayer.setSelectedItem(layer.getShowItemName()); |
|
|
|
|
customLayers.setSelectedItem(layer.getShowItemName()); |
|
|
|
|
|
|
|
|
|
switch (layer.getGisLayerType()) { |
|
|
|
|
case CUSTOM_WMS_LAYER: |
|
|
|
@ -297,6 +318,7 @@ public class GisLayerPane extends JPanel implements UIObserver {
|
|
|
|
|
if (isAuto()) { |
|
|
|
|
layer.setGisLayerType(GISLayerType.AUTO); |
|
|
|
|
layer.setLayerName(GISLayerType.getLocString(GISLayerType.AUTO)); |
|
|
|
|
adaptEditingTemplateTheme(layer); |
|
|
|
|
} else if (isStandardGis()) { |
|
|
|
|
updateStandardGis(layer); |
|
|
|
|
} else { |
|
|
|
@ -305,9 +327,9 @@ public class GisLayerPane extends JPanel implements UIObserver {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void updateStandardGis(GisLayer layer) { |
|
|
|
|
String layerName = Utils.objectToString(gisGaoDeLayer.getSelectedItem()); |
|
|
|
|
String layerName = Utils.objectToString(standardLayers.getSelectedItem()); |
|
|
|
|
layer.setLayerName(layerName); |
|
|
|
|
if (gisGaoDeLayer.getSelectedIndex() == gisGaoDeLayer.getItemCount() - 1) { |
|
|
|
|
if (standardLayers.getSelectedIndex() == standardLayers.getItemCount() - 1) { |
|
|
|
|
layer.setGisLayerType(MapLayerConfigManager.getGisLayerType(layerName)); |
|
|
|
|
} else { |
|
|
|
|
layer.setGisLayerType(GISLayerType.GAO_DE_API); |
|
|
|
@ -316,7 +338,7 @@ public class GisLayerPane extends JPanel implements UIObserver {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void updateCustomGis(GisLayer layer) { |
|
|
|
|
String layerName = Utils.objectToString(gisLayer.getSelectedItem()); |
|
|
|
|
String layerName = Utils.objectToString(customLayers.getSelectedItem()); |
|
|
|
|
layer.setLayerName(layerName); |
|
|
|
|
layer.setGisLayerType(MapLayerConfigManager.getGisLayerType(layerName)); |
|
|
|
|
|
|
|
|
@ -329,4 +351,18 @@ public class GisLayerPane extends JPanel implements UIObserver {
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 切换图层时根据主题切换图层名称 |
|
|
|
|
* |
|
|
|
|
* @param layer 图层 |
|
|
|
|
*/ |
|
|
|
|
private void adaptEditingTemplateTheme(GisLayer layer) { |
|
|
|
|
JTemplate<?, ?> currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
if(JTemplate.isValid(currentEditingTemplate)) { |
|
|
|
|
boolean dark = currentEditingTemplate.getTemplateTheme().isDark(); |
|
|
|
|
String name = dark ? Toolkit.i18nText("Fine-Design_Chart_Layer_Black") : Toolkit.i18nText("Fine-Design_Chart_Layer_MapBox"); |
|
|
|
|
layer.setLayerName(name); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|