Changeset 32109 in osm for applications/editors/josm


Ignore:
Timestamp:
2016-03-09T17:13:00+01:00 (8 years ago)
Author:
roland
Message:

Fixed various bugs (see git repo)

Location:
applications/editors/josm/plugins/indoor_sweepline/src/indoor_sweepline
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/indoor_sweepline/src/indoor_sweepline/Beam.java

    r32103 r32109  
    66public class Beam
    77{
    8     public Beam(double width, CorridorPart.ReachableSide defaultSide)
    9     {
     8    public Beam(Vector<Double> blueprint, double blueprintOffset, CorridorPart.ReachableSide defaultSide)
     9    {
     10        offset = blueprintOffset;
    1011        parts = new Vector<CorridorPart>();
    1112       
    12         setDefaultSide_(defaultSide);   
    13         addCorridorPart_(true, width);
     13        setDefaultSide_(defaultSide);
     14        if (defaultSide == CorridorPart.ReachableSide.RIGHT)
     15        {
     16            for (int i = 1; i < blueprint.size(); i += 2)
     17            {
     18                addCorridorPart_(true, CorridorPart.Type.WALL,
     19                    blueprint.elementAt(i).doubleValue() - blueprint.elementAt(i-1).doubleValue());
     20                if (i+1 < blueprint.size())
     21                    addCorridorPart_(true, CorridorPart.Type.VOID,
     22                        blueprint.elementAt(i+1).doubleValue() - blueprint.elementAt(i).doubleValue());
     23            }
     24        }
     25        else
     26        {
     27            for (int i = 1; i < blueprint.size(); i += 2)
     28            {
     29                addCorridorPart_(true, CorridorPart.Type.PASSAGE,
     30                    blueprint.elementAt(i).doubleValue() - blueprint.elementAt(i-1).doubleValue());
     31                if (i+1 < blueprint.size())
     32                    addCorridorPart_(true, CorridorPart.Type.VOID,
     33                        blueprint.elementAt(i+1).doubleValue() - blueprint.elementAt(i).doubleValue());
     34            }
     35        }
    1436        adjustStripCache();
    1537    }
     
    1941    {
    2042        this.defaultSide = defaultSide;
    21         defaultType = defaultSide == CorridorPart.ReachableSide.RIGHT ?
    22             CorridorPart.Type.WALL : CorridorPart.Type.PASSAGE;
    2343    }
    2444   
     
    3454        return parts;
    3555    }
    36 
    37    
    38     private void addCorridorPart_(boolean append, double width)
     56   
     57   
     58    public double getBeamOffset()
     59    {
     60        return offset;
     61    }
     62   
     63    public void setBeamOffset(double beamOffset)
     64    {
     65        offset = beamOffset;
     66    }
     67
     68   
     69    private void addCorridorPart_(boolean append, CorridorPart.Type type, double width)
    3970    {
    4071        CorridorPart.ReachableSide side = defaultSide == CorridorPart.ReachableSide.RIGHT ?
     
    4273           
    4374        if (append)
    44             parts.add(new CorridorPart(width, defaultType, side));
    45         else
    46             parts.add(0, new CorridorPart(width, defaultType, side));
     75            parts.add(new CorridorPart(width, type, side));
     76        else
     77            parts.add(0, new CorridorPart(width, type, side));
    4778    }
    4879
    4980    public void addCorridorPart(boolean append, double width)
    5081    {
    51         addCorridorPart_(append, width);
     82        addCorridorPart_(append,
     83            defaultSide == CorridorPart.ReachableSide.RIGHT ? CorridorPart.Type.WALL : CorridorPart.Type.PASSAGE,
     84            width);
    5285        adjustStripCache();
    5386    }
     
    177210   
    178211   
     212    private double offset;
    179213    private Vector<CorridorPart> parts;
    180214    private Vector<StripPosition> lhsStrips;
     
    314348   
    315349   
    316     private CorridorPart.Type defaultType;
    317350    private CorridorPart.ReachableSide defaultSide;
    318351}
  • applications/editors/josm/plugins/indoor_sweepline/src/indoor_sweepline/BeamGeography.java

    r32103 r32109  
    4646
    4747   
    48     public void adjustNodes(LatLon pivot, Vector<CorridorPart> parts)
     48    public void adjustNodes(LatLon pivot, Vector<CorridorPart> parts, double beamOffset)
    4949    {
     50        double offset = -beamOffset;
    5051        this.parts = parts;
    51         adjustNode(0, new LatLon(pivot.lat(), pivot.lon()));
     52       
     53        adjustNode(0, new LatLon(addMetersToLat(pivot, offset), pivot.lon()));
    5254   
    53         double offset = 0;
    5455        for (int i = 0; i < parts.size(); ++i)
    5556        {
  • applications/editors/josm/plugins/indoor_sweepline/src/indoor_sweepline/IndoorSweeplineController.java

    r32103 r32109  
    7373    }
    7474   
     75    public double getBeamOffset(int index)
     76    {
     77        return model.getBeamOffset(index);
     78    }
     79   
     80    public void setBeamOffset(int index, double beamOffset)
     81    {
     82        model.setBeamOffset(index, beamOffset);
     83    }
     84   
    7585    public List<CorridorPart> getBeamParts(int index)
    7686    {
  • applications/editors/josm/plugins/indoor_sweepline/src/indoor_sweepline/IndoorSweeplineModel.java

    r32107 r32109  
    1111
    1212/* TODO:
    13 - offset
    14 - replicate last stopline
    1513- focus to useful table entry after cell edit
    1614- keyboard shortcuts
     
    6361        for (int i = 0; i < strips.size(); ++i)
    6462            offset += strips.elementAt(i).width;
    65            
    66         beams.add(new Beam(width, side));
     63       
     64        if (strips.size() == 0)
     65        {
     66            Vector<Double> blueprint = new Vector<Double>();
     67            blueprint.addElement(0.);
     68            blueprint.addElement(10.);
     69            beams.add(new Beam(blueprint, 0., side));
     70        }
     71        else
     72            beams.add(new Beam(strips.elementAt(strips.size()-1).lhs,
     73                beams.elementAt(beams.size()-1).getBeamOffset(), side));
    6774       
    6875        if (strips.size() > 0)
     
    128135        strips.elementAt(index / 2).width = value;
    129136       
     137        updateOsmModel();
     138    }
     139   
     140   
     141    public double getBeamOffset(int index)
     142    {
     143        return beams.elementAt(index / 2).getBeamOffset();
     144    }
     145   
     146    public void setBeamOffset(int index, double beamOffset)
     147    {
     148        beams.elementAt(index / 2).setBeamOffset(beamOffset);       
    130149        updateOsmModel();
    131150    }
  • applications/editors/josm/plugins/indoor_sweepline/src/indoor_sweepline/IndoorSweeplineWizardDialog.java

    r32103 r32109  
    5454        panel.add(new JButton(next), 2, 2, 2, 1);
    5555
    56         panel.add(new JLabel(tr("Strip width:")), 0, 3, 3, 1);
     56        panel.add(makeWidthLabel(), 0, 3, 3, 1);
    5757        panel.add(makeWidthField(), 3, 3, 1, 1);
    5858
     
    8585        try
    8686        {
    87             stripWidth.setEditable(beamIndex % 2 == 1);
    8887            if (beamIndex % 2 == 0)
    89                 stripWidth.setText("---");
     88            {
     89                widthOffsetLabel.setText("Offset into background:");
     90                stripWidth.setText(Double.toString(controller.getBeamOffset(beamIndex)));
     91            }
    9092            else
     93            {
     94                widthOffsetLabel.setText("Strip width:");
    9195                stripWidth.setText(Double.toString(controller.getStripWidth(beamIndex)));
     96            }
    9297        }
    9398        catch (IllegalStateException ex)
     
    364369   
    365370   
     371    private JLabel widthOffsetLabel;
     372   
     373    private JLabel makeWidthLabel()
     374    {
     375        widthOffsetLabel = new JLabel(tr("Offset into background:"));
     376        return widthOffsetLabel;
     377    }
     378   
     379   
    366380    private JTextField stripWidth;
    367381   
     
    399413            try
    400414            {
    401                 if (beamIndex % 2 == 1)
     415                if (beamIndex % 2 == 0)
     416                    controller.setBeamOffset(beamIndex, Double.parseDouble(stripWidth.getText()));
     417                else
    402418                    controller.setStripWidth(beamIndex, Double.parseDouble(stripWidth.getText()));
    403419            }
  • applications/editors/josm/plugins/indoor_sweepline/src/indoor_sweepline/ModelGeography.java

    r32107 r32109  
    7676                beamsGeography.setElementAt(new BeamGeography(dataSet, this), i);
    7777            beamsGeography.elementAt(i).adjustNodes(new LatLon(center.lat(), addMetersToLon(center, offset)),
    78                 beams.elementAt(i).getBeamParts());
     78                beams.elementAt(i).getBeamParts(), beams.elementAt(i).getBeamOffset());
    7979               
    8080            if (i < strips.size())
Note: See TracChangeset for help on using the changeset viewer.