source: josm/trunk/src/org/openstreetmap/josm/gui/mappaint/xml/LinemodPrototype.java@ 8256

Last change on this file since 8256 was 6890, checked in by Don-vip, 10 years ago

fix some Sonar issues (Constructor Calls Overridable Method)

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.mappaint.xml;
3
4import org.openstreetmap.josm.gui.mappaint.Range;
5
6public class LinemodPrototype extends LinePrototype implements Comparable<LinemodPrototype> {
7
8 public boolean over;
9
10 public enum WidthMode { ABSOLUTE, PERCENT, OFFSET }
11 public WidthMode widthMode;
12
13 public LinemodPrototype(LinemodPrototype s, Range range) {
14 super(s, range);
15 this.over = s.over;
16 this.widthMode = s.widthMode;
17 }
18
19 public LinemodPrototype() { init(); }
20
21 @Override
22 public final void init() {
23 super.init();
24 over = true;
25 widthMode = WidthMode.ABSOLUTE;
26 }
27
28 /** get width for overlays */
29 public float getWidth(float ref) {
30 float res;
31 if(widthMode == WidthMode.ABSOLUTE) {
32 res = width;
33 } else if(widthMode == WidthMode.OFFSET) {
34 res = ref + width;
35 } else
36 {
37 if(width < 0) {
38 res = 0;
39 } else {
40 res = ref*width/100;
41 }
42 }
43 return res <= 0 ? 1 : res;
44 }
45
46 @Override
47 public int getWidth() {
48 throw new UnsupportedOperationException();
49 }
50
51 @Override
52 public int compareTo(LinemodPrototype s) {
53 if(s.priority != priority)
54 return s.priority > priority ? 1 : -1;
55 if(!over && s.over)
56 return -1;
57 // we have no idea how to order other objects :-)
58 return 0;
59 }
60}
Note: See TracBrowser for help on using the repository browser.