public ShapeAttributes() { this.drawInterior = true; this.drawOutline = true; this.drawVerticals = false; this.depthTest = true; this.enableLighting = false; this.interiorColor = new Color(1, 1, 1, 1); // white this.outlineColor = new Color(1, 0, 0, 1); // red this.outlineWidth = 1.0f; this.interiorImageSource = null; this.outlineImageSource = null; }
public TextCacheKey set(String text, TextAttributes attributes) { this.text = text; if (attributes != null) { this.textColor = (this.textColor != null) ? this.textColor.set(attributes.getTextColor()) : new Color(attributes.getTextColor()); this.textSize = attributes.getTextSize(); this.typeface = attributes.getTypeface(); this.enableOutline = attributes.isEnableOutline(); this.outlineColor = (this.outlineColor != null) ? this.outlineColor.set(attributes.getOutlineColor()) : new Color(attributes.getOutlineColor()); this.outlineWidth = attributes.getOutlineWidth(); } else { this.textColor = null; this.textSize = 0; this.typeface = null; this.enableOutline = false; this.outlineColor = null; this.outlineWidth = 0; } return this; }
@Override public int hashCode() { int result = (this.text != null ? this.text.hashCode() : 0); result = 31 * result + (this.textColor != null ? this.textColor.hashCode() : 0); result = 31 * result + (this.textSize != +0.0f ? Float.floatToIntBits(this.textSize) : 0); result = 31 * result + (this.typeface != null ? this.typeface.hashCode() : 0); result = 31 * result + (this.enableOutline ? 1 : 0); result = 31 * result + (this.outlineColor != null ? this.outlineColor.hashCode() : 0); result = 31 * result + (this.outlineWidth != +0.0f ? Float.floatToIntBits(this.outlineWidth) : 0); return result; } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || this.getClass() != o.getClass()) { return false; } TextCacheKey that = (TextCacheKey) o; return ((this.text == null) ? (that.text == null) : this.text.equals(that.text)) && ((this.textColor == null) ? (that.textColor == null) : this.textColor.equals(that.textColor)) && this.textSize == that.textSize && ((this.typeface == null) ? (that.typeface == null) : this.typeface.equals(that.typeface)) && this.enableOutline == that.enableOutline && ((this.outlineColor == null) ? (that.outlineColor == null) : this.outlineColor.equals(that.outlineColor)) && this.outlineWidth == that.outlineWidth; }
public void loadColor(Color visibleColor, Color occludedColor) { visibleColor.premultiplyToArray(this.array, 0); occludedColor.premultiplyToArray(this.array, 4); GLES20.glUniform4fv(this.colorId, 2, this.array, 0); } }
this.paint.setColor(this.outlineColor != null ? this.outlineColor.toColorInt() : Color.BLACK); this.canvas.drawText(text, 0, text.length(), x, y, this.paint); this.paint.setColor(this.textColor != null ? this.textColor.toColorInt() : Color.WHITE); this.canvas.drawText(text, 0, text.length(), x, y, this.paint);
commonAttrs.getInteriorColor().set(1.0f, 1.0f, 0.0f, 0.5f); commonAttrs.getOutlineColor().set(0.0f, 0.0f, 0.0f, 1.0f); commonAttrs.setOutlineWidth(3); highlightAttrs.getInteriorColor().set(1.0f, 1.0f, 1.0f, 0.5f); highlightAttrs.getOutlineColor().set(1.0f, 1.0f, 1.0f, 1.0f); highlightAttrs.setOutlineWidth(5); polygon.setDisplayName(fields[1]); polygon.setAttributes(new ShapeAttributes(commonAttrs)); polygon.getAttributes().setInteriorColor(new Color(random.nextFloat(), random.nextFloat(), random.nextFloat(), 0.3f)); polygon.setHighlightAttributes(highlightAttrs);
@Override public int hashCode() { int result = this.textColor.hashCode(); result = 31 * result + this.textOffset.hashCode(); result = 31 * result + (this.textSize != +0.0f ? Float.floatToIntBits(this.textSize) : 0); result = 31 * result + (this.typeface != null ? this.typeface.hashCode() : 0); result = 31 * result + (this.enableOutline ? 1 : 0); result = 31 * result + this.outlineColor.hashCode(); result = 31 * result + (this.enableDepthTest ? 1 : 0); result = 31 * result + (this.outlineWidth != +0.0f ? Float.floatToIntBits(this.outlineWidth) : 0); return result; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || this.getClass() != o.getClass()) { return false; } TextAttributes that = (TextAttributes) o; return this.textColor.equals(that.textColor) && this.textOffset.equals(that.textOffset) && this.textSize == that.textSize && ((this.typeface == null) ? (that.typeface == null) : this.typeface.equals(that.typeface)) && this.enableOutline == that.enableOutline && this.outlineColor.equals(that.outlineColor) && this.enableDepthTest == that.enableDepthTest && this.outlineWidth == that.outlineWidth; }
public void color(Color color) { this.color.set(color); }
@Test public void testModifiedAttrs() { // Common Text Attributes TextAttributes attrs = new TextAttributes(); attrs.setEnableOutline(true); attrs.setOutlineColor(new Color(0.5f, 0.2f, 0.3f, 1)); attrs.setOutlineWidth(15); attrs.setTextColor(new Color(1, 1, 0.2f, 1)); attrs.setTextSize(90); // Common Text String text = "Testing"; // Cache Key 1 RenderContext.TextCacheKey textCacheKeyOne = new RenderContext.TextCacheKey().set(text, attrs); // Modify color property Color outlineColor = attrs.getOutlineColor().set(1, 1, 0.3f, 1); attrs.setOutlineColor(outlineColor); // Cache Key 2 RenderContext.TextCacheKey textCacheKeyTwo = new RenderContext.TextCacheKey().set(text, attrs); assertFalse("TextCacheKey modified attributes equals", textCacheKeyOne.equals(textCacheKeyTwo)); assertFalse("TextCacheKey modified attributes hashcode", textCacheKeyOne.hashCode() == textCacheKeyTwo.hashCode()); } }
@Override public int hashCode() { int result; long temp; result = (this.drawInterior ? 1 : 0); result = 31 * result + (this.drawOutline ? 1 : 0); result = 31 * result + (this.depthTest ? 1 : 0); result = 31 * result + (this.drawVerticals ? 1 : 0); result = 31 * result + (this.enableLighting ? 1 : 0); result = 31 * result + this.interiorColor.hashCode(); result = 31 * result + this.outlineColor.hashCode(); temp = Double.doubleToLongBits(this.outlineWidth); result = 31 * result + (int) (temp ^ (temp >>> 32)); result = 31 * result + (this.interiorImageSource != null ? this.interiorImageSource.hashCode() : 0); result = 31 * result + (this.outlineImageSource != null ? this.outlineImageSource.hashCode() : 0); return result; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || this.getClass() != o.getClass()) { return false; } ShapeAttributes that = (ShapeAttributes) o; return this.drawInterior == that.drawInterior && this.drawOutline == that.drawOutline && this.drawVerticals == that.drawVerticals && this.depthTest == that.depthTest && this.enableLighting == that.enableLighting && this.interiorColor.equals(that.interiorColor) && this.outlineColor.equals(that.outlineColor) && this.outlineWidth == that.outlineWidth && ((this.interiorImageSource == null) ? (that.interiorImageSource == null) : this.interiorImageSource.equals(that.interiorImageSource)) && ((this.outlineImageSource == null) ? (that.outlineImageSource == null) : this.outlineImageSource.equals(that.outlineImageSource)); }
public ShapeAttributes(ShapeAttributes attributes) { if (attributes == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "ShapeAttributes", "constructor", "missingAttributes")); } this.drawInterior = attributes.drawInterior; this.drawOutline = attributes.drawOutline; this.drawVerticals = attributes.drawVerticals; this.depthTest = attributes.depthTest; this.enableLighting = attributes.enableLighting; this.interiorColor = new Color(attributes.interiorColor); this.outlineColor = new Color(attributes.outlineColor); this.outlineWidth = attributes.outlineWidth; this.interiorImageSource = attributes.interiorImageSource; this.outlineImageSource = attributes.outlineImageSource; }
@Override public int hashCode() { int result; long temp; result = (this.imageSource != null) ? this.imageSource.hashCode() : 0; result = 31 * result + this.imageColor.hashCode(); result = 31 * result + this.imageOffset.hashCode(); temp = Double.doubleToLongBits(this.imageScale); result = 31 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.minimumImageScale); result = 31 * result + (int) (temp ^ (temp >>> 32)); result = 31 * result + (this.drawLeader ? 1 : 0); result = 31 * result + (this.depthTest ? 1 : 0); result = 31 * result + (this.labelAttributes != null ? this.labelAttributes.hashCode() : 0); result = 31 * result + (this.leaderAttributes != null ? this.leaderAttributes.hashCode() : 0); return result; }