use of com.sldeditor.datasource.RenderSymbolInterface in project sldeditor by robward-scisys.
the class SLDTree method leafSelected.
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.tree.SLDTreeUpdatedInterface#leafSelected()
*/
@Override
public void leafSelected() {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) symbolTree.getLastSelectedPathComponent();
DefaultMutableTreeNode parent = null;
if (node != null) {
Object nodeInfo = node.getUserObject();
if (nodeInfo != null) {
Class<?> classSelected = nodeInfo.getClass();
SLDTreeItemInterface treeItem = TreeItemMap.getInstance().getValue(classSelected);
if (treeItem != null) {
treeItem.itemSelected(node, nodeInfo);
}
if (displayPanel != null) {
Controller.getInstance().setPopulating(true);
Class<?> parentClass = null;
if (node.getParent() != null) {
parent = (DefaultMutableTreeNode) node.getParent();
parentClass = parent.getUserObject().getClass();
// Check to see if node represents a fill
if (classSelected == FillImpl.class) {
// Check to see if fill has been selected
Symbolizer symbolizer = (Symbolizer) parent.getUserObject();
if (!SLDTreeLeafFactory.getInstance().hasFill(symbolizer)) {
parentClass = null;
classSelected = null;
}
} else if (classSelected == StrokeImpl.class) {
// Check to see if stroke has been selected
Symbolizer symbolizer = (Symbolizer) parent.getUserObject();
if (!SLDTreeLeafFactory.getInstance().hasStroke(symbolizer)) {
parentClass = null;
classSelected = null;
}
}
}
displayPanel.show(parentClass, classSelected);
Controller.getInstance().setPopulating(false);
}
if (renderList != null) {
for (RenderSymbolInterface render : renderList) {
render.renderSymbol();
}
}
}
}
if (treeTools != null) {
treeTools.setButtonState(parent, node, this.currentGeometryType);
}
}
use of com.sldeditor.datasource.RenderSymbolInterface in project sldeditor by robward-scisys.
the class SingleSymbolUI method createSymbolSelectionPanel.
/**
* Creates the symbol selection panel.
*
* @return the j panel
*/
public JPanel createSymbolSelectionPanel() {
JPanel symbolPanel = new JPanel();
symbolPanel.setLayout(new GridLayout(2, 1));
RenderSymbolInterface renderSymbol = RenderPanelFactory.getRenderer(SingleSymbolUI.class.getName());
symbolPanel.add((Component) renderSymbol);
JPanel symbolTreePanel = getSymbolTree();
symbolPanel.add(symbolTreePanel);
return symbolPanel;
}
use of com.sldeditor.datasource.RenderSymbolInterface in project sldeditor by robward-scisys.
the class SingleSymbolUI method getSymbolizerDetailsPanel.
/**
* Gets the symbolizer details panel.
*
* @return the marker details panel
*/
private JPanel getSymbolizerDetailsPanel() {
if (panelSymbolizerDetails == null) {
List<RenderSymbolInterface> rendererList = new ArrayList<RenderSymbolInterface>();
rendererList.add(RenderPanelFactory.getRenderer(SingleSymbolUI.class.getName()));
rendererList.add(LegendManager.getInstance().getRendererUpdate());
rendererList.add(SLDEditorFile.getInstance());
rendererList.add(RenderPanelFactory.getMapRenderer());
panelSymbolizerDetails = new SymbolizerDetailsPanel(rendererList, getSymbolTree());
}
return panelSymbolizerDetails;
}
use of com.sldeditor.datasource.RenderSymbolInterface in project sldeditor by robward-scisys.
the class SLDTreeTools method moveItem.
/**
* Move item within a list. The direction parameter determines which way the item is moved.
*
* @param moveUp the move up flags (true), or down (false)
*/
public void moveItem(boolean moveUp) {
if (symbolTree == null) {
return;
}
if (treeModel == null) {
return;
}
if (sldTree == null) {
return;
}
TreePath path = symbolTree.getSelectionPath();
if (path == null) {
return;
}
DefaultMutableTreeNode lastNode = (DefaultMutableTreeNode) path.getLastPathComponent();
if (lastNode == null) {
return;
}
Object obj = lastNode.getUserObject();
if (obj == null) {
return;
}
DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) lastNode.getParent();
if (parentNode == null) {
return;
}
Object parentObj = parentNode.getUserObject();
if (parentObj == null) {
return;
}
// Calculate index offset value based on direction
int direction = moveUp ? -1 : 1;
// Store current state of the SLD before the move
// CHECKSTYLE:OFF
Object oldValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
if (obj instanceof StyledLayer) {
StyledLayerDescriptor sld = (StyledLayerDescriptor) parentObj;
// NamedLayerImpl.equals() doesn't work in the way I
// want it to, so indexOf() does not work
boolean found = false;
int index = 0;
for (StyledLayer styledLayer : sld.layers()) {
if (styledLayer == obj) {
found = true;
break;
} else {
index++;
}
}
if (found && ((index + direction) >= 0) && (index + direction) < sld.layers().size()) {
StyledLayer styledLayer = sld.layers().remove(index);
sld.layers().add(index + direction, styledLayer);
treeModel.removeNodeFromParent(lastNode);
treeModel.insertNodeInto(lastNode, parentNode, index + direction);
} else {
return;
}
} else if (obj instanceof Style) {
if (parentObj instanceof NamedLayerImpl) {
NamedLayerImpl namedLayer = (NamedLayerImpl) parentObj;
int index = namedLayer.styles().indexOf(obj);
if (((index + direction) >= 0) && (index + direction) < namedLayer.styles().size()) {
Style style = namedLayer.styles().remove(index);
namedLayer.styles().add(index + direction, style);
treeModel.removeNodeFromParent(lastNode);
treeModel.insertNodeInto(lastNode, parentNode, index + direction);
} else {
return;
}
}
} else if (obj instanceof FeatureTypeStyle) {
Style style = (Style) parentObj;
int index = style.featureTypeStyles().indexOf(obj);
if (((index + direction) >= 0) && (index + direction) < style.featureTypeStyles().size()) {
FeatureTypeStyle fts = style.featureTypeStyles().remove(index);
style.featureTypeStyles().add(index + direction, fts);
treeModel.removeNodeFromParent(lastNode);
treeModel.insertNodeInto(lastNode, parentNode, index + direction);
} else {
return;
}
} else if (obj instanceof Rule) {
FeatureTypeStyle fts = (FeatureTypeStyle) parentObj;
int index = fts.rules().indexOf(obj);
if (((index + direction) >= 0) && (index + direction) < fts.rules().size()) {
Rule rule = fts.rules().remove(index);
fts.rules().add(index + direction, rule);
treeModel.removeNodeFromParent(lastNode);
treeModel.insertNodeInto(lastNode, parentNode, index + direction);
} else {
return;
}
} else if (obj instanceof Symbolizer) {
Rule rule = (Rule) parentObj;
int index = rule.symbolizers().indexOf(obj);
if (((index + direction) >= 0) && (index + direction) < rule.symbolizers().size()) {
Symbolizer symbolizer = rule.symbolizers().remove(index);
rule.symbolizers().add(index + direction, symbolizer);
treeModel.removeNodeFromParent(lastNode);
treeModel.insertNodeInto(lastNode, parentNode, index + direction);
} else {
return;
}
}
// Refresh the tree structure. Not very efficient but gets result wanted.
// The node has been moved in the tree above. Now going to refresh model.
treeModel.nodeStructureChanged(lastNode);
// Get path for item moved
TreePath newNodePath = getPath(lastNode);
int[] selectedRows = new int[1];
selectedRows[0] = symbolTree.getRowForPath(newNodePath);
// Find the row of item moved
// Now clear tree structure and re-populate, inefficient but it means
// that all items are expanded as required.
SLDTreeManager.getInstance().rebuildTree((SLDTree) sldTree);
// Make item moved selected again
symbolTree.setSelectionRows(selectedRows);
// Re-render the symbol
if (renderList != null) {
for (RenderSymbolInterface render : renderList) {
render.renderSymbol();
}
}
// Store current state of the SLD after the move
Object newValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
UndoManager.getInstance().addUndoEvent(new UndoEvent(sldTree.getUndoObject(), getClass().getName(), oldValueObj, newValueObj));
}
Aggregations