Skip to content

Commit

Permalink
remove unused code, add javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
don-vip committed Aug 23, 2016
1 parent 9192262 commit c252db4
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 235 deletions.
17 changes: 12 additions & 5 deletions src/org/openstreetmap/josm/plugins/shapetools/DrawableSegment.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,29 @@
/**
* Base class used for adding colored segments on map as temporary MapViewPaintables
* @author Adrian_antochi
*
*/
public class DrawableSegment implements MapViewPaintable {

protected WaySegment segment;
protected Color color;
protected Stroke stroke;

/**
* Constructs a new {@code DrawableSegment}.
* @param segment way segment
*/
public DrawableSegment(WaySegment segment) {
int strokeThickness = 3;
this.segment = segment;
this.color = Color.WHITE;
this.stroke = new BasicStroke(strokeThickness);
}

/**
* Constructs a new {@code DrawableSegment}.
* @param segment way segment
* @param color color
*/
public DrawableSegment(WaySegment segment, Color color) {
int strokeThickness = 3;
this.segment = segment;
Expand All @@ -41,8 +49,8 @@ public DrawableSegment(WaySegment segment, Color color) {
@Override
public void paint(Graphics2D g, MapView mv, Bounds bbox) {
if (segment != null) {
g.setColor(this.color);
g.setStroke(this.stroke);
g.setColor(color);
g.setStroke(stroke);
Node firstNode = segment.getFirstNode();
Node secondNode = segment.getSecondNode();

Expand All @@ -67,7 +75,6 @@ public void setSegment(WaySegment segment) {
}

public WaySegment getSegment() {
return this.segment;
return segment;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
import java.awt.Color;

import org.openstreetmap.josm.data.osm.WaySegment;

/**
* Adding this as a temporary layer on mapview will color the selected segment green
* @author Adrian_antochi
*
*/
public class DrawableSegmentBuilding extends DrawableSegment {

/**
* Constructs a new {@code DrawableSegmentBuilding}.
* @param segment way segment
*/
public DrawableSegmentBuilding(WaySegment segment) {
super(segment);
this.color = Color.GREEN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
import java.awt.Color;

import org.openstreetmap.josm.data.osm.WaySegment;

/**
* Adding this as a temporary layer on mapview will color the selected segment yellow
* @author Adrian_antochi
*
*/
public class DrawableSegmentRoad extends DrawableSegment {

/**
* Constructs a new {@code DrawableSegmentRoad}.
* @param segment way segment
*/
public DrawableSegmentRoad(WaySegment segment) {
super(segment);
this.color = Color.YELLOW;
}

}
84 changes: 0 additions & 84 deletions src/org/openstreetmap/josm/plugins/shapetools/DrawableWay.java

This file was deleted.

4 changes: 0 additions & 4 deletions src/org/openstreetmap/josm/plugins/shapetools/Point.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ public Point(double x, double y) {
this.y = y;
}

public static double distance(Point x1, Point x2) {
return Math.sqrt(Math.pow(x2.x - x1.x, 2) + Math.pow(x2.y - x1.y, 2)); // always positive
}

public static double distance(Point lineX1, Point lineX2, Point p) {
double A = p.x - lineX1.x;
double B = p.y - lineX1.y;
Expand Down
39 changes: 0 additions & 39 deletions src/org/openstreetmap/josm/plugins/shapetools/ShapeMath.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,21 +169,6 @@ public static EastNorth getCentroid(WaySegment segment) {
return new EastNorth(x, y);
}

/**
* @return center-point of a list of ways
*/
public static EastNorth getCentroid(List<Way> wayList) {
double x = 0, y = 0;
for (int i = 0; i < wayList.size(); i++) {
EastNorth currentCenter = getCentroid(wayList.get(i));
x += currentCenter.getX();
y += currentCenter.getY();
}
x = x / wayList.size();
y = y / wayList.size();
return new EastNorth(x, y);
}

/**
* @return center-point of a set of nodes
*/
Expand Down Expand Up @@ -275,30 +260,6 @@ public static void align(WaySegment roadSegment, WaySegment toRotateSegment) {
Main.map.repaint();
}

/**
* Aligns a way to a segment, mostly used to align a building to a road segment
*/
public static void align(WaySegment roadSegment, Way building) {
WaySegment closestSegment = ShapeMath.getClosestSegment(building, roadSegment);
double x1 = roadSegment.getFirstNode().getEastNorth().getX();
double x2 = roadSegment.getSecondNode().getEastNorth().getX();
double x3 = closestSegment.getFirstNode().getEastNorth().getX();
double x4 = closestSegment.getSecondNode().getEastNorth().getX();
double y1 = roadSegment.getFirstNode().getEastNorth().getY();
double y2 = roadSegment.getSecondNode().getEastNorth().getY();
double y3 = closestSegment.getFirstNode().getEastNorth().getY();
double y4 = closestSegment.getSecondNode().getEastNorth().getY();

double requiredAngle = Math.atan2(y2 - y1, x2 - x1) - Math.atan2(y4 - y3, x4 - x3);
System.out.println("Angle calculated from align() " + requiredAngle);

requiredAngle = normalise(requiredAngle);

SequenceCommand commands = new SequenceCommand("aligningBuilding", rotate(building, requiredAngle, getCentroid(building)));
Main.main.undoRedo.add(commands);
Main.map.repaint();
}

/**
* Aligns the building only if the distance between the closest wall of the building and it's closest road-segment is smaller than epsilon
*/
Expand Down
8 changes: 4 additions & 4 deletions src/org/openstreetmap/josm/plugins/shapetools/ShapeMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
import org.openstreetmap.josm.gui.MapFrame;

public class ShapeMode extends MapMode {
MapFrame thisMapFrame;
WaySegment firstSegment;
WaySegment secondSegment;
static ButtonGroup group;
static DrawableSegmentBuilding buildingSegm;
static DrawableSegmentRoad roadSegm;

/**
* Constructs a new {@code ShapeMode}.
* @param mapFrame map frame
*/
public ShapeMode(MapFrame mapFrame) {
super("ShapeMode", "mode.png", "shapeModeTooltip", mapFrame, Cursor.getDefaultCursor());
thisMapFrame = mapFrame;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
*
*/
public class ShapePanelDialog extends ToggleDialog {
JPanel dialogPane;

/**
* Constructs a new {@code ShapePanelDialog}.
*/
public ShapePanelDialog() {
super(tr("Shape actions panel"), "shapePanelButton.png", tr("Shape mode control panel"),
null, 70);
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ public class ShapeToolsPlugin extends Plugin {
@SuppressWarnings("unused")
private static IconToggleButton optButton;

public ShapeToolsPlugin(PluginInformation info) {
/**
* Constructs a new {@code ShapeToolsPlugin}.
* @param info plugin information
*/
public ShapeToolsPlugin(PluginInformation info) { // NO_UCD (unused code)
super(info);
sDialog = new ShapePanelDialog();
}
Expand Down

0 comments on commit c252db4

Please sign in to comment.