Package de.hpi.eworld.model.db.data.event

Examples of de.hpi.eworld.model.db.data.event.PolygonLocationModel


      }
      // if the location is a polygon
      else if (environmentEvent.getLocation() instanceof PolygonLocationModel) {
        log.debug("environmentEvent is PolygonLocationModel");
        PolygonLocationModel location =
          (PolygonLocationModel) environmentEvent.getLocation();

        List<GlobalPosition> points = location.getPoints();

        GeneralPath path = new GeneralPath();

        Float pos0x = new Float(points.get(0).getLongitude());
View Full Code Here


   * de.hpi.eworld.model.db.data.event.PolygonLocation
   */
  @Test
  public void testPolygonLocation () {
   
    PolygonLocationModel pl = new PolygonLocationModel();
   
    List<GlobalPosition> positions = new ArrayList<GlobalPosition>();
   
    Point2D p1 = new Point2D.Double(3,4);
    GlobalPosition gp1 = GlobalPosition.from(p1);
    positions.add(gp1);
   
    Point2D p2 = new Point2D.Double(13,14);
    GlobalPosition gp2 = GlobalPosition.from(p2);
    positions.add(gp2);
   
    Point2D p3 = new Point2D.Double(22,23);
    GlobalPosition gp3 = GlobalPosition.from(p3);
    positions.add(gp3);
   
    Point2D p4 = new Point2D.Double(12,9);
    GlobalPosition gp4 = GlobalPosition.from(p4);
    positions.add(gp4);
   
    Point2D p5 = new Point2D.Double(3,34);
    GlobalPosition gp5 = GlobalPosition.from(p5);
    positions.add(gp5);
   
    pl.setPoints(positions);
   
   
    Assert.assertEquals(5, pl.getPoints().size());
   
    pl.removePointAt(5);
    Assert.assertEquals(5, pl.getPoints().size());
   
    pl.removePointAt(-12);
    Assert.assertEquals(5, pl.getPoints().size());
   
    pl.removePointAt(3);
    Assert.assertEquals(4, pl.getPoints().size());
   
    pl.removePoint(gp1);
    Assert.assertEquals(3, pl.getPoints().size());
    Assert.assertNotSame(gp1, pl.getPoints().get(0));
    Assert.assertEquals(gp2, pl.getPoints().get(0));
   
    Point2D p6 = new Point2D.Double(33,16);
    GlobalPosition gp6 = GlobalPosition.from(p6);
    pl.addPoint(gp6);
    Assert.assertEquals(4, pl.getPoints().size());
   
    Point2D p7 = new Point2D.Double(33,16);
    GlobalPosition gp7 = GlobalPosition.from(p7);
    pl.addPointAt(2, gp7);
    Assert.assertEquals(gp7, pl.getPoints().get(2));
  }
View Full Code Here

   
   
    ///////////////////////////////////
    // set up PolygonLocation
   
    PolygonLocationModel pl = new PolygonLocationModel();
   
    List<GlobalPosition> positions = new ArrayList<GlobalPosition>();
   
    Point2D p1 = new Point2D.Double(3,4);
    GlobalPosition gp1 = GlobalPosition.from(p1);
    positions.add(gp1);
   
    Point2D p2 = new Point2D.Double(13,14);
    GlobalPosition gp2 = GlobalPosition.from(p2);
    positions.add(gp2);
   
    Point2D p3 = new Point2D.Double(22,23);
    GlobalPosition gp3 = GlobalPosition.from(p3);
    positions.add(gp3);
   
    Point2D p4 = new Point2D.Double(12,9);
    GlobalPosition gp4 = GlobalPosition.from(p4);
    positions.add(gp4);
   
    Point2D p5 = new Point2D.Double(3,34);
    GlobalPosition gp5 = GlobalPosition.from(p5);
    positions.add(gp5);
   
    pl.setPoints(positions);
   
   
    ///////////////////////////////////
    // set up EdgeLocation
   
View Full Code Here

    Assert.assertSame(circleEvent, viewItem.getModelElement());
  }

  @Test
  public void testPolyEnvironmentEventItem() {
    PolygonLocationModel polygonLocation = new PolygonLocationModel();
    PolygonEventModel polygonEvent = new PolygonEventModel(EnvironmentEventModel.Type.Ice, 1, polygonLocation);
    AbstractView<Observable> viewItem = AbstractViewFactory.createView(polygonEvent);
    Assert.assertNotNull(viewItem);
    Assert.assertTrue(viewItem instanceof AbstractView<?>);
//    PolygonEventItem polygonEventItem = (PolygonEventItem) viewItem;
View Full Code Here

      new EnvironmentEventModel(EnvironmentEventModel.Type.CO2, 12, cl);
   
    ///////////////////////////////////
    // set up ee2 with PloygonLocation
   
    PolygonLocationModel pl = new PolygonLocationModel();
   
    List<GlobalPosition> positions = new ArrayList<GlobalPosition>();
   
    Point2D p1 = new Point2D.Double(3,4);
    GlobalPosition gp1 = GlobalPosition.from(p1);
    positions.add(gp1);
   
    Point2D p2 = new Point2D.Double(13,14);
    GlobalPosition gp2 = GlobalPosition.from(p2);
    positions.add(gp2);
   
    Point2D p3 = new Point2D.Double(22,23);
    GlobalPosition gp3 = GlobalPosition.from(p3);
    positions.add(gp3);
   
    Point2D p4 = new Point2D.Double(12,9);
    GlobalPosition gp4 = GlobalPosition.from(p4);
    positions.add(gp4);
   
    Point2D p5 = new Point2D.Double(3,34);
    GlobalPosition gp5 = GlobalPosition.from(p5);
    positions.add(gp5);
   
    pl.setPoints(positions);
   
    EnvironmentEventModel ee2 =
      new EnvironmentEventModel(EnvironmentEventModel.Type.Fog, -23, pl);
   
    ///////////////////////////////////
View Full Code Here

      new EnvironmentEventModel(EnvironmentEventModel.Type.CO2, 12, cl);
   
    ///////////////////////////////////
    // set up ee2 with PloygonLocation
   
    PolygonLocationModel pl = new PolygonLocationModel();
   
    List<GlobalPosition> positions = new ArrayList<GlobalPosition>();
   
    Point2D p1 = new Point2D.Double(3,4);
    GlobalPosition gp1 = GlobalPosition.from(p1);
    positions.add(gp1);
   
    Point2D p2 = new Point2D.Double(13,14);
    GlobalPosition gp2 = GlobalPosition.from(p2);
    positions.add(gp2);
   
    Point2D p3 = new Point2D.Double(22,23);
    GlobalPosition gp3 = GlobalPosition.from(p3);
    positions.add(gp3);
   
    Point2D p4 = new Point2D.Double(12,9);
    GlobalPosition gp4 = GlobalPosition.from(p4);
    positions.add(gp4);
   
    Point2D p5 = new Point2D.Double(3,34);
    GlobalPosition gp5 = GlobalPosition.from(p5);
    positions.add(gp5);
   
    pl.setPoints(positions);
   
    EnvironmentEventModel ee2 =
      new EnvironmentEventModel(EnvironmentEventModel.Type.Fog, -23, pl);
   
    ///////////////////////////////////
View Full Code Here

    // update of location should be already implemented in the resizer)
  }

  @Override
  public Rectangle2D getInitialBounds() {
    PolygonLocationModel model = (PolygonLocationModel) getModelElement()
        .getLocation();
    Polygon2D poly = new Polygon2D();
    for (GlobalPosition p : model.getPoints()) {
      poly.addPoint(p.projected());
    }

    return poly.getBounds2D();
  }
View Full Code Here

  @Override
  public ModelElement getAdjustedAssociatedElement(Point2D scrolledPoint,
      GraphController graphModel) {
    EnvironmentEventModel clonedModel = (EnvironmentEventModel) getModelElement()
        .clone();
    PolygonLocationModel locationModel = new PolygonLocationModel();
    List<GlobalPosition> globals = new ArrayList<GlobalPosition>();
    for (Point2D p : basicShape.translated(scrolledPoint.getX(),
        scrolledPoint.getY()).getPoints()) {
      globals.add(GlobalPosition.from(p));
    }
    locationModel.setPoints(globals);
    clonedModel.setLocation(locationModel);
    return clonedModel;
  }
View Full Code Here

TOP

Related Classes of de.hpi.eworld.model.db.data.event.PolygonLocationModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.