public static ImageryLayer create(ImageryInfo info) { if (info.getImageryType() == ImageryType.WMS || info.getImageryType() == ImageryType.HTML) return new WMSLayer(info); else if (info.getImageryType() == ImageryType.TMS || info.getImageryType() == ImageryType.BING || info.getImageryType() == ImageryType.SCANEX) return new TMSLayer(info); else throw new AssertionError(); }
@Override public Object getValueAt(int row, int column) { ImageryInfo info = layerInfo.getLayers().get(row); switch (column) { case 0: return info.getName(); case 1: return info.getExtendedUrl(); default: throw new ArrayIndexOutOfBoundsException(); } }
@Override public ImageryInfo getImageryInfo() { final ImageryInfo info; if (endpoint.isSelected()) { info = new ImageryInfo(getImageryName(), getImageryRawUrl()); info.setImageryType(ImageryInfo.ImageryType.WMS_ENDPOINT); } else { info = wms.toImageryInfo(getImageryName(), tree.getSelectedLayers()); info.setUrl(getWmsUrl()); } return info; }
@Override public Object getValueAt(int row, int column) { ImageryInfo info = layerInfo.getDefaultLayers().get(row); switch (column) { case 0: return info.getCountryCode(); case 1: return info; case 2: return info.getExtendedUrl(); } return null; }
@Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { ImageryInfo info = (ImageryInfo) value; JLabel label = (JLabel) super.getTableCellRendererComponent( table, info == null ? null : info.getName(), isSelected, hasFocus, row, column); GuiHelper.setBackgroundReadable(label, UIManager.getColor("Table.background")); if (info != null) { label.setToolTipText(info.getToolTipText()); } return label; }
@Override protected AbstractTMSTileSource getTileSource(ImageryInfo info) { try { if (info.getImageryType() == ImageryType.WMTS && info.getUrl() != null) { WMTSTileSource.checkUrl(info.getUrl()); WMTSTileSource tileSource = new WMTSTileSource(info); info.setAttribution(tileSource); return tileSource; } return null; } catch (IOException e) { Main.warn(e); throw new IllegalArgumentException(e); } }
@Override public void setValueAt(Object o, int row, int column) { if (layerInfo.getLayers().size() <= row) return; ImageryInfo info = layerInfo.getLayers().get(row); switch (column) { case 0: info.setName((String) o); info.clearId(); break; case 1: info.setExtendedUrl((String) o); info.clearId(); break; default: throw new ArrayIndexOutOfBoundsException(); } }
@Override public void actionPerformed(ActionEvent e) { int[] lines = defaultTable.getSelectedRows(); if (lines.length == 0) { JOptionPane.showMessageDialog( gui, tr("Please select at least one row to copy."), tr("Information"), JOptionPane.INFORMATION_MESSAGE); return; } Set<String> acceptedEulas = new HashSet<>(); outer: for (int line : lines) { ImageryInfo info = defaultModel.getRow(line); // Check if an entry with exactly the same values already exists for (int j = 0; j < activeModel.getRowCount(); j++) { if (info.equalsBaseValues(activeModel.getRow(j))) { // Select the already existing row so the user has // some feedback in case an entry exists activeTable.getSelectionModel().setSelectionInterval(j, j); activeTable.scrollRectToVisible(activeTable.getCellRect(j, 0, true)); continue outer; } } String eulaURL = info.getEulaAcceptanceRequired(); // If set and not already accepted, ask for EULA acceptance if (eulaURL != null && !acceptedEulas.contains(eulaURL)) { if (confirmEulaAcceptance(gui, eulaURL)) { acceptedEulas.add(eulaURL); } else { continue outer; } } activeModel.addRow(new ImageryInfo(info)); int lastLine = activeModel.getRowCount() - 1; activeTable.getSelectionModel().setSelectionInterval(lastLine, lastLine); activeTable.scrollRectToVisible(activeTable.getCellRect(lastLine, 0, true)); } }
@Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel label = (JLabel) super.getTableCellRendererComponent( table, value, isSelected, hasFocus, row, column); GuiHelper.setBackgroundReadable(label, UIManager.getColor("Table.background")); if (value != null) { // Fix #8159 String t = value.toString(); for (ImageryInfo l : layers) { if (l.getExtendedUrl().equals(t)) { GuiHelper.setBackgroundReadable(label, IMAGERY_BACKGROUND_COLOR.get()); break; } } label.setToolTipText((String) value); } return label; }
public ImageryLayer(ImageryInfo info) { super(info.getName()); this.info = info; if (info.getIcon() != null) { icon = new ImageProvider(info.getIcon()) .setOptional(true) .setMaxHeight(ICON_SIZE) .setMaxWidth(ICON_SIZE) .get(); } if (icon == null) { icon = ImageProvider.get("imagery_small"); } this.sharpenLevel = PROP_SHARPEN_LEVEL.get(); if (OffsetServer.PROP_SERVER_ENABLED.get()) { offsetServerThread = createoffsetServerThread(); offsetServerThread.start(); } }