use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.
the class LegendTool method saveAllLegendToFolder.
/**
* Save all legend to folder.
*
* @param destinationFolder the destination folder
*/
private void saveAllLegendToFolder(File destinationFolder) {
if (!destinationFolder.exists()) {
destinationFolder.mkdirs();
}
logger.info(Localisation.getString(LegendTool.class, "LegendTool.saveAllLayerLegends"));
for (SLDDataInterface sldData : sldDataList) {
StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
if (sld != null) {
String heading = null;
String filename = null;
String layerName = sldData.getLayerNameWithOutSuffix();
List<String> filenameList = new ArrayList<String>();
LegendManager.getInstance().saveLegendImage(sld, destinationFolder, layerName, heading, filename, filenameList);
}
}
}
use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.
the class MapBoxTool method setSelectedItems.
/*
* (non-Javadoc)
*
* @see com.sldeditor.tool.ToolInterface#setSelectedItems(java.util.List, java.util.List)
*/
@Override
public void setSelectedItems(List<NodeInterface> nodeTypeList, List<SLDDataInterface> sldDataList) {
this.sldDataList = sldDataList;
if (exportToSLDButton != null) {
int mapBoxFilesCount = 0;
if (sldDataList != null) {
for (SLDDataInterface sldData : sldDataList) {
String fileExtension = ExternalFilenames.getFileExtension(sldData.getSLDFile().getAbsolutePath());
if (fileExtension.compareTo(MapBoxTool.MAPBOX_FILE_EXTENSION) == 0) {
mapBoxFilesCount++;
}
}
}
exportToSLDButton.setEnabled(mapBoxFilesCount > 0);
}
}
use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.
the class ExportHTML method save.
/**
* Save all html to folder.
*
* @param destinationFolder the destination folder
* @param filename the filename
* @param sldDataList the sld data list
* @param backgroundColour the background colour
*/
public static void save(File destinationFolder, String filename, List<SLDDataInterface> sldDataList, Color backgroundColour) {
if (!destinationFolder.exists()) {
destinationFolder.mkdirs();
}
InputStream inputStream = ExportHTML.class.getResourceAsStream(HTML_TEMPLATE);
if (inputStream == null) {
ConsoleManager.getInstance().error(ExportHTML.class, "Failed to find html template");
} else {
String htmlTemplate = null;
BufferedReader reader = null;
File file = null;
try {
file = stream2file(inputStream);
reader = new BufferedReader(new FileReader(file));
String line = null;
StringBuilder stringBuilder = new StringBuilder();
String ls = System.getProperty("line.separator");
while ((line = reader.readLine()) != null) {
stringBuilder.append(line);
stringBuilder.append(ls);
}
htmlTemplate = stringBuilder.toString();
} catch (Exception e) {
ConsoleManager.getInstance().exception(ExportHTML.class, e);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
ConsoleManager.getInstance().exception(ExportHTML.class, e);
}
}
}
StringBuilder sb = new StringBuilder();
sb.append(" <tr>\n");
sb.append(" <th>Layer Name</th>\n");
sb.append(" <th>Legend</th>\n");
sb.append(" </tr>\n");
for (SLDDataInterface sldData : sldDataList) {
StyleWrapper styleWrapper = sldData.getStyle();
String layerName = styleWrapper.getStyle();
sb.append(" <tr>\n");
sb.append(String.format(" <td>%s</td>\n", layerName));
StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
if (sld != null) {
String showHeading = null;
String showFilename = null;
List<String> legendFileNameList = new ArrayList<String>();
boolean result = LegendManager.getInstance().saveLegendImage(sld, destinationFolder, layerName, showHeading, showFilename, legendFileNameList);
if (result) {
String legendFilename = legendFileNameList.get(0);
sb.append(String.format(" <td><img src=\"%s\" alt=\"%s\" ></td>\n", legendFilename, layerName));
}
}
sb.append(" </tr>\n");
}
if (htmlTemplate != null) {
htmlTemplate = htmlTemplate.replace(TEMPLATE_INSERT_CODE, sb.toString());
PrintWriter out;
try {
File f = new File(destinationFolder, filename);
out = new PrintWriter(f);
out.println(htmlTemplate);
out.close();
} catch (FileNotFoundException e) {
ConsoleManager.getInstance().exception(ExportHTML.class, e);
}
}
if (file != null) {
file.delete();
}
}
}
use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.
the class ScaleToolPanel method populate.
/**
* Populate the dialog.
*
* @param sldDataList the sld data list
*/
public void populate(List<SLDDataInterface> sldDataList) {
List<ScaleSLDData> scaleDataList = new ArrayList<ScaleSLDData>();
for (SLDDataInterface sldData : sldDataList) {
List<ScaleSLDData> scaleSLDDataList = ScalePanelUtils.containsScales(sldData);
if ((scaleSLDDataList != null) && !scaleSLDDataList.isEmpty()) {
scaleDataList.addAll(scaleSLDDataList);
}
}
dataModel.loadData(scaleDataList);
}
use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.
the class ScaleSLDData method updateScales.
/**
* Update scales.
*
* @param sldWriter the sld writer
*/
public boolean updateScales(SLDWriterInterface sldWriter) {
boolean refreshUI = false;
if (rule != null) {
if (isMinimumScaleUpdated()) {
rule.setMinScaleDenominator(minScale);
minimumScaleUpdated = false;
}
if (isMaximumScaleUpdated()) {
rule.setMaxScaleDenominator(maxScale);
maximumScaleUpdated = false;
}
String sldContents = sldWriter.encodeSLD(null, this.sld);
SLDDataInterface current = SLDEditorFile.getInstance().getSLDData();
if (current.getSLDFile().equals(sldData.getSLDFile()) || current.getSLDURL().equals(sldData.getSLDURL())) {
Rule currentFule = SLDUtils.findRule(sld, rule, SelectedSymbol.getInstance().getSld());
if (currentFule != null) {
currentFule.setMinScaleDenominator(minScale);
currentFule.setMaxScaleDenominator(maxScale);
refreshUI = true;
}
}
sldData.updateSLDContents(sldContents);
}
return refreshUI;
}
Aggregations