<applications> <application name="uaappli"> <deployment> <lib url="UAApplication.jar" /> <lib url="UAAppliHelper.jar" /> </deployment> <modules> <module name="uaappli"/> </modules> </application> </applications>As for the first A tutorial, we will define our UA configuration using the uaImpl and uaPath properties:
<properties> <application name="uaappli" > <module name="uaappli" > <moduleProperty key="uaImpl" value="UAMapTutorial.jar" /> <moduleProperty key="uaPath" value="org.da.protoframework.tutorialMap.uaappli.UATutorial" /> <moduleProperty key="a661Config" value="a661/tutorial.properties" /> <moduleProperty key="includeServer" value="true" /> </module> </application> </properties>We don't need any services or types, which means that our filelist configuration will be very basic:
<files> <file url="applications.xml" /> <file url="properties.xml" /> </files>
connected()
method will be used to add the listeners which will listen to the click on buittons, and to initialize the characteristics of the Mapconnected()
method will be used to initialize the event handlers on the buttons, and to set the MapHorz characteristicspublic class UATutorial3 extends AbstractFunctionalUA { public UATutorial3() { } @Override public void connected() { } }
public class UATutorial3 extends AbstractFunctionalUA { private static final double PRP_LAT = 44.65; private static final double PRP_LON = 4.73; public void connected() { this.initEventHandlers(); runtimeAPIHelper.setA661WidgetParameterFromName("maphorz", "ProjectionReferencePointLatitude", PRP_LAT); runtimeAPIHelper.setA661WidgetParameterFromName("maphorz", "ProjectionReferencePointLongitude", PRP_LON); } private void initEventHandlers() { } }Note that for now we have an empty
initEventHandlers()
method but we will code it in the next step.
private void initEventHandlers() { // listen to send button runtimeAPIHelper.addA661WidgetEventListener("SendButton", new ARINCEventListener() { public void eventReceived(ARINCEvent evt) { try { send(); } catch (ARINCRuntimeException ex) { logger.error(module, ex.getMessage()); } } }); // listen to rotation buttons runtimeAPIHelper.addA661WidgetEventListener("RotateMoins", new ARINCEventListener() { public void eventReceived(ARINCEvent evt) { try { rotateMap(-10); } catch (ARINCRuntimeException ex) { logger.error(module, ex.getMessage()); } } }); runtimeAPIHelper.addA661WidgetEventListener("RotatePlus", new ARINCEventListener() { public void eventReceived(ARINCEvent evt) { try { rotateMap(10); } catch (ARINCRuntimeException ex) { logger.error(module, ex.getMessage()); } } }); } private void rotateMap(double orientation) { } private void send() { }For now the
send()
and rotateMap(double)
methods are emtpy but we will code it in the next step.
public class UATutorial3 extends AbstractFunctionalUA { private static final double PRP_LAT = 44.65; private static final double PRP_LON = 4.73; private double orientation; private void rotateMap(double orientation) { double _orientation = this.orientation + orientation; _orientation = UnitsConverter.convert(_orientation, Units.DEG, Units.DEG360); this.orientation = _orientation; runtimeAPIHelper.setA661WidgetParameterFromName("maphorz", "Orientation", _orientation); api.sendAll(); } }
MapItems
public class UATutorial3 extends AbstractFunctionalUA { private static final double PRP_LAT = 44.65; private static final double PRP_LON = 4.73; private MapItemListRep mapItemsRep; public void connected() { this.initEventHandlers(); runtimeAPIHelper.setA661WidgetParameterFromName("maphorz", "ProjectionReferencePointLatitude", PRP_LAT); runtimeAPIHelper.setA661WidgetParameterFromName("maphorz", "ProjectionReferencePointLongitude", PRP_LON); _ mapItemsRep = runtimeAPIHelper.addMapItemListRep("MapItems"); } }
private void send() { MapPosition pos1 = new MapPosition.Double(45.13, 4.96, Units.DEG360); MapPosition pos2 = new MapPosition.Double(44.92, 5.93, Units.DEG360); ItemMap item = mapItemsRep.addItem(1, "A661_LINE_START"); item.addProperty("X", pos1.getFirstCoordDouble()); item.addProperty("Y", pos1.getSecondCoordDouble()); item = mapItemsRep.addItem(2, "A661_LINE_SEGMENT"); item.addProperty("X", pos2.getFirstCoordDouble()); item.addProperty("Y", pos2.getSecondCoordDouble()); item.addProperty("EndFlag", true); }
private void send() { ... double midPointX = pos1.getFirstCoordDouble() + (pos2.getFirstCoordDouble() - pos1.getFirstCoordDouble())/2; double midPointY = pos1.getSecondCoordDouble() + (pos2.getSecondCoordDouble() - pos1.getSecondCoordDouble())/2; MapPosition midPoint = new MapPosition.Double(midPointX, midPointY, Units.DEG360); item = mapItemsRep.addItem(3, "A661_SYMBOL_GENERIC"); item.addProperty("X", midPoint.getFirstCoordDouble()); item.addProperty("Y", midPoint.getSecondCoordDouble()); item.addProperty("SymbolType", 0); }
pper
) to a point in the direction of the second point ( p3
)pper
) to a point in the direction of the first point ( p4
)pper
, p3
, and p4
points:public class UATutorial3 extends AbstractFunctionalUA { private static final double PRP_LAT = 44.65; private static final double PRP_LON = 4.73; private static final double Z2D_CIRCLE_SCREEN_RANGE = 9000; private MapItemListRep mapItemsRep; private final ProjectionHelper projHelper = new ProjectionHelper(); public void connected() { this.initEventHandlers(); runtimeAPIHelper.setA661WidgetParameterFromName("maphorz", "ProjectionReferencePointLatitude", PRP_LAT); runtimeAPIHelper.setA661WidgetParameterFromName("maphorz", "ProjectionReferencePointLongitude", PRP_LON); _ mapItemsRep = runtimeAPIHelper.addMapItemListRep("MapItems"); projHelper.setPRP(PRP_LAT, PRP_LON); // set the same reference in the ProjectionHelper as in the MapHorz projHelper.setRange(40, Z2D_CIRCLE_SCREEN_RANGE); // set the same range in the ProjectionHelper as in the MapHorz } }
public class UATutorial3 extends AbstractFunctionalUA { private static final double PRP_LAT = 44.65; private static final double PRP_LON = 4.73; private static final double Z2D_CIRCLE_SCREEN_RANGE = 9000; private MapItemListRep mapItemsRep; private static final long DISTANCEMM = 1000; }To compute the position of
p3
, we need to compute a position between the mid-point to a point at the fistance of 1000 1/100 mm in the bearing of the segment between pos1
and pos2
:private void send() { ... // compute the bearing of the segment double bearing = projHelper.getBearingFromLatLong(pos1, pos2, Units.DEG360); // create a point from the mid-point to point 2, with bearing MapPosition p3 = projHelper.getLatLongPositionFromMM(midPoint, DISTANCEMM, bearing, Units.DEG360); }Now we can add the associated Symbol:
private void send() { ... // to have a different color for the next MapItems item = mapItemsRep.addItem(4, "A661_ITEM_STYLE"); item.addProperty("ItemStyleSet", 1); item = mapItemsRep.addItem(5, "A661_SYMBOL_GENERIC"); item.addProperty("X", p3.getFirstCoordDouble()); item.addProperty("Y", p3.getSecondCoordDouble()); item.addProperty("SymbolType", 1); // the value 1 is to have a smaller size for the circle }
p4
, we do the same as p3
, except the we go in the opposite direction:private void send() { ... // create a point from the mid-point to point 2, with bearing MapPosition p4 = projHelper.getLatLongPositionFromMM(midPoint, DISTANCEMM, bearing + 180, Units.DEG360); }Now we can add the associated Symbol:
private void send() { ... item = mapItemsRep.addItem(6, "A661_SYMBOL_GENERIC"); item.addProperty("X", p4.getFirstCoordDouble()); item.addProperty("Y", p4.getSecondCoordDouble()); item.addProperty("SymbolType", 1); }
pper
is a point perpendicular to the segment from the mid-point. private void send() { ... MapPosition pper = projHelper.getLatLongPositionFromMM(midPoint, DISTANCEMM, bearing + 90, Units.DEG360); }
private void send() { ... item = mapItemsRep.addItem(7, "A661_SYMBOL_GENERIC"); item.addProperty("X", pper.getFirstCoordDouble()); item.addProperty("Y", pper.getSecondCoordDouble()); item.addProperty("SymbolType", 1); }
p4
to pper
to p3
:private void send() { ... item = mapItemsRep.addItem(8, "A661_LINE_START"); item.addProperty("X", p4.getFirstCoordDouble()); item.addProperty("Y", p4.getSecondCoordDouble()); item = mapItemsRep.addItem(9, "A661_LINE_SEGMENT"); item.addProperty("X", pper.getFirstCoordDouble()); item.addProperty("Y", pper.getSecondCoordDouble()); item = mapItemsRep.addItem(10, "A661_LINE_SEGMENT"); item.addProperty("X", p3.getFirstCoordDouble()); item.addProperty("Y", p3.getSecondCoordDouble()); item.addProperty("EndFlag", true); }
private void send() { ... mapItemsRep.setBufferContent(); }
MapItems
Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence