Changeset 1501 in osm
- Timestamp:
- 2006-10-24T01:10:23+02:00 (18 years ago)
- Location:
- utils/josm/plugins/mappaint/src/mappaint
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
utils/josm/plugins/mappaint/src/mappaint/AreaElemStyle.java
r1436 r1501 6 6 Color colour; 7 7 8 public AreaElemStyle (Color colour )8 public AreaElemStyle (Color colour, int minZoom) 9 9 { 10 10 this.colour = colour; 11 this.minZoom = minZoom; 11 12 } 12 13 -
utils/josm/plugins/mappaint/src/mappaint/ElemStyle.java
r1436 r1501 1 1 package mappaint; 2 2 3 // nothing in here yet4 3 abstract public class ElemStyle 5 4 { 5 // zoom range to display the feature 6 protected int minZoom; 7 8 public int getMinZoom() 9 { 10 return minZoom; 11 } 6 12 } 7 13 -
utils/josm/plugins/mappaint/src/mappaint/ElemStyleHandler.java
r1436 r1501 13 13 public class ElemStyleHandler extends DefaultHandler 14 14 { 15 boolean inDoc, inRule, inCondition, inElemStyle, inLine, inIcon, inArea; 16 ElemStyle curStyle; 17 ElemStyles styles; 18 String curWidth, curKey, curValue; 19 ImageIcon curIcon; 20 Color curColour; 21 boolean curAnnotate; 15 boolean inDoc, inRule, inCondition, inElemStyle, inLine, inIcon, inArea; 16 ElemStyle curStyle; 17 ElemStyles styles; 18 String curWidth, curKey, curValue; 19 int curMinZoom; 20 ImageIcon curIcon; 21 Color curColour; 22 boolean curAnnotate; 22 23 23 24 25 26 27 24 public ElemStyleHandler( ) 25 { 26 inDoc=inRule=inCondition=inElemStyle=inLine=inIcon=inArea=false; 27 styles = new ElemStyles(); 28 } 28 29 29 30 31 32 30 public void setElemStyles(ElemStyles styles) 31 { 32 this.styles = styles; 33 } 33 34 34 35 36 37 38 39 35 /* 36 ElemStyles getElemStyles() 37 { 38 return styles; 39 } 40 */ 40 41 41 42 43 44 42 @Override public void startDocument() 43 { 44 inDoc = true; 45 } 45 46 46 47 48 49 47 @Override public void endDocument() 48 { 49 inDoc = false; 50 } 50 51 51 @Override public void startElement(String uri,String name, String qName, 52 Attributes atts) 53 { 54 if(inDoc==true) 55 { 56 if(qName.equals("rule")) 52 @Override public void startElement(String uri,String name, String qName, 53 Attributes atts) 54 { 55 if(inDoc==true) 56 { 57 if(qName.equals("rule")) 58 { 59 inRule=true; 60 } 61 else if (qName.equals("condition") && inRule) 62 { 63 inCondition=true; 64 for(int count=0; count<atts.getLength(); count++) 65 { 66 if(atts.getQName(count).equals("k")) 67 curKey = atts.getValue(count); 68 else if(atts.getQName(count).equals("v")) 69 curValue = atts.getValue(count); 70 } 71 } 72 else if (qName.equals("line")) 73 { 74 inLine = true; 75 for(int count=0; count<atts.getLength(); count++) 76 { 77 if(atts.getQName(count).equals("width")) 78 curWidth = atts.getValue(count); 79 else if (atts.getQName(count).equals("colour")) 80 curColour=ColorHelper.html2color(atts.getValue(count)); 81 } 82 } 83 else if (qName.equals("zoom")) 57 84 { 58 inRule=true; 59 } 60 else if (qName.equals("condition") && inRule) 61 { 62 inCondition=true; 63 for(int count=0; count<atts.getLength(); count++) 64 { 65 if(atts.getQName(count).equals("k")) 66 curKey = atts.getValue(count); 67 else if(atts.getQName(count).equals("v")) 68 curValue = atts.getValue(count); 69 } 70 } 71 else if (qName.equals("line")) 72 { 73 inLine = true; 74 for(int count=0; count<atts.getLength(); count++) 75 { 76 if(atts.getQName(count).equals("width")) 77 curWidth = atts.getValue(count); 78 else if (atts.getQName(count).equals("colour")) 79 curColour=ColorHelper.html2color(atts.getValue(count)); 80 } 81 } 82 else if (qName.equals("icon")) 83 { 84 inIcon = true; 85 for(int count=0; count<atts.getLength(); count++) 86 { 87 if(atts.getQName(count).equals("src")) { 88 URL path = getClass().getResource("/images/nodes/"+atts.getValue(count)); 89 curIcon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(path)); 90 } else if (atts.getQName(count).equals("annotate")) 91 curAnnotate = Boolean.parseBoolean 92 (atts.getValue(count)); 93 } 94 } 95 else if (qName.equals("area")) 96 { 97 inArea = true; 98 for(int count=0; count<atts.getLength(); count++) 99 { 100 if (atts.getQName(count).equals("colour")) 101 curColour=ColorHelper.html2color(atts.getValue(count)); 102 } 103 } 104 } 105 } 85 curMinZoom = 0; 86 for(int count=0; count<atts.getLength(); count++) 87 { 88 if(atts.getQName(count).equals("min")) 89 curMinZoom = Integer.parseInt(atts.getValue(count)); 90 } 91 } 92 else if (qName.equals("icon")) 93 { 94 inIcon = true; 95 for(int count=0; count<atts.getLength(); count++) 96 { 97 if(atts.getQName(count).equals("src")) { 98 URL path = getClass().getResource("/images/nodes/"+atts.getValue(count)); 99 curIcon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(path)); 100 } else if (atts.getQName(count).equals("annotate")) 101 curAnnotate = Boolean.parseBoolean 102 (atts.getValue(count)); 103 } 104 } 105 else if (qName.equals("area")) 106 { 107 inArea = true; 108 for(int count=0; count<atts.getLength(); count++) 109 { 110 if (atts.getQName(count).equals("colour")) 111 curColour=ColorHelper.html2color(atts.getValue(count)); 112 } 113 } 114 } 115 } 106 116 107 117 108 @Override public void endElement(String uri,String name, String qName) 109 { 110 if(inRule && qName.equals("rule")) 111 { 112 inRule = false; 113 styles.add (curKey, curValue, curStyle); 114 } 115 else if (inCondition && qName.equals("condition")) 116 inCondition = false; 117 else if (inLine && qName.equals("line")) 118 { 119 inLine = false; 120 curStyle = new LineElemStyle(Integer.parseInt(curWidth), curColour); 121 } 122 else if (inIcon && qName.equals("icon")) 123 { 124 inIcon = false; 125 curStyle = new IconElemStyle(curIcon,curAnnotate); 126 } 127 else if (inArea && qName.equals("area")) 128 { 129 inArea = false; 130 curStyle = new AreaElemStyle (curColour); 131 } 118 @Override public void endElement(String uri,String name, String qName) 119 { 120 if(inRule && qName.equals("rule")) 121 { 122 inRule = false; 123 styles.add (curKey, curValue, curStyle); 124 } 125 else if (inCondition && qName.equals("condition")) 126 inCondition = false; 127 else if (inLine && qName.equals("line")) 128 { 129 inLine = false; 130 curStyle = new LineElemStyle(Integer.parseInt(curWidth), curColour, 131 curMinZoom); 132 } 133 else if (inIcon && qName.equals("icon")) 134 { 135 inIcon = false; 136 curStyle = new IconElemStyle(curIcon,curAnnotate,curMinZoom); 137 } 138 else if (inArea && qName.equals("area")) 139 { 140 inArea = false; 141 curStyle = new AreaElemStyle (curColour,curMinZoom); 142 } 132 143 133 144 } 134 145 135 136 137 146 @Override public void characters(char ch[], int start, int length) 147 { 148 } 138 149 } 139 150 //////////////////////////////////////////////////////////////////////////////// -
utils/josm/plugins/mappaint/src/mappaint/ElemStyles.java
r1436 r1501 37 37 return null; 38 38 } 39 40 public boolean isArea(OsmPrimitive p) 41 { 42 return getStyle(p) instanceof AreaElemStyle; 43 } 39 44 } -
utils/josm/plugins/mappaint/src/mappaint/IconElemStyle.java
r1436 r1501 7 7 boolean annotate; 8 8 9 public IconElemStyle (ImageIcon icon, boolean annotate )9 public IconElemStyle (ImageIcon icon, boolean annotate, int minZoom) 10 10 { 11 11 this.icon=icon; 12 12 this.annotate=annotate; 13 this.minZoom = minZoom; 13 14 } 14 15 -
utils/josm/plugins/mappaint/src/mappaint/LineElemStyle.java
r1436 r1501 7 7 Color colour; 8 8 9 public LineElemStyle (int width, Color colour )9 public LineElemStyle (int width, Color colour, int minZoom) 10 10 { 11 11 this.width = width; 12 12 this.colour = colour; 13 this.minZoom = minZoom; 13 14 } 14 15 -
utils/josm/plugins/mappaint/src/mappaint/MapPaintVisitor.java
r1443 r1501 31 31 @Override public void visit(Node n) { 32 32 ElemStyle nodeStyle = MapPaintPlugin.elemStyles.getStyle(n); 33 if(nodeStyle!=null) 34 { 35 if(nodeStyle instanceof IconElemStyle) 36 { 33 if(nodeStyle!=null && Main.map.mapView.zoom()>=nodeStyle.getMinZoom()){ 34 if(nodeStyle instanceof IconElemStyle) { 37 35 drawNode(n, ((IconElemStyle)nodeStyle).getIcon()); 38 } 39 else 40 { 36 } else { 41 37 // throw some sort of exception 42 38 } 43 } 44 else 45 { 39 } else { 46 40 drawNode(n, n.selected ? getPreferencesColor("selected", 47 41 Color.YELLOW)
Note:
See TracChangeset
for help on using the changeset viewer.