start Line and Area builders
This commit is contained in:
parent
14e5e28998
commit
ff7c74bc70
@ -26,27 +26,74 @@ import org.oscim.theme.IRenderTheme.Callback;
|
||||
*/
|
||||
public final class Area extends RenderStyle {
|
||||
|
||||
public Area(int fill) {
|
||||
this(0, fill);
|
||||
public static class AreaBuilder {
|
||||
public int level;
|
||||
public String style;
|
||||
public Line outline;
|
||||
public int color;
|
||||
public int fade;
|
||||
public int blendColor;
|
||||
public int blend;
|
||||
public TextureItem texture;
|
||||
|
||||
public AreaBuilder set(Area area) {
|
||||
this.level = area.level;
|
||||
this.style = area.style;
|
||||
this.fade = area.fade;
|
||||
this.blendColor = area.blendColor;
|
||||
this.blend = area.blend;
|
||||
this.color = area.color;
|
||||
this.texture = area.texture;
|
||||
this.outline = area.outline;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AreaBuilder setColor(int color) {
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AreaBuilder setColor(String color) {
|
||||
this.color = Color.parseColor(color);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AreaBuilder setBlendColor(int color) {
|
||||
this.blendColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AreaBuilder setBlendColor(String color) {
|
||||
this.blendColor = Color.parseColor(color);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Area build() {
|
||||
return new Area(this);
|
||||
}
|
||||
}
|
||||
|
||||
public Area(int level, int fill) {
|
||||
public Area(int color) {
|
||||
this(0, color);
|
||||
}
|
||||
|
||||
public Area(int level, int color) {
|
||||
this.level = level;
|
||||
this.style = "";
|
||||
this.fade = -1;
|
||||
this.blendColor = 0;
|
||||
this.blend = -1;
|
||||
this.color = fill;
|
||||
this.color = color;
|
||||
this.texture = null;
|
||||
this.outline = null;
|
||||
}
|
||||
|
||||
public Area(String style, int fill, int stroke, float strokeWidth,
|
||||
int fade, int level, int blend, int blendFill, TextureItem texture) {
|
||||
public Area(String style, int color, int stroke, float strokeWidth,
|
||||
int fade, int level, int blend, int blendColor, TextureItem texture) {
|
||||
|
||||
this.style = style;
|
||||
this.color = fill;
|
||||
this.blendColor = blendFill;
|
||||
this.color = color;
|
||||
this.blendColor = blendColor;
|
||||
this.blend = blend;
|
||||
this.fade = fade;
|
||||
this.level = level;
|
||||
@ -60,6 +107,17 @@ public final class Area extends RenderStyle {
|
||||
this.outline = new Line(level + 1, stroke, strokeWidth);
|
||||
}
|
||||
|
||||
public Area(AreaBuilder areaBuilder) {
|
||||
this.level = areaBuilder.level;
|
||||
this.style = areaBuilder.style;
|
||||
this.fade = areaBuilder.fade;
|
||||
this.blendColor = areaBuilder.blendColor;
|
||||
this.blend = areaBuilder.blend;
|
||||
this.color = areaBuilder.color;
|
||||
this.texture = areaBuilder.texture;
|
||||
this.outline = areaBuilder.outline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWay(Callback renderCallback) {
|
||||
renderCallback.renderArea(this, level);
|
||||
@ -69,11 +127,18 @@ public final class Area extends RenderStyle {
|
||||
}
|
||||
|
||||
private final int level;
|
||||
public String style;
|
||||
public final String style;
|
||||
public final Line outline;
|
||||
public final int color;
|
||||
public final int fade;
|
||||
public final int blendColor;
|
||||
public final int blend;
|
||||
public final TextureItem texture;
|
||||
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (outline != null)
|
||||
outline.update();
|
||||
}
|
||||
}
|
||||
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.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.styles;
|
||||
|
||||
import org.oscim.theme.IRenderTheme.Callback;
|
||||
|
||||
public class AreaLevel extends RenderStyle {
|
||||
private final Area area;
|
||||
private final int level;
|
||||
|
||||
public AreaLevel(Area area, int level) {
|
||||
this.area = area;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWay(Callback renderCallback) {
|
||||
renderCallback.renderArea(this.area, level);
|
||||
if (this.area.outline != null)
|
||||
renderCallback.renderWay(this.area.outline, level + 1);
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.oscim.theme.styles;
|
||||
|
||||
import org.oscim.backend.canvas.Color;
|
||||
import org.oscim.backend.canvas.Paint.Cap;
|
||||
import org.oscim.theme.IRenderTheme.Callback;
|
||||
|
||||
@ -25,7 +26,59 @@ import org.oscim.theme.IRenderTheme.Callback;
|
||||
*/
|
||||
public final class Line extends RenderStyle {
|
||||
|
||||
private final int level;
|
||||
public final static class LineBuilder {
|
||||
public int level;
|
||||
|
||||
public String style;
|
||||
public float width;
|
||||
public int color;
|
||||
public Cap cap;
|
||||
public boolean outline;
|
||||
public boolean fixed;
|
||||
public int fade;
|
||||
public float blur;
|
||||
|
||||
public int stipple;
|
||||
public int stippleColor;
|
||||
public float stippleWidth;
|
||||
|
||||
public LineBuilder set(Line line) {
|
||||
this.level = line.level;
|
||||
this.style = line.style;
|
||||
this.width = line.width;
|
||||
this.color = line.color;
|
||||
this.cap = line.cap;
|
||||
this.outline = line.outline;
|
||||
this.fixed = line.fixed;
|
||||
this.fade = line.fade;
|
||||
this.blur = line.blur;
|
||||
this.stipple = line.stipple;
|
||||
this.stippleColor = line.stippleColor;
|
||||
this.stippleWidth = line.stippleWidth;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LineBuilder setColor(int color) {
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LineBuilder setStippleColor(int color) {
|
||||
this.stippleColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LineBuilder setColor(String color) {
|
||||
this.color = Color.parseColor(color);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Line build() {
|
||||
return new Line(this);
|
||||
}
|
||||
}
|
||||
|
||||
final int level;
|
||||
|
||||
public final String style;
|
||||
public final float width;
|
||||
@ -40,6 +93,21 @@ public final class Line extends RenderStyle {
|
||||
public final int stippleColor;
|
||||
public final float stippleWidth;
|
||||
|
||||
private Line(LineBuilder builer) {
|
||||
this.level = builer.level;
|
||||
this.style = builer.style;
|
||||
this.width = builer.width;
|
||||
this.color = builer.color;
|
||||
this.cap = builer.cap;
|
||||
this.outline = builer.outline;
|
||||
this.fixed = builer.fixed;
|
||||
this.fade = builer.fade;
|
||||
this.blur = builer.blur;
|
||||
this.stipple = builer.stipple;
|
||||
this.stippleColor = builer.stippleColor;
|
||||
this.stippleWidth = builer.stippleWidth;
|
||||
}
|
||||
|
||||
public Line(int level, String style, int color, float width,
|
||||
Cap cap, boolean fixed,
|
||||
int stipple, int stippleColor, float stippleWidth,
|
||||
|
Loading…
x
Reference in New Issue
Block a user