#158 Width of destination line

closed-accepted
nobody
None
5
2012-04-03
2012-03-25
Martin
No

The with of the destination line should be twice the configured width value.
So, for a value of 1 the line should be 2 pixels in width, for the value 2 it should be 4 pixels and for the value 0 it should be 1 pixel.
Actually the value 1 does not work because of the method drawWideLine in WaySegment.java.
Please change:
if (linewidth > 1) {
to
if (linewidth > 0) {

Discussion

  • sk750

    sk750 - 2012-03-26

    It also seems to me 2 is more wide than 2 pixels.

    However, I don't understand why the width should be the double value. Shouldn't 0 width be no visible line, 1 width a normal line, 2 width a 2 pixel wide line, etc. ?

     
  • Martin

    Martin - 2012-03-26

    I added a drawWideLineSimple method which draws no line for value 0, a 1 pixel wide line for value 1 and thicker lines for larger values. Although I don't know, how thick this lines are exactly. But this method at leaves give the expected result.

    Put the method in WaySegment.java:

    public void drawWideLineSimple(int color, IntPoint point1, IntPoint point2, int linewidth, PaintContext pc) {

    if ( linewidth == 0 )
    return;

    pc.g.setColor(color);

    /* Always draw a line with px1 width also for wide lines because drawing a wide line might not work in every case.
    * This is at least the case on Nokia 5800 with very offscreen lines in some angles (line to destination several 100 km in normal zoom)
    */
    pc.g.drawLine(point1.x, point1.y, point2.x, point2.y);

    if (linewidth > 1) {
    linePoints.set(point1,point2,linewidth-1);

    pc.g.fillTriangle(linePoints.a.x, linePoints.a.y, linePoints.b.x, linePoints.b.y,linePoints.d.x, linePoints.d.y);
    pc.g.fillTriangle(linePoints.a.x, linePoints.a.y, linePoints.c.x, linePoints.c.y,linePoints.d.x, linePoints.d.y);
    }
    }

    and change the call in Trace.java to:

    waySegment.drawWideLineSimple(
    Legend.COLORS[Legend.COLOR_DEST_LINE],
    new IntPoint(pc.getP().getImageCenter().x - imageCollector.xScreenOverscan, pc.getP().getImageCenter().y - imageCollector.yScreenOverscan),
    new IntPoint(x, y),
    Configuration.getDestLineWidth(), pc
    );

     
  • Martin

    Martin - 2012-04-03

    This is in Git now. Closed.

     
  • Martin

    Martin - 2012-04-03
    • status: open --> closed-accepted
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks