Search in sources :

Example 26 with MapPanel

use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.

the class SelectMapScale method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    final MapPanel map = getMap();
    if (map != null) {
        try {
            final Object item = getSelectedItem();
            String string = DataTypes.toString(item);
            string = string.replaceAll("((^1:)|([^0-9\\.])+)", "");
            final double scale = Double.parseDouble(string);
            map.setScale(scale);
        } catch (final Throwable t) {
        }
    }
}
Also used : MapPanel(com.revolsys.swing.map.MapPanel)

Example 27 with MapPanel

use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.

the class AbstractLayer method showProperties.

@Override
public void showProperties(final String tabName) {
    final MapPanel map = getMapPanel();
    if (map != null) {
        if (this.exists) {
            if (checkShowProperties()) {
                try {
                    final Window window = SwingUtilities.getWindowAncestor(map);
                    final TabbedValuePanel panel = newPropertiesPanel();
                    panel.setSelectdTab(tabName);
                    panel.showDialog(window);
                    refresh();
                } finally {
                    removeProperty("INTERNAL_PROPERTIES_VISIBLE");
                }
            }
        }
    }
}
Also used : Window(java.awt.Window) MapPanel(com.revolsys.swing.map.MapPanel) TabbedValuePanel(com.revolsys.swing.component.TabbedValuePanel)

Example 28 with MapPanel

use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.

the class Layer method showRendererProperties.

default void showRendererProperties(final LayerRenderer<?> renderer) {
    final MapPanel map = getMapPanel();
    if (map != null && isExists() && checkShowProperties()) {
        try {
            final Window window = SwingUtilities.getWindowAncestor(map);
            final TabbedValuePanel panel = newPropertiesPanel();
            panel.setSelectdTab("Style");
            final LayerStylePanel stylePanel = panel.getTab("Style");
            if (stylePanel != null) {
                stylePanel.setSelectedRenderer(renderer);
                panel.showDialog(window);
            }
            refresh();
        } finally {
            removeProperty("INTERNAL_PROPERTIES_VISIBLE");
        }
    }
}
Also used : Window(java.awt.Window) MapPanel(com.revolsys.swing.map.MapPanel) TabbedValuePanel(com.revolsys.swing.component.TabbedValuePanel) LayerStylePanel(com.revolsys.swing.map.layer.record.style.panel.LayerStylePanel)

Example 29 with MapPanel

use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.

the class AbstractRecordLayer method initRecordMenu.

protected LayerRecordMenu initRecordMenu() {
    final LayerRecordMenu menu = new LayerRecordMenu(this);
    this.recordMenu = menu;
    if (this.recordDefinition != null) {
        final RecordDefinition recordDefinition = getRecordDefinition();
        final boolean hasGeometry = recordDefinition.hasGeometryField();
        final Predicate<LayerRecord> modified = LayerRecord::isModified;
        final Predicate<LayerRecord> notDeleted = ((Predicate<LayerRecord>) this::isDeleted).negate();
        final Predicate<LayerRecord> modifiedOrDeleted = modified.or(LayerRecord::isDeleted);
        final EnableCheck editableEnableCheck = this::isEditable;
        menu.addGroup(0, "default");
        menu.addGroup(1, "record");
        menu.addGroup(2, "dnd");
        final MenuFactory layerMenuFactory = MenuFactory.findMenu(this);
        if (layerMenuFactory != null) {
            menu.addComponentFactory("default", 0, new WrappedMenuFactory("Layer", layerMenuFactory));
        }
        menu.addMenuItem("record", "View/Edit Record", "table_edit", notDeleted, this::showForm);
        if (hasGeometry) {
            menu.addMenuItem("record", "Zoom to Record", "magnifier_zoom_selected", notDeleted, this::zoomToRecord);
            menu.addMenuItem("record", "Pan to Record", "pan_selected", notDeleted, (record) -> {
                final MapPanel mapPanel = getMapPanel();
                if (mapPanel != null) {
                    mapPanel.panToRecord(record);
                }
            });
            final MenuFactory editMenu = new MenuFactory("Edit Record Operations");
            editMenu.setEnableCheck(LayerRecordMenu.enableCheck(notDeleted));
            final DataType geometryDataType = recordDefinition.getGeometryField().getDataType();
            if (geometryDataType == DataTypes.LINE_STRING || geometryDataType == DataTypes.MULTI_LINE_STRING) {
                if (DirectionalFields.getProperty(recordDefinition).hasDirectionalFields()) {
                    LayerRecordMenu.addMenuItem(editMenu, "geometry", LayerRecordForm.FLIP_RECORD_NAME, LayerRecordForm.FLIP_RECORD_ICON, editableEnableCheck, this::actionFlipRecordOrientation);
                    LayerRecordMenu.addMenuItem(editMenu, "geometry", LayerRecordForm.FLIP_LINE_ORIENTATION_NAME, LayerRecordForm.FLIP_LINE_ORIENTATION_ICON, editableEnableCheck, this::actionFlipLineOrientation);
                    LayerRecordMenu.addMenuItem(editMenu, "geometry", LayerRecordForm.FLIP_FIELDS_NAME, LayerRecordForm.FLIP_FIELDS_ICON, editableEnableCheck, this::actionFlipFields);
                } else {
                    LayerRecordMenu.addMenuItem(editMenu, "geometry", "Flip Line Orientation", "flip_line", editableEnableCheck, this::actionFlipLineOrientation);
                }
            }
            menu.addComponentFactory("record", editMenu);
        }
        menu.addMenuItem("record", "Delete Record", "table_row_delete", LayerRecord::isDeletable, this::deleteRecord);
        menu.addMenuItem("record", "Revert Record", "arrow_revert", modifiedOrDeleted, LayerRecord::revertChanges);
        final Predicate<LayerRecord> hasModifiedEmptyFields = LayerRecord::isHasModifiedEmptyFields;
        menu.addMenuItem("record", "Revert Empty Fields", "field_empty_revert", hasModifiedEmptyFields, LayerRecord::revertEmptyFields);
        menu.addMenuItem("dnd", "Copy Record", "page_copy", this::copyRecordToClipboard);
        if (hasGeometry) {
            menu.addMenuItem("dnd", "Paste Geometry", "geometry_paste", this::canPasteRecordGeometry, this::pasteRecordGeometry);
        }
    }
    return menu;
}
Also used : MapPanel(com.revolsys.swing.map.MapPanel) WrappedMenuFactory(com.revolsys.swing.menu.WrappedMenuFactory) MenuFactory(com.revolsys.swing.menu.MenuFactory) WrappedMenuFactory(com.revolsys.swing.menu.WrappedMenuFactory) DataType(com.revolsys.datatype.DataType) EnableCheck(com.revolsys.swing.action.enablecheck.EnableCheck) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 30 with MapPanel

use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.

the class AbstractRecordLayer method addNewRecord.

public void addNewRecord() {
    final RecordDefinition recordDefinition = getRecordDefinition();
    final FieldDefinition geometryField = recordDefinition.getGeometryField();
    if (geometryField == null) {
        showAddForm(null);
    } else {
        final MapPanel map = getMapPanel();
        if (map != null) {
            final EditRecordGeometryOverlay addGeometryOverlay = map.getMapOverlay(EditRecordGeometryOverlay.class);
            synchronized (addGeometryOverlay) {
                clearSelectedRecords();
                addGeometryOverlay.addRecord(this, this);
            }
        }
    }
}
Also used : EditRecordGeometryOverlay(com.revolsys.swing.map.overlay.record.EditRecordGeometryOverlay) MapPanel(com.revolsys.swing.map.MapPanel) FieldDefinition(com.revolsys.record.schema.FieldDefinition) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Aggregations

MapPanel (com.revolsys.swing.map.MapPanel)32 Point (com.revolsys.geometry.model.Point)6 Viewport2D (com.revolsys.swing.map.Viewport2D)6 BoundingBox (com.revolsys.geometry.model.BoundingBox)4 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)4 LineString (com.revolsys.geometry.model.LineString)4 RecordDefinition (com.revolsys.record.schema.RecordDefinition)4 CloseLocation (com.revolsys.swing.map.overlay.CloseLocation)4 ArrayList (java.util.ArrayList)4 DataType (com.revolsys.datatype.DataType)3 FieldDefinition (com.revolsys.record.schema.FieldDefinition)3 Project (com.revolsys.swing.map.layer.Project)3 Set (java.util.Set)3 TreeMap (java.util.TreeMap)3 JLabel (javax.swing.JLabel)3 Geometry (com.revolsys.geometry.model.Geometry)2 RectangularMapGrid (com.revolsys.gis.grid.RectangularMapGrid)2 EnableCheck (com.revolsys.swing.action.enablecheck.EnableCheck)2 TabbedValuePanel (com.revolsys.swing.component.TabbedValuePanel)2 Layer (com.revolsys.swing.map.layer.Layer)2