Commit de86334e authored by Stefan Sechelmann's avatar Stefan Sechelmann

resolve warnings

parent 1cf28e28
......@@ -30,11 +30,11 @@ import de.jtem.jrworkspace.plugin.flavor.ToolBarFlavor;
public class AlgorithmDropdownToolbar extends Plugin implements ToolBarFlavor {
private Map<String, JComboBox<AlgorithmPlugin>>
private Map<AlgorithmCategory, JComboBox<AlgorithmPlugin>>
comboMap = new HashMap<>();
private Map<String, Set<AlgorithmPlugin>>
algoMap = new HashMap<String, Set<AlgorithmPlugin>>();
private Map<AlgorithmCategory, Set<AlgorithmPlugin>>
algoMap = new HashMap<AlgorithmCategory, Set<AlgorithmPlugin>>();
private JToolBar
comboToolBar = new JToolBar("Halfedge Algorithms");
......@@ -43,15 +43,15 @@ public class AlgorithmDropdownToolbar extends Plugin implements ToolBarFlavor {
}
private void addComboBox(String cat) {
private void addComboBox(AlgorithmCategory cat) {
JComboBox<AlgorithmPlugin> catCombo = new JComboBox<>();
catCombo.setMaximumRowCount(50);
AlgorithmComboModel model = new AlgorithmComboModel(cat);
catCombo.setModel(model);
AlgorithmCellRenderer renderer = new AlgorithmCellRenderer(cat);
catCombo.setRenderer(renderer);
comboMap.put(cat.toString(), catCombo);
algoMap.put(cat.toString(), new HashSet<AlgorithmPlugin>());
comboMap.put(cat, catCombo);
algoMap.put(cat, new HashSet<AlgorithmPlugin>());
updateComboBoxes();
}
......@@ -63,10 +63,10 @@ public class AlgorithmDropdownToolbar extends Plugin implements ToolBarFlavor {
private static final long
serialVersionUID = 1L;
private String
category = AlgorithmCategory.Custom.toString();
private AlgorithmCategory
category = AlgorithmCategory.Custom;
public AlgorithmCellRenderer(String cat) {
public AlgorithmCellRenderer(AlgorithmCategory cat) {
this.category = cat;
}
......@@ -92,10 +92,10 @@ public class AlgorithmDropdownToolbar extends Plugin implements ToolBarFlavor {
private class AlgorithmComboModel implements ComboBoxModel<AlgorithmPlugin> {
private String
category = AlgorithmCategory.Custom.toString();
private AlgorithmCategory
category = AlgorithmCategory.Custom;
public AlgorithmComboModel(String cat) {
public AlgorithmComboModel(AlgorithmCategory cat) {
this.category = cat;
}
......@@ -136,7 +136,7 @@ public class AlgorithmDropdownToolbar extends Plugin implements ToolBarFlavor {
}
protected List<AlgorithmPlugin> getAlgorithms(String cat) {
protected List<AlgorithmPlugin> getAlgorithms(AlgorithmCategory cat) {
List<AlgorithmPlugin> result = new LinkedList<AlgorithmPlugin>();
Set<AlgorithmPlugin> algoSet = algoMap.get(cat);
result.addAll(algoSet);
......@@ -151,10 +151,10 @@ public class AlgorithmDropdownToolbar extends Plugin implements ToolBarFlavor {
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = 1;
int numCombos = 0;
LinkedList<String> algorithmCategories = new LinkedList<String>(comboMap.keySet());
LinkedList<AlgorithmCategory> algorithmCategories = new LinkedList<>(comboMap.keySet());
Collections.sort(algorithmCategories);
for (String cat : algorithmCategories) {
for (AlgorithmCategory cat : algorithmCategories) {
JComboBox<AlgorithmPlugin> combo = comboMap.get(cat);
Set<AlgorithmPlugin> algos = algoMap.get(cat);
if (algos.isEmpty()) continue;
......@@ -183,7 +183,7 @@ public class AlgorithmDropdownToolbar extends Plugin implements ToolBarFlavor {
}
public void addAlgorithm(AlgorithmPlugin ap) {
String algoName = ap.getCategory();
AlgorithmCategory algoName = ap.getCategory();
if(!algoMap.containsKey(algoName)) {
addComboBox(algoName);
}
......
......@@ -197,7 +197,7 @@ public abstract class AlgorithmPlugin extends Plugin implements Comparable<Algor
view = c.getPlugin(View.class);
hcp = c.getPlugin(HalfedgeInterface.class);
viewMenuBar = c.getPlugin(ViewMenuBar.class);
String catName = getCategory();
String catName = getCategory().toString();
viewMenuBar.addMenuItem(getClass(), getPriority(), action, "Halfedge", catName);
dropdownToolbar = c.getPlugin(AlgorithmDropdownToolbar.class);
dropdownToolbar.addAlgorithm(this);
......@@ -219,8 +219,8 @@ public abstract class AlgorithmPlugin extends Plugin implements Comparable<Algor
return null;
}
public String getCategory() {
return getAlgorithmCategory().toString();
public AlgorithmCategory getCategory() {
return getAlgorithmCategory();
}
public AlgorithmCategory getAlgorithmCategory() {
......
......@@ -33,12 +33,10 @@ package de.jtem.halfedgetools.util;
import java.util.HashSet;
import java.util.Set;
import java.util.Stack;
import java.util.TreeSet;
import de.jtem.halfedge.Edge;
import de.jtem.halfedge.Face;
import de.jtem.halfedge.HalfEdgeDataStructure;
import de.jtem.halfedge.Vertex;
public class PathUtility {
......@@ -101,29 +99,6 @@ public class PathUtility {
}
/**
* The path must not contain opposite edges!
* @param <V>
* @param <E>
* @param <F>
* @param path
* @param wa
* @return
*/
// public static <
// V extends Vertex<V, E, F>,
// E extends Edge<V, E, F>,
// F extends Face<V, E, F>
// > double getTotalPathWeight(Set<E> path, WeightAdapter<E> wa) {
// double result = 0.0;
// for (E e : path) {
// result += wa.getWeight(e);
// }
// return result;
// }
/**
* Checks whether a given cycle is a simple path
* i.e. it has no self-intersections
......@@ -149,47 +124,5 @@ public class PathUtility {
return true;
}
/**
* Checks whether a cycle is essential
* @param <V>
* @param <E>
* @param <F>
* @param cycle must be a cycle of consistently oriented half-edges
* @return
*/
public static <
V extends Vertex<V, E, F>,
E extends Edge<V, E, F>,
F extends Face<V, E, F>
> boolean isCycleEssential(Set<E> cycle) {
if (cycle.size() == 0) {
return false;
}
if (!isCycleSimple(cycle)) {
return false;
}
E seed = cycle.iterator().next();
V startLeft = seed.getNextEdge().getTargetVertex();
V startRight = seed.getOppositeEdge().getNextEdge().getTargetVertex();
Set<V> leftVisited = new HashSet<V>();
Set<V> rightVisited = new HashSet<V>();
Stack<V> leftPath = new Stack<V>();
Stack<V> rightPath = new Stack<V>();
leftPath.push(startLeft);
rightPath.push(startRight);
leftVisited.add(startLeft);
rightVisited.add(startRight);
HalfEdgeDataStructure<V, E, F> hds = startLeft.getHalfEdgeDataStructure();
Set<V> validVertices = new HashSet<V>(hds.getVertices());
validVertices.removeAll(cycle);
return false;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment