- started overlays

- started symbol layer
- move renderer and generator out of view package
  - hopefully the last big refactoring for a while...
- improve perspective, plane should be more far away to decrease foreshortening
This commit is contained in:
Hannes Janetzek
2012-10-09 13:23:15 +02:00
parent 2713f3bc6f
commit 33d8865d7b
128 changed files with 2360 additions and 1417 deletions

View File

@@ -15,9 +15,8 @@
package org.oscim.theme;
import org.oscim.theme.renderinstruction.Area;
import org.oscim.theme.renderinstruction.Caption;
import org.oscim.theme.renderinstruction.Line;
import org.oscim.theme.renderinstruction.PathText;
import org.oscim.theme.renderinstruction.Text;
import android.graphics.Bitmap;
import android.graphics.Paint;
@@ -36,14 +35,6 @@ public interface IRenderCallback {
*/
void renderArea(Area area, int level);
/**
* Renders an area caption with the given text.
*
* @param caption
* the text to be rendered.
*/
void renderAreaCaption(Caption caption);
/**
* Renders an area symbol with the given bitmap.
*
@@ -52,14 +43,6 @@ public interface IRenderCallback {
*/
void renderAreaSymbol(Bitmap symbol);
/**
* Renders a point of interest caption with the given text.
*
* @param caption
* the text to be rendered.
*/
void renderPointOfInterestCaption(Caption caption);
/**
* Renders a point of interest circle with the given parameters.
*
@@ -105,8 +88,25 @@ public interface IRenderCallback {
/**
* Renders a way with the given text along the way path.
*
* @param pathText
* @param text
* ...
*/
void renderWayText(PathText pathText);
void renderWayText(Text text);
/**
* Renders an area caption with the given text.
*
* @param text
* the text to be rendered.
*/
void renderAreaCaption(Text text);
/**
* Renders a point of interest caption with the given text.
*
* @param text
* the text to be rendered.
*/
void renderPointOfInterestCaption(Text text);
}

View File

