本文整理汇总了Java中org.openstreetmap.josm.gui.layer.OsmDataLayer类的典型用法代码示例。如果您正苦于以下问题:Java OsmDataLayer类的具体用法?Java OsmDataLayer怎么用?Java OsmDataLayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OsmDataLayer类属于org.openstreetmap.josm.gui.layer包,在下文中一共展示了OsmDataLayer类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: action
import org.openstreetmap.josm.gui.layer.OsmDataLayer; //导入依赖的package包/类
public boolean action(Event evt, Object arg) {
try {
KatApplet map = KaporMenuActionListener.applet;
DataSet dataset;
if (arg.equals("Export"))
dataset = ExportAll.exportAll(map);
else if (arg.equals("Budovy"))
dataset = ExportBudovy.exportBudovy(map);
else
return false;
if (dataset.getNodes().size() > 0)
Main.main.addLayer(new OsmDataLayer(dataset, OsmDataLayer
.createNewName(), null));
return true;
} catch (TransformException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}
}
示例2: getLayer
import org.openstreetmap.josm.gui.layer.OsmDataLayer; //导入依赖的package包/类
static public OsmDataLayer getLayer(DataSet data) {
if (!Main.isDisplayingMapView()) return null;
Collection<Layer> layers = Main.map.mapView.getAllLayersAsList();
for (Layer layer : layers) {
if (layer instanceof OsmDataLayer && ((OsmDataLayer) layer).data==data)
return (OsmDataLayer) layer;
}
return null;
}
示例3: testDxfImportTask
import org.openstreetmap.josm.gui.layer.OsmDataLayer; //导入依赖的package包/类
@Test
public void testDxfImportTask() throws Exception {
OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null);
MainApplication.getLayerManager().addLayer(layer);
try {
for (Path p : listDataFiles("dxf")) {
doTestDxfFile(p.toFile());
}
} finally {
MainApplication.getLayerManager().removeLayer(layer);
}
}
示例4: initAlignAll
import org.openstreetmap.josm.gui.layer.OsmDataLayer; //导入依赖的package包/类
private void initAlignAll() {
alignAllBuildings = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
ShapeMode mode = ShapeToolsPlugin.getMode();
if (mode != null) {
DrawableSegmentRoad road = ShapeMode.roadSegm;
if (road != null) {
try {
Logging.debug("AlignAllBuildings button pressed, non-null parameters found");
double epsilon = Double.parseDouble(epsilonInput.getText());
OsmDataLayer currentLayer = MainApplication.getLayerManager().getEditLayer();
DataSet data = currentLayer.data;
Collection<Way> selectedWays = data.getSelectedWays();
for (Way way : selectedWays) {
ShapeMath.alignUsingEpsilon(road.segment, way, epsilon);
ShapeMode.cleanup();
MainApplication.getMap().repaint();
}
} catch (NumberFormatException ex) {
new Notification(tr("Please enter minimal distance in metres")).show();
}
}
}
}
};
}
示例5: initRotate
import org.openstreetmap.josm.gui.layer.OsmDataLayer; //导入依赖的package包/类
private void initRotate() {
rotate = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
double angle = 0;
try {
angle = Math.toRadians(Double.parseDouble(angleInput.getText()));
} catch (NumberFormatException ex) {
new Notification(tr("Please enter numeric angle in degrees")).show();
} catch (Throwable ex) {
Logging.error(ex);
}
OsmDataLayer currentLayer = MainApplication.getLayerManager().getEditLayer();
DataSet data = currentLayer.data;
Collection<Node> selectedNodes = data.getSelectedNodes();
Collection<Way> selectedWays = data.getSelectedWays();
if (directionComboBox.getSelectedIndex() == 0) {
Logging.debug("User requires clockwise rotation");
Logging.debug("Using angle: " + -angle);
ShapeMath.doRotate(selectedWays, selectedNodes, -angle);
} else if (directionComboBox.getSelectedIndex() == 1) {
Logging.debug("User requires antiClockwise rotation");
Logging.debug("Using angle: " + angle);
ShapeMath.doRotate(selectedWays, selectedNodes, angle);
}
}
};
}
示例6: acceptFile
import org.openstreetmap.josm.gui.layer.OsmDataLayer; //导入依赖的package包/类
@Override
public boolean acceptFile(File pathname, Layer layer) {
if (!(layer instanceof OsmDataLayer))
return false;
return super.acceptFile(pathname, layer);
}
示例7: checkOsmDataLayer
import org.openstreetmap.josm.gui.layer.OsmDataLayer; //导入依赖的package包/类
protected static void checkOsmDataLayer(Layer layer) throws IllegalArgumentException {
if (!(layer instanceof OsmDataLayer)) {
throw new IllegalArgumentException(MessageFormat.format("Expected instance of OsmDataLayer. Got ''{0}''.", layer
.getClass().getName()));
}
}
示例8: save
import org.openstreetmap.josm.gui.layer.OsmDataLayer; //导入依赖的package包/类
private void save(File file, OsmDataLayer layer, boolean noBackup) {
File tmpFile = null;
try {
// use a tmp file because if something errors out in the
// process of writing the file, we might just end up with
// a truncated file. That can destroy lots of work.
if (file.exists()) {
tmpFile = new File(file.getPath() + "~");
Utils.copyFile(file, tmpFile);
}
doSave(file, layer.data);
if (noBackup || !Main.pref.getBoolean("save.keepbackup", false)) {
if (tmpFile != null) {
tmpFile.delete();
}
}
layer.onPostSaveToFile();
} catch (IOException e) {
Main.error(e);
JOptionPane.showMessageDialog(
Main.parent,
tr("<html>An error occurred while saving.<br>Error is:<br>{0}</html>", e.getMessage()),
tr("Error"),
JOptionPane.ERROR_MESSAGE
);
try {
// if the file save failed, then the tempfile will not
// be deleted. So, restore the backup if we made one.
if (tmpFile != null && tmpFile.exists()) {
Utils.copyFile(tmpFile, file);
}
} catch (IOException e2) {
Main.error(e2);
JOptionPane.showMessageDialog(
Main.parent,
tr("<html>An error occurred while restoring backup file.<br>Error is:<br>{0}</html>", e2.getMessage()),
tr("Error"),
JOptionPane.ERROR_MESSAGE
);
}
}
}
示例9: save
import org.openstreetmap.josm.gui.layer.OsmDataLayer; //导入依赖的package包/类
private void save(File file, OsmDataLayer layer, boolean noBackup) {
File tmpFile = null;
try {
// use a tmp file because if something errors out in the
// process of writing the file, we might just end up with
// a truncated file. That can destroy lots of work.
if (file.exists()) {
tmpFile = new File(file.getPath() + "~");
Utils.copyFile(file, tmpFile);
}
doSave(file, layer.data);
if (noBackup || !Main.pref.getBoolean("save.keepbackup", false)) {
if (tmpFile != null) {
tmpFile.delete();
}
}
layer.onPostSaveToFile();
} catch (IOException e) {
Main.error(e);
JOptionPane.showMessageDialog(
Main.parent,
tr("<html>An error occurred while saving.<br>Error is:<br>{0}</html>", e.getMessage()),
tr("Error"),
JOptionPane.ERROR_MESSAGE
);
try {
// if the file save failed, then the tempfile will not
// be deleted. So, restore the backup if we made one.
if (tmpFile != null && tmpFile.exists()) {
Utils.copyFile(tmpFile, file);
}
} catch (IOException e2) {
Main.error(e2);
JOptionPane.showMessageDialog(
Main.parent,
tr("<html>An error occurred while restoring backup file.<br>Error is:<br>{0}</html>", e2.getMessage()),
tr("Error"),
JOptionPane.ERROR_MESSAGE
);
}
}
}
示例10: realRun
import org.openstreetmap.josm.gui.layer.OsmDataLayer; //导入依赖的package包/类
@Override
protected void realRun() throws SAXException, IOException, OsmTransferException {
for(UploadInfo info : PescePlugin.getUploadInfo()) {
if(cancel) return;
progressMonitor.beginTask(tr("Converting {0} data...",info.layerName));
StringWriter sw = new StringWriter();
String contentType = null;
OsmDataLayer layer = PescePlugin.getLayer(info.dataSet);
if(null != layer) {
layer.onPostUploadToServer();
Main.debug("[IlocateUploadTask.realRun] Layer name: "+layer.getName());
} else {
Main.error("[IlocateUploadTask.realRun] Layer not found. It could be removed");
cancel();
return;
}
switch(info.type) {
case BUILDING:
Main.debug("[IlocateUploadTask.realRun] Building layer upload not implemented");
contentType = "application/json";
break;
case IGML:
Main.debug("[IlocateUploadTask.realRun] IGML");
PesceExporter.doSave(sw, info.dataSet);
// I need the OsmLayer of dataset here
// layer.onPostUploadToServer();
contentType = "text/xml";
break;
}
progressMonitor.beginTask(tr("Uploading {0} data...",info.layerName));
// String diffUploadResponse = sendRequest("POST", "changeset/" + changeset.getId() + "/upload", diffUploadRequest,monitor);
boolean uploadImplemented = false;
if(uploadImplemented) {
response = postRequest(new URL(info.url), sw.toString(), contentType, progressMonitor, false, true);
Main.debug(response);
}
}
}
示例11: layerIsSupported
import org.openstreetmap.josm.gui.layer.OsmDataLayer; //导入依赖的package包/类
@Override
public boolean layerIsSupported(Layer l) {
return l instanceof OsmDataLayer;
}
示例12: layerAdded
import org.openstreetmap.josm.gui.layer.OsmDataLayer; //导入依赖的package包/类
public void layerAdded(Layer newLayer) {
if(newLayer instanceof OsmDataLayer) {
// start the auto download loop
NavigatableComponent.addZoomChangeListener(this);
}
}
示例13: exportData
import org.openstreetmap.josm.gui.layer.OsmDataLayer; //导入依赖的package包/类
@Override
public void exportData(File file, Layer layer) throws IOException {
checkOsmDataLayer(layer);
save(file, (OsmDataLayer) layer, true);
}
示例14: exportData
import org.openstreetmap.josm.gui.layer.OsmDataLayer; //导入依赖的package包/类
/**
* Exports OSM data to the given file.
* @param file Output file
* @param layer Data layer. Must be an instance of {@link OsmDataLayer}.
* @param noBackup if {@code true}, the potential backup file created if the output file already exists will be deleted
* after a successful export
* @throws IllegalArgumentException if {@code layer} is not an instance of {@code OsmDataLayer}
*/
public void exportData(File file, Layer layer, boolean noBackup) throws IllegalArgumentException {
checkOsmDataLayer(layer);
save(file, (OsmDataLayer) layer, noBackup);
}