ShapeAttributes commonAttrs = new ShapeAttributes(); 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); ShapeAttributes highlightAttrs = new ShapeAttributes(); 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.setFollowTerrain(true); // essential for preventing long segments from intercepting ellipsoid. 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);
@Test public void testHashCode() throws Exception { // Three differing sets of attributes ShapeAttributes a = new ShapeAttributes(); ShapeAttributes b = new ShapeAttributes(); ShapeAttributes c = new ShapeAttributes(); b.setDrawInterior(false); c.setDrawOutline(false); 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); }
@Test(expected = IllegalArgumentException.class) public void testSet_WithNull() throws Exception { ShapeAttributes attributes = new ShapeAttributes(); attributes.set(null); fail("Expected an IllegalArgumentException to be thrown."); }
/** * Constructs an OmnidirectionalSightline that displays the line-of-sight from a specified center position and * range. Visible features are displayed in white, while occluded features are displayed in red. * * @param position the position where the sightline is centered * @param range the sightline's range in meters from its position * * @throws IllegalArgumentException If the position is null, or if the range is negative */ public OmnidirectionalSightline(Position position, double range) { if (position == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "OmnidirectionalSightline", "constructor", "missingPosition")); } if (range < 0) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "OmnidirectionalSightline", "constructor", "invalidRange")); } this.position.set(position); this.range = range; this.attributes = new ShapeAttributes(); this.occludeAttributes = new ShapeAttributes(); this.occludeAttributes.setInteriorColor(new Color(1, 0, 0, 1)); // red }
protected void populateFlightPaths() { ShapeAttributes attrs = new ShapeAttributes(); attrs.getInteriorColor().set(0.8f, 0.8f, 1.0f, 0.8f); attrs.getOutlineColor().set(1.0f, 1.0f, 0.0f, 1.0f); Airport dept = this.airportIkoIndex.get("KSEA"); for (Airport dest : this.airportTable) { if (dest.equals(dept)) { continue; // the destination and departure must be different } if (dest.iko.length() != 4) { continue; // the destination must be a major airfield } if (!dest.na3.startsWith("US")) { continue; // the destination must be in the United States } if (!dest.use.equals("49")) { continue; // the destination must a Civilian/Public airport } List<Position> positions = new ArrayList<>(); positions.add(dept.pos); Path path = new Path(positions, attrs); path.putUserProperty("dept", dept); path.putUserProperty("dest", dest); this.flightPathLayer.addRenderable(path); } }
Position.fromDegrees(20, -40, 1e5) ); ShapeAttributes attrs = new ShapeAttributes(); attrs.setDrawVerticals(true); // display the extruded verticals attrs.setInteriorColor(new Color(1, 1, 1, 0.5f)); // 50% transparent white attrs.setOutlineWidth(3); path = new Path(positions, attrs); path.setExtrude(true); // extrude the path from the ground to each path position's altitude
public AbstractShape() { this.attributes = new ShapeAttributes(); }
ShapeAttributes thickenLine = new ShapeAttributes(); thickenLine.setOutlineWidth(4f); ); Path path = new Path(positions); ShapeAttributes sa = new ShapeAttributes(thickenLine); sa.setOutlineImageSource(ImageSource.fromLineStipple(2 /*factor*/, (short) 0xF0F0 /*pattern*/)); path.setAttributes(sa); layer.addRenderable(path); ); path = new Path(positions); sa = new ShapeAttributes(thickenLine); sa.setOutlineImageSource(ImageSource.fromLineStipple(4 /*factor*/, (short) 0xF0F0 /*pattern*/)); path.setAttributes(sa); layer.addRenderable(path); ); path = new Path(positions); sa = new ShapeAttributes(thickenLine); sa.setOutlineImageSource(ImageSource.fromLineStipple(8 /*factor*/, (short) 0xDFF6 /*pattern*/)); path.setAttributes(sa); path.setAltitudeMode(WorldWind.CLAMP_TO_GROUND); sa = new ShapeAttributes(thickenLine); sa.setInteriorImageSource(ImageSource.fromResource(R.drawable.pattern_sample_houndstooth)); ellipse.setAttributes(sa); layer.addRenderable(ellipse);
ShapeAttributes attrs = new ShapeAttributes(); attrs.getOutlineColor().set(1.0f, 1.0f, 0.0f, 1.0f); attrs.setOutlineWidth(3); ShapeAttributes highlightAttrs = new ShapeAttributes(); highlightAttrs.getOutlineColor().set(1.0f, 0.0f, 0.0f, 1.0f); highlightAttrs.setOutlineWidth(7);
@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 testSetOutlineWidth() throws Exception { ShapeAttributes attributes = new ShapeAttributes(); float width = 2.5f; attributes.setOutlineWidth(width); assertEquals(width, attributes.outlineWidth, 1e-15); }
@Test public void testSetDrawVerticals() throws Exception { ShapeAttributes attributes = new ShapeAttributes(); attributes.drawVerticals = true; attributes.setDrawVerticals(false); assertFalse(attributes.drawVerticals); }
@Test public void testSetOutlineImageSource() throws Exception { ShapeAttributes attributes = new ShapeAttributes(); ImageSource imageSource = ImageSource.fromObject(new Object()); attributes.setOutlineImageSource(imageSource); assertEquals(imageSource, attributes.outlineImageSource); } }
@Test public void testSetInteriorImageSource() throws Exception { ShapeAttributes attributes = new ShapeAttributes(); ImageSource imageSource = ImageSource.fromObject(new Object()); attributes.setInteriorImageSource(imageSource); assertEquals(imageSource, attributes.interiorImageSource); }
@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()); }
@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()); }
@Test public void testIsDrawInterior() throws Exception { ShapeAttributes attributes = new ShapeAttributes(); // Assert the getter is returning the changed member attributes.drawInterior = true; assertTrue(attributes.isDrawInterior()); attributes.drawInterior = false; assertFalse(attributes.isDrawInterior()); }
@Test public void testSetDrawOutline() throws Exception { ShapeAttributes attributes = new ShapeAttributes(); attributes.drawOutline = true; attributes.setDrawOutline(false); assertFalse(attributes.drawOutline); }
@Test public void testGetOutlineWidth() throws Exception { ShapeAttributes attributes = new ShapeAttributes(); float width = 2.5f; attributes.outlineWidth = width; assertEquals(width, attributes.getOutlineWidth(), 1e-15); }
@Test public void testSetDrawInterior() throws Exception { ShapeAttributes attributes = new ShapeAttributes(); attributes.drawInterior = true; attributes.setDrawInterior(false); assertFalse(attributes.drawInterior); }