start to make line stipple themeable
This commit is contained in:
@@ -47,24 +47,40 @@ public final class Line extends RenderInstruction {
|
||||
*/
|
||||
public static Line create(Line line, String elementName, Attributes attributes,
|
||||
int level, boolean isOutline) {
|
||||
String src = null;
|
||||
int stroke = Color.BLACK;
|
||||
float strokeWidth = 0;
|
||||
int stipple = 0;
|
||||
Cap strokeLinecap = Cap.ROUND;
|
||||
|
||||
// Style name
|
||||
String style = null;
|
||||
// Bitmap
|
||||
//String src = null;
|
||||
|
||||
float width = 0;
|
||||
Cap cap = Cap.ROUND;
|
||||
|
||||
// Extras
|
||||
int fade = -1;
|
||||
boolean fixed = false;
|
||||
String style = null;
|
||||
float blur = 0;
|
||||
float min = 0;
|
||||
|
||||
// Stipple
|
||||
int stipple = 0;
|
||||
float stippleWidth = 0;
|
||||
|
||||
float[] color = null;
|
||||
float[] stippleColor = null;
|
||||
|
||||
if (line != null) {
|
||||
color = line.color;
|
||||
fixed = line.fixed;
|
||||
fade = line.fade;
|
||||
strokeLinecap = line.cap;
|
||||
cap = line.cap;
|
||||
blur = line.blur;
|
||||
min = line.min;
|
||||
stipple = line.stipple;
|
||||
stippleColor = line.stippleColor;
|
||||
stippleWidth = line.stippleWidth;
|
||||
}
|
||||
|
||||
for (int i = 0; i < attributes.getLength(); ++i) {
|
||||
String name = attributes.getLocalName(i);
|
||||
String value = attributes.getValue(i);
|
||||
@@ -72,21 +88,27 @@ public final class Line extends RenderInstruction {
|
||||
if ("name".equals(name))
|
||||
style = value;
|
||||
else if ("src".equals(name)) {
|
||||
src = value;
|
||||
//src = value;
|
||||
} else if ("stroke".equals(name)) {
|
||||
stroke = Color.parseColor(value);
|
||||
int stroke = Color.parseColor(value);
|
||||
color = GlUtils.colorToFloatP(stroke);
|
||||
} else if ("width".equals(name)) {
|
||||
strokeWidth = Float.parseFloat(value);
|
||||
width = Float.parseFloat(value);
|
||||
} else if ("cap".equals(name)) {
|
||||
cap = Cap.valueOf(value.toUpperCase(Locale.ENGLISH));
|
||||
} else if ("fixed".equals(name)) {
|
||||
fixed = Boolean.parseBoolean(value);
|
||||
} else if ("stipple".equals(name)) {
|
||||
stipple = Integer.parseInt(value);
|
||||
} else if ("cap".equals(name)) {
|
||||
strokeLinecap = Cap.valueOf(value.toUpperCase(Locale.ENGLISH));
|
||||
} else if ("stipple-stroke".equals(name)) {
|
||||
int stroke = Color.parseColor(value);
|
||||
stippleColor = GlUtils.colorToFloatP(stroke);
|
||||
} else if ("stipple-width".equals(name)) {
|
||||
stippleWidth = Float.parseFloat(value);
|
||||
} else if ("fade".equals(name)) {
|
||||
fade = Integer.parseInt(value);
|
||||
} else if ("min".equals(name)) {
|
||||
min = Float.parseFloat(value);
|
||||
} else if ("fixed".equals(name)) {
|
||||
fixed = Boolean.parseBoolean(value);
|
||||
} else if ("blur".equals(name)) {
|
||||
blur = Float.parseFloat(value);
|
||||
} else if ("from".equals(name)) {
|
||||
@@ -95,38 +117,27 @@ public final class Line extends RenderInstruction {
|
||||
}
|
||||
}
|
||||
|
||||
if (stipple != 0)
|
||||
strokeLinecap = Cap.BUTT;
|
||||
// hint that sth is missing
|
||||
if (color == null)
|
||||
color = GlUtils.colorToFloatP(Color.RED);
|
||||
|
||||
if (stipple != 0 && stippleColor == null)
|
||||
stippleColor = GlUtils.colorToFloatP(Color.GREEN);
|
||||
|
||||
// inherit properties from 'line'
|
||||
if (line != null) {
|
||||
// use stroke width relative to 'line'
|
||||
width = line.width + width;
|
||||
if (width <= 0)
|
||||
width = 1;
|
||||
|
||||
strokeWidth = line.width + strokeWidth;
|
||||
if (strokeWidth <= 0)
|
||||
strokeWidth = 1;
|
||||
|
||||
return new Line(line, style, src, stroke, strokeWidth, stipple,
|
||||
strokeLinecap, level, fixed, fade, blur, isOutline, min);
|
||||
} else if (!isOutline) {
|
||||
validate(width);
|
||||
}
|
||||
|
||||
if (!isOutline)
|
||||
validate(strokeWidth);
|
||||
|
||||
return new Line(style, src, stroke, strokeWidth, stipple, strokeLinecap,
|
||||
level, fixed, fade, blur, isOutline, min);
|
||||
}
|
||||
|
||||
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;
|
||||
this.min = 0;
|
||||
color = GlUtils.colorToFloatP(stroke);
|
||||
return new Line(level, style, color, width, cap, fixed,
|
||||
stipple, stippleColor, stippleWidth,
|
||||
fade, blur, isOutline, min);
|
||||
}
|
||||
|
||||
private static void validate(float strokeWidth) {
|
||||
@@ -147,59 +158,28 @@ public final class Line extends RenderInstruction {
|
||||
|
||||
private final int level;
|
||||
|
||||
public final float width;
|
||||
|
||||
// public final boolean round;
|
||||
|
||||
public final float color[];
|
||||
|
||||
public final boolean outline;
|
||||
|
||||
public final boolean fixed;
|
||||
|
||||
public final int fade;
|
||||
|
||||
public final String style;
|
||||
|
||||
public final float width;
|
||||
public final float[] color;
|
||||
public final Cap cap;
|
||||
|
||||
public final boolean outline;
|
||||
public final boolean fixed;
|
||||
public final int fade;
|
||||
public final float blur;
|
||||
|
||||
public final int stipple;
|
||||
|
||||
public final float min;
|
||||
|
||||
/**
|
||||
* @param style
|
||||
* ...
|
||||
* @param src
|
||||
* ...
|
||||
* @param stroke
|
||||
* ...
|
||||
* @param strokeWidth
|
||||
* ...
|
||||
* @param stipple
|
||||
* ...
|
||||
* @param strokeLinecap
|
||||
* ...
|
||||
* @param level
|
||||
* ...
|
||||
* @param fixed
|
||||
* ...
|
||||
* @param fade
|
||||
* ...
|
||||
* @param blur
|
||||
* ...
|
||||
* @param isOutline
|
||||
* ...
|
||||
* @param min ...
|
||||
*/
|
||||
private Line(String style, String src, int stroke, float strokeWidth,
|
||||
int stipple, Cap strokeLinecap, int level, boolean fixed,
|
||||
int fade, float blur, boolean isOutline, float min) {
|
||||
super();
|
||||
public final int stipple;
|
||||
public final float[] stippleColor;
|
||||
public final float stippleWidth;
|
||||
|
||||
private Line(int level, String style, float[] stroke, float width,
|
||||
Cap cap, boolean fixed,
|
||||
int stipple, float[] stippleColor, float stippleWidth,
|
||||
int fade, float blur, boolean isOutline, float min) {
|
||||
|
||||
this.level = level;
|
||||
this.style = style;
|
||||
this.outline = isOutline;
|
||||
|
||||
// paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
//
|
||||
@@ -213,51 +193,55 @@ public final class Line extends RenderInstruction {
|
||||
// if (strokeDasharray != null) {
|
||||
// paint.setPathEffect(new DashPathEffect(strokeDasharray, 0));
|
||||
// }
|
||||
// paint.setStrokeCap(strokeLinecap);
|
||||
|
||||
// round = (strokeLinecap == Cap.ROUND);
|
||||
|
||||
this.cap = strokeLinecap;
|
||||
|
||||
color = GlUtils.colorToFloatP(stroke);
|
||||
|
||||
this.width = strokeWidth;
|
||||
this.level = level;
|
||||
this.outline = isOutline;
|
||||
this.cap = cap;
|
||||
this.color = stroke;
|
||||
this.width = width;
|
||||
this.fixed = fixed;
|
||||
|
||||
this.stipple = stipple;
|
||||
this.stippleColor = stippleColor;
|
||||
this.stippleWidth = stippleWidth;
|
||||
|
||||
this.blur = blur;
|
||||
this.fade = fade;
|
||||
this.stipple = stipple;
|
||||
this.min = min;
|
||||
}
|
||||
|
||||
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 = 0;
|
||||
this.stippleColor = null;
|
||||
this.stippleWidth = 0;
|
||||
this.min = 0;
|
||||
this.color = GlUtils.colorToFloatP(stroke);
|
||||
}
|
||||
|
||||
private Line(Line line, String style, String src, int stroke, float strokeWidth,
|
||||
int stipple, Cap strokeLinecap, int level, boolean fixed,
|
||||
int fade, float blur, boolean isOutline, float min) {
|
||||
super();
|
||||
|
||||
this.style = style;
|
||||
|
||||
// round = (strokeLinecap == Cap.ROUND);
|
||||
|
||||
color = line.color;
|
||||
|
||||
this.width = strokeWidth;
|
||||
this.level = level;
|
||||
this.outline = isOutline;
|
||||
this.fixed = fixed;
|
||||
this.fade = fade;
|
||||
this.cap = strokeLinecap;
|
||||
this.blur = blur;
|
||||
public Line(int stroke, float width, int stipple) {
|
||||
this.level = 0;
|
||||
this.blur = 0;
|
||||
this.cap = Cap.BUTT;
|
||||
this.outline = false;
|
||||
this.style = "";
|
||||
this.width = width;
|
||||
this.fixed = true;
|
||||
this.fade = -1;
|
||||
this.stipple = stipple;
|
||||
this.min = min;
|
||||
this.stippleColor = null;
|
||||
this.stippleWidth = 0;
|
||||
this.min = 0;
|
||||
color = GlUtils.colorToFloatP(stroke);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
|
||||
// renderCallback.renderWay(mPaint, mLevel, mColor, mStrokeWidth,
|
||||
// mRound, mOutline);
|
||||
renderCallback.renderWay(this, level);
|
||||
}
|
||||
|
||||
@@ -266,7 +250,5 @@ public final class Line extends RenderInstruction {
|
||||
// paint.setStrokeWidth(strokeWidth * scaleFactor);
|
||||
// }
|
||||
|
||||
public int getLevel() {
|
||||
return this.level;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user