@@ -26,13 +26,12 @@ import javax.xml.parsers.SAXParserFactory;
import org.oscim.theme.renderinstruction.Area;
import org.oscim.theme.renderinstruction.AreaLevel;
import org.oscim.theme.renderinstruction.Caption;
import org.oscim.theme.renderinstruction.Circle;
import org.oscim.theme.renderinstruction.Line;
import org.oscim.theme.renderinstruction.LineSymbol;
import org.oscim.theme.renderinstruction.PathText;
import org.oscim.theme.renderinstruction.RenderInstruction;
import org.oscim.theme.renderinstruction.Symbol;
import org.oscim.theme.renderinstruction.Text;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -55,7 +54,7 @@ public class RenderThemeHandler extends DefaultHandler {
private static final String ELEMENT_NAME_RENDER_THEME = "rendertheme";
private static final String ELEMENT_NAME_RULE = "rule";
private static final String ELEMENT_NAME_STYPE_PATH_TEXT = "style-pathtext";
private static final String ELEMENT_NAME_STYLE_TEXT = "style-text";
private static final String ELEMENT_NAME_STYLE_AREA = "style-area";
private static final String ELEMENT_NAME_STYLE_LINE = "style-line";
private static final String ELEMENT_NAME_STYLE_OUTLINE = "style-outline";
@@ -68,7 +67,8 @@ public class RenderThemeHandler extends DefaultHandler {
/**
* @param inputStream
* an input stream containing valid render theme XML data.
* @return a new RenderTheme which is created by parsing the XML data from the input stream.
* @return a new RenderTheme which is created by parsing the XML data from
* the input stream.
* @throws SAXException
* if an error occurs while parsing the render theme XML.
* @throws ParserConfigurationException
@@ -171,11 +171,11 @@ public class RenderThemeHandler extends DefaultHandler {
mRuleStack.push(mCurrentRule);
}
else if (ELEMENT_NAME_STYPE_PATH_TEXT.equals(localName)) {
else if (ELEMENT_NAME_STYLE_TEXT.equals(localName)) {
checkState(localName, Element.STYLE);
PathText pathText = PathText.create(localName, attributes);
tmpStyleHash.put("t" + pathText.style, pathText);
// System.out.println("add style: " + pathText.style);
Text text = Text.create(localName, attributes, false);
tmpStyleHash.put("t" + text.style, text);
// System.out.println("add style: " + text.style);
}
else if (ELEMENT_NAME_STYLE_AREA.equals(localName)) {
@@ -194,7 +194,8 @@ public class RenderThemeHandler extends DefaultHandler {
Line line = Line.create((Line) ri, localName, attributes, 0,
false);
tmpStyleHash.put("l" + line.style, line);
// System.out.println("add style: " + line.style + " from " + style);
// System.out.println("add style: " + line.style +
// " from " + style);
}
else {
Log.d("...", "this aint no style! " + style);
@@ -222,8 +223,11 @@ public class RenderThemeHandler extends DefaultHandler {
else if ("caption".equals(localName)) {
checkState(localName, Element.RENDERING_INSTRUCTION);
Caption caption = Caption.create(localName, attributes);
mCurrentRule.addRenderingInstruction(caption);
Text text = Text.create(localName, attributes, true);
mCurrentRule.addRenderingInstruction(text);
// Caption caption = Caption.create(localName, attributes);
// mCurrentRule.addRenderingInstruction(caption);
}
else if ("circle".equals(localName)) {
@@ -244,10 +248,10 @@ public class RenderThemeHandler extends DefaultHandler {
mCurrentRule.addRenderingInstruction(lineSymbol);
}
else if ("pathText".equals(localName)) {
else if ("text".equals(localName)) {
checkState(localName, Element.RENDERING_INSTRUCTION);
PathText pathText = PathText.create(localName, attributes);
mCurrentRule.addRenderingInstruction(pathText);
Text text = Text.create(localName, attributes, false);
mCurrentRule.addRenderingInstruction(text);
}
else if ("symbol".equals(localName)) {
@@ -262,7 +266,8 @@ public class RenderThemeHandler extends DefaultHandler {
if (style != null) {
Line line = (Line) tmpStyleHash.get("l" + style);
if (line != null) {
// System.out.println("found style line : " + line.style);
// System.out.println("found style line : " +
// line.style);
Line newLine = Line.create(line, localName, attributes,
mLevel++, false);
@@ -290,13 +295,13 @@ public class RenderThemeHandler extends DefaultHandler {
mCurrentRule.addRenderingInstruction(new AreaLevel(area,
mLevel++));
else
Log.d("...", "this aint no style inna di area! " + style);
Log.d("...", "this aint no style inna d'area! " + style);
}
} else if (ELEMENT_NAME_USE_STYLE_PATH_TEXT.equals(localName)) {
checkState(localName, Element.RENDERING_INSTRUCTION);
String style = attributes.getValue("name");
if (style != null) {
PathText pt = (PathText) tmpStyleHash.get("t" + style);
Text pt = (Text) tmpStyleHash.get("t" + style);
if (pt != null)
mCurrentRule.addRenderingInstruction(pt);
else

View File

@@ -4,8 +4,8 @@
xsi:schemaLocation="http://mapsforge.org/renderTheme ../renderTheme.xsd"
version="1" map-background="#fcfcfa">
<style-pathtext name="road" k="name" font-size="16" fill="#101010" stroke="#ffffff" stroke-width="2.0" />
<style-pathtext name="major-road" k="name" font-style="bold" font-size="16" fill="#101010" stroke="#ffffff" stroke-width="2.0" />
<style-text name="road" k="name" font-size="16" fill="#101010" stroke="#ffffff" stroke-width="2.0" />
<style-text name="major-road" k="name" font-style="bold" font-size="16" fill="#101010" stroke="#ffffff" stroke-width="2.0" />
<style-area name="residential" fill="#f0eee8" fade="10"/>
@@ -65,14 +65,14 @@
<style-line name="steps" stroke="#f1f0f4" width="0.25" cap="butt" />
<style-line name="water:outline" stroke="#a4bbcc" width="1.0" fixed="true" cap="butt" />
<style-line name="water" stroke="#b4cbdc" width="1.0" cap="butt" />
<style-line name="water" stroke="#afcbf3" width="1.0" cap="butt" />
<style-area name="water" fill="#afcbf3" />
<!-- no-go area boundary -->
<style-line name="fence" stroke="#444444" width="1.2" fixed="true" cap="butt"/>
<style-line name="aeroway:runway" stroke="#c8ccbe" width="1.8" cap="butt" />
<style-line name="building" stroke="#c9c3c1" width="1.2" fixed="true" cap="butt" fade="15"/>
<style-line name="building" stroke="#c9c3c1" width="1.0" fixed="true" cap="butt" fade="15"/>
<style-area name="building" fill="#e9e6e3" fade="15"/>
<!-- ways -->
@@ -487,11 +487,11 @@
</rule>
<!-- outline 1 - 4 -->
<style-outline name="1" stroke="#ee605020" width="0.02"/>
<style-outline name="1" stroke="#aa807040" width="0.1"/>
<!-- <style-outline name="1" stroke="#404030"/> -->
<style-outline name="2" stroke="#c0c0c0" />
<style-outline name="primary" stroke="#7f7700" width="0.025"/>
<style-outline name="motorway" stroke="#805f2e" width="0.025"/>
<style-outline name="primary" stroke="#aa7f7700" width="0.1"/>
<style-outline name="motorway" stroke="#aa805f2e" width="0.1"/>
<!-- highway -->
@@ -499,23 +499,23 @@
<rule e="way" k="*" v="*" zoom-min="5" zoom-max="10">
<rule e="way" k="area" v="~|no|false">
<rule e="way" k="*" v="secondary|primary_link" zoom-min="9">
<line stroke="#f2df6d" width="1.8" cap="butt" fixed="true" fade="9"/>
<line stroke="#f2df6d" width="1.3" cap="butt" fixed="true" fade="9"/>
</rule>
<rule e="way" k="*" v="trunk_link|motorway_link" zoom-min="8">
<line stroke="#fed6a3" width="1.8" cap="butt" fixed="true" fade="8"/>
<line stroke="#fed6a3" width="1.4" cap="butt" fixed="true" fade="8"/>
</rule>
<rule e="way" k="*" v="primary" zoom-min="5">
<line stroke="#f2df6d" width="1.8" cap="butt" fixed="true" fade="5"/>
<line stroke="#f2df6d" width="1.4" cap="butt" fixed="true" fade="5"/>
</rule>
<rule e="way" k="*" v="trunk" zoom-min="5">
<line stroke="#fed6a3" width="2.0" cap="butt" fixed="true" fade="5"/>
<line stroke="#fed6a3" width="1.4" cap="butt" fixed="true" fade="5"/>
</rule>
<rule e="way" k="*" v="motorway">
<line stroke="#eec693" width="2.2" cap="butt" fixed="true" fade="5"/>
<line stroke="#eec693" width="1.5" cap="butt" fixed="true" fade="5"/>
</rule>
</rule>
</rule>
@@ -790,7 +790,7 @@
src="jar:/org/mapsforge/android/maps/rendertheme/osmarender/symbols/cable_car.png"
/> </rule> <rule e="way" k="aerialway" v="chair_lift"> <lineSymbol src="jar:/org/mapsforge/android/maps/rendertheme/osmarender/symbols/chair_lift_2.png"
/> </rule> <rule e="way" k="aerialway" v="gondola"> <lineSymbol src="jar:/org/mapsforge/android/maps/rendertheme/osmarender/symbols/gondola.png"
/> </rule> <rule e="way" k="*" v="*" zoom-min="14"> <pathText k="name" font-style="bold"
/> </rule> <rule e="way" k="*" v="*" zoom-min="14"> <text k="name" font-style="bold"
font-size="10" fill="#606060" stroke="#ffffff" width="2.0" /> </rule>
</rule> -->
@@ -831,7 +831,7 @@
</rule>
<rule e="way" k="railway" v="rail|turntable" >
<line stroke="#887766" width="0.8" cap="butt" fixed="true" fade="12"/>
<line stroke="#ccaa9988" width="1.0" cap="butt" fixed="true" fade="12"/>
</rule>
<!-- <rule e="way" k="railway" v="rail" zoom-max="14" zoom-min="13">
<line stroke="#8888aa" width="0.6" cap="butt"
@@ -969,6 +969,165 @@
stroke="#ffffff" stroke-width="2.0" /> -->
</rule>
</rule>
<!-- aeroway -->
<rule e="node" k="aeroway" v="*">
<rule e="node" k="aeroway" v="helipad" zoom-min="17">
<symbol src="jar:symbols/helipad.png" />
</rule>
<rule e="node" k="aeroway" v="aerodrome|airport" zoom-max="13">
<symbol src="jar:symbols/airport.png" />
</rule>
</rule>
<!-- amenity -->
<rule e="node" k="amenity" v="*">
<rule e="node" k="amenity" v="atm" zoom-min="17">
<symbol src="jar:symbols/atm.png" />
</rule>
<rule e="node" k="amenity" v="bank" zoom-min="17">
<symbol src="jar:symbols/bank.png" />
</rule>
<rule e="node" k="amenity" v="bench" zoom-min="17">
<symbol src="jar:symbols/bench.png" />
</rule>
<rule e="node" k="amenity" v="bicycle_rental" zoom-min="17">
<symbol src="jar:symbols/bicycle_rental.png" />
</rule>
<rule e="node" k="amenity" v="bus_station" zoom-min="17">
<symbol src="jar:symbols/bus_sta.png" />
</rule>
<rule e="node" k="amenity" v="cafe" zoom-min="17">
<symbol src="jar:symbols/cafe.png" />
</rule>
<rule e="node" k="amenity" v="cinema" zoom-min="17">
<symbol src="jar:symbols/cinema.png" />
</rule>
<rule e="node" k="amenity" v="drinking_water" zoom-min="17">
<symbol src="jar:symbols/drinking_water.png" />
</rule>
<rule e="node" k="amenity" v="fast_food" zoom-min="17">
<symbol src="jar:symbols/fastfood.png" />
</rule>
<rule e="node" k="amenity" v="fire_station" zoom-min="17">
<symbol src="jar:symbols/firebrigade.png" />
</rule>
<rule e="node" k="amenity" v="fountain" zoom-min="17">
<symbol src="jar:symbols/fountain.png" />
</rule>
<rule e="node" k="amenity" v="fuel" zoom-min="17">
<symbol src="jar:symbols/petrolStation.png" />
</rule>
<rule e="node" k="amenity" v="hospital" zoom-min="15">
<symbol src="jar:symbols/hospital.png" />
</rule>
<!-- <rule e="node" k="amenity" v="kindergarten" zoom-min="17">
<symbol src="jar:symbols/kindergarten.png" />
</rule>-->
<rule e="node" k="amenity" v="library" zoom-min="17">
<symbol src="jar:symbols/library.png" />
</rule>
<rule e="node" k="amenity" v="parking" zoom-min="17">
<symbol src="jar:symbols/parking.png" />
</rule>
<rule e="node" k="amenity" v="pharmacy" zoom-min="17">
<symbol src="jar:symbols/pharmacy.png" />
</rule>
<rule e="node" k="amenity" v="place_of_worship" zoom-min="17">
<rule e="node" k="denomination|religion" v="jewish">
<symbol src="jar:symbols/synagogue.png" />
</rule>
<rule e="node" k="denomination|religion" v="muslim|moslem">
<symbol src="jar:symbols/mosque.png" />
</rule>
<rule e="node" k="denomination|religion" v="christian">
<symbol src="jar:symbols/church.png" />
</rule>
</rule>
<rule e="node" k="amenity" v="post_box" zoom-min="17">
<symbol src="jar:symbols/postbox.png" />
</rule>
<rule e="node" k="amenity" v="post_office" zoom-min="17">
<symbol src="jar:symbols/postoffice.png" />
</rule>
<rule e="node" k="amenity" v="pub|bar" zoom-min="17">
<symbol src="jar:symbols/pub.png" />
</rule>
<!-- <rule e="node" k="amenity" v="recycling" zoom-min="17">
<symbol src="jar:symbols/recycling.png" />
</rule> -->
<rule e="node" k="amenity" v="restaurant" zoom-min="17">
<symbol src="jar:symbols/restaurant.png" />
</rule>
<rule e="node" k="amenity" v="school" zoom-min="17">
<symbol src="jar:symbols/school.png" />
</rule>
<rule e="node" k="amenity" v="shelter" zoom-min="17">
<symbol src="jar:symbols/shelter.png" />
</rule>
<!-- <rule e="node" k="amenity" v="telephone" zoom-min="17">
<symbol src="jar:symbols/telephone.png" />
</rule> -->
<rule e="node" k="amenity" v="theatre" zoom-min="17">
<symbol src="jar:symbols/theatre.png" />
</rule>
<rule e="node" k="amenity" v="toilets" zoom-min="17">
<symbol src="jar:symbols/toilets.png" />
</rule>
<rule e="node" k="amenity" v="university|college" zoom-min="17">
<symbol src="jar:symbols/university.png" />
</rule>
<!-- <rule e="node" k="*" v="*" zoom-min="17">
<caption k="name" font-style="bold" font-size="10" fill="#4040ff" stroke="#ffffff" stroke-width="2.0" />
</rule>-->
</rule>
<!-- shop -->
<rule e="node" k="shop" v="*">
<rule e="node" k="shop" v="bakery" zoom-min="17">
<symbol src="jar:symbols/bakery.png" />
</rule>
<rule e="node" k="shop" v="florist" zoom-min="17">
<symbol src="jar:symbols/florist.png" />
</rule>
<rule e="node" k="shop" v="supermarket|organic" zoom-min="17">
<symbol src="jar:symbols/supermarket.png" />
</rule>
<rule e="node" k="*" v="*" zoom-min="17">
<caption k="name" font-style="bold" font-size="10" fill="#4040ff" stroke="#ffffff" stroke-width="2.0" />
</rule>
</rule>
<!-- tourism -->
<rule e="node" k="tourism" v="*">
<rule e="node" k="tourism" v="alpine_hut" zoom-min="16">
<symbol src="jar:symbols/alpine_hut.png" />
</rule>
<rule e="node" k="tourism" v="camp_site" zoom-min="17">
<symbol src="jar:symbols/campSite.png" />
</rule>
<rule e="node" k="tourism" v="hostel" zoom-min="17">
<symbol src="jar:symbols/hostel.png" />
</rule>
<rule e="node" k="tourism" v="hotel" zoom-min="17">
<symbol src="jar:symbols/hotel.png" />
</rule>
<rule e="node" k="tourism" v="information" zoom-min="17">
<symbol src="jar:symbols/information.png" />
</rule>
<rule e="node" k="tourism" v="viewpoint" zoom-min="15">
<symbol src="jar:symbols/viewpoint.png" />
</rule>
<rule e="node" k="*" v="*" zoom-min="17">
<caption k="name" font-style="bold" font-size="10" fill="#4040ff" stroke="#ffffff" stroke-width="2.0" />
</rule>
</rule>
</rule>
</rendertheme>

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 742 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 717 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 997 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 708 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 733 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 896 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 419 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 705 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 385 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 806 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 616 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 703 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 565 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 609 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

View File

@@ -4,8 +4,8 @@
xsi:schemaLocation="http://mapsforge.org/renderTheme ../renderTheme.xsd"
version="1" map-background="#050508">
<style-pathtext name="road" k="name" font-style="bold" font-size="18" stroke="#606050" fill="#eeffee" stroke-width="2.5" />
<style-pathtext name="major-road" k="name" font-style="bold" font-size="19" fill="#e2cf5d" stroke="#101010" stroke-width="2.5" />
<style-text name="road" k="name" font-style="bold" font-size="18" stroke="#606050" fill="#eeffee" stroke-width="2.5" />
<style-text name="major-road" k="name" font-style="bold" font-size="19" fill="#e2cf5d" stroke="#101010" stroke-width="2.5" />
<style-area name="residential" fill="#ff0000" fade="10"/>
@@ -807,7 +807,7 @@
src="jar:/org/mapsforge/android/maps/rendertheme/osmarender/symbols/cable_car.png"
/> </rule> <rule e="way" k="aerialway" v="chair_lift"> <lineSymbol src="jar:/org/mapsforge/android/maps/rendertheme/osmarender/symbols/chair_lift_2.png"
/> </rule> <rule e="way" k="aerialway" v="gondola"> <lineSymbol src="jar:/org/mapsforge/android/maps/rendertheme/osmarender/symbols/gondola.png"
/> </rule> <rule e="way" k="*" v="*" zoom-min="14"> <pathText k="name" font-style="bold"
/> </rule> <rule e="way" k="*" v="*" zoom-min="14"> <text k="name" font-style="bold"
font-size="10" fill="#606060" stroke="#ffffff" width="2.0" /> </rule>
</rule> -->

View File

@@ -162,7 +162,7 @@
default="false" />
</xs:complexType>
<xs:complexType name="pathText">
<xs:complexType name="text">
<xs:attribute name="style" type="xs:string" use="optional" default="0"/>
<xs:attribute name="k" type="tns:textKey" use="required" />
<xs:attribute name="dy" type="xs:float" use="optional"
@@ -179,6 +179,8 @@
default="#000000" />
<xs:attribute name="stroke-width" type="tns:nonNegativeFloat"
use="optional" default="0" />
<xs:attribute name="caption" type="xs:boolean" use="optional"
default="false" />
</xs:complexType>
<xs:complexType name="symbol">
@@ -198,8 +200,8 @@
<xs:element name="line" type="tns:line" />
<xs:element name="outline" type="tns:outline" />
<xs:element name="lineSymbol" type="tns:lineSymbol" />
<xs:element name="pathText" type="tns:pathText" />
<xs:element name="stylePathText type="xs:string" />
<xs:element name="text" type="tns:text" />
<xs:element name="styletext type="xs:string" />
<xs:element name="symbol" type="tns:symbol" />
</xs:choice>
<xs:attribute name="e" type="tns:elementList" use="required" />
@@ -218,7 +220,7 @@
<xs:complexType name="rendertheme">
<xs:sequence minOccurs="0" maxOccurds="256">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="style-pathtext" type="tns:pathText" />
<xs:element name="style-text" type="tns:text" />
<xs:element name="style-area" type="tns:area" />
</xs:choice>
</xs:sequence)

View File

@@ -80,6 +80,41 @@ public final class Area extends RenderInstruction {
}
}
public Area(int fill) {
this.level = 0;
this.style = "";
this.fade = -1;
blendColor = null;
blend = -1;
strokeWidth = 0;
color = new float[4];
color[3] = (fill >> 24 & 0xff) / 255.0f;
color[0] = (fill >> 16 & 0xff) / 255.0f * color[3];
color[1] = (fill >> 8 & 0xff) / 255.0f * color[3];
color[2] = (fill >> 0 & 0xff) / 255.0f * color[3];
}
/**
* @param style
* ...
* @param src
* ...
* @param fill
* ...
* @param stroke
* ...
* @param strokeWidth
* ...
* @param fade
* ...
* @param level
* ...
* @param blend
* ...
* @param blendFill
* ...
*/
private Area(String style, String src, int fill, int stroke, float strokeWidth,
int fade, int level, int blend, int blendFill) {
super();

View File

@@ -25,16 +25,18 @@ import android.graphics.BitmapFactory;
import android.graphics.BitmapShader;
import android.graphics.Shader.TileMode;
final class BitmapUtils {
public final class BitmapUtils {
private static final String PREFIX_FILE = "file:";
private static final String PREFIX_JAR = "jar:";
private static InputStream createInputStream(String src) throws FileNotFoundException {
if (src.startsWith(PREFIX_JAR)) {
String name = src.substring(PREFIX_JAR.length());
InputStream inputStream = Thread.currentThread().getClass().getResourceAsStream(name);
String name = "/org/oscim/theme/osmarender/" + src.substring(PREFIX_JAR.length());
InputStream inputStream = BitmapUtils.class
.getResourceAsStream(name);
if (inputStream == null) {
throw new FileNotFoundException("resource not found: " + src);
throw new FileNotFoundException("resource not found: " + src + " " + name);
}
return inputStream;
} else if (src.startsWith(PREFIX_FILE)) {
@@ -51,7 +53,7 @@ final class BitmapUtils {
throw new IllegalArgumentException("invalid bitmap source: " + src);
}
static Bitmap createBitmap(String src) throws IOException {
public static Bitmap createBitmap(String src) throws IOException {
if (src == null || src.length() == 0) {
// no image source defined
return null;

View File

@@ -1,148 +0,0 @@
/*
* Copyright 2010, 2011, 2012 mapsforge.org
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.theme.renderinstruction;
import java.util.Locale;
import org.oscim.core.Tag;
import org.oscim.theme.IRenderCallback;
import org.oscim.theme.RenderThemeHandler;
import org.xml.sax.Attributes;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Paint.FontMetrics;
import android.graphics.Paint.Style;
import android.graphics.Typeface;
import android.util.FloatMath;
/**
* Represents a text label on the map.
*/
public final class Caption extends RenderInstruction {
/**
* @param elementName
* the name of the XML element.
* @param attributes
* the attributes of the XML element.
* @return a new Caption with the given rendering attributes.
*/
public static Caption create(String elementName, Attributes attributes) {
String textKey = null;
float dy = 0;
FontFamily fontFamily = FontFamily.DEFAULT;
FontStyle fontStyle = FontStyle.NORMAL;
float fontSize = 0;
int fill = Color.BLACK;
int stroke = Color.BLACK;
float strokeWidth = 0;
for (int i = 0; i < attributes.getLength(); ++i) {
String name = attributes.getLocalName(i);
String value = attributes.getValue(i);
if ("k".equals(name)) {
textKey = TextKey.getInstance(value);
} else if ("dy".equals(name)) {
dy = Float.parseFloat(value);
} else if ("font-family".equals(name)) {
fontFamily = FontFamily.valueOf(value.toUpperCase(Locale.ENGLISH));
} else if ("font-style".equals(name)) {
fontStyle = FontStyle.valueOf(value.toUpperCase(Locale.ENGLISH));
} else if ("font-size".equals(name)) {
fontSize = Float.parseFloat(value);
} else if ("fill".equals(name)) {
fill = Color.parseColor(value);
} else if ("stroke".equals(name)) {
stroke = Color.parseColor(value);
} else if ("stroke-width".equals(name)) {
strokeWidth = Float.parseFloat(value);
} else {
RenderThemeHandler.logUnknownAttribute(elementName, name, value, i);
}
}
validate(elementName, textKey, fontSize, strokeWidth);
Typeface typeface = Typeface.create(fontFamily.toTypeface(), fontStyle.toInt());
return new Caption(textKey, dy, typeface, fontSize, fill, stroke, strokeWidth);
}
private static void validate(String elementName, String textKey, float fontSize,
float strokeWidth) {
if (textKey == null) {
throw new IllegalArgumentException("missing attribute k for element: "
+ elementName);
} else if (fontSize < 0) {
throw new IllegalArgumentException("font-size must not be negative: "
+ fontSize);
} else if (strokeWidth < 0) {
throw new IllegalArgumentException("stroke-width must not be negative: "
+ strokeWidth);
}
}
public final float dy;
public float fontSize;
public final Paint paint;
public final Paint stroke;
public final String textKey;
public final float fontHeight;
public final float fontDescent;
private Caption(String textKey, float dy, Typeface typeface, float fontSize,
int fillColor, int strokeColor, float strokeWidth) {
super();
this.textKey = textKey.intern();
this.dy = dy;
this.fontSize = fontSize;
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setTextAlign(Align.CENTER);
paint.setTypeface(typeface);
paint.setColor(fillColor);
stroke = new Paint(Paint.ANTI_ALIAS_FLAG);
stroke.setStyle(Style.STROKE);
stroke.setTextAlign(Align.CENTER);
stroke.setTypeface(typeface);
stroke.setColor(strokeColor);
stroke.setStrokeWidth(strokeWidth);
paint.setTextSize(fontSize);
stroke.setTextSize(fontSize);
FontMetrics fm = paint.getFontMetrics();
fontHeight = FloatMath.ceil(Math.abs(fm.bottom) + Math.abs(fm.top));
fontDescent = FloatMath.ceil(Math.abs(fm.descent));
}
@Override
public void renderNode(IRenderCallback renderCallback, Tag[] tags) {
renderCallback.renderPointOfInterestCaption(this);
}
@Override
public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
renderCallback.renderAreaCaption(this);
}
@Override
public void scaleTextSize(float scaleFactor) {
paint.setTextSize(fontSize * scaleFactor);
stroke.setTextSize(fontSize * scaleFactor);
}
}

View File

@@ -49,7 +49,7 @@ public final class Line extends RenderInstruction {
String src = null;
int stroke = Color.BLACK;
float strokeWidth = 0;
float[] strokeDasharray = null;
int stipple = 0;
Cap strokeLinecap = Cap.ROUND;
int fade = -1;
boolean fixed = false;
@@ -75,8 +75,8 @@ public final class Line extends RenderInstruction {
stroke = Color.parseColor(value);
} else if ("width".equals(name)) {
strokeWidth = Float.parseFloat(value);
} else if ("stroke-dasharray".equals(name)) {
strokeDasharray = parseFloatArray(value);
} else if ("stipple".equals(name)) {
stipple = Integer.parseInt(value);
} else if ("cap".equals(name)) {
strokeLinecap = Cap.valueOf(value.toUpperCase(Locale.ENGLISH));
} else if ("fade".equals(name)) {
@@ -91,23 +91,43 @@ public final class Line extends RenderInstruction {
}
}
if (stipple != 0)
strokeLinecap = Cap.BUTT;
if (line != null) {
strokeWidth = line.width + strokeWidth;
if (strokeWidth <= 0)
strokeWidth = 1;
return new Line(line, style, src, stroke, strokeWidth, strokeDasharray,
return new Line(line, style, src, stroke, strokeWidth, stipple,
strokeLinecap, level, fixed, fade, blur, isOutline);
}
if (!isOutline)
validate(strokeWidth);
return new Line(style, src, stroke, strokeWidth, strokeDasharray, strokeLinecap,
return new Line(style, src, stroke, strokeWidth, stipple, strokeLinecap,
level, fixed, fade, blur, isOutline);
}
public Line(int stroke, float width, Cap cap) {
this.level = 0;
this.blur = 0;
this.cap = cap;
this.outline = false;
this.style = "";
this.width = width;
this.fixed = true;
this.fade = -1;
this.stipple = 2;
color = new float[4];
color[3] = (stroke >> 24 & 0xff) / 255.0f;
color[0] = (stroke >> 16 & 0xff) / 255.0f * color[3];
color[1] = (stroke >> 8 & 0xff) / 255.0f * color[3];
color[2] = (stroke >> 0 & 0xff) / 255.0f * color[3];
}
private static void validate(float strokeWidth) {
if (strokeWidth < 0) {
throw new IllegalArgumentException("width must not be negative: "
@@ -124,34 +144,16 @@ public final class Line extends RenderInstruction {
return dashIntervals;
}
/**
*
*/
private final int level;
/**
*
*/
// public final Paint paint;
/**
*
*/
public final float width;
/**
*
*/
public final boolean round;
/**
*
*/
// public final boolean round;
public final float color[];
/**
*
*/
public final boolean outline;
/**
*
*/
public final boolean fixed;
public final int fade;
@@ -162,8 +164,34 @@ public final class Line extends RenderInstruction {
public final float blur;
public final int stipple;
/**
* @param style
* ...
* @param src
* ...
* @param stroke
* ...
* @param strokeWidth
* ...
* @param stipple
* ...
* @param strokeLinecap
* ...
* @param level
* ...
* @param fixed
* ...
* @param fade
* ...
* @param blur
* ...
* @param isOutline
* ...
*/
private Line(String style, String src, int stroke, float strokeWidth,
float[] strokeDasharray, Cap strokeLinecap, int level, boolean fixed,
int stipple, Cap strokeLinecap, int level, boolean fixed,
int fade, float blur, boolean isOutline) {
super();
@@ -183,7 +211,7 @@ public final class Line extends RenderInstruction {
// }
// paint.setStrokeCap(strokeLinecap);
round = (strokeLinecap == Cap.ROUND);
// round = (strokeLinecap == Cap.ROUND);
this.cap = strokeLinecap;
@@ -199,16 +227,43 @@ public final class Line extends RenderInstruction {
this.fixed = fixed;
this.blur = blur;
this.fade = fade;
this.stipple = stipple;
}
/**
* @param line
* ...
* @param style
* ...
* @param src
* ...
* @param stroke
* ...
* @param strokeWidth
* ...
* @param stipple
* ...
* @param strokeLinecap
* ...
* @param level
* ...
* @param fixed
* ...
* @param fade
* ...
* @param blur
* ...
* @param isOutline
* ...
*/
private Line(Line line, String style, String src, int stroke, float strokeWidth,
float[] strokeDasharray, Cap strokeLinecap, int level, boolean fixed,
int stipple, Cap strokeLinecap, int level, boolean fixed,
int fade, float blur, boolean isOutline) {
super();
this.style = style;
round = (strokeLinecap == Cap.ROUND);
// round = (strokeLinecap == Cap.ROUND);
color = line.color;
@@ -219,11 +274,13 @@ public final class Line extends RenderInstruction {
this.fade = fade;
this.cap = strokeLinecap;
this.blur = blur;
this.stipple = stipple;
}
@Override
public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
// renderCallback.renderWay(mPaint, mLevel, mColor, mStrokeWidth, mRound, mOutline);
// renderCallback.renderWay(mPaint, mLevel, mColor, mStrokeWidth,
// mRound, mOutline);
renderCallback.renderWay(this, level);
}

View File

@@ -62,26 +62,26 @@ public final class Symbol extends RenderInstruction {
}
}
private final Bitmap mBitmap;
public final Bitmap bitmap;
private Symbol(String src) throws IOException {
public Symbol(String src) throws IOException {
super();
mBitmap = BitmapUtils.createBitmap(src);
bitmap = BitmapUtils.createBitmap(src);
}
@Override
public void destroy() {
mBitmap.recycle();
bitmap.recycle();
}
@Override
public void renderNode(IRenderCallback renderCallback, Tag[] tags) {
renderCallback.renderPointOfInterestSymbol(mBitmap);
renderCallback.renderPointOfInterestSymbol(bitmap);
}
@Override
public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
renderCallback.renderAreaSymbol(mBitmap);
renderCallback.renderAreaSymbol(bitmap);
}
}

View File

@@ -32,15 +32,17 @@ import android.util.FloatMath;
/**
* Represents a text along a polyline on the map.
*/
public final class PathText extends RenderInstruction {
public final class Text extends RenderInstruction {
/**
* @param elementName
* the name of the XML element.
* @param attributes
* the attributes of the XML element.
* @return a new PathText with the given rendering attributes.
* @param caption
* ...
* @return a new Text with the given rendering attributes.
*/
public static PathText create(String elementName, Attributes attributes) {
public static Text create(String elementName, Attributes attributes, boolean caption) {
String textKey = null;
FontFamily fontFamily = FontFamily.DEFAULT;
FontStyle fontStyle = FontStyle.NORMAL;
@@ -49,7 +51,8 @@ public final class PathText extends RenderInstruction {
int stroke = Color.BLACK;
float strokeWidth = 0;
String style = null;
// boolean caption = false;
float dy = 0;
for (int i = 0; i < attributes.getLength(); ++i) {
String name = attributes.getLocalName(i);
String value = attributes.getValue(i);
@@ -69,6 +72,10 @@ public final class PathText extends RenderInstruction {
stroke = Color.parseColor(value);
} else if ("stroke-width".equals(name)) {
strokeWidth = Float.parseFloat(value);
} else if ("caption".equals(name)) {
caption = Boolean.parseBoolean(value);
} else if ("dy".equals(name)) {
dy = Float.parseFloat(value);
} else {
RenderThemeHandler.logUnknownAttribute(elementName, name, value, i);
}
@@ -76,7 +83,7 @@ public final class PathText extends RenderInstruction {
validate(elementName, textKey, fontSize, strokeWidth);
Typeface typeface = Typeface.create(fontFamily.toTypeface(), fontStyle.toInt());
return new PathText(style, textKey, typeface, fontSize, fill, stroke, strokeWidth);
return new Text(style, textKey, typeface, fontSize, fill, stroke, strokeWidth, dy, caption);
}
private static void validate(String elementName, String textKey, float fontSize,
@@ -100,14 +107,17 @@ public final class PathText extends RenderInstruction {
public final float fontHeight;
public final float fontDescent;
public String style;
public final boolean caption;
public final float dy;
private PathText(String style, String textKey, Typeface typeface, float fontSize,
int fill, int outline, float strokeWidth) {
private Text(String style, String textKey, Typeface typeface, float fontSize,
int fill, int outline, float strokeWidth, float dy, boolean caption) {
super();
this.style = style;
this.textKey = textKey;
this.caption = caption;
this.dy = dy;
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setTextAlign(Align.CENTER);
@@ -131,9 +141,18 @@ public final class PathText extends RenderInstruction {
fontDescent = FloatMath.ceil(Math.abs(fm.descent));
}
@Override
public void renderNode(IRenderCallback renderCallback, Tag[] tags) {
if (caption)
renderCallback.renderPointOfInterestCaption(this);
}
@Override
public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
renderCallback.renderWayText(this);
if (caption)
renderCallback.renderAreaCaption(this);
else
renderCallback.renderWayText(this);
}
@Override