// // Name: Labels Demo. // License: Public Domain // Author: Matthew Gates // Description: Example script to show how to use LabelMgr // // set default view, location and date. LabelMgr.deleteAllLabels(); core.clear("natural"); core.setObserverLocation("York, UnitedKingdom"); core.setTimeRate(1); core.setDate("2008:10:30T21:00:00"); core.moveToAltAzi(30, 90); StelMovementMgr.zoomTo(70, 2); core.wait(2.5); // When you create a label, the return value is an ID of a label which // is subsequently used to refer to that label when calling functions // in the label manager (e.g. turning the label on and off) // This function prints a line of text at a fixed place on the screen // pauses for a few seconds and then hides the text. I will use this // for providing information to the user. // // The label is created in an "off" state, and then faded in and out. // The label is deleted after it has been displayed. function commentary(text) { commentary_at(text, 30, 30); } function commentary_at(text, x, y) { var id = LabelMgr.labelScreen(text, x, y, false, 20, "#aaaaaa"); LabelMgr.setLabelShow(id, true); core.wait(2); LabelMgr.setLabelShow(id, false); core.wait(1); LabelMgr.deleteLabel(id); } commentary("This script is a test of LabelMgr."); commentary("Labels can be fixed to screen x,y values..."); commentary_at("0,0", 0, 0); commentary_at("100,100", 100, 100); commentary_at("0,400", 0, 400); commentary_at("600,20", 600, 20); commentary("Or they can be attached to a named object..."); var myOb = "HP 21421"; // Aldebaran var id = LabelMgr.labelObject("A bright star!" , myOb, false, 16, "#aaaaaa", "S", 10); LabelMgr.setLabelShow(id, true); core.wait(1); commentary("The label above is connected to " + myOb); core.setTimeRate(150); commentary("Watch as the time advances"); commentary("The label is stuck to the object"); core.setTimeRate(1); LabelMgr.deleteLabel(id); commentary("You can display object labels in different positions...") commentary("Use cardinal point names to choose"); var sides = new Array("N", "NE", "E", "SE", "S", "SW", "W", "NW"); var position_ids = new Array(); // create labels and turn them on with a short staggering. for (i=0; i