private Polygon createPolygon(Project project, Animation animation) { java.awt.Polygon shape = (java.awt.Polygon) animation.getShape(0); Polygon p = activaMpeg7Factory.createRegionLocatorTypePolygon(); IntegerMatrixType value = activaMpeg7Factory.createIntegerMatrixType(); value.getDim().add(BigInteger.valueOf(2)); value.getDim().add(BigInteger.valueOf(shape.npoints)); for (int i = 1; i < shape.npoints; i++) { value.getValue().add(BigInteger.valueOf(shape.xpoints[i])); value.getValue().add(BigInteger.valueOf(shape.ypoints[i])); } p.setCoords(value); return p; }
private void createSegmentInformation(Project project, TVAMainType tva) { if (project.getVideo().getAnimations() == null) return; SegmentInformationTableType segmentInformationTable = tvaFactory.createSegmentInformationTableType(); SegmentListType segmentList = tvaFactory.createSegmentListType(); for (Integer frame : project.getVideo().getAnimations().keySet()) { ExtendedSegmentInformationType segmentInformation = activaFactory.createExtendedSegmentInformationType(); segmentInformation.setSegmentId(frame.toString()); boolean hasContent = false; for (Animation animation : project.getVideo().getAnimations().get(frame)) { if (animation.getEntityId() == 0) continue; IEntity entity = entityServices.getByAnimation(animation); if (entity == null) continue; EntityRegionType entityRegion = activaFactory.createEntityRegionType(); // entityRegion.setEntityRef("entity_" + animation.getEntityId()); entityRegion.setEntityRef(addedEntities.get(Long.valueOf(animation.getEntityId()))); RegionLocatorType regionLocator = activaMpeg7Factory.createRegionLocatorType(); if (animation.getKind() == ShapeKind.RECTANGLE) { regionLocator.getBox().add(createBox(project, animation)); } else if (animation.getKind() == ShapeKind.POLYGON) { regionLocator.getPolygon().add(createPolygon(project, animation)); } entityRegion.setRegion(regionLocator); segmentInformation.getEntityRegion().add(entityRegion); hasContent = true; } if (hasContent) segmentList.getSegmentInformation().add(segmentInformation); } segmentInformationTable.setSegmentList(segmentList); tva.getProgramDescription().setSegmentInformationTable(segmentInformationTable); }
private Box createBox(Project project, Animation animation) { java.awt.Rectangle shape = (java.awt.Rectangle) animation.getShape(0); Box b = activaMpeg7Factory.createRegionLocatorTypeBox(); b.getDim().add(BigInteger.valueOf(2)); b.getDim().add(BigInteger.valueOf(4)); b.getValue().add(BigInteger.valueOf(shape.x)); b.getValue().add(BigInteger.valueOf(shape.y)); b.getValue().add(BigInteger.valueOf(shape.x + shape.width)); b.getValue().add(BigInteger.valueOf(shape.y)); b.getValue().add(BigInteger.valueOf(shape.x)); b.getValue().add(BigInteger.valueOf(shape.y + shape.height)); b.getValue().add(BigInteger.valueOf(shape.x + shape.width)); b.getValue().add(BigInteger.valueOf(shape.y + shape.height)); return b; }