[clean] Apply formatting and add formatter configuration.
This commit is contained in:
committed by
Mikael CAPELLE
parent
2f936d44ec
commit
730cda6426
@@ -33,16 +33,14 @@ public class NodesInputPanel extends JPanel
|
||||
implements DrawingClickListener, DrawingChangeListener, GraphChangeListener {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Color DEFAULT_MARKER_COLOR = Color.BLUE;
|
||||
|
||||
/**
|
||||
* Utility class that can be used to find a node from coordinates in a "fast"
|
||||
* way.
|
||||
*
|
||||
* Utility class that can be used to find a node from coordinates in a "fast" way.
|
||||
*/
|
||||
private static class NodeFinder {
|
||||
|
||||
@@ -58,14 +56,13 @@ public class NodesInputPanel extends JPanel
|
||||
|
||||
/**
|
||||
* @param point
|
||||
*
|
||||
* @return the closest node to the given point, or null if no node is "close
|
||||
* enough".
|
||||
*/
|
||||
public Node findClosestNode(Point point) {
|
||||
Node minNode = null;
|
||||
double minDis = Double.POSITIVE_INFINITY;
|
||||
for (Node node: graph.getNodes()) {
|
||||
for (Node node : graph.getNodes()) {
|
||||
double dlon = point.getLongitude() - node.getPoint().getLongitude();
|
||||
double dlat = point.getLatitude() - node.getPoint().getLatitude();
|
||||
double dis = dlon * dlon + dlat * dlat; // No need to square
|
||||
@@ -81,12 +78,11 @@ public class NodesInputPanel extends JPanel
|
||||
|
||||
/**
|
||||
* Event data send when a node input has changed.
|
||||
*
|
||||
*/
|
||||
public class InputChangedEvent extends ActionEvent {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3440024811352247731L;
|
||||
|
||||
@@ -98,7 +94,8 @@ public class NodesInputPanel extends JPanel
|
||||
List<Node> nodes;
|
||||
|
||||
public InputChangedEvent(List<Node> nodes2) {
|
||||
super(NodesInputPanel.this, ALL_INPUT_FILLED_EVENT_ID, ALL_INPUT_FILLED_EVENT_COMMAND);
|
||||
super(NodesInputPanel.this, ALL_INPUT_FILLED_EVENT_ID,
|
||||
ALL_INPUT_FILLED_EVENT_COMMAND);
|
||||
this.nodes = nodes2;
|
||||
}
|
||||
|
||||
@@ -110,7 +107,8 @@ public class NodesInputPanel extends JPanel
|
||||
|
||||
// Node inputs and markers.
|
||||
private final ArrayList<JTextField> nodeInputs = new ArrayList<>();
|
||||
private final Map<JTextField, MarkerOverlay> markerTrackers = new IdentityHashMap<JTextField, MarkerOverlay>();
|
||||
private final Map<JTextField, MarkerOverlay> markerTrackers =
|
||||
new IdentityHashMap<JTextField, MarkerOverlay>();
|
||||
|
||||
// Component that can be enabled/disabled.
|
||||
private ArrayList<JComponent> components = new ArrayList<>();
|
||||
@@ -126,7 +124,6 @@ public class NodesInputPanel extends JPanel
|
||||
|
||||
/**
|
||||
* Create a new NodesInputPanel.
|
||||
*
|
||||
*/
|
||||
public NodesInputPanel() {
|
||||
super(new GridBagLayout());
|
||||
@@ -134,12 +131,11 @@ public class NodesInputPanel extends JPanel
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an InputChanged listener to this panel. This listener will be notified by
|
||||
* a {@link InputChangedEvent} each time an input in this panel change (click,
|
||||
* clear, manual input).
|
||||
*
|
||||
* Add an InputChanged listener to this panel. This listener will be notified by a
|
||||
* {@link InputChangedEvent} each time an input in this panel change (click, clear,
|
||||
* manual input).
|
||||
*
|
||||
* @param listener Listener to add.
|
||||
*
|
||||
* @see InputChangedEvent
|
||||
*/
|
||||
public void addInputChangedListener(ActionListener listener) {
|
||||
@@ -149,7 +145,7 @@ public class NodesInputPanel extends JPanel
|
||||
@Override
|
||||
public void setVisible(boolean visible) {
|
||||
super.setVisible(visible);
|
||||
for (JTextField input: nodeInputs) {
|
||||
for (JTextField input : nodeInputs) {
|
||||
MarkerOverlay marker = markerTrackers.getOrDefault(input, null);
|
||||
if (marker != null) {
|
||||
marker.setVisible(visible && !input.getText().trim().isEmpty());
|
||||
@@ -159,7 +155,7 @@ public class NodesInputPanel extends JPanel
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
for (JComponent component: components) {
|
||||
for (JComponent component : components) {
|
||||
component.setEnabled(enabled);
|
||||
}
|
||||
super.setEnabled(enabled);
|
||||
@@ -176,7 +172,7 @@ public class NodesInputPanel extends JPanel
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
for (JTextField field: nodeInputs) {
|
||||
for (JTextField field : nodeInputs) {
|
||||
field.setText("");
|
||||
markerTrackers.put(field, null);
|
||||
}
|
||||
@@ -248,8 +244,8 @@ public class NodesInputPanel extends JPanel
|
||||
MarkerOverlay tracker = markerTrackers.getOrDefault(textField, null);
|
||||
if (curnode != null) {
|
||||
if (tracker == null) {
|
||||
tracker = drawing.drawMarker(curnode.getPoint(), markerColor, Color.BLACK,
|
||||
AlphaMode.TRANSPARENT);
|
||||
tracker = drawing.drawMarker(curnode.getPoint(), markerColor,
|
||||
Color.BLACK, AlphaMode.TRANSPARENT);
|
||||
markerTrackers.put(textField, tracker);
|
||||
}
|
||||
else {
|
||||
@@ -268,7 +264,7 @@ public class NodesInputPanel extends JPanel
|
||||
List<Node> nodes = getNodeForInputs();
|
||||
|
||||
// Trigger change event.
|
||||
for (ActionListener lis: inputChangeListeners) {
|
||||
for (ActionListener lis : inputChangeListeners) {
|
||||
lis.actionPerformed(new InputChangedEvent(nodes));
|
||||
}
|
||||
}
|
||||
@@ -317,21 +313,21 @@ public class NodesInputPanel extends JPanel
|
||||
}
|
||||
|
||||
/**
|
||||
* @return List of nodes associated with the input. Some nodes may be null if
|
||||
* their associated input is invalid.
|
||||
* @return List of nodes associated with the input. Some nodes may be null if their
|
||||
* associated input is invalid.
|
||||
*/
|
||||
public List<Node> getNodeForInputs() {
|
||||
List<Node> nodes = new ArrayList<>(nodeInputs.size());
|
||||
for (JTextField input: nodeInputs) {
|
||||
for (JTextField input : nodeInputs) {
|
||||
nodes.add(getNodeForInput(input));
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next input that should be filled by a click, or null if none should
|
||||
* be filled.
|
||||
*
|
||||
* Get the next input that should be filled by a click, or null if none should be
|
||||
* filled.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected JTextField getInputToFill() {
|
||||
@@ -350,7 +346,7 @@ public class NodesInputPanel extends JPanel
|
||||
|
||||
/**
|
||||
* Set the next input to fill to the given text field.
|
||||
*
|
||||
*
|
||||
* @param input
|
||||
*/
|
||||
protected void setInputToFill(JTextField input) {
|
||||
@@ -410,7 +406,7 @@ public class NodesInputPanel extends JPanel
|
||||
|
||||
@Override
|
||||
public void onRedrawRequest() {
|
||||
for (JTextField input: nodeInputs) {
|
||||
for (JTextField input : nodeInputs) {
|
||||
MarkerOverlay tracker = markerTrackers.getOrDefault(input, null);
|
||||
if (tracker != null) {
|
||||
MarkerOverlay newMarker = this.drawing.drawMarker(tracker.getPoint(),
|
||||
|
||||
Reference in New Issue
Block a user