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 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; }
public TextAttributes(TextAttributes attributes) { if (attributes == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "TextAttributes", "constructor", "missingAttributes")); } this.textColor = new Color(attributes.textColor); this.textOffset = new Offset(attributes.textOffset); this.textSize = attributes.textSize; this.typeface = attributes.typeface; this.outlineColor = new Color(attributes.outlineColor); this.enableOutline = attributes.enableOutline; this.enableDepthTest = attributes.enableDepthTest; this.outlineWidth = attributes.outlineWidth; }
/** * Constructs a placemark attributes bundle. The defaults indicate a placemark displayed as a white 1x1 pixel square * centered on the placemark's geographic position. */ public PlacemarkAttributes() { this.imageSource = null; this.imageColor = new Color(1, 1, 1, 1); // white this.imageOffset = Offset.center(); this.imageScale = 1; this.minimumImageScale = 0; this.drawLeader = false; this.depthTest = true; this.labelAttributes = new TextAttributes(); this.leaderAttributes = new ShapeAttributes(); }
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; }
@Test public void testSet() throws Exception { ShapeAttributes attributes = new ShapeAttributes(); // create another attribute bundle with differing values ShapeAttributes other = new ShapeAttributes(); other.drawInterior = false; other.drawOutline = false; other.drawVerticals = true; other.depthTest = false; other.enableLighting = true; other.interiorColor = new Color(0, 0, 0, 0); other.outlineColor = new Color(0, 1, 1, 0); other.outlineWidth = 0.0f; other.interiorImageSource = ImageSource.fromObject(new Object()); other.outlineImageSource = ImageSource.fromObject(new Object()); attributes.set(other); assertEquals(attributes, other); }
@Test public void testGetOutlineColor() throws Exception { ShapeAttributes attributes = new ShapeAttributes(); Color black = new Color(0, 0, 0, 1); attributes.outlineColor = black; assertEquals(black, attributes.getOutlineColor()); }
/** * Helper method to create vehicle placemarks. */ protected static Placemark createAutomobilePlacemark(Position position, String name, String automotiveType) { if (!automotiveIconMap.containsKey(automotiveType)) { throw new IllegalArgumentException(automotiveType + " is not valid."); } Placemark placemark = Placemark.createWithImage(position, ImageSource.fromResource(automotiveIconMap.get(automotiveType))); placemark.getAttributes().setImageOffset(Offset.bottomCenter()).setImageScale(NORMAL_IMAGE_SCALE); placemark.setHighlightAttributes(new PlacemarkAttributes(placemark.getAttributes()).setImageScale(HIGHLIGHTED_IMAGE_SCALE).setImageColor(new Color(android.graphics.Color.YELLOW))); placemark.setDisplayName(name); // The AUTOMOTIVE_TYPE property is used to exchange the vehicle type with the VehicleTypeDialog placemark.putUserProperty(AUTOMOTIVE_TYPE, automotiveType); // The select/drag controller will examine a placemark's "capabilities" to determine what operations are applicable: placemark.putUserProperty(SELECTABLE, null); placemark.putUserProperty(EDITABLE, null); placemark.putUserProperty(MOVABLE, null); return placemark; }
@Test public void testGetTextColor() throws Exception { TextAttributes attributes = new TextAttributes(); Color black = new Color(0, 0, 0, 1); attributes.textColor = black; assertEquals(black, attributes.getTextColor()); }
@Test public void testGetInteriorColor() throws Exception { ShapeAttributes attributes = new ShapeAttributes(); Color black = new Color(0, 0, 0, 1); attributes.interiorColor = black; assertEquals(black, attributes.getInteriorColor()); }
/** * Helper method to create aircraft placemarks. The aircraft are selectable, movable, and editable. */ protected static Placemark createAircraftPlacemark(Position position, String aircraftName, String aircraftType) { if (!aircraftIconMap.containsKey(aircraftType)) { throw new IllegalArgumentException(aircraftType + " is not valid."); } Placemark placemark = Placemark.createWithImage(position, ImageSource.fromResource(aircraftIconMap.get(aircraftType))); placemark.getAttributes().setImageOffset(Offset.bottomCenter()).setImageScale(NORMAL_IMAGE_SCALE).setDrawLeader(true); placemark.getAttributes().getLeaderAttributes().setOutlineWidth(4); placemark.setHighlightAttributes(new PlacemarkAttributes(placemark.getAttributes()).setImageScale(HIGHLIGHTED_IMAGE_SCALE).setImageColor(new Color(android.graphics.Color.YELLOW))); placemark.setDisplayName(aircraftName); // The AIRCRAFT_TYPE property is used to exchange the vehicle type with the VehicleTypeDialog placemark.putUserProperty(AIRCRAFT_TYPE, aircraftType); // The select/drag controller will examine a placemark's "capabilities" to determine what operations are applicable: placemark.putUserProperty(SELECTABLE, null); placemark.putUserProperty(EDITABLE, null); placemark.putUserProperty(MOVABLE, null); return placemark; }
@Test public void testSetOutlineColor() throws Exception { ShapeAttributes attributes = new ShapeAttributes(); Color black = new Color(0, 0, 0, 1); attributes.setOutlineColor(black); // Verify that the object is an equivalent deep copy. assertEquals(black, attributes.outlineColor); assertTrue(black != attributes.outlineColor); }
@Test public void testSetTextColor() throws Exception { TextAttributes attributes = new TextAttributes(); Color black = new Color(0, 0, 0, 1); attributes.setTextColor(black); // Verify that the object is an equivalent deep copy. assertEquals(black, attributes.textColor); assertTrue(black != attributes.textColor); }
@Test public void testSetInteriorColor() throws Exception { ShapeAttributes attributes = new ShapeAttributes(); Color black = new Color(0, 0, 0, 1); attributes.setInteriorColor(black); // Verify that the object is an equivalent deep copy. assertEquals(black, attributes.interiorColor); assertTrue(black != attributes.interiorColor); }
@Test public void testConstructor_Default() throws Exception { ShapeAttributes shapeAttributes = new ShapeAttributes(); assertNotNull(shapeAttributes); // Assert default values are as expected. assertTrue("drawInterior should be true", shapeAttributes.drawInterior); assertTrue("drawOutline should be true", shapeAttributes.drawOutline); assertFalse("drawVerticals should be false", shapeAttributes.drawVerticals); assertTrue("depthTest should be true", shapeAttributes.depthTest); assertFalse("enableLighting should be false", shapeAttributes.enableLighting); assertEquals("interiorColor should be white", new Color(1, 1, 1, 1), shapeAttributes.interiorColor); assertEquals("outlineColor should be red", new Color(1, 0, 0, 1), shapeAttributes.outlineColor); assertEquals("outlineWidth should be 1.0", 1.0f, shapeAttributes.outlineWidth, 0.0f); assertNull("interiorImageSource should be null", shapeAttributes.interiorImageSource); assertNull("outlineImageSource should be null", shapeAttributes.outlineImageSource); }
@Test public void testSet() throws Exception { TextAttributes attributes = new TextAttributes(); // create another attribute bundle with differing values TextAttributes other = new TextAttributes(); other.textColor = new Color(0, 0, 0, 0); other.textOffset = new Offset(WorldWind.OFFSET_PIXELS, 0, WorldWind.OFFSET_PIXELS, 0); other.textSize = 0.0f; other.typeface = Typeface.defaultFromStyle(Typeface.NORMAL); other.enableOutline = false; other.enableDepthTest = false; other.outlineWidth = 0.0f; attributes.set(other); assertEquals(attributes, other); }
@Test public void testConstructorWithAttriubutes() { Position position = new Position(12, 34, 56); double majorRadius = 1000; double minorRadius = 500; ShapeAttributes attrs = new ShapeAttributes(); attrs.setInteriorColor(new Color(0, 1, 0, 1)); attrs.setDrawOutline(false); Ellipse ellipse = new Ellipse(position, majorRadius, minorRadius, attrs); assertEquals("constructor position", position, ellipse.center); assertEquals("constructor major radius", majorRadius, ellipse.majorRadius, 1e-9); assertEquals("constructor minor radius", minorRadius, ellipse.minorRadius, 1e-9); assertEquals("constructor attributes", attrs, ellipse.attributes); }
@Test public void testConstructor_Default() throws Exception { TextAttributes attributes = new TextAttributes(); assertNotNull(attributes); // Assert default values are as expected. assertEquals("textColor should be white", new Color(1, 1, 1, 1), attributes.textColor); assertEquals("textOffset should be bottom center", Offset.bottomCenter(), attributes.textOffset); assertEquals("textSize should be 24.0", 24.0f, attributes.textSize, 0.0f); assertEquals("typeface should be null", null, attributes.typeface); assertEquals("enableOutline should be true", true, attributes.enableOutline); assertEquals("enableDepthTest should be true", true, attributes.enableDepthTest); assertEquals("outlineWidth should be 3.0", 3.0f, attributes.outlineWidth, 0.0f); }
@Test public void testHashCode() throws Exception { // Three differing sets of attributes TextAttributes a = new TextAttributes(); TextAttributes b = new TextAttributes(); TextAttributes c = new TextAttributes(); b.setTextColor(new Color(0, 0, 0, 0)); c.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL)); int aHash = a.hashCode(); int bHash = b.hashCode(); int cHash = c.hashCode(); assertNotEquals("a hash vs b hash", bHash, aHash); assertNotEquals("b hash vs c hash", cHash, bHash); assertNotEquals("c hash vs a hash", aHash, cHash); }