Last change
on this file since 8395 was 8395, checked in by Don-vip, 9 years ago |
convention - An open curly brace should be located at the end of a line
|
-
Property svn:eol-style
set to
native
|
File size:
1.5 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.mappaint.xml;
|
---|
3 |
|
---|
4 | import org.openstreetmap.josm.gui.mappaint.Range;
|
---|
5 |
|
---|
6 | public 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 | if (width < 0) {
|
---|
37 | res = 0;
|
---|
38 | } else {
|
---|
39 | res = ref*width/100;
|
---|
40 | }
|
---|
41 | }
|
---|
42 | return res <= 0 ? 1 : res;
|
---|
43 | }
|
---|
44 |
|
---|
45 | @Override
|
---|
46 | public int getWidth() {
|
---|
47 | throw new UnsupportedOperationException();
|
---|
48 | }
|
---|
49 |
|
---|
50 | @Override
|
---|
51 | public int compareTo(LinemodPrototype s) {
|
---|
52 | if(s.priority != priority)
|
---|
53 | return s.priority > priority ? 1 : -1;
|
---|
54 | if(!over && s.over)
|
---|
55 | return -1;
|
---|
56 | // we have no idea how to order other objects :-)
|
---|
57 | return 0;
|
---|
58 | }
|
---|
59 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